[libvirt] connecting to qemu domain monitor socket outside of libvirt/virsh
eblake at redhat.com
Tue Dec 20 18:56:55 UTC 2016
On 12/20/2016 12:48 PM, Jason Miesionczek wrote:
> So I see that when i have a qemu vm running, that i created via libvirt,
> there is a socket here:
> I am trying to connect to this socket via cli or a completely separate
> C/C++ application to be able to control the VM, but I can't seem to get it
> to work.
> Does anyone know if/how this is possible?
Not by connecting directly to the socket, but you CAN use
libvirt-qemu.so, which provides the virDomainQemuMonitorCommand() API
(also conveniently exposed to shell programming via 'virsh
qemu-monitor-command') to do what you want.
> I've tried 'nc', 'socat', and based on the qemu libvirt code,
> 'socket'/'connect', but nothing seems to work.
Going behind libvirt's back and trying to use the same socket that
libvirt is using will never work. But going through libvirt's API
should work (we document that use of libvirt-qemu.so is explicitly
unsupported, not because it doesn't work, but because it is powerful
enough to let you change state of the VM behind libvirt's back in ways
that libvirt can't cope with - but as long as you use it for safe
actions only, such as QMP commands starting with query-, you should be
fine). Ideally, however, if there's something you can currently only
accomplish by using libvirt-qemu.so, we should really enhance libvirt to
natively provide that through supported APIs that belong to libvirt.so.
> Also, is it possible through libvirt, when creating a qemu VM, one can
> specify to enable the QMP socket?
Libvirt creates a QMP socket already. If you're asking if it is
possible to create a second QMP socket for use in parallel with
libvirt's socket, it might be possible using <qemu:commandline> XML in
your domain description; but in general, it's usually sufficient to rely
on virDomainQemuMonitorCommand() instead of needing a second QMP monitor.
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 604 bytes
Desc: OpenPGP digital signature
More information about the libvir-list