3

I am trying to get my Windows VM to access my USB pen drive, but I am having problems passing this USB over to the VM.

On my Linux host machine, I ran lsusb where my device was identified as

Bus 001 Device 018 : ID 8564:1000 Transcend Information, Inc. Jetflash

Looking at a few guides, I tried to pass this USB to kvm using

qemu-system-x86_64 -m 3G --enable-kvm "Windows 10.qcow2" -usb -device usb-host,hostbus=1,hostaddr=18

No matter what I try, I get the error saying "usb-host" is not a valid device.

I tried to change that to usb-storage, since that is the class of device I see for it when doing lsusb -t, but I don't know what to pass for Device ID..If I leave it blank, it says property ".drive" is missing, as expected.

I tried doing a ls /sys/bus/usb/devices which printed out some information like

1-0:10 1-1 1-1.1 ........usb1 usb2

But no matter which id I try and pass along in the command qemu-system-x86_64 -m 3G --enable-kvm "Windows 10.qcow2" -usb -device usb-storage,drive=<one of the above>,

it says no such property with given value exists.

So,

  1. Should I be concerned that usb-host is not a valid device?
  2. What do I need to do to get usb-storage with device id to work?
  3. Does qemu-kvm support usb 2, 3 and streaming camera?

I'm using QEMU emulator version 4.1.0

2
  • The fact that you're getting a "usb-host" error may mean something. If you do qemu-system-x86_64 -device help | grep usb-host does it show up? If not you might need to recompile qemu. usb-storage is probably not what you want, that's for adding a file image as a usb storage device in the VM though maybe it can use a raw device. USB2 is supported. USB3 is not AFAIK but I haven't checked in a long time.
    – CR.
    Mar 8, 2022 at 20:15
  • usb-host is not among the possible domains names here if I execute a command like the on @CR. gave. Aug 10, 2022 at 15:11

4 Answers 4

3

just thought I'd put my two cents in. I was trying to add a usb printer to my VM and tried the whole "qemu-kvm" command route to no avail. I eventually just manually added the xml entry into my VM's domain xml following this libvirt link. On the host machine run:

lsusb

Find the line that represents your usb device.

Bus 001 Device 003: ID 03f0:1617 HP, Inc LaserJet 3015

"ID" represents your vendor id and product id seperated by a colon. Then simply replace your devices vendor and product id in the xml code below (include the 0x for hex) and add it as an element with-in your VM's "devices" block:

<hostdev mode='subsystem' type='usb'>                                                            
  <source startupPolicy='optional'>                                                              
    <vendor id='0x03f0'/>                                                                        
    <product id='0x1617'/>                                                                       
  </source>                                                                                      
  <boot order='2'/>                                                                              
</hostdev>

Good luck and hope this helps. FYI, to edit your domain's xml file, run:

virsh dumpxml yourdomain

and then

virsh edit yourdomain

This will load the xml file you can edit.

1
  • nice! i just removed the <address type="usb" bus="2" port="3"/> from my previous config and press "apply" and the bus and port will be autodetected, when usb device itself is connected. While using virt-manager. Also, I would like to add, the bus=2 and port=3 does not apply on the host machine in either bus or port.
    – LAamanni
    Sep 21, 2023 at 19:15
2

If using a graphical front-end is okay for you, virt-manager's USB-passthrough works.

In the info section click add Hardware and select USB Host Device.

I use it to pass pen drives to Windows 10 guests and didn't encounter any problems until now.

If a USB device is added, the machine will not boot, when it is not detected. I.e. the pen drive has to be attached for the VM to boot.

0

I'm new to this platform, so forgive my formatting. As indicated before it all starts with

lsusb

Get the bus and device numbers, in your case 1 and 18. Then, make a jetflash.xml file containing:

<hostdev mode='subsystem' type='usb' managed='yes'>
  <source>
    <address bus='1' device='18'/>
  </source>
</hostdev>

You see where the numbers go! Now, to attach/detach to the running vmID:

virsh attach-device vmID /path/to/jetflash.xml
virsh detach-device vmID /path/to/jetflash.xml

I hope this helps.

0

I've had a very alike problem, however im using virt manager and i spent hours trying to figure out what could be wrong, initially i assumed something is wrong in my xml file. However I came to the realization that this problem appeared after running sudo pacman -Syu

For some reason this made my qemu-hw-usb-host go missing which caused usb host to not be recognized as a valid device name.

My solution was to reinstall libusb sudo pacman -S libusb (not sure if this was necessary) and then sudo pacman -S qemu-hw-usb-host

I hope this is a simple and helpful solution for anyone with this problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .