I'm attempting to pass through USB devices through a qemu KVM and receiving the following error:

libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/009: Operation not permitted

I've made the following udev (/etc/udev/rules.d/50-qemuusb.rules) rule of:

SUBSYSTEM=="usb|usb_device", ATTRS{idVendor}=="04f2", MODE="0666"

At first I thought it wasn't working properly, but when I checked, it surely was. ls -l in /dev/bus/usb/001 reports this:

lmfaoown@Lmfaoown:/dev/bus/usb/001$ ls -l
total 0
crw-rw-r-- 1 root root 189, 0 Sep 17 18:33 001
crw-rw-r-- 1 root root 189, 1 Sep 17 18:33 002
crw-rw-r-- 1 root root 189, 2 Sep 17 18:33 003
crw-rw-r-- 1 root root 189, 3 Sep 17 18:33 004
crw-rw-r-- 1 root root 189, 4 Sep 17 18:33 005
crw-rw-r-- 1 root root 189, 6 Sep 17 18:33 007
crw-rw-rw- 1 root root 189, 8 Sep 17 18:42 009

You can see that for 009 everyone has R/W, yet it still throws the error.

The program that logs this error is QEMU inside of libvirt (/vars/log/libvirt/qemu).

Does anyone know if I'm doing something wrong with my permissions? I've tried chowning the USB to dialout with my user being a member, including libvirt-qemu being a member of it, I've tried seting MODE to 777, all with the same outcome. I do know the udev has some effect as once I remove the rule QEMU throws this:

libusb:error [op_open] libusb couldn't open USB device /dev/bus/usb/001/003: Permission denied.
libusb:error [op_open] libusb requires write access to USB device nodes.


I've seen such issues and they are often due to apparmor denials. You might report your dmesg here if and which `Apparmor Denies´ it contains to match them.

Others and myself have brought several changes to the apparmor profile upstream so that works by default, but this is only available in later versions.

Below you'll find the most recent section about it and the commits in upstream libvirt.

2df320609ac # For hostdev access. The actual devices will be added dynamically
2df320609ac /sys/bus/usb/devices/ r,
f88a3d9b0c7 /sys/devices/**/usb[0-9]*/** r,
bf3a4140877 # libusb needs udev data about usb devices (~equal to content of lsusb -v)
bf3a4140877 /run/udev/data/c16[6,7]* r,
bf3a4140877 /run/udev/data/c18[0,8,9]* r,
d4d50bcc799 /run/udev/data/+usb* r,

You can add what you need to your /etc/apparmor.d/abstractions/libvirt-qemu to get that back to your installation.

There are plenty of other changes that affect the dynamic creation of rules for your guest. So if the above isn't enough you might have to try a newer version of libvirt/qemu which means a newer Ubuntu release if that gets you going.

P.S. I file this as an answer, even thou there are chances it isn't your case. But the symptoms you have match exactly, so at least others might find the answer they need here.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.