When connected to a VM's graphical display, any USB device plugged in to your physical host will be automatically redirected to the VM. This is great for easily sharing a usb drive with your VM. Existing devices can also be manually attached via the VM window menu option 'Virtual Machine->Redirect USB Device'
The great thing about Spice USB redirection is that it doesn't require configuring the spice agent or any special drivers inside the VM, so for example it will 'just work' for your existing windows VMs. And since the streaming is done via the spice display widget, you can easily share a local USB device with a VM on a remote host.
This feature is only properly enabled for KVM VMs that are created with virt-manager 1.0 or later. Configuring an existing VM requires 3 changes:
- Set the graphics type to Spice
- Set the USB controller model to USB2
- Add a 'Redirection USB' device to the VM. Add multiple redirection devices to allow redirecting multiple host USB devices simultaneously.
For more details, like how to do this using libvirt XML or the qemu command line, check the documentation over here:
http://people.freedesktop.org/~teuf/spice-doc/html/
Great news! I have not tested yet.
ReplyDeleteSo we will no more require to install Windows XP & torture our new hardware, just to activate UMTS/EV-DO dongles :)
Just use a VM instance of WinXP. Am I right?
virt-manager + qemu have supported USB device assignment for a long time, Add Hardware->USB Host Device.
DeleteThis feature is just about the automatic assignment when you plug in a device while connected to the guest console, and being able to use it for a VM on a remote machine.
But yes, hopefully this can be used to accomplish that use case :)
Hi. I am looking for a way to automatically redirect my (internal) Bluetooth adapter to the VM. Spice is working, and I can accomplish it manually through the USB redirection menu option. But I would like to have it done automatically every time I start up the VM. Is that possible?
ReplyDeleteUse Add Hardware->Host USB device option to permanently attach it
DeleteI guess I was not reading properly, and read this "Add Hardware-> Host USB device" as being the manual option. It works like a charm. Thanks!
DeleteMy Windows 7 VM is running on a CentOS box with a Fedora 20 workstation client. I'd like to share a USB device plugged into the workstation. The VM domain XML has had the and a element added. The remote-viewer shows all the USB devices on my workstation, but they are greyed out and an Alert message says "Some USB devices are blocked by host policy". What configuration file on which machine is needed to "unblock" the host policy? I'm already enabling the redirection in the remote-viewer INI file use to launch the client.
ReplyDeleteI replied to your email thread: https://lists.fedoraproject.org/pipermail/virt/2015-January/004202.html
DeleteI tried this and it doesn't work. The virt-viewer says "USB Support not compiled in". Did you miss a step?
ReplyDeleteThose are the steps for fedora. You're distro probably isn't compiling spice-gtk against libusbredir or something along those lines
DeleteHow can I do usb redirection from the command line?
ReplyDeleteUbuntu 15.04
I need to distribute several usb test devices to running VM's for testing. The VM's go up run a test then go away to make room for other VM's.
I started with virsh attach-device/detach-device. This works in that the device appears on the host, but a 'scan for hardware changes' is not triggered. It is similar to the add usb device function in behavior, the xml files at /var/run/libvirt are modified.
Your virt-manager USB host works completely. It triggers the scan, breaks the usb device into its composite device components, and tries to load a driver. The XML files are not modified, so I don't understand how you are doing this, and if it can be scripted.
Is there a way to do what you are doing in virsh? or any command line method?
I know when the VM's are going up and down, and I need a way to script the attachment/detachment of test devices.
Thanks!
The redirection described in this post requires the spice graphical console to be connected, so AFAIK there isn't anyway to do it headless from the commandline.
Delete