Patchwork [06/17] monitor: Convert do_info_status() to QObject

login
register
mail settings
Submitter Luiz Capitulino
Date Nov. 23, 2009, 8:06 p.m.
Message ID <1259006783-945-7-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/39085/
State New
Headers show

Comments

Luiz Capitulino - Nov. 23, 2009, 8:06 p.m.
Return a QString with status information.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index e3368c8..c9104c3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1678,16 +1678,36 @@  static void do_inject_nmi(Monitor *mon, const QDict *qdict)
 }
 #endif
 
-static void do_info_status(Monitor *mon)
+static void do_info_status_print(Monitor *mon, const QObject *data)
 {
+    monitor_printf(mon, "VM status: %s\n",
+                   qstring_get_str(qobject_to_qstring(data)));
+}
+
+/**
+ * do_info_status(): VM status
+ *
+ * Return a QString with status information, which can be:
+ *
+ * - "running"
+ * - "running (single step mode)"
+ * - "paused"
+ */
+static void do_info_status(Monitor *mon, QObject **ret_data)
+{
+    QString *qs;
+
     if (vm_running) {
         if (singlestep) {
-            monitor_printf(mon, "VM status: running (single step mode)\n");
+            qs = qstring_from_str("running (single step mode)");
         } else {
-            monitor_printf(mon, "VM status: running\n");
+            qs = qstring_from_str("running");
         }
-    } else
-       monitor_printf(mon, "VM status: paused\n");
+    } else {
+       qs = qstring_from_str("paused");
+    }
+
+    *ret_data = QOBJECT(qs);
 }
 
 /**
@@ -2123,7 +2143,8 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM status (running|paused)",
-        .mhandler.info = do_info_status,
+        .user_print = do_info_status_print,
+        .mhandler.info_new = do_info_status,
     },
     {
         .name       = "pcmcia",