# qemu-kvm usb passthrought problem.

## madchaz

Good day. 

First, I am not 100% sure this is where it should go, so moderators, feel free to scold me and move this to the appropriate forum if needed. 

I have a bit of a usb problem with qemu-kvm. 

I'm trying to get my arduino board to speak with a gentoo x86 virtual machine, but it's proving to be rather stuborn. 

Connecting the board via USB and doing lsusb on the host. 

```

host local.d # lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply

Bus 005 Device 007: ID 2341:0042

```

Bus 005 Device 007: ID 2341:0042  this gives me the ID to use to give qemu-kvm. 

I start the virtual machine. 

```
qemu-kvm -smp 2 -name "dragonball1",process="dragonball1" -vnc 192.168.X.XX:5 -net nic,macaddr=00:00:00:00:00:06 -net vde -hda PATH_TO_DISK_IMAGE -m 512 -daemonize -usb -usbdevice host:2341:0042  

```

In the virtual machine, it shows up as /dev/ttyACM0 as it should and lsusb shows it properly, but I can't talk to it. Communication does not go from the VM to the board (it doesn't react to commands I send) and does not flow back (I get no output). 

I've done this in virtualbox on my windows machine and it worked flawlessly, but I don't want virtualbox on my server. (Oracle ...) 

I know the firmware on the board is good and should both take input and send output, so something isn't talking. 

Any help would be appreciated.

----------

## nativemad

Hi, 

I've had similar problems with some usb modems that wouldn't work properly....

What worked for me is the pci paththrough of the whole usb port (via intel VT-D).

This is what I use to map the usb port:

```

echo 8086 3a36 >/sys/bus/pci/drivers/pci-stub/new_id

echo 0000:00:1d.2 >/sys/bus/pci/devices/0000\:00\:1d.2/driver/unbind

echo 0000:00:1d.2 >/sys/bus/pci/drivers/pci-stub/bind

qemu-kvm -device pci-assign,host=00:1d.2 $all_other_kvm_options
```

See lspci -n for the numbers...

http://www.linux-kvm.org/page/How_to_assign_devices_with_VT-d_in_KVM

HTH, cheers

----------

## madchaz

Sounds interesting. I'm not on intel, unfortunatly. I'm on AMD. I'm guessing there is a similar procedure?

----------

## madchaz

I had a look at the page and I'm not convinced this will work for me. It requires hardware support I most likely do not have, not according to the wiki for AMD boards anyway. 

I could use a litle more help making sure. 

Motherboard is an Asus M4A87TD

CPU is a Phenom II x6 1090T

----------

## nativemad

You'll probably see an option to enable iommu (maybe it is called something else about virtualization) within the bios.

```

dmesg | grep AMD-Vi
```

should tell you if it is enabled... or grep for IOMMU

HTH

----------

## Circuitsoft

 *madchaz wrote:*   

> Motherboard is an Asus A8N-E. 
> 
> CPU is a Phenom II x6 1090T

 How did you fit a Phenom II into a socket 939 motherboard?

----------

## madchaz

Edit: Because I fail at IT 101 and checked  the wrong box. Dur. Corrected above

----------

## madchaz

 *nativemad wrote:*   

> You'll probably see an option to enable iommu (maybe it is called something else about virtualization) within the bios.
> 
> ```
> 
> dmesg | grep AMD-Vi
> ...

 

```
dmesg | grep IOMMU

[    0.000000] Please enable the IOMMU option in the BIOS setup

[    0.602420] PCI-DMA: using GART IOMMU.

[    0.602496] PCI-DMA: Reserving 64MB of IOMMU area in the AGP aperture

```

Option isn't there in the bios, so going to have to check if I can find an update with the option.

----------

## madchaz

Updated to the latest bios from asus. Still don't have the option in the BIOS. Only option I have is "Secure Virtual Machine Mode" and that is turned on right now.

----------

## madchaz

Did some more digging. Doesn't look like I'll be able to use  direct PCI mapping with this board. Any other idea?

----------

## madchaz

Tried using virt-manager to connect the device to the VM. Everything works fine, just like before and I still can't talk to the board. 

Starting to think I'll give up for now and install virtual-box for the one machine ...

----------

## nativemad

yeah, virtualbox might be better in regard of usb devices, as kvm seems to be refactoring these things and has some problems with it right now... https://bugs.gentoo.org/show_bug.cgi?id=428476

----------

