From: Martin Kletzander Date: Tue, 23 Apr 2013 14:23:51 +0000 (+0200) Subject: Fix usb master startport parsing X-Git-Tag: v1.0.5-rc1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a553dbedb892625fbb13cbd88348603105fa8817;p=thirdparty%2Flibvirt.git Fix usb master startport parsing When all usb controllers connected to the same bus have specified, none of them have 'id=usb' assigned and thus qemu fails due to invalid masterport specification (we use 'usb' for that purpose). Adding a check that at least one of the controllers is specified without and in case this happens, error out due to invalid configuration. --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cb691785c9..efeaa251d6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9930,6 +9930,7 @@ virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr cur; bool usb_none = false; bool usb_other = false; + bool usb_master = false; bool primaryVideo = false; if (VIR_ALLOC(def) < 0) { @@ -10890,12 +10891,21 @@ virDomainDefParseXML(xmlDocPtr xml, } usb_other = true; } + + if (controller->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE) + usb_master = true; } virDomainControllerInsertPreAlloced(def, controller); } VIR_FREE(nodes); + if (usb_other && !usb_master) { + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("No master USB controller specified")); + goto error; + } + if (def->virtType == VIR_DOMAIN_VIRT_QEMU || def->virtType == VIR_DOMAIN_VIRT_KQEMU || def->virtType == VIR_DOMAIN_VIRT_KVM) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml new file mode 100644 index 0000000000..895d932281 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + /usr/bin/qemu + + +
+ + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e4103ec19f..25fa5b702a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -768,6 +768,9 @@ mymain(void) DO_TEST("usb-ich9-companion", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1); + DO_TEST_PARSE_ERROR("usb-ich9-no-companion", + QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1); DO_TEST("usb-hub", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_USB_HUB, QEMU_CAPS_NODEFCONFIG);