yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-Fix-machine-options-accel-kernel_irqchip-kvm_shadow_.patch

218e99
From 63d9ae740b30071f01c5fd1196f077b635491530 Mon Sep 17 00:00:00 2001
218e99
From: Markus Armbruster <armbru@redhat.com>
218e99
Date: Tue, 6 Aug 2013 13:17:03 +0200
218e99
Subject: [PATCH 10/28] Fix -machine options accel, kernel_irqchip, kvm_shadow_mem
218e99
218e99
RH-Author: Markus Armbruster <armbru@redhat.com>
218e99
Message-id: <1375795025-28674-5-git-send-email-armbru@redhat.com>
218e99
Patchwork-id: 52993
218e99
O-Subject: [PATCH 7.0 qemu-kvm 4/6] Fix -machine options accel, kernel_irqchip, kvm_shadow_mem
218e99
Bugzilla: 980782
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
218e99
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
218e99
218e99
Multiple -machine options with the same ID are merged.  All but the
218e99
one without an ID are to be silently ignored.
218e99
218e99
In most places, we query these options with a null ID.  This is
218e99
correct.
218e99
218e99
In some places, we instead query whatever options come first in the
218e99
list.  This is wrong.  When the -machine processed first happens to
218e99
have an ID, options are taken from that ID, and the ones specified
218e99
without ID are silently ignored.
218e99
218e99
Example:
218e99
218e99
    $ upstream-qemu -nodefaults -S -display none -monitor stdio -machine id=foo -machine accel=kvm,usb=on
218e99
    $ upstream-qemu -nodefaults -S -display none -monitor stdio -machine id=foo,accel=kvm,usb=on -machine accel=xen
218e99
    $ upstream-qemu -nodefaults -S -display none -monitor stdio -machine accel=xen -machine id=foo,accel=kvm,usb=on
218e99
218e99
    $ qemu-system-x86_64 -nodefaults -S -display none -monitor stdio -machine accel=kvm,usb=on
218e99
    QEMU 1.5.50 monitor - type 'help' for more information
218e99
    (qemu) info kvm
218e99
    kvm support: enabled
218e99
    (qemu) info usb
218e99
    (qemu) q
218e99
    $ qemu-system-x86_64 -nodefaults -S -display none -monitor stdio -machine id=foo -machine accel=kvm,usb=on
218e99
    QEMU 1.5.50 monitor - type 'help' for more information
218e99
    (qemu) info kvm
218e99
    kvm support: disabled
218e99
    (qemu) info usb
218e99
    (qemu) q
218e99
    $ qemu-system-x86_64 -nodefaults -S -display none -monitor stdio -machine id=foo,accel=kvm,usb=on -machine accel=xen
218e99
    QEMU 1.5.50 monitor - type 'help' for more information
218e99
    (qemu) info kvm
218e99
    kvm support: enabled
218e99
    (qemu) info usb
218e99
    USB support not enabled
218e99
    (qemu) q
218e99
    $ qemu-system-x86_64 -nodefaults -S -display none -monitor stdio -machine accel=xen -machine id=foo,accel=kvm,usb=on
218e99
    xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error
218e99
    xen be core: can't open xen interface
218e99
    failed to initialize Xen: Operation not permitted
218e99
218e99
Option usb is queried correctly, and the one without an ID wins,
218e99
regardless of option order.
218e99
218e99
Option accel is queried incorrectly, and which one wins depends on
218e99
option order and ID.
218e99
218e99
Affected options are accel (and its sugared forms -enable-kvm and
218e99
-no-kvm), kernel_irqchip, kvm_shadow_mem.
218e99
218e99
Additionally, option kernel_irqchip is normally on by default, except
218e99
it's off when no -machine options are given.  Bug can't bite, because
218e99
kernel_irqchip is used only when KVM is enabled, KVM is off by
218e99
default, and enabling always creates -machine options.  Downstreams
218e99
that enable KVM by default do get bitten, though.
218e99
218e99
Use qemu_get_machine_opts() to fix these bugs.
218e99
218e99
Signed-off-by: Markus Armbruster <armbru@redhat.com>
218e99
Message-id: 1372943363-24081-5-git-send-email-armbru@redhat.com
218e99
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
218e99
(cherry picked from commit 36ad0e948e15d8d86c8dec1c17a8588d87b0107d)
218e99
218e99
Conflicts:
218e99
	hw/ppc/e500.c
218e99
218e99
Conflicts, because we don't have commit d85937e "kvm/openpic:
218e99
in-kernel mpic support".  Resolution is trivial: drop the hunk.
218e99
218e99
There's a pasto in upstream's commit message.  The first paragraph
218e99
after "Example:" shouldn't be there.
218e99
---
218e99
 kvm-all.c         |  5 +----
218e99
 target-i386/kvm.c | 17 +++++++----------
218e99
 vl.c              |  8 ++------
218e99
 3 files changed, 10 insertions(+), 20 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 kvm-all.c         |    5 +----
218e99
 target-i386/kvm.c |   17 +++++++----------
218e99
 vl.c              |    8 ++------
218e99
 3 files changed, 10 insertions(+), 20 deletions(-)
218e99
218e99
diff --git a/kvm-all.c b/kvm-all.c
218e99
index 8222729..6c9d51e 100644
218e99
--- a/kvm-all.c
218e99
+++ b/kvm-all.c
218e99
@@ -1256,12 +1256,9 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
218e99
 
218e99
 static int kvm_irqchip_create(KVMState *s)
218e99
 {
218e99
-    QemuOptsList *list = qemu_find_opts("machine");
218e99
     int ret;
218e99
 
218e99
-    if (QTAILQ_EMPTY(&list->head) ||
218e99
-        !qemu_opt_get_bool(QTAILQ_FIRST(&list->head),
218e99
-                           "kernel_irqchip", true) ||
218e99
+    if (!qemu_opt_get_bool(qemu_get_machine_opts(), "kernel_irqchip", true) ||
218e99
         !kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
218e99
         return 0;
218e99
     }
218e99
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
218e99
index 9ffb6ca..8da6a0d 100644
218e99
--- a/target-i386/kvm.c
218e99
+++ b/target-i386/kvm.c
218e99
@@ -741,7 +741,6 @@ static int kvm_get_supported_msrs(KVMState *s)
218e99
 
218e99
 int kvm_arch_init(KVMState *s)
218e99
 {
218e99
-    QemuOptsList *list = qemu_find_opts("machine");
218e99
     uint64_t identity_base = 0xfffbc000;
218e99
     uint64_t shadow_mem;
218e99
     int ret;
218e99
@@ -790,15 +789,13 @@ int kvm_arch_init(KVMState *s)
218e99
     }
218e99
     qemu_register_reset(kvm_unpoison_all, NULL);
218e99
 
218e99
-    if (!QTAILQ_EMPTY(&list->head)) {
218e99
-        shadow_mem = qemu_opt_get_size(QTAILQ_FIRST(&list->head),
218e99
-                                       "kvm_shadow_mem", -1);
218e99
-        if (shadow_mem != -1) {
218e99
-            shadow_mem /= 4096;
218e99
-            ret = kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem);
218e99
-            if (ret < 0) {
218e99
-                return ret;
218e99
-            }
218e99
+    shadow_mem = qemu_opt_get_size(qemu_get_machine_opts(),
218e99
+                                   "kvm_shadow_mem", -1);
218e99
+    if (shadow_mem != -1) {
218e99
+        shadow_mem /= 4096;
218e99
+        ret = kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem);
218e99
+        if (ret < 0) {
218e99
+            return ret;
218e99
         }
218e99
     }
218e99
     return 0;
218e99
diff --git a/vl.c b/vl.c
218e99
index fe58eff..0ed9257 100644
218e99
--- a/vl.c
218e99
+++ b/vl.c
218e99
@@ -2661,17 +2661,13 @@ static struct {
218e99
 
218e99
 static int configure_accelerator(void)
218e99
 {
218e99
-    const char *p = NULL;
218e99
+    const char *p;
218e99
     char buf[10];
218e99
     int i, ret;
218e99
     bool accel_initialised = false;
218e99
     bool init_failed = false;
218e99
 
218e99
-    QemuOptsList *list = qemu_find_opts("machine");
218e99
-    if (!QTAILQ_EMPTY(&list->head)) {
218e99
-        p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
218e99
-    }
218e99
-
218e99
+    p = qemu_opt_get(qemu_get_machine_opts(), "accel");
218e99
     if (p == NULL) {
218e99
         /* Use the default "accelerator", tcg */
218e99
         p = "kvm:tcg";
218e99
-- 
218e99
1.7.1
218e99