From ba3daaef85007c5ef48c0057284654cd22c168f7 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Fri, 2 Aug 2013 04:13:33 -0400 Subject: [PATCH] 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. (cherry picked from commit c66da9d224ffba1d972beaf049c00dbebda4e8ea) --- 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 783df96..18c6acf 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 da3b768..648121a 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,