Patchwork [14/15] monitor: Convert do_info_balloon() to QObject

login
register
mail settings
Submitter Luiz Capitulino
Date Oct. 7, 2009, 12:27 a.m.
Message ID <1254875232-25012-15-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/35186/
State Changes Requested
Headers show

Comments

Luiz Capitulino - Oct. 7, 2009, 12:27 a.m.
On success return a QInt with the balloon's value.

This also introduces monitor_print_balloon() to print the
balloon information in the user protocol.

Please, note that errors are not being converted yet.

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

Patch

diff --git a/monitor.c b/monitor.c
index 2a1e4d7..0dcf478 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1634,7 +1634,16 @@  static void do_balloon(Monitor *mon, const QDict *qdict, QObject **ret_data)
     qemu_balloon(target << 20);
 }
 
-static void do_info_balloon(Monitor *mon)
+static void monitor_print_balloon(Monitor *mon, const QObject *data)
+{
+    monitor_printf(mon, "balloon: actual=%d\n",
+                                     (int)qint_get_int(qobject_to_qint(data)));
+}
+
+/**
+ * do_info_balloon(): Balloon information
+ */
+static void do_info_balloon(Monitor *mon, QObject **ret_data)
 {
     ram_addr_t actual;
 
@@ -1645,7 +1654,7 @@  static void do_info_balloon(Monitor *mon)
     else if (actual == 0)
         monitor_printf(mon, "Ballooning not activated in VM\n");
     else
-        monitor_printf(mon, "balloon: actual=%d\n", (int)(actual >> 20));
+        *ret_data = QOBJECT(qint_from_int((int)(actual >> 20)));
 }
 
 static qemu_acl *find_acl(Monitor *mon, const char *name)
@@ -2137,7 +2146,7 @@  static const mon_cmd_t info_cmds[] = {
         .name       = "balloon",
         .args_type  = "",
         .handler    = do_info_balloon,
-        .user_print = NULL,
+        .user_print = monitor_print_balloon,
         .params     = "",
         .help       = "show balloon information"
     },