qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Getting VM state from outside QEMU?


From: John Snow
Subject: Re: [Qemu-devel] Getting VM state from outside QEMU?
Date: Tue, 07 Apr 2015 14:16:43 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0



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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]