提交 a553dbed 编写于 作者: M Martin Kletzander

Fix usb master startport parsing

When all usb controllers connected to the same bus have <master
startport='x'/> 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 <master startport='x'/> and in case
this happens, error out due to invalid configuration.
上级 01d5a972
...@@ -9930,6 +9930,7 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -9930,6 +9930,7 @@ virDomainDefParseXML(xmlDocPtr xml,
xmlNodePtr cur; xmlNodePtr cur;
bool usb_none = false; bool usb_none = false;
bool usb_other = false; bool usb_other = false;
bool usb_master = false;
bool primaryVideo = false; bool primaryVideo = false;
if (VIR_ALLOC(def) < 0) { if (VIR_ALLOC(def) < 0) {
...@@ -10890,12 +10891,21 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -10890,12 +10891,21 @@ virDomainDefParseXML(xmlDocPtr xml,
} }
usb_other = true; usb_other = true;
} }
if (controller->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE)
usb_master = true;
} }
virDomainControllerInsertPreAlloced(def, controller); virDomainControllerInsertPreAlloced(def, controller);
} }
VIR_FREE(nodes); 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 || if (def->virtType == VIR_DOMAIN_VIRT_QEMU ||
def->virtType == VIR_DOMAIN_VIRT_KQEMU || def->virtType == VIR_DOMAIN_VIRT_KQEMU ||
def->virtType == VIR_DOMAIN_VIRT_KVM) def->virtType == VIR_DOMAIN_VIRT_KVM)
......
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<devices>
<emulator>/usr/bin/qemu</emulator>
<controller type='usb' index='0' model='ich9-uhci2'>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0'/>
</controller>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0'/>
</memballoon>
</devices>
</domain>
...@@ -768,6 +768,9 @@ mymain(void) ...@@ -768,6 +768,9 @@ mymain(void)
DO_TEST("usb-ich9-companion", DO_TEST("usb-ich9-companion",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1); 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", DO_TEST("usb-hub",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_USB_HUB, QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_USB_HUB,
QEMU_CAPS_NODEFCONFIG); QEMU_CAPS_NODEFCONFIG);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册