From: John Snow <jsnow@redhat.com>
To: Erik Rull <erik.rull@rdsoftware.de>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Getting VM state from outside QEMU?
Date: Tue, 07 Apr 2015 14:16:43 -0400 [thread overview]
Message-ID: <55241F0B.5010500@redhat.com> (raw)
In-Reply-To: <1746798507.1094444.1428413473548.JavaMail.open-xchange@oxbaltgw09.schlund.de>
On 04/07/2015 09:31 AM, Erik Rull wrote:
> Hi all,
>
> I need a pretty simple way to get the current state of the VM running in QEMU -
> I only need the VM state (e.g. running, paused,...). Since my environment does
> not have any perl, python or other high level scripting capabilities, a simple
> way e.g. via a shell script would be nice. QEMU is running daemonized, so
> interacting with the qemu console is not possible.
> Are there any usable entries in /proc, /dev or /sys that could be used?
>
> Thanks.
>
> Best regards,
>
> Erik
>
Assuming this is some sort of embedded system under which python is not
an option:
You'll need to use the monitor interface (-monitor), and set it to a
pipe. you can echo commands into the pipe ("info status") and read lines
out of it.
try:
mkfifo monitor.out
mkfifo monitor.in
./qemu-system-blah -monitor pipe:monitor &
echo "info status" > monitor.in
read $line < monitor.out # 'info status'
read $line < monitor.out # 'VM status: running'
And now you've got e.g. "VM status: running" in $line. Use whichever
shell tricks to distill this down as needed.
Warning: this is using the human monitor protocol, which as the name
implies, is not meant for you to be scraping it with tools. It could
change arbitrarily in the future and shouldn't be used in production.
Really recommend the QMP interface and something capable of
sending/reading JSON for programmatic scripting of QEMU. Check out
scripts/qmp.py for a nice library for sending/receiving these sorts of
things.
Alternatively you can use a similar fifo trick for -qmp and try to parse
the answers you get with sed/awk/bash regex etc.
prev parent reply other threads:[~2015-04-07 18:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 13:31 [Qemu-devel] Getting VM state from outside QEMU? Erik Rull
2015-04-07 13:42 ` Paulo Ricardo Paz Vital
2015-04-08 16:10 ` Erik Rull
2015-04-08 16:16 ` Eric Blake
2015-04-08 16:21 ` Erik Rull
2015-04-08 16:34 ` Eric Blake
2015-04-09 7:33 ` Paulo Ricardo Paz Vital
2015-04-07 18:16 ` John Snow [this message]
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=55241F0B.5010500@redhat.com \
--to=jsnow@redhat.com \
--cc=erik.rull@rdsoftware.de \
--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).