mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
Fix usb device version parsing issues
Request that the number be parsed as decimal, to allow 08 and 09. Format it with the leading zero, 1.01 and 1.10 are two different versions. https://bugzilla.redhat.com/show_bug.cgi?id=1210650
This commit is contained in:
parent
3f4c27497e
commit
a75069be35
@ -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 +
|
||||
|
@ -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
|
@ -0,0 +1,32 @@
|
||||
<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>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<redirdev bus='usb' type='spicevmc'>
|
||||
<address type='usb' bus='0' port='4'/>
|
||||
</redirdev>
|
||||
<redirdev bus='usb' type='spicevmc'>
|
||||
<address type='usb' bus='0' port='5'/>
|
||||
</redirdev>
|
||||
<redirfilter>
|
||||
<usbdev class='0x08' vendor='0x15E1' product='0x2007' version='1.09' allow='yes'/>
|
||||
<usbdev class='0x08' vendor='0x15E1' product='0x2007' version='9.4' allow='yes'/>
|
||||
<usbdev allow='no'/>
|
||||
</redirfilter>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
@ -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,
|
||||
|
@ -0,0 +1,32 @@
|
||||
<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>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu</emulator>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<redirdev bus='usb' type='spicevmc'>
|
||||
<address type='usb' bus='0' port='4'/>
|
||||
</redirdev>
|
||||
<redirdev bus='usb' type='spicevmc'>
|
||||
<address type='usb' bus='0' port='5'/>
|
||||
</redirdev>
|
||||
<redirfilter>
|
||||
<usbdev class='0x08' vendor='0x15E1' product='0x2007' version='1.09' allow='yes'/>
|
||||
<usbdev class='0x08' vendor='0x15E1' product='0x2007' version='9.40' allow='yes'/>
|
||||
<usbdev allow='no'/>
|
||||
</redirfilter>
|
||||
<memballoon model='virtio'/>
|
||||
</devices>
|
||||
</domain>
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user