Re: [PATCH 3/5] qemu: build USB redirection filter qemu command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 12, 2012 at 04:35:48PM +0800, Guannan Ren wrote:
> <redirdev bus='usb' type='spicevmc'>
>    <address type='usb' bus='0' port='4'/>
>  </redirdev>
> <redirfilter>
>   <usbdev class='0x08' vendor='0x1234' product='0xbeef' \
>           version='2.00' allow='yes'/>
>   <usbdev class='-1' vendor='-1' product='-1' version='-1' allow='no'/>
> </redirfilter>
> 
> will be converted to:
> -device usb-redir,chardev=charredir0,id=redir0,\
> filter=0x08:0x1234:0xBEEF:0x2000:1|-1:-1:-1:-1:0,bus=usb.0,port=4
> ---
>  src/qemu/qemu_command.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
>  src/qemu/qemu_command.h |  5 +++--
>  src/qemu/qemu_hotplug.c |  3 ++-
>  3 files changed, 48 insertions(+), 5 deletions(-)
> 

> +    if (redirfilter && redirfilter->nusbdevs) {
> +        if (!qemuCapsGet(qemuCaps, QEMU_CAPS_USB_REDIR_FILTER)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("USB redirection filter is not "
> +                             "supported by this version of QEMU"));
> +            goto error;
> +        }
> +
> +        virBufferAsprintf(&buf, ",filter=");
> +
> +        for (i = 0; i < redirfilter->nusbdevs; i++) {
> +            virDomainRedirFilterUsbDevDefPtr usbdev = redirfilter->usbdevs[i];
> +            if (usbdev->usbClass > 0)
> +                virBufferAsprintf(&buf, "0x%02X:", usbdev->usbClass);
> +            else
> +                virBufferAsprintf(&buf, "-1:");
> +
> +            if (usbdev->vendor > 0)
> +                virBufferAsprintf(&buf, "0x%04X:", usbdev->vendor);
> +            else
> +                virBufferAsprintf(&buf, "-1:");
> +
> +            if (usbdev->product > 0)
> +                virBufferAsprintf(&buf, "0x%04X:", usbdev->product);
> +            else
> +                virBufferAsprintf(&buf, "-1:");
> +
> +            if (usbdev->version > 0)
> +                virBufferAsprintf(&buf, "0x%04X:", usbdev->version);
> +            else
> +                virBufferAsprintf(&buf, "-1:");

Here you're adding '-1' for either 0 or any negative number.

When parsing & formatting though, you're treating '0' in the
same way as positive numbers.

I think we need to treat 0 as we do any other number,
because it is valid for a vendor to use a product ID
of 0x0 for their device.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]