2

I would like to have qemu started machines running in user space, but during development I would like to issue commands to it using virtsh. (note, this is not because I need virtsh, but the QEMU developers only expose APIs that work with virtsh. I guess I could also ask "how to manipulate snapshots from a running QEMU via command line, not interactive qemu monitor sessions?" this virtsh question is following what qemu docs recommend)

The manual is not very clear how to attach qemu to libvirt instance with either qemu:///session and qemu+unix:///session, it just assumes you will let libvirt start all the hooks so it doesn't explain anything.

And what i think is the solution, qemu:///embed is extremely lacking of details and cryptic for non libvirt developers https://libvirt.org/drvqemu.html#embedded-driver

$ ps aux | grep qemu
gcb    ...    qemu-system-x86_64 -machine pc...

$ virsh -c qemu+unix:///session list --all
 Id   Name   State
--------------------

$ virsh -c qemu:///session list --all
 Id   Name   State
--------------------

$ id
uid=1000(gcb) ...

How exactly libvirt looks for user-session qemu? And how can I simply use virtsh commands to interface with a running qemu from the same user as shown above?

1 Answer 1

0

wish i'm wrong, but after reading their docs:

Answer, it is not possible.

libvirt is a redhat+gnome project. As such is is bad by design (and was pushed from top to bottom, just like systemd). Manual is full of condescending passages that instead of explaining they cut corners and now they are afraid any action out of their control will cause bugs, they berate the user about they not having anything good to do with basic things like getting a PID of a running vm. Deeper parts of the manual is full 404 links pointing to personal blogs in gnome.org.

There is little documentation on how to author the configuration xml for a new vm. You are supposed to depend on GUI programs or even-worse documented hacky scripts virsh-install. Both of them assume you have a full installation with a system dedicated to running libvirtd and other services, and will outright refuse to do any action (even spit out a xml template) unless you have those services up. At some point they had a convenience translator from qemu args to their xml, but that is long gone (already served the purpose to lure contributors from other projects).

avoid libvirt unless your employer uses it. Keep to qemu frontends for now.

edit: maybe a workaround, untested so far:

virt-install --import --connect qemu://session --qemu-commandline '-m ...' to start your qemu machine without the system-wide libvirtd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.