6

I have a setup with two Logitech Unifying receivers, each receiver has a keyboard bound to it. One of the receiver is to be used by the physical machine to which the devices are connected, the other one has to be passed to a QEMU virtual machine.

I am able to manually unbind one receiver following the instructions in How to use Linux kernel driver bind/unbind interface for USB-HID devices?. This method has some disadvantages:

  • I have to determine the device identifier manually by looking at dmesg.
  • Each time the virtual machine is closed, and on every reboot, the unbinding process has to be repeated.

I then tried to find kernel module options that prevents the USB driver from binding it at all and found the quirks option for usbhid. Unfortunately, this parameter cannot be used since I have two identical receivers with the same vendor and device ID.

The two devices are distinguishable by their separate buses. That is, lsusb looks like:

Bus 001 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 002 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver

Is there a way to prevent hid-logitech-dj (or usbhid) from binding a USB device on a certain bus?

The target machine is running Arch Linux 64-bit with a Linux 3.9 kernel.

1
  • Interestingly, QEMU takes over the USB device without me having to do anything. For example, pressing Alt+Tab has only effect in QEMU, it is not registered by the host anymore. I do not know whether this is guaranteed behavior though.
    – Lekensteyn
    Commented Jun 4, 2013 at 20:49

2 Answers 2

1

Within UDEV it is possible to add a rule to search for the specific bus and set the OPTIONS to "ignore_device". Did you mention your Kernel version or OS?

1
  • 1
    ignore_device was removed a while back, that won't work.
    – Lekensteyn
    Commented Jun 4, 2013 at 20:47
0

First of all have a look at my answer here - you should have all the info needed to understand how usb devices are connected.

You can then connect your device while running udevadm monitor to see what events are being triggered, and udevadm test --action=<action> <path> to see what actions udev is taking.

The system rules should be in /lib/udev/rules.d - you most likely want to override them in the /etc/udev/rules.d path so they don't get overridden by package upgrades. You have two choices:

  1. Copy the rule from /lib/udev/rules.d to the same path/name in /etc/udev/rules.d and edit it - this is easiest as you can just alter slightly the matching filters to exclude your device/bus combination. Udev will not run any system rule for which there is a matching etc rule. Otoh any udev maintainer's change will have to me manually added.

  2. Create a subsequent rule (with a higher priority so it runs after) and override the actions taken by earlier rules (such has removing or changing RUN actions).

If you have no existing rule to override, you can just add a rule to do the extra work needed such as running the unbind/bind commands.

To find appropriate rule filters, you can use usevadm info <path> to see device properties. With the -a switch you will instead get all sysfs attributes for the device and all its parent nodes, which can all be used for matching as well (for attributes duplicates, the first match is used).

See man udev (7) for detailed instructions on writing rules.

You must log in to answer this question.

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