43fe83
From de73bf2cf5f37eab8fd19c4a5a773484c6e6b464 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <de73bf2cf5f37eab8fd19c4a5a773484c6e6b464.1377873636.git.jdenemar@redhat.com>
43fe83
From: Laine Stump <laine@laine.org>
43fe83
Date: Tue, 6 Aug 2013 13:23:18 -0600
43fe83
Subject: [PATCH] conf: add default USB controller in qemu post-parse callback
43fe83
43fe83
This patch is part of the resolution to:
43fe83
43fe83
   https://bugzilla.redhat.com/show_bug.cgi?id=819968
43fe83
43fe83
The parser shouldn't be doing arch-specific things like adding in
43fe83
implicit controllers to the config. This should instead be done in the
43fe83
hypervisor's post-parse callback.
43fe83
43fe83
This patch removes the auto-add of a usb controller from the domain
43fe83
parser, and puts it into the qemu driver's post-parse callback (just
43fe83
as is already done with the auto-add of the pci-root controller). In
43fe83
the future, any machine/arch that shouldn't have a default usb
43fe83
controller added should just set addDefaultUSB = false in this
43fe83
function.
43fe83
43fe83
We've recently seen that q35 and ARMV7L domains shouldn't get a default USB
43fe83
controller, so I've set addDefaultUSB to false for both of those.
43fe83
(cherry picked from commit c66da9d224ffba1d972beaf049c00dbebda4e8ea)
43fe83
---
43fe83
 src/conf/domain_conf.c |  6 ------
43fe83
 src/qemu/qemu_domain.c | 14 +++++++++++++-
43fe83
 2 files changed, 13 insertions(+), 7 deletions(-)
43fe83
43fe83
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
43fe83
index 783df96..18c6acf 100644
43fe83
--- a/src/conf/domain_conf.c
43fe83
+++ b/src/conf/domain_conf.c
43fe83
@@ -11718,12 +11718,6 @@ virDomainDefParseXML(xmlDocPtr xml,
43fe83
         goto error;
43fe83
     }
43fe83
 
43fe83
-    if (def->virtType == VIR_DOMAIN_VIRT_QEMU ||
43fe83
-        def->virtType == VIR_DOMAIN_VIRT_KQEMU ||
43fe83
-        def->virtType == VIR_DOMAIN_VIRT_KVM)
43fe83
-        if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
43fe83
-            goto error;
43fe83
-
43fe83
     /* analysis of the resource leases */
43fe83
     if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0) {
43fe83
         virReportError(VIR_ERR_INTERNAL_ERROR,
43fe83
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
43fe83
index da3b768..648121a 100644
43fe83
--- a/src/qemu/qemu_domain.c
43fe83
+++ b/src/qemu/qemu_domain.c
43fe83
@@ -699,6 +699,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
43fe83
                        virCapsPtr caps,
43fe83
                        void *opaque ATTRIBUTE_UNUSED)
43fe83
 {
43fe83
+    bool addDefaultUSB = true;
43fe83
     bool addPCIRoot = false;
43fe83
 
43fe83
     /* check for emulator and create a default one if needed */
43fe83
@@ -714,8 +715,10 @@ qemuDomainDefPostParse(virDomainDefPtr def,
43fe83
             break;
43fe83
         if (STRPREFIX(def->os.machine, "pc-q35") ||
43fe83
             STREQ(def->os.machine, "q35") ||
43fe83
-            STREQ(def->os.machine, "isapc"))
43fe83
+            STREQ(def->os.machine, "isapc")) {
43fe83
+            addDefaultUSB = false;
43fe83
             break;
43fe83
+        }
43fe83
         if (!STRPREFIX(def->os.machine, "pc-0.") &&
43fe83
             !STRPREFIX(def->os.machine, "pc-1.") &&
43fe83
             !STRPREFIX(def->os.machine, "pc-i440") &&
43fe83
@@ -725,6 +728,10 @@ qemuDomainDefPostParse(virDomainDefPtr def,
43fe83
         addPCIRoot = true;
43fe83
         break;
43fe83
 
43fe83
+    case VIR_ARCH_ARMV7L:
43fe83
+       addDefaultUSB = false;
43fe83
+       break;
43fe83
+
43fe83
     case VIR_ARCH_ALPHA:
43fe83
     case VIR_ARCH_PPC:
43fe83
     case VIR_ARCH_PPC64:
43fe83
@@ -737,6 +744,11 @@ qemuDomainDefPostParse(virDomainDefPtr def,
43fe83
         break;
43fe83
     }
43fe83
 
43fe83
+    if (addDefaultUSB &&
43fe83
+        virDomainDefMaybeAddController(
43fe83
+            def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
43fe83
+        return -1;
43fe83
+
43fe83
     if (addPCIRoot &&
43fe83
         virDomainDefMaybeAddController(
43fe83
             def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
43fe83
-- 
43fe83
1.8.3.2
43fe83