From patchwork Wed Sep 14 20:49:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 114709 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 3D82EB70C3 for ; Thu, 15 Sep 2011 07:11:22 +1000 (EST) Received: from localhost ([::1]:55234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3wQG-000092-5e for incoming@patchwork.ozlabs.org; Wed, 14 Sep 2011 16:51:08 -0400 Received: from eggs.gnu.org ([140.186.70.92]:52279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3wPT-0006lW-QM for qemu-devel@nongnu.org; Wed, 14 Sep 2011 16:50:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3wPS-0000wN-Bx for qemu-devel@nongnu.org; Wed, 14 Sep 2011 16:50:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3wPR-0000vz-Uy for qemu-devel@nongnu.org; Wed, 14 Sep 2011 16:50:18 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8EKoHve029239 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 14 Sep 2011 16:50:17 -0400 Received: from localhost (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8EKoGYu018722; Wed, 14 Sep 2011 16:50:16 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Wed, 14 Sep 2011 17:49:57 -0300 Message-Id: <1316033398-26582-9-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1316033398-26582-1-git-send-email-lcapitulino@redhat.com> References: <1316033398-26582-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org 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 ac68edf..ab71d2d 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 686e491..08591c3 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);