Skip to content

Instantly share code, notes, and snippets.

@aluedeke
Last active August 29, 2022 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aluedeke/37a74364700296d4540d51d937f1b3d9 to your computer and use it in GitHub Desktop.
Save aluedeke/37a74364700296d4540d51d937f1b3d9 to your computer and use it in GitHub Desktop.
hot plug usb devices to qemu (lima,colima) vms using qmp/hmp

Install qmp-shell

pip3 install qmp.qmp

This should have added the qemu-shell command to your shell.

You need to connect then to the qemu qmp socket. If you are starting the qemu vm yourself add this to your qemu launch command:
-chardev socket,id=char-qmp,path=PATH_TO_YOUR_QMP_SOCKET,server=on,wait=off -qmp chardev:char-qmp

If you are using lima/colima or other tools do:
ps -A | grep qmp
and pick the path of the qmp socket.

now connect to the socket using qmp-shell and hmp protocol:
qmp-shell -H PATH_TO_YOUR_QMP_SOCKET

then add a device: device_add usb-host,vendorid=0x534d,productid=0x2109

Checkout the qemu docs for different ways of selecting a device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment