aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/qemu-option.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/util/qemu-option.c b/util/qemu-option.c
index c88e159f18..91f4120ce1 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -619,7 +619,17 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
{
QemuOpts *opts = NULL;
- if (id) {
+ if (list->merge_lists) {
+ if (id) {
+ error_setg(errp, QERR_INVALID_PARAMETER, "id");
+ return NULL;
+ }
+ opts = qemu_opts_find(list, NULL);
+ if (opts) {
+ return opts;
+ }
+ } else if (id) {
+ assert(fail_if_exists);
if (!id_wellformed(id)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id",
"an identifier");
@@ -629,17 +639,8 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
}
opts = qemu_opts_find(list, id);
if (opts != NULL) {
- if (fail_if_exists && !list->merge_lists) {
- error_setg(errp, "Duplicate ID '%s' for %s", id, list->name);
- return NULL;
- } else {
- return opts;
- }
- }
- } else if (list->merge_lists) {
- opts = qemu_opts_find(list, NULL);
- if (opts) {
- return opts;
+ error_setg(errp, "Duplicate ID '%s' for %s", id, list->name);
+ return NULL;
}
}
opts = g_malloc0(sizeof(*opts));
@@ -893,7 +894,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
* (if unlikely) future misuse:
*/
assert(!defaults || list->merge_lists);
- opts = qemu_opts_create(list, id, !defaults, errp);
+ opts = qemu_opts_create(list, id, !list->merge_lists, errp);
g_free(id);
if (opts == NULL) {
return NULL;