diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 880b89cc43..5005d2e167 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11386,8 +11386,8 @@ virDomainRedirFilterUSBVersionHelper(const char *version, *temp = '\0'; temp++; - if ((virStrToLong_ui(version_copy, NULL, 0, &major)) < 0 || - (virStrToLong_ui(temp, NULL, 0, &minor)) < 0) { + if ((virStrToLong_ui(version_copy, NULL, 10, &major)) < 0 || + (virStrToLong_ui(temp, NULL, 10, &minor)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Cannot parse USB version %s"), version); goto cleanup; @@ -20256,7 +20256,7 @@ virDomainRedirFilterDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " product='0x%04X'", usbdev->product); if (usbdev->version >= 0) - virBufferAsprintf(buf, " version='%d.%d'", + virBufferAsprintf(buf, " version='%d.%02d'", ((usbdev->version & 0xf000) >> 12) * 10 + ((usbdev->version & 0x0f00) >> 8), ((usbdev->version & 0x00f0) >> 4) * 10 + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter-version.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter-version.args new file mode 100644 index 0000000000..463e9ded2c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter-version.args @@ -0,0 +1,14 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S \ +-M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c \ +-usb -chardev spicevmc,id=charredir0,name=usbredir \ +-device 'usb-redir,chardev=charredir0,id=redir0,\ +filter=0x08:0x15E1:0x2007:0x0109:1|0x08:0x15E1:0x2007:0x0940:1|\ +-1:-1:-1:-1:0,bus=usb.0,port=4' \ +-chardev spicevmc,id=charredir1,name=usbredir \ +-device 'usb-redir,chardev=charredir1,id=redir1,\ +filter=0x08:0x15E1:0x2007:0x0109:1|0x08:0x15E1:0x2007:0x0940:1|\ +-1:-1:-1:-1:0,bus=usb.0,port=5' \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter-version.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter-version.xml new file mode 100644 index 0000000000..c07cddd9f5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-filter-version.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c02555dcd4..8d0a4aa319 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1153,6 +1153,11 @@ mymain(void) QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_USB_REDIR, QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC, QEMU_CAPS_USB_REDIR_FILTER); + DO_TEST("usb-redir-filter-version", + QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_USB_REDIR, + QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC, + QEMU_CAPS_USB_REDIR_FILTER); DO_TEST("usb1-usb2", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_PIIX3_USB_UHCI, diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-redir-filter-version.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-redir-filter-version.xml new file mode 100644 index 0000000000..f111755c2e --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-redir-filter-version.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + +
+ + + + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index dce7a83fee..5a5812fae0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -505,6 +505,7 @@ mymain(void) DO_TEST("usb-redir"); DO_TEST_DIFFERENT("usb-redir-filter"); + DO_TEST_DIFFERENT("usb-redir-filter-version"); DO_TEST("blkdeviotune"); DO_TEST_FULL("seclabel-dynamic-baselabel", false, WHEN_INACTIVE);