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
This commit is contained in:
Ján Tomko 2016-11-28 11:05:22 +01:00
parent a101588921
commit 2650d5e1f5
3 changed files with 35 additions and 0 deletions

View File

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

View File

@ -0,0 +1,25 @@
<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>

View File

@ -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);