[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 27/28] qemu-option: remove now-dead code
From: |
Paolo Bonzini |
Subject: |
[PATCH 27/28] qemu-option: remove now-dead code |
Date: |
Wed, 2 Dec 2020 04:03:04 -0500 |
-M was the sole user of qemu_opts_set and qemu_opts_set_defaults,
remove them and the arguments that they used.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qemu/option.h | 3 ---
tests/test-qemu-opts.c | 35 -----------------------------
util/qemu-option.c | 51 +++++++++---------------------------------
3 files changed, 10 insertions(+), 79 deletions(-)
diff --git a/include/qemu/option.h b/include/qemu/option.h
index fffb03d848..306bf07575 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -119,7 +119,6 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char
*id,
int fail_if_exists, Error **errp);
void qemu_opts_reset(QemuOptsList *list);
void qemu_opts_loc_restore(QemuOpts *opts);
-bool qemu_opts_set(QemuOptsList *list, const char *name, const char *value,
Error **errp);
const char *qemu_opts_id(QemuOpts *opts);
void qemu_opts_set_id(QemuOpts *opts, char *id);
void qemu_opts_del(QemuOpts *opts);
@@ -130,8 +129,6 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const
char *params,
bool permit_abbrev);
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
bool permit_abbrev, Error **errp);
-void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
- int permit_abbrev);
QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
Error **errp);
QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict,
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index 8bbb17b1c7..0239876e36 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -410,40 +410,6 @@ static void test_qemu_opts_reset(void)
g_assert(opts == NULL);
}
-static void test_qemu_opts_set(void)
-{
- QemuOptsList *list;
- QemuOpts *opts;
- const char *opt;
-
- list = qemu_find_opts("opts_list_04");
- g_assert(list != NULL);
- g_assert(QTAILQ_EMPTY(&list->head));
- g_assert_cmpstr(list->name, ==, "opts_list_04");
-
- /* should not find anything at this point */
- opts = qemu_opts_find(list, NULL);
- g_assert(opts == NULL);
-
- /* implicitly create opts and set str3 value */
- qemu_opts_set(list, "str3", "value", &error_abort);
- g_assert(!QTAILQ_EMPTY(&list->head));
-
- /* get the just created opts */
- opts = qemu_opts_find(list, NULL);
- g_assert(opts != NULL);
-
- /* check the str3 value */
- opt = qemu_opt_get(opts, "str3");
- g_assert_cmpstr(opt, ==, "value");
-
- qemu_opts_del(opts);
-
- /* should not find anything at this point */
- opts = qemu_opts_find(list, NULL);
- g_assert(opts == NULL);
-}
-
static int opts_count_iter(void *opaque, const char *name, const char *value,
Error **errp)
{
@@ -1030,7 +996,6 @@ int main(int argc, char *argv[])
g_test_add_func("/qemu-opts/opt_get_size", test_qemu_opt_get_size);
g_test_add_func("/qemu-opts/opt_unset", test_qemu_opt_unset);
g_test_add_func("/qemu-opts/opts_reset", test_qemu_opts_reset);
- g_test_add_func("/qemu-opts/opts_set", test_qemu_opts_set);
g_test_add_func("/qemu-opts/opts_parse/general", test_opts_parse);
g_test_add_func("/qemu-opts/opts_parse/bool", test_opts_parse_bool);
g_test_add_func("/qemu-opts/opts_parse/number", test_opts_parse_number);
diff --git a/util/qemu-option.c b/util/qemu-option.c
index afba08d92e..94a6bea767 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -479,19 +479,14 @@ int qemu_opt_unset(QemuOpts *opts, const char *name)
}
}
-static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value,
- bool prepend)
+static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value)
{
QemuOpt *opt = g_malloc0(sizeof(*opt));
opt->name = g_strdup(name);
opt->str = value;
opt->opts = opts;
- if (prepend) {
- QTAILQ_INSERT_HEAD(&opts->head, opt, next);
- } else {
- QTAILQ_INSERT_TAIL(&opts->head, opt, next);
- }
+ QTAILQ_INSERT_TAIL(&opts->head, opt, next);
return opt;
}
@@ -518,7 +513,7 @@ static bool opt_validate(QemuOpt *opt, Error **errp)
bool qemu_opt_set(QemuOpts *opts, const char *name, const char *value,
Error **errp)
{
- QemuOpt *opt = opt_create(opts, name, g_strdup(value), false);
+ QemuOpt *opt = opt_create(opts, name, g_strdup(value));
if (!opt_validate(opt, errp)) {
qemu_opt_del(opt);
@@ -662,15 +657,6 @@ void qemu_opts_loc_restore(QemuOpts *opts)
loc_restore(&opts->loc);
}
-bool qemu_opts_set(QemuOptsList *list, const char *name, const char *value,
Error **errp)
-{
- QemuOpts *opts;
-
- assert(list->merge_lists);
- opts = qemu_opts_create(list, NULL, 0, &error_abort);
- return qemu_opt_set(opts, name, value, errp);
-}
-
const char *qemu_opts_id(QemuOpts *opts)
{
return opts->id;
@@ -807,7 +793,7 @@ static const char *get_opt_name_value(const char *params,
}
static bool opts_do_parse(QemuOpts *opts, const char *params,
- const char *firstname, bool prepend,
+ const char *firstname,
bool warn_on_flag, bool *help_wanted, Error **errp)
{
char *option, *value;
@@ -829,7 +815,7 @@ static bool opts_do_parse(QemuOpts *opts, const char
*params,
continue;
}
- opt = opt_create(opts, option, value, prepend);
+ opt = opt_create(opts, option, value);
g_free(option);
if (!opt_validate(opt, errp)) {
qemu_opt_del(opt);
@@ -885,11 +871,11 @@ bool has_help_option(const char *params)
bool qemu_opts_do_parse(QemuOpts *opts, const char *params,
const char *firstname, Error **errp)
{
- return opts_do_parse(opts, params, firstname, false, false, NULL, errp);
+ return opts_do_parse(opts, params, firstname, false, NULL, errp);
}
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
- bool permit_abbrev, bool defaults,
+ bool permit_abbrev,
bool warn_on_flag, bool *help_wanted, Error **errp)
{
const char *firstname;
@@ -899,21 +885,13 @@ static QemuOpts *opts_parse(QemuOptsList *list, const
char *params,
assert(!permit_abbrev || list->implied_opt_name);
firstname = permit_abbrev ? list->implied_opt_name : NULL;
- /*
- * This code doesn't work for defaults && !list->merge_lists: when
- * params has no id=, and list has an element with !opts->id, it
- * appends a new element instead of returning the existing opts.
- * However, we got no use for this case. Guard against possible
- * (if unlikely) future misuse:
- */
- assert(!defaults || list->merge_lists);
opts = qemu_opts_create(list, id, !list->merge_lists, errp);
g_free(id);
if (opts == NULL) {
return NULL;
}
- if (!opts_do_parse(opts, params, firstname, defaults,
+ if (!opts_do_parse(opts, params, firstname,
warn_on_flag, help_wanted, errp)) {
qemu_opts_del(opts);
return NULL;
@@ -932,7 +910,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char
*params,
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
bool permit_abbrev, Error **errp)
{
- return opts_parse(list, params, permit_abbrev, false, false, NULL, errp);
+ return opts_parse(list, params, permit_abbrev, false, NULL, errp);
}
/**
@@ -950,7 +928,7 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, const
char *params,
QemuOpts *opts;
bool help_wanted = false;
- opts = opts_parse(list, params, permit_abbrev, false, true,
+ opts = opts_parse(list, params, permit_abbrev, true,
opts_accepts_any(list) ? NULL : &help_wanted,
&err);
if (!opts) {
@@ -964,15 +942,6 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list,
const char *params,
return opts;
}
-void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
- int permit_abbrev)
-{
- QemuOpts *opts;
-
- opts = opts_parse(list, params, permit_abbrev, true, false, NULL, NULL);
- assert(opts);
-}
-
static bool qemu_opts_from_qdict_entry(QemuOpts *opts,
const QDictEntry *entry,
Error **errp)
--
2.26.2
- [PATCH 08/28] tests: convert check-qom-proplist to keyval, (continued)
- [PATCH 08/28] tests: convert check-qom-proplist to keyval, Paolo Bonzini, 2020/12/02
- [PATCH 09/28] keyval: introduce keyval_parse_into, Paolo Bonzini, 2020/12/02
- [PATCH 19/28] qemu-io: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 25/28] vl: rename local variable in configure_accelerators, Paolo Bonzini, 2020/12/02
- [PATCH 24/28] qom: export more functions for use with non-UserCreatable objects, Paolo Bonzini, 2020/12/02
- [PATCH 10/28] hmp: replace "O" parser with keyval, Paolo Bonzini, 2020/12/02
- [PATCH 14/28] qemu-config: add error propagation to qemu_config_parse, Paolo Bonzini, 2020/12/02
- [PATCH 13/28] remove -writeconfig, Paolo Bonzini, 2020/12/02
- [PATCH 18/28] qom: do not modify QDict argument in user_creatable_add_dict, Paolo Bonzini, 2020/12/02
- [PATCH 28/28] vl: switch -accel parsing to keyval, Paolo Bonzini, 2020/12/02
- [PATCH 27/28] qemu-option: remove now-dead code,
Paolo Bonzini <=
- [PATCH 12/28] hmp: special case help options for object_add, Paolo Bonzini, 2020/12/02
- [PATCH 22/28] qemu: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 21/28] qemu-img: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 23/28] storage-daemon: do not register the "object" group with QemuOpts, Paolo Bonzini, 2020/12/02
- [PATCH 15/28] qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict, Paolo Bonzini, 2020/12/02
- [PATCH 16/28] qemu-config: parse configuration files to a QDict, Paolo Bonzini, 2020/12/02
- [PATCH 17/28] vl: plumb keyval-based options into -set and -readconfig, Paolo Bonzini, 2020/12/02
- [PATCH 20/28] qemu-nbd: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 26/28] vl: switch -M parsing to keyval, Paolo Bonzini, 2020/12/02