No USB connection on VM (libvirt, virt-manager)

  • Host Machine
    • Manjaro 6.6.47-1-MANJARO x86_64
  • Guest VM
    • Artix Linux 6.10.2-artix1-1 x86_64

I have yet another issue I keep having to deal with.
For whatever reason the USB connection can never be made.
It does not show up in lsblk or lsusb.

USB device in virt-manager

<hostdev mode="subsystem" type="usb" managed="yes">
  <source>
    <vendor id="0x0781"/>
    <product id="0xcfcb"/>
    <address bus="2" device="4"/>
  </source>
  <alias name="hostdev0"/>
  <address type="usb" bus="0" port="4"/>
</hostdev>

First, you need a USB forwarder device.
Then you add a USB host device as a new device.

for instance:
I want to forward my laptops camera:

When I add it, I get a menu, showing me all the connected devices.
This one as:
002:003 Foxconn / Hon Hai USB2.0 Camera

The resulting XML looks like this:

<hostdev mode="subsystem" type="usb" managed="yes">
  <source>
    <vendor id="0x0489"/>
    <product id="0xd600"/>
  </source>
  <address type="usb" bus="0" port="4"/>
</hostdev>

But that is not edited by me - that happened automatically

no address bus
no alias name

Forwarder device like this?

<redirdev bus="usb" type="spicevmc">
  <alias name="redir0"/>
  <address type="usb" bus="0" port="2"/>
</redirdev>

yes - like this

but again:
without an alias name

This is (for me) all just through the GUI - no xml editing.

But that’s what I already have.

image

I can choose the USB device and then it shows up in the devices list,
but it doesn’t show up in lsusb or lsblk.

Then I’m afraid I cannot help you.

It may be because the device is already in use by the host - the disk may be mounted, not just connected/present … I don’t know.

Or:
the guest, upon installation, might not have detected that it is in fact installed as a VM
and some piece of software might be missing in the guest.
I don’t know the name - something about guest utilities would be my guess.

My host is Mint, my guests are all major Manjaro versions and also the newer than host Mint version itself.

Artix is the distro that is determined to not use systemd and which offers the use of a few different init systems, right?
That may have something to do with it - maybe the software is even there, but not activated by the init system?
Who knows?
I don’t.

Rebuild and reinstalled the VM and it works again.
No idea what happened.

When you add through virsh edit, or let virt-manager add by clicking on the device, it just adds:

<hostdev mode="subsystem" type="usb" managed="yes">
  <source>
    <vendor id="0x0781"/>
    <product id="0xcfcb"/>
  </source>
<hostdev>

The libvirt configuration parser, will automatically pick a virtual bus/device for you if you don’t specify (so you don’t conflict with others) , and add the line for you:

<hostdev ...>
  <source>
  </source>
  <address bus="0" device="4"/> <!-- This line -->
</hostdev>

Mine always come up as bus=“0”, which was probably the problem? And Just deleting that line would have fixed it for you. (It would have inserted it for you after you hit Apply in virt-manager.)

These are good for hotswapping USB devices on the fly, especially with just clicking around virt-manager’s GUI to click the device you want. (In the guest VM window menu, Virtual Machine/Redirect USB device). So it’s easy to configure. And you do need to set up more, if you want more than one USB device passed through.

Using virsh add-device DOMAIN usb-drive.xml, for example, is a little more efficient for hotswapping (USB) devices.

But just installing qemu-desktop even 2-3 years ago, had SPICE and USB redirection all setup and ready to go, at least for me. So it’s a much more GUI friendly way.

To take it further, I also share a whole PCIe device, which is a USB controller. So I can just plug in devices to certain ports on my desktop to go directly to the guest. (Most efficient of all.)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.