]> git.ipfire.org Git - thirdparty/libvirt.git/commit
tools: add virt-qemu-qmp-proxy for proxying QMP via libvirt QEMU guests
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 27 May 2022 09:34:47 +0000 (10:34 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 7 Oct 2022 13:32:36 +0000 (14:32 +0100)
commit83c6d80abca73f5b7af2b7d06afc7b37568663af
treed695bfb1d8744ad87998b253b1ab727befcd9b56
parent491d918502e50bf15c75d183bb41e3c0de5a0e1b
tools: add virt-qemu-qmp-proxy for proxying QMP via libvirt QEMU guests

Libvirt provides QMP passthrough APIs for the QEMU driver and these are
exposed in virsh. It is not especially pleasant, however, using the raw
QMP JSON syntax. QEMU has a tool 'qmp-shell' which can speak QMP and
exposes a human friendly interactive shell. It is not possible to use
this with libvirt managed guest, however, since only one client can
attach to the QMP socket at any point in time. While it would be
possible to configure a second QMP socket for a VM, it may not be
an known requirement at the time the guest is provisioned.

The virt-qmp-proxy tool aims to solve this problem. It opens a UNIX
socket and listens for incoming client connections, speaking QMP on
the connected socket. It will forward any QMP commands received onto
the running libvirt QEMU guest, and forward any replies back to the
QMP client. It will also forward back events.

  $ virsh start demo
  $ virt-qmp-proxy demo demo.qmp &
  $ qmp-shell demo.qmp
  Welcome to the QMP low-level shell!
  Connected to QEMU 6.2.0

  (QEMU) query-kvm
  {
      "return": {
          "enabled": true,
          "present": true
      }
  }

Note this tool of course has the same risks as the raw libvirt
QMP passthrough. It is safe to run query commands to fetch information
but commands which change the QEMU state risk disrupting libvirt's
management of QEMU, potentially resulting in data loss/corruption in
the worst case. Any use of this tool will cause the guest to be marked
as tainted as an warning that it could be in an unexpected state.

Since this tool introduces a python dependency it is not desirable
to include it in any of the existing RPMs in libvirt. This tool is
also QEMU specific, so isn't appropriate to bundle with the generic
tools. Thus a new RPM is introduced 'libvirt-clients-qemu', to
contain additional QEMU specific tools, with extra external deps.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
build-aux/syntax-check.mk
docs/manpages/meson.build
docs/manpages/virt-qemu-qmp-proxy.rst [new file with mode: 0644]
libvirt.spec.in
tools/meson.build
tools/virt-qemu-qmp-proxy [new file with mode: 0755]