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.
This commit is contained in:
Laine Stump 2013-08-02 04:13:33 -04:00
parent 010065d702
commit c66da9d224
2 changed files with 13 additions and 7 deletions

View File

@ -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,

View File

@ -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,