Pass a usb device to ZVM?

Is this possible? I can’t find an option anywhere. Does anyone have a workaround? Even something hacky will do until official support comes.

I need to pass my zigbee dongle to Home Assistant OS.

1 Like

Sorry, it’s not supported yet.

Do you know if it’s on the list to be implemented soon?

USB pass through and auto starting a ZVM are the features that I really need

1 Like

Hello, I will give feedback to the product manager soon. I’m sorry that we are a small team and cannot meet everyone’s needs at the first time, but we will speed up and I will tell you any updates!

Hello I have seen people successfully completing this, perhaps you could try it?

1 Like

This worked, thanks.

1 Like

Marvelous!

It gets easier:

Connect to the ZimaOS server using ssh with the root account

type lsusb and identify your key


Bus 001 Device 003: ID 1a86:55d4 QinHeng Electronics SONOFF Zigbee 3.0 USB Dongle Plus V2

The 1a86:55d4 is the Vendor ID:Product ID (VID:PID).

Create the file /tmp/usb-sonoff.xml and fill it with the following information

<hostdev mode='subsystem' type='usb'>

<source>

<vendor id='0x1a86'/>

<product id='0x55d4'/>

</source>

</hostdev>

Next, add the key to the virtual machine

virsh attach-device your_vm_name --file /tmp/usb-sonoff.xml --persistent

Restart your VM and you’ll see Zigbee integration in Home assistant

10 Likes

that actually worked for my UPS. Thanks

Worked for me too. Thanks leglen38

This didn’t seem to work for me, after following the instructions I get

“error:failed to connect to the hypervisor”

“error: cannot create user runtime directory ‘/DATA/.cache/libvirt’: Permission denied"

I was following through trying to get an external HDD to show up in ZVM. I substituted the vendor/product id but kept everything else the same.

Yes, this method is correct and currently the cleanest way to pass a USB device to a ZVM on ZimaOS.

Using lsusb to identify the VID:PID and attaching it with virsh attach-device is the proper libvirt approach.

Two small additions for stability:

  1. If the device disconnects/reconnects, re-attach may be required unless it’s defined persistently in the VM XML.
  2. For best reliability, you can permanently add the <hostdev> block directly into the VM definition via:
virsh edit your_vm_name

Then paste the <hostdev> section inside the <devices> block.

This avoids using /tmp and survives reboots cleanly.

Good share, much simpler than earlier workaround methods.

1 Like

That’s because you missed a critical step “Create the file /tmp/usb-sonoff.xml“ that is above the screenshot from Leglen38

I just wanted to mention that if you don’t use the seperate file name, and edit your VM XML, any changes you do in ZVM after (like reduce CPU cores or update drive space) will overwrite those changes. So if you have a bunch of USB passthrough devices like me (Bluetooth, Zigbee, etc), it’s better to keep the separate file so that ZVM does not overwrite the manually entered XML entries.

It’s a shame that ZVM does an overwrite rather than just an amend to the criteria. Also too bad the ZVM doesn’t have "additional criteria” entry points like the “app containers”

Yep this works, but just to clarify for anyone following along:

If you use the /tmp/usb-*.xml method with virsh attach-device, it’s good for quick testing but may need re-attaching after reboot or disconnect.

If you want it to persist, you can add the <hostdev> block directly into the VM with:

virsh edit <vm_name>

and place it inside <devices>.

Just be aware if you later change CPU/RAM/disk in ZVM, those manual edits can get overwritten, so you may need to add it again.

Also for that error:

error: cannot create user runtime directory ‘/DATA/.cache/libvirt’: Permission denied

That’s a permissions issue on /DATA, not related to USB. Worth checking the folder permissions there.

2 Likes

Sorry very new to this, what command do you use to create the XML file?

No problems but just a reminder that this is not for someone not really familiar with linux.

at the command prompt to create a file you want to use “vi” or “nano”

example:

$ nano /tmp/myfilename.xml

if it’s a restricted (as in you cannot create a file because you are not root you can “sudo”

$ sudo nano /tmp/myfilename.xml

or if you are logged in as root, the “$” will be a “#”

# nano /tmp/myfilename.xml

I hope that helps but I would recommend not putting files in the /tmp directory as you never know when the system clears that folder.

Thank you I have managed to get it working.