From patchwork Wed Aug 10 20:33:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 109457 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 3E8F9B6F7A for ; Thu, 11 Aug 2011 07:19:48 +1000 (EST) Received: from localhost ([::1]:50855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrFU6-00028B-IM for incoming@patchwork.ozlabs.org; Wed, 10 Aug 2011 16:34:38 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrFTS-00015K-2h for qemu-devel@nongnu.org; Wed, 10 Aug 2011 16:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrFTM-000886-Qi for qemu-devel@nongnu.org; Wed, 10 Aug 2011 16:33:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrFTM-00087z-G4 for qemu-devel@nongnu.org; Wed, 10 Aug 2011 16:33:52 -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 p7AKXpvl005243 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 10 Aug 2011 16:33:51 -0400 Received: from localhost (ovpn-113-72.phx2.redhat.com [10.3.113.72]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7AKXoTP005470; Wed, 10 Aug 2011 16:33:51 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 10 Aug 2011 17:33:28 -0300 Message-Id: <1313008408-23161-9-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1313008408-23161-1-git-send-email-lcapitulino@redhat.com> References: <1313008408-23161-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, avi@redhat.com, amit.shah@redhat.com Subject: [Qemu-devel] [PATCH 8/8] HMP: info status: Print the VM state 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 Today our printf format for the "info status" command is: VM status: %s Where the string can be "running", "running (single step mode)" or "paused". This commit extends it to: VM status: %s (%s) The second string corresponds to the "status" field as returned by the query-status QMP command and it's only printed if "status" is not "running" or "paused". Example: VM status: paused (shutdown) PS: libvirt uses "info status" when using HMP, but the new format should not break it. Signed-off-by: Luiz Capitulino --- monitor.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index c9e65fa..c186d6b 100644 --- a/monitor.c +++ b/monitor.c @@ -2604,6 +2604,7 @@ static int do_inject_nmi(Monitor *mon, const QDict *qdict, QObject **ret_data) static void do_info_status_print(Monitor *mon, const QObject *data) { QDict *qdict; + const char *status; qdict = qobject_to_qdict(data); @@ -2617,6 +2618,11 @@ static void do_info_status_print(Monitor *mon, const QObject *data) monitor_printf(mon, "paused"); } + status = qdict_get_str(qdict, "status"); + if (strcmp(status, "paused") && strcmp(status, "running")) { + monitor_printf(mon, " (%s)", status); + } + monitor_printf(mon, "\n"); }