From 1585c39e3d4b02806aff05a420a13aa9c9a31d14 Mon Sep 17 00:00:00 2001
Message-Id: <1585c39e3d4b02806aff05a420a13aa9c9a31d14.1350567686.git.minovotn@redhat.com>
In-Reply-To: <e8d21dedbb11e84476f54f7285e4758556f1395f.1350567686.git.minovotn@redhat.com>
References: <e8d21dedbb11e84476f54f7285e4758556f1395f.1350567686.git.minovotn@redhat.com>
From: Jason Baron <jbaron@redhat.com>
Date: Fri, 12 Oct 2012 19:44:32 +0200
Subject: [PATCH 6/7] Make -machine/-enable-kvm options merge into a single
 list

RH-Author: Jason Baron <jbaron@redhat.com>
Message-id: <2b8bace4ed6b45fdfa4b88ec0e131956147c3c23.1350069767.git.jbaron@redhat.com>
Patchwork-id: 43074
O-Subject: [RHEL 6.4 qemu-kvm PATCH v4 6/7] Make -machine/-enable-kvm options merge into a single list
Bugzilla: 859447
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Pavel Hrdina <phrdina@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

From: Peter Maydell <peter.maydell@linaro.org>

Make the "machine" option list use list merging, so that multiple
-machine arguments (and the -enable-kvm argument) all merge together
into a single list. Drop the calls to qemu_opts_reset() which meant
that only the last -machine or -enable-kvm option had any effect.

This fixes the bug where "-enable-kvm -machine foo" would ignore
the '-enable-kvm' option, and "-machine foo -enable-kvm" would
ignore the '-machine foo' option.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
(cherry picked from commit 9de36b1a7cf61aa8be365f13c81668b3e19fbc7f)

Removed reset from QEMU_OPTION_no_kvm as well.

Signed-off-by: Jason Baron <jbaron@redhat.com>
---
 qemu-config.c |    1 +
 vl.c          |    3 ---
 2 files changed, 1 insertions(+), 3 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 qemu-config.c | 1 +
 vl.c          | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index aba8be5..232f984 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -422,6 +422,7 @@ QemuOptsList qemu_option_rom_opts = {
 static QemuOptsList qemu_machine_opts = {
     .name = "machine",
     .implied_opt_name = "type",
+    .merge_lists = true,
     .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head),
     .desc = {
         {
diff --git a/vl.c b/vl.c
index f349db9..5d94e02 100644
--- a/vl.c
+++ b/vl.c
@@ -5730,12 +5730,10 @@ int main(int argc, char **argv, char **envp)
 #ifdef CONFIG_KVM
             case QEMU_OPTION_enable_kvm:
                 olist = qemu_find_opts("machine");
-                qemu_opts_reset(olist);
                 qemu_opts_parse(olist, "accel=kvm", 0);
                 break;
             case QEMU_OPTION_no_kvm:
                 olist = qemu_find_opts("machine");
-                qemu_opts_reset(olist);
                 qemu_opts_parse(olist, "accel=tcg", 0);
                 break;
 	    case QEMU_OPTION_no_kvm_irqchip: {
@@ -5768,7 +5766,6 @@ int main(int argc, char **argv, char **envp)
 #endif
             case QEMU_OPTION_machine:
                 olist = qemu_find_opts("machine");
-                qemu_opts_reset(olist);
                 opts = qemu_opts_parse(olist, optarg, 1);
                 if (!opts) {
                     fprintf(stderr, "parse error: %s\n", optarg);
-- 
1.7.11.7

