[Spice-devel] USB redirection issues

Christophe Fergeau cfergeau at redhat.com
Thu Jul 2 09:10:56 PDT 2015


Hey Viacheslav,

On Tue, Jun 30, 2015 at 07:18:56PM +0400, Viacheslav Ivanov wrote:
> Hello, 
> we're using virt-viewer 0.5.7-8 to connect to VMs and found an issue
> that usb tokens are not always redirected to vm:
> they're always recognized by the host kernel on connect/disconnect
> events and properly handled by the pcscd daemon.

> Guest OS is RHEL 64. with SSO enabled. On connect to remote desktop VM
> doesn't have any USB devices like keyboard and mouse  or tokens. Guest
> has only linux root hub in lsusb output. One thing is that mouse and
> keyboard work well even they are missing in the lsusb output 

Keyboard/mouse are handled natively by SPICE so they don't go through
USB redirection.

> 
> remote-viewer has the following command line with the spice-usbredir-auto-redirect-filter option enabled:
> 
> #!/usr/bin/python
> 
> import subprocess
> 
> d = {}
> 
> args = ['host', 'vmid', 'cert_subj', 'port', 'sport', 'ticket', 'ca_cert']
> 
> if __name__ == "__main__":
> 	with open('/tmp/vm_log') as f:
> 		for line, arg in zip(f, args):
> 			d[arg] = line.rstrip('\n')
> 
> 	subprocess.call('remote-viewer -t \"VM Session\" -k --spice-usbredir-auto-redirect-filter="-1,-1,-1,-1,1" --spice-ca-file %s --spice-host-subject=\'%s\' spice://%s/?port=%s\&tls-port=%s\&password=%s' % (d['ca_cert'], d['cert_subj'], d['host'], d['port'], d['sport'], d['ticket']), shell=True)
> 
> The token is a smartcard in a form of a usb flash drive. I am
> attaching files with lsusb -vv and pcscd debug output for it.
> 
> Any usb device, e.g. a keyboard or usb flash drive, is redirected on
> reconnect to host machine, but if they were already in the host at the
> moment of a spice connection, they do not appear in the guest machine.
>
> If we force a reconnect from the system by rebinding the usb bus on
> host machine with something like:
> echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind && echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind
> all the devices connected to it will appear in the system, including the keyboard and mouse

If you look at remote-viewer --help-spice you'll see:
--spice-usbredir-auto-redirect-filter=<filter-string> Filter selecting USB devices to be auto-redirected when plugged in
--spice-usbredir-redirect-on-connect=<filter-string>  Filter selecting USB devices to redirect on connect

You are using --spice-usbredir-auto-redirect-filter so the behaviour you
describe is actually the documented one, the devices get automatically
redirected when they are physically plugged in in the client (or
unbound/bound again).
--spice-usbredir-redirect-on-connect will redirect the devices "on
connect", that is when the SPICE connection is established with the
remote VM. Given your requirements description, I think this is this
option you are after, not --spice-usbredir-auto-redirect-filter.
This option was added in spice-gtk 0.14. You should use a more specific
filter though, otherwise this is going to redirect your client
keyboard/mouse to the VM, and they will no longer be usable with your
client OS.

Hope that helps,

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150702/3b2811cb/attachment-0001.sig>


More information about the Spice-devel mailing list