[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/7] conf: add default USB controller in qemu post-parse callback



The parser shouldn't be doing arch-specific things like adding in
implicit controllers to the config. This should instead be done in the
hypervisor's post-parse callback.

This patch removes the auto-add of a usb controller from the domain
parser, and puts it into the qemu driver's post-parse callback (just
as is already done with the auto-add of the pci-root controller). In
the future, any machine/arch that shouldn't have a default usb
controller added should just set addDefaultUSB = false in this
function.

We've recently seen that q35 and ARMV7L domains shouldn't get a default USB
controller, so I've set addDefaultUSB to false for both of those.
---
 src/conf/domain_conf.c |  6 ------
 src/qemu/qemu_domain.c | 14 +++++++++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e3aec69..63350b6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11718,12 +11718,6 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto error;
     }
 
-    if (def->virtType == VIR_DOMAIN_VIRT_QEMU ||
-        def->virtType == VIR_DOMAIN_VIRT_KQEMU ||
-        def->virtType == VIR_DOMAIN_VIRT_KVM)
-        if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
-            goto error;
-
     /* analysis of the resource leases */
     if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1ff802c..d3da666 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -699,6 +699,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
                        virCapsPtr caps,
                        void *opaque ATTRIBUTE_UNUSED)
 {
+    bool addDefaultUSB = true;
     bool addPCIRoot = false;
 
     /* check for emulator and create a default one if needed */
@@ -714,8 +715,10 @@ qemuDomainDefPostParse(virDomainDefPtr def,
             break;
         if (STRPREFIX(def->os.machine, "pc-q35") ||
             STREQ(def->os.machine, "q35") ||
-            STREQ(def->os.machine, "isapc"))
+            STREQ(def->os.machine, "isapc")) {
+            addDefaultUSB = false;
             break;
+        }
         if (!STRPREFIX(def->os.machine, "pc-0.") &&
             !STRPREFIX(def->os.machine, "pc-1.") &&
             !STRPREFIX(def->os.machine, "pc-i440") &&
@@ -725,6 +728,10 @@ qemuDomainDefPostParse(virDomainDefPtr def,
         addPCIRoot = true;
         break;
 
+    case VIR_ARCH_ARMV7L:
+       addDefaultUSB = false;
+       break;
+
     case VIR_ARCH_ALPHA:
     case VIR_ARCH_PPC:
     case VIR_ARCH_PPC64:
@@ -737,6 +744,11 @@ qemuDomainDefPostParse(virDomainDefPtr def,
         break;
     }
 
+    if (addDefaultUSB &&
+        virDomainDefMaybeAddController(
+            def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
+        return -1;
+
     if (addPCIRoot &&
         virDomainDefMaybeAddController(
             def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]