Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


These scripts help you passthrough many identical usb-devices (with the same vendorid:productid pair) for selected virtual machines, using usbredir protocol in daemon mode, without using spice.

USB Server install

  • Install usbredirserver, inotifywait and fuser packages, it is required
  • Install units and script:
curl -o /etc/systemd/system/usbredirserver\@.service
curl -o /etc/systemd/system/usbredirserver.service
curl -o /bin/
chmod +x /bin/
  • mkdir /var/lib/usbredirserver/

Export usb-devce

  • run lsusb, find your device:
Bus 003 Device 090: ID 125f:c82a A-DATA Technology Co., Ltd. 
  • run udevadm info -a -n /dev/bus/usb/003/090 | grep 'ATTR{serial}\|KERNEL[^S]'
  • vim /etc/udev/rules.d/99-usb-serial.rules
# by serial number
ACTION=="add", ATTR{serial}=="11C130317234004B", RUN+="/bin/bash -c 'PORT=4000; echo -e BUS=$attr{busnum}\\nDEV=$attr{devnum} > /var/lib/usbredirserver/$PORT'"
# by phisical port
ACTION=="add", KERNEL=="3-2", RUN+="/bin/bash -c 'PORT=4000; echo -e BUS=$attr{busnum}\\nDEV=$attr{devnum} > /var/lib/usbredirserver/$PORT'"
  • udevadm control --reload-rules
  • Start and enable usbredirserver service:
systemctl start usbredirserver.service
systemctl enable usbredirserver.service

Hypervisor install (opennebula)

hook setup

  • curl -o /var/lib/one/remotes/hooks/
  • chmod +x /var/lib/one/remotes/hooks/
  • Declare hook in /etc/one/oned.conf:
    name      = "usbredir_connect",
    on        = "RUNNING",
    command   = "",
    arguments = "connect $ID $TEMPLATE" ]

    name      = "usbredir_disconnect",
    on        = "CUSTOM",
    state     = "ACTIVE",
    lcm_state = "SAVE_SUSPEND",
    command   = "",
    arguments = "disconnect $ID $TEMPLATE" ]
  • systemctl restart opennebula

vm setup

  • add this code to your template, into kvm raw data section:
<controller type='usb' index='0' model='ich9-ehci1'><address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x7'/></controller>
<controller type='usb' index='0' model='ich9-uhci1'><master startport='0'/><address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0' multifunction='on'/></controller>
<controller type='usb' index='0' model='ich9-uhci2'><master startport='2'/><address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x1'/></controller>
<controller type='usb' index='0' model='ich9-uhci3'><master startport='4'/><address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x2'/></controller>
  • add your usb devices into your template, like:

Hypervisor install (proxmox)

qemu setup

  • curl --create-dirs -o /etc/qemu/ich9-ehci-uhci.cfg

vm setup

  • add this options to start command in virtual machine config file into args section:
  -readconfig /etc/qemu/ich9-ehci-uhci.cfg
  -chardev socket,id=charredir3,port=4000,host=
  -device usb-redir,chardev=charredir3,id=redir3,bus=usb.0

Watchdog service

Optionally, you may install usbredirwatchdog service on your hypervisors, it will reconnect the usb-devices if they was disconnected for some reasons.

It works this way: Every n times, watchdog script calls ps aux and checks for running virtual machines with chadredir parameters. After this watchdog script check the status of each chardev and reconnect it if it does not exist or disconnected. The frequency is configured as the first script argument, by default it is 10 seconds. Warning: this watchdog does not work with devices connected via opennebula hook.

Install instructions

  • For proxmox you need install expect package.
  • curl -o /usr/local/bin/
  • chmod +x /usr/local/bin/
  • curl -o /etc/systemd/system/usbredirwatchdog.service
  • systemctl enable usbredirwatchdog
  • systemctl start usbredirwatchdog
You can’t perform that action at this time.