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

login
register
mail settings
Submitter Luiz Capitulino
Date Nov. 1, 2009, 2:51 p.m.
Message ID <1257087078-5757-9-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/37387/
State New
Headers show

Comments

Luiz Capitulino - Nov. 1, 2009, 2:51 p.m.
Return a QString with status information.

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

Patch

diff --git a/monitor.c b/monitor.c
index 4e19fdf..78a2df5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1678,16 +1678,38 @@  static void do_inject_nmi(Monitor *mon, const QDict *qdict)
 }
 #endif
 
-static void do_info_status(Monitor *mon)
+static void monitor_print_status(Monitor *mon, const QObject *data)
 {
+    QString *qs;
+
+    qs = qobject_to_qstring(data);
+    monitor_printf(mon, "VM status: %s\n", qstring_get_str(qs));
+}
+
+/**
+ * do_info_status(): VM status
+ *
+ * Return a QString with status information.
+ *
+ * Example:
+ *
+ * "running"
+ */
+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);
 }
 
 /**
@@ -2119,7 +2141,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 = monitor_print_status,
+        .mhandler.info_new = do_info_status,
     },
     {
         .name       = "pcmcia",