QEMU and the webcam, howto

Here you can find how to attach a webcam to a QEMU VM.

We must add some knowledge.

As said here

in chapter

WARNING: this is an experimental feature. QEMU will slow down when using it. USB devices requiring real time streaming (i.e. USB Video Cameras) are not supported yet.

My two cents :

Low throughput webcam are well suited to “usb-host” QEMU feature.
I assume in USB world this is “Low speed” (1.5 Mbit/s) or “Full speed” (12 Mbit/s)

High throughput webcam are not suited to “usb-host” QEMU device.
I assume in USB world this is “High speed” (400 Mbit/s) or “Super speed” (5 Gbit/s)
Also, there is sync issue between the webcam and usb-host QEMU device.

I advise you to use an old webcam like Logitech 270 and 310 (better).

For example, Logitech 920 Pro or Brio 300 does not work with QEMU.

In QEMU, if you want your webcam runs well, you must attach it to “ehci” QEMU hub.

Here is a part of my QEMU invocation :

-device qemu-xhci,p2=5,p3=5,id=xhci
-device usb-ehci,id=ehci
-device usb-kbd
-device usb-mouse
-device usb-tablet

-device usb-host,vendorid=0x046d,productid=0x0825 \ <<<<<<<< C270
-device usb-host,bus=xhci.0,port=1,vendorid=0x0a5c,productid=0x21e8 \ <<<<<<<<<< Bluetooth dongle

By default, an ehci device gets 4 ports then you can attach 4 USB host device, not more.

By default, the first 4 USB host devices in the invocation are attached to the ehci device.

That is why I add a xhci device to attach the Bluetooth dongle, and we must add “bus=xhci.0,port=1”.
If not, QEMU wants to attach the Bluetooth dongle to ehci port 5 which does not exist!