[libvirt] [PATCH 0/5] add usb redirection filter support

Guannan Ren gren at redhat.com
Sun Aug 19 15:42:43 UTC 2012


BZ RFE https://bugzilla.redhat.com/show_bug.cgi?id=795929
qemu support:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=6af165892cf900291046f1d25f95416f379504c2

Since qemu has have the code to support USB redirection filter. This set of
patches try to support it from libvirt.
The XML format is like this:
 <devices>
   ...
   <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>
   ...
 </devices>

Multiple <usbdev> element as one of filter rule could be added into parent
element <redirfilter>, only no more than <redirfilter> element could exists.
There is no 1:1 mapping between ports and redirected devices and qemu and
spicy client couldn't decide into which usbredir ports the client can 'plug'
redirected devices. So it make sense to apply all of filter rules global to
all existing usb redirection devices. class attribute is USB Class codes.
version is bcdDevice value of USB device. vendor and product is USB vendorId
and productId.
-1 can be used to allow any value for a field. Except allow attribute
the other four are optional, default value is -1.

The above XML will be converted to the following qemu command line:
If there are multiple usb-redir device, all of them have the same filter rules.
-device usb-redir,chardev=charredir0,id=redir0,\
filter=0x08:0x1234:0xBEEF:0x2000:1|-1:-1:-1:-1:0,bus=usb.0,port=4

Guannan Ren(0/5)
  qemu: add usb-redir.filter qemu capability flag
  qemu: define and parse USB redirection filter XML
  qemu: build USB redirection filter qemu command line
  test: add xml2argvtest for usb-redir filter and update
  doc: update usb redirection filter infomation on

 docs/formatdomain.html.in                          |   38 ++-
 docs/schemas/domaincommon.rng                      |   66 ++++
 src/conf/domain_conf.c                             |  346 ++++++++++++++++++++
 src/conf/domain_conf.h                             |   21 ++
 src/qemu/qemu_capabilities.c                       |    4 +
 src/qemu/qemu_capabilities.h                       |    1 +
 src/qemu/qemu_command.c                            |   45 +++-
 src/qemu/qemu_command.h                            |    5 +-
 src/qemu/qemu_hotplug.c                            |    3 +-
 .../qemuxml2argv-usb-redir-filter.args             |   10 +
 .../qemuxml2argv-usb-redir-filter.xml              |   45 +++
 tests/qemuxml2argvtest.c                           |    6 +
 12 files changed, 571 insertions(+), 19 deletions(-)




More information about the libvir-list mailing list