Patchwork [8/8] HMP: info status: Print the VM state

login
register
mail settings
Submitter Luiz Capitulino
Date Aug. 10, 2011, 8:33 p.m.
Message ID <1313008408-23161-9-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/109457/
State New
Headers show

Comments

Luiz Capitulino - Aug. 10, 2011, 8:33 p.m.
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 <lcapitulino@redhat.com>
---
 monitor.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Patch

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");
 }