From patchwork Fri Sep 9 20:25:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 114137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B7EB4B6FA0 for ; Sat, 10 Sep 2011 06:48:32 +1000 (EST) Received: from localhost ([::1]:52360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R27fc-00075c-AS for incoming@patchwork.ozlabs.org; Fri, 09 Sep 2011 16:27:28 -0400 Received: from eggs.gnu.org ([140.186.70.92]:41775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R27eM-00032g-2L for qemu-devel@nongnu.org; Fri, 09 Sep 2011 16:26:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R27eK-0001tt-HA for qemu-devel@nongnu.org; Fri, 09 Sep 2011 16:26:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R27eK-0001tZ-2s for qemu-devel@nongnu.org; Fri, 09 Sep 2011 16:26:08 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p89KQ5X2026834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 9 Sep 2011 16:26:05 -0400 Received: from localhost (ovpn-113-92.phx2.redhat.com [10.3.113.92]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p89KQ47u023768; Fri, 9 Sep 2011 16:26:05 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Fri, 9 Sep 2011 17:25:45 -0300 Message-Id: <1315599946-27081-9-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1315599946-27081-1-git-send-email-lcapitulino@redhat.com> References: <1315599946-27081-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, aliguori@us.ibm.com, jan.kiszka@siemens.com, armbru@redhat.com, amit.shah@redhat.com, vilanova@ac.upc.edu Subject: [Qemu-devel] [PATCH 8/9] QMP: query-status: Introduce 'status' key X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- monitor.c | 3 +-- qmp-commands.hx | 19 ++++++++++++++++++- sysemu.h | 1 + vl.c | 23 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index 6e5bb56..7684ba9 100644 --- a/monitor.c +++ b/monitor.c @@ -2636,8 +2636,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/qmp-commands.hx b/qmp-commands.hx index 27cc66e..0cf1321 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1571,11 +1571,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 9a2c531..43ff546 100644 --- a/sysemu.h +++ b/sysemu.h @@ -39,6 +39,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 e0b1f85..6ebc101 100644 --- a/vl.c +++ b/vl.c @@ -378,6 +378,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; @@ -406,6 +422,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);