From 3813397ff4a8b94c252d4d8e851cfc0c13eeb275 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Wed, 19 Oct 2011 14:53:53 +0200 Subject: [PATCH 07/13] QMP: query-status: Introduce 'status' key RH-Author: Luiz Capitulino Message-id: <1319036039-4358-8-git-send-email-lcapitulino@redhat.com> Patchwork-id: 34411 O-Subject: [PATCH RHEL6.2 qemu-kvm v3 07/13] QMP: query-status: Introduce 'status' key Bugzilla: 617889 RH-Acked-by: Paolo Bonzini RH-Acked-by: Markus Armbruster RH-Acked-by: Kevin Wolf 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 (cherry picked from commit 9e37b9dc5bf037453e062ee515014875cd05068d) --- monitor.c | 3 +-- qemu-monitor.hx | 19 ++++++++++++++++++- sysemu.h | 1 + vl.c | 23 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) Signed-off-by: Michal Novotny --- monitor.c | 3 +-- qemu-monitor.hx | 19 ++++++++++++++++++- sysemu.h | 1 + vl.c | 23 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index c806ec2..535a330 100644 --- a/monitor.c +++ b/monitor.c @@ -2420,8 +2420,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 }", - runstate_is_running(), singlestep); + *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i, 'status': %s }", runstate_is_running(), singlestep, runstate_as_string()); } static qemu_acl *find_acl(Monitor *mon, const char *name) diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 72e38dc..b771797 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -2516,11 +2516,28 @@ 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 + "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 1231280..cbb1af3 100644 --- a/sysemu.h +++ b/sysemu.h @@ -47,6 +47,7 @@ void runstate_init(void); bool runstate_check(RunState state); void runstate_set(RunState new_state); int runstate_is_running(void); +const char *runstate_as_string(void); typedef struct vm_change_state_entry VMChangeStateEntry; typedef void VMChangeStateHandler(void *opaque, int running, RunState state); diff --git a/vl.c b/vl.c index 626cb68..d6ad447 100644 --- a/vl.c +++ b/vl.c @@ -414,6 +414,22 @@ static const RunStateTransition runstate_transitions_def[] = { static bool runstate_valid_transitions[RSTATE_MAX][RSTATE_MAX]; +static const char *const runstate_name_tbl[RSTATE_MAX] = { + [RSTATE_DEBUG] = "debug", + [RSTATE_IN_MIGRATE] = "incoming-migration", + [RSTATE_PANICKED] = "internal-error", + [RSTATE_IO_ERROR] = "io-error", + [RSTATE_PAUSED] = "paused", + [RSTATE_POST_MIGRATE] = "post-migrate", + [RSTATE_PRE_LAUNCH] = "prelaunch", + [RSTATE_PRE_MIGRATE] = "finish-migrate", + [RSTATE_RESTORE] = "restore-vm", + [RSTATE_RUNNING] = "running", + [RSTATE_SAVEVM] = "save-vm", + [RSTATE_SHUTDOWN] = "shutdown", + [RSTATE_WATCHDOG] = "watchdog", +}; + bool runstate_check(RunState state) { return current_run_state == state; @@ -442,6 +458,13 @@ void runstate_set(RunState new_state) current_run_state = new_state; } +const char *runstate_as_string(void) +{ + assert(current_run_state > RSTATE_NO_STATE && + current_run_state < RSTATE_MAX); + return runstate_name_tbl[current_run_state]; +} + int runstate_is_running(void) { return runstate_check(RSTATE_RUNNING); -- 1.7.4.4