From: Peter Krempa <pkrempa@redhat.com>
To: Claudio Fontana <cfontana@suse.de>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
libvir-list@redhat.com, qemu-devel@nongnu.org,
"John Snow" <jsnow@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [libvirt PATCH] tools: add virt-qmp-proxy for proxying QMP clients to libvirt QEMU guests
Date: Fri, 27 May 2022 12:48:50 +0200 [thread overview]
Message-ID: <YpCskqbkDVuvp4D+@angien.pipo.sk> (raw)
In-Reply-To: <94610f98-9075-83f5-3d4f-b745467171da@suse.de>
On Fri, May 27, 2022 at 12:35:45 +0200, Claudio Fontana wrote:
> On 5/27/22 12:20 PM, Peter Krempa wrote:
> > On Fri, May 27, 2022 at 10:47:58 +0100, Daniel P. Berrangé wrote:
> >> 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 he QMP socket at any point in time.
> >>
> >> 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.
> >>
> >> $ 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.
> >>
> >> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> >> ---
> >>
> >> CC'ing QEMU since this is likely of interest to maintainers and users
> >> who work with QEMU and libvirt
> >>
> >> Note this impl is fairly crude in that it assumes it is receiving
> >> the QMP commands linewise one at a time. None the less it is good
> >> enough to work with qmp-shell already, so I figured it was worth
> >> exposing to the world. It also lacks support for forwarding events
> >> back to the QMP client.
> >
> > I originally wanted to teach the qemu tools to work with libvirt
> > directly similarly how 'scripts/render_block_graph.py' from the qemu
> > tree already does but I guess this is also an option.
> >
> > This is an option too albeit a bit more complex to set up, but on the
> > other hand a bit more universal.
> >
> > I'll have a look at the code a bit later.
> >
>
> Would have found it useful, at the time I wrote the multifd save series I ended up just scripting around virsh qemu-monitor-command from either bash or C.
I'd consider this to be just something to achieve compatibility with
tools that already exist and expect monitor socket.
If you are writing new software with libvirt connection in mind you can
use 'virDomainQemuMonitorCommand()' or
'virDomainQemuMonitorCommandWithFiles()' directly or via the language
bindings for your language.
Obviously not for bash though.
next prev parent reply other threads:[~2022-05-27 11:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 9:47 [libvirt PATCH] tools: add virt-qmp-proxy for proxying QMP clients to libvirt QEMU guests Daniel P. Berrangé
2022-05-27 10:20 ` Peter Krempa
2022-05-27 10:35 ` Claudio Fontana
2022-05-27 10:48 ` Peter Krempa [this message]
2022-05-27 11:30 ` Daniel P. Berrangé
2022-05-27 11:32 ` Daniel P. Berrangé
2022-05-27 16:07 ` John Snow
2022-05-27 16:38 ` Daniel P. Berrangé
2022-05-27 14:14 ` Peter Krempa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YpCskqbkDVuvp4D+@angien.pipo.sk \
--to=pkrempa@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=cfontana@suse.de \
--cc=dgilbert@redhat.com \
--cc=jsnow@redhat.com \
--cc=libvir-list@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).