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

login
register
mail settings
Submitter Luiz Capitulino
Date Dec. 4, 2009, 5:11 p.m.
Message ID <1259946695-15784-7-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/40345/
State New
Headers show

Comments

Luiz Capitulino - Dec. 4, 2009, 5:11 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(-)
Anthony Liguori - Dec. 7, 2009, 7:31 p.m.
Luiz Capitulino wrote:
> Return a QString with status information.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  monitor.c |   33 +++++++++++++++++++++++++++------
>  1 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 8cedfa9..03f5d7a 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1865,16 +1865,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);
>  }
>   

Wouldn't this be better as "{'running': true, 'single-step': false}"?

Please send an incremental patch.

Regards,

Anthony Liguori

Patch

diff --git a/monitor.c b/monitor.c
index 8cedfa9..03f5d7a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1865,16 +1865,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);
 }
 
 /**
@@ -2317,7 +2337,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",