From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, amit.shah@redhat.com, aliguori@us.ibm.com,
jan.kiszka@web.de, avi@redhat.com
Subject: [Qemu-devel] [PATCH 7/7] QMP: query-status: Introduce 'status' key
Date: Wed, 3 Aug 2011 12:17:23 -0300 [thread overview]
Message-ID: <1312384643-581-8-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1312384643-581-1-git-send-email-lcapitulino@redhat.com>
This new key reports the current VM status to clients. Please, check
the documentation being added in this commit for more details.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
monitor.c | 3 +--
qmp-commands.hx | 21 ++++++++++++++++++++-
sysemu.h | 1 +
vl.c | 24 ++++++++++++++++++++++++
4 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/monitor.c b/monitor.c
index f1cb5af..a444924 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2625,8 +2625,7 @@ static void do_info_status_print(Monitor *mon, const QObject *data)
static void do_info_status(Monitor *mon, QObject **ret_data)
{
- *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }",
- qemu_is_running(), singlestep);
+ *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i, 'status': %s }", qemu_is_running(), singlestep, qemu_state_get_name());
}
static qemu_acl *find_acl(Monitor *mon, const char *name)
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 03f67da..87e042f 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1547,11 +1547,30 @@ Return a json-object with the following information:
- "running": true if the VM is running, or false if it is paused (json-bool)
- "singlestep": true if the VM is in single step mode,
false otherwise (json-bool)
+- "status": one of the following values (json-string)
+ "debug" - QEMU is running on a debugger
+ "inmigrate" - guest is paused waiting for an incoming migration
+ "internal-error" - An internal error that prevents further guest
+ execution has occurred
+ "io-error" - the last IOP has failed and the device is configured
+ to pause on I/O errors
+ "paused" - guest has been paused via the 'stop' command
+ "postmigrate" - guest is paused following a successful 'migrate'
+ "prelaunch" - QEMU was started with -S and guest has not started
+ "finish-migrate" - guest is paused to finish the migration process
+ "restore-vm" - guest is paused to restore VM state
+ "restore-vm-failed" - guest is paused following a failed attempt to
+ restore the VM state
+ "running" - guest is actively running
+ "save-vm" - guest is paused to save the VM state
+ "shutdown" - guest is shut down (and -no-shutdown is in use)
+ "watchdog" - the watchdog action is configured to pause and
+ has been triggered
Example:
-> { "execute": "query-status" }
-<- { "return": { "running": true, "singlestep": false } }
+<- { "return": { "running": true, "singlestep": false, "status": "running" } }
EQMP
diff --git a/sysemu.h b/sysemu.h
index 12a3f6a..6ae4db9 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -38,6 +38,7 @@ int qemu_uuid_parse(const char *str, uint8_t *uuid);
int qemu_is_running(void);
QemuState qemu_state_get(void);
+const char *qemu_state_get_name(void);
void qemu_state_set(QemuState state);
typedef struct vm_change_state_entry VMChangeStateEntry;
typedef void VMChangeStateHandler(void *opaque, int running, QemuState state);
diff --git a/vl.c b/vl.c
index 7fad355..e41c32f 100644
--- a/vl.c
+++ b/vl.c
@@ -321,6 +321,23 @@ static int default_driver_check(QemuOpts *opts, void *opaque)
/***********************************************************/
/* QEMU state */
+static const char *const qemu_state_name_tbl[QSTATE_MAX] = {
+ [QSTATE_DEBUG] = "debug",
+ [QSTATE_INMIGRATE] = "incoming-migration",
+ [QSTATE_INTERROR] = "internal-error",
+ [QSTATE_IOERROR] = "io-error",
+ [QSTATE_PAUSED] = "paused",
+ [QSTATE_POSTMIGRATE] = "post-migrate",
+ [QSTATE_PRELAUNCH] = "prelaunch",
+ [QSTATE_PREMIGRATE] = "finish-migrate",
+ [QSTATE_RESTVM] = "restore-vm",
+ [QSTATE_RESTVMFAILED] = "restore-vm-failed",
+ [QSTATE_RUNNING] = "running",
+ [QSTATE_SAVEVM] = "save-vm",
+ [QSTATE_SHUTDOWN] = "shutdown",
+ [QSTATE_WATCHDOG] = "watchdog",
+};
+
static QemuState qemu_current_state = QSTATE_NOSTATE;
QemuState qemu_state_get(void)
@@ -334,6 +351,13 @@ void qemu_state_set(QemuState state)
qemu_current_state = state;
}
+const char *qemu_state_get_name(void)
+{
+ assert(qemu_current_state > QSTATE_NOSTATE &&
+ qemu_current_state < QSTATE_MAX);
+ return qemu_state_name_tbl[qemu_current_state];
+}
+
int qemu_is_running(void)
{
return qemu_current_state == QSTATE_RUNNING;
--
1.7.6.396.ge0613
next prev parent reply other threads:[~2011-08-03 15:19 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 15:17 [Qemu-devel] [PATCH 0/7]: Introduce the QemuState type Luiz Capitulino
2011-08-03 15:17 ` [Qemu-devel] [PATCH 1/7] Move vm_state_notify() prototype from cpus.h to sysemu.h Luiz Capitulino
2011-08-03 15:17 ` [Qemu-devel] [PATCH 2/7] Replace VMSTOP macros with a proper QemuState type Luiz Capitulino
2011-08-04 9:55 ` Avi Kivity
2011-08-04 10:17 ` Jan Kiszka
2011-08-04 10:27 ` Jan Kiszka
2011-08-04 14:06 ` Luiz Capitulino
2011-08-08 11:22 ` Avi Kivity
2011-08-08 13:25 ` Luiz Capitulino
2011-08-08 13:27 ` Avi Kivity
2011-08-08 13:28 ` Luiz Capitulino
2011-08-08 13:40 ` Avi Kivity
2011-08-08 13:47 ` Luiz Capitulino
2011-08-08 13:54 ` Avi Kivity
2011-08-08 14:06 ` Luiz Capitulino
2011-08-08 14:27 ` Avi Kivity
2011-08-08 20:25 ` Luiz Capitulino
2011-08-03 15:17 ` [Qemu-devel] [PATCH 3/7] QemuState: Add additional states Luiz Capitulino
2011-08-04 9:02 ` Markus Armbruster
2011-08-04 12:32 ` Kevin Wolf
2011-08-04 13:23 ` Anthony Liguori
2011-08-04 13:54 ` Luiz Capitulino
2011-08-08 6:02 ` Markus Armbruster
2011-08-03 15:17 ` [Qemu-devel] [PATCH 4/7] Drop the incoming_expected global variable Luiz Capitulino
2011-08-03 15:17 ` [Qemu-devel] [PATCH 5/7] Drop the vm_running " Luiz Capitulino
2011-08-03 15:17 ` [Qemu-devel] [PATCH 6/7] Monitor: Don't allow cont on bad VM state Luiz Capitulino
2011-08-03 15:32 ` Jan Kiszka
2011-08-03 17:32 ` Luiz Capitulino
2011-08-04 8:42 ` Jan Kiszka
2011-08-03 15:17 ` Luiz Capitulino [this message]
2011-08-04 9:06 ` [Qemu-devel] [PATCH 0/7]: Introduce the QemuState type Markus Armbruster
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=1312384643-581-8-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=amit.shah@redhat.com \
--cc=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=jan.kiszka@web.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).