From patchwork Wed Aug 3 15:17:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 108294 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 B6F58B71DB for ; Thu, 4 Aug 2011 02:02:21 +1000 (EST) Received: from localhost ([::1]:38047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodE8-0000r1-9M for incoming@patchwork.ozlabs.org; Wed, 03 Aug 2011 11:19:20 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodDt-0008Uo-1V for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:19:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QodCz-0006fy-5U for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:18:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodCy-0006ck-Pr for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:18:09 -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 p73FHqPL004681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Aug 2011 11:17:52 -0400 Received: from localhost (ovpn-113-124.phx2.redhat.com [10.3.113.124]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p73FHpPd025821; Wed, 3 Aug 2011 11:17:51 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 3 Aug 2011 12:17:23 -0300 Message-Id: <1312384643-581-8-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1312384643-581-1-git-send-email-lcapitulino@redhat.com> References: <1312384643-581-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: 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 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 | 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;