LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Problem passing through usb devices in qemu (https://www.linuxquestions.org/questions/slackware-14/problem-passing-through-usb-devices-in-qemu-4175492519/)

insectiod 01-25-2014 09:31 AM

Problem passing through usb devices in qemu
 
I'm running qemu without libvirt on slackware 14.1. I want to pass through a usb device from host to guest. I start the quest machine as root and add -usb. Typing info usbhost in guest monitor gives: USB host devices not supported.

Some tutorials mention looking at permissions in /proc/bus/usb/devices. But I only have /proc/bus/input and /proc/bus/pci. But lsusb works and shows my devices. Could this be related to my problem?

I have tried with both ubuntu and slackware as guests.

Versions:
Slackware 14.1 32 bit (host)
qemu 1.7.0

xj25vm 01-26-2014 04:24 PM

I use qemu without libvirt on Slackware as well. I use the following to connect to my HP printer from the guest:

Code:

      -usb -device usb-host,vendorid=0x03f0,productid=0x1312
It took me a while to find the syntax for using the vendorid and productid - instead of the hostbus and hostaddr which most online examples seem to use.

Coming back to your problem, I don't know how you installed qemu - but I used the SlackBuilds.org script. If you want to use usb redirection, you have to install first the usbredir package - than build qemu and the SBo build script will automatically enable usbredirection for qemu.

The usbredir package can be found here:

http://slackbuilds.org/repository/14...earch=usbredir

Otherwise, if you compile qemu by hand, you will have to install somehow the usbredir package first, and then pass --enable-usb-redir when configuring qemu.

Hope the above helps.

insectiod 01-27-2014 06:32 PM

Thanks for helping out.

I tried uninstalling qemu, then building and installing usbredir-0.6, and then building and installing qemu-1.7.0, both from slackbuilds. info usbhost in guest monitor still gives: USB host devices not supported.

I also tried with the command line options suggested:
Code:

>>>qemu-system-i386 -usb -device usb-host,vendorid=0x0781,productid=0x5151 slack.vmdk
qemu-system-i386: -device usb-host,vendorid=0x0781,productid=0x5151: Parameter 'driver' expects device type

Maybe this is because I got the vendor or product id wrong. But either way I dont think thats the problem. I think the problem is that I somehow don't have usb support in qemu.

All I want is to pass through usb from host to guest. So I think that what I need is libusb, not usb-redir:
Code:

>>>./configure --help | grep usb
  --disable-libusb        disable libusb (for usb passthrough)
  --enable-libusb          enable libusb (for usb passthrough)
  --disable-usb-redir      disable usb network redirection support
  --enable-usb-redir      enable usb network redirection support

Trying to compile qemu manually I get this:
Code:

>>>./configure --target-list=i386-softmmu,x86_64-softmmu --enable-kvm --enable-libusb
ERROR: User requested feature libusb
      configure was not able to find it

But I have checked and libusb-1.0.9 is installed.

xj25vm 01-28-2014 03:31 AM

Hmm - yes, thinking about it libusb sounds the more likely candidate. I'm not really sure though why the config process can't find it. On the other hand, looking at my qemu.Slackbuild script, it looks like I didn't add --enable-libusb, so it must get enabled automatically if it finds libusb. Maybe somebody with a bit more experience of libraries/compilation issues could weigh in.

On my box, I get the following when searching for libusb, in case it helps:

Code:

# ls /var/log/packages/ | grep libusb
libusb-1.0.9-x86_64-1
libusb-compat-0.1.4-x86_64-1


insectiod 01-28-2014 07:28 AM

I also have libusb-1.0.9.

It is strange because qemu 1.6.1 (and 1.7.0) have this line in configure:
Code:

if $pkg_config --atleast-version=1.0.13 libusb-1.0 >/dev/null 2>&1 ; then
If that returns false then libusb support is not added. But the latest version of libusb is 1.0.9. Not only for slackware, I couldn't even find a development version of libusb with version 1.0.13.

xj25vm, if you have the time could you check this. Goto the monitor prompt of any guest machine and run 'info usbhost' and post the result.

Did your version of qemu compile with libusb support? Post the output of:
Code:

grep libusb /tmp/SBo/qemu-1.6.1/config-host.mak

ml4711 01-28-2014 11:46 AM

Maybe this helps

http://sourceforge.net/projects/libu...libusb-1.0.18/

enjoy

insectiod 01-28-2014 04:40 PM

Ok, I got it working.

I switched to libusb-1.0.18 and then built qemu-1.7.0 using the slackbuild script. Started qemu with -usb option and now I can add usb devices in qemu monitor with usb_add. I also had to check permissions for the device I wanted to pass through in /dev/bus/usb/bus/port.

xj25vm 01-29-2014 03:11 AM

Great stuff. Glad it is working. It's strange that you needed libusb-1.0.18 as at least qemu 1.6.1 seems to be happy with libusb-1.0.9

SpiderTux 11-09-2014 03:53 PM

Sorry for re-open this old thread.
I need "passing through usb devices in qemu" release 2.1.2
Reading this old thread and comments in slackbuilds.org qemu.SlackBuild:
http://slackbuilds.org/slackbuilds/1...emu.SlackBuild
#usb passthrough may fail since Slackware's libusb is too old.
# Slackware-14.1 ships with an ancient libusb. Check for updates to enable.

Are there known issues with last release (libusb-1.0.19)?
Lib is used in many other Slackware packages...
anyone have try it?
why has not been updated in a long time?

P.S. seems there is new site http://libusb.info/


All times are GMT -5. The time now is 07:49 AM.