提交 2650d5e1 编写于 作者: J Ján Tomko

qemu: error out on USB ports out of range

My overly sophisticated address reservation code forgot
to add an error message for user-requested ports out of range.

https://bugzilla.redhat.com/show_bug.cgi?id=1399260
上级 a1015889
......@@ -1987,6 +1987,13 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info,
portStr)))
goto cleanup;
if (targetPort >= virBitmapSize(targetHub->portmap)) {
virReportError(VIR_ERR_XML_ERROR,
_("requested USB port %s not present on USB bus %u"),
portStr, info->addr.usb.bus);
goto cleanup;
}
if (virBitmapIsBitSet(targetHub->portmap, targetPort)) {
virReportError(VIR_ERR_XML_ERROR,
_("Duplicate USB address bus %u port %s"),
......
<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'/>
<memballoon model='virtio'/>
<hub type='usb'>
<address type='usb' bus='0' port='1'/>
</hub>
<input type='mouse' bus='usb'>
<address type='usb' bus='0' port='4'/>
</input>
<hub type='usb'>
<address type='usb' bus='0' port='1.9'/>
</hub>
</devices>
</domain>
......@@ -1320,6 +1320,9 @@ mymain(void)
DO_TEST("usb-ports",
QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
QEMU_CAPS_NODEFCONFIG);
DO_TEST_PARSE_ERROR("usb-ports-out-of-range",
QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
QEMU_CAPS_NODEFCONFIG);
DO_TEST("usb-port-autoassign",
QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB,
QEMU_CAPS_NODEFCONFIG);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册