Skip to contentSkip to conversation

usb-redir: Add the posibility to filter out certain devices from redirecion

PATCH In review Hans de Goede 3 participants 5 messages Jan 12, 2012 – Jan 25, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb-redir: Add the posibility to filter out certain devices from redirecion

This patch adds the posibility to filter out certain devices from redirecion. To use this pass the filter property to -device usb-redir. The filter property takes a string consisting of filter rules, the format for a rule is:
<class>:<vendor>:<product>:<version>:<allow>

-1 can be used to allow any value for a field.

Muliple rules can be concatonated using | as a separator. Note that if a device matches none of the passed in rules, redirecting it will not be allowed!

Example:
-device usb-redir,filter='-1:0x0781:0x5567:-1:0|0x08:-1:-1:-1:1'

This example will deny the Sandisk Cruzer Blade being redirected, as it has a usb id of 0781:5567, it will allow any other usb mass storage devices, and it will deny any other devices (the default for devices not matching any of the rules.

---
 configure   |    2 +-
 usb-redir.c |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 105 insertions(+), 11 deletions(-)
configure +1 -1
index 7ecf44e..c7e37df 100755
@@ -2541,7 +2541,7 @@ fi
 
 # check for usbredirparser for usb network redirection support
 if test "$usb_redir" != "no" ; then
-    if $pkg_config libusbredirparser >/dev/null 2>&1 ; then
+    if $pkg_config --atleast-version=0.3.3 libusbredirparser >/dev/null 2>&1 ; then
         usb_redir="yes"
         usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
         usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
usb-redir.c +104 -10

200 lines not on this page · raw message

Signature · 1 line
1.7.7.4
#1 lore raw
Quoted 11 lines · Hans de Goede

This patch adds the posibility to filter out certain devices from redirecion. To use this pass the filter property to -device usb-redir. The filter property takes a string consisting of filter rules, the format for a rule is:
<class>:<vendor>:<product>:<version>:<allow>

-1 can be used to allow any value for a field.

Muliple rules can be concatonated using | as a separator. Note that if a device matches none of the passed in rules, redirecting it will not be allowed!

Hmm, '|' makes quoting mandatory. And the :<allow> is also not that beautiful IMHO.

What about

[+]|-<class>:<vendor>:<product>:<version>[/[+]|-<class>:...]

? Optional '+' means allow, '-' disallow. An empty field could also serve as wildcard (instead of explicit -1 which would collide with disallow).

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#2 lore raw
In reply to Hans de Goede
Quoted 4 lines · Hans de Goede

This patch adds the posibility to filter out certain devices from redirecion. To use this pass the filter property to -device usb-redir. The filter property takes a string consisting of filter rules, the format for a rule is:
<class>:<vendor>:<product>:<version>:<allow>

Hmm, what is the point of having this filter in qemu?

I'd expect the other end of the network connection which talks to the actual usb device (i.e. the tcp standalone server or spice client) doing the filtering ...

cheers,
Gerd

#3 lore raw
Quoted 11 lines · Gerd Hoffmann
Quoted 4 lines · Hans de Goede

This patch adds the posibility to filter out certain devices from redirecion. To use this pass the filter property to -device usb-redir. The filter property takes a string consisting of filter rules, the format for a rule is:
<class>:<vendor>:<product>:<version>:<allow>

Hmm, what is the point of having this filter in qemu?

I'd expect the other end of the network connection which talks to the actual usb device (i.e. the tcp standalone server or spice client) doing the filtering ...

Also fails checkpatch:

WARNING: line over 80 characters
#75: FILE: usb-redir.c:898:
+ qerror_report(QERR_INVALID_PARAMETER_VALUE, "filter", "a
usb device filter string");

total: 0 errors, 1 warnings, 208 lines checked

cheers,
Gerd

#4 lore raw

Hi,

Quoted 7 lines · Gerd Hoffmann
Quoted 6 lines · Gerd Hoffmann
Quoted 4 lines · Hans de Goede

This patch adds the posibility to filter out certain devices from redirecion. To use this pass the filter property to -device usb-redir. The filter property takes a string consisting of filter rules, the format for a rule is:
<class>:<vendor>:<product>:<version>:<allow>

Quoted 5 lines
Quoted 5 lines

Hmm, what is the point of having this filter in qemu?

I'd expect the other end of the network connection which talks to the actual usb device (i.e. the tcp standalone server or spice client) doing the filtering ...

The admin of the vm may want to allow only certain devices to be redirected to the vm. And while he has administrative control over the vm, he does not necessarily have administrative control over the client.

Quoted 7 lines

Also fails checkpatch:

WARNING: line over 80 characters
#75: FILE: usb-redir.c:898:
+ qerror_report(QERR_INVALID_PARAMETER_VALUE, "filter", "a
usb device filter string");

Oops, I'll send a new version.

Regards,

Hans