Patchwork [05/17] monitor: Fix do_info_balloon() output

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

Comments

Luiz Capitulino - Dec. 4, 2009, 5:11 p.m.
New monitor commands should always return values in bytes.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
Anthony Liguori - Dec. 7, 2009, 7:41 p.m.
Luiz Capitulino wrote:
> New monitor commands should always return values in bytes.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  monitor.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 5bf32f0..8cedfa9 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1889,12 +1889,18 @@ static void do_balloon(Monitor *mon, const QDict *qdict, QObject **ret_data)
>  
>  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)));
> +    monitor_printf(mon, "balloon: actual=%" PRId64 "\n",
> +                        qint_get_int(qobject_to_qint(data)) >> 20);
>  }
>  
>  /**
>   * do_info_balloon(): Balloon information
> + *
> + * Return a QInt with current ballooning value.
> + *
> + * Example:
> + *
> + * 1073741824
>   */
>  static void do_info_balloon(Monitor *mon, QObject **ret_data)
>  {
> @@ -1906,7 +1912,7 @@ static void do_info_balloon(Monitor *mon, QObject **ret_data)
>      else if (actual == 0)
>          qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon");
>      else
> -        *ret_data = QOBJECT(qint_from_int((int)(actual >> 20)));
> +        *ret_data = QOBJECT(qint_from_int(actual));
>  }
>   

Returning a dictionary would allow us to extend this information more 
easily.

Regards,

Anthony Liguori

Patch

diff --git a/monitor.c b/monitor.c
index 5bf32f0..8cedfa9 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1889,12 +1889,18 @@  static void do_balloon(Monitor *mon, const QDict *qdict, QObject **ret_data)
 
 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)));
+    monitor_printf(mon, "balloon: actual=%" PRId64 "\n",
+                        qint_get_int(qobject_to_qint(data)) >> 20);
 }
 
 /**
  * do_info_balloon(): Balloon information
+ *
+ * Return a QInt with current ballooning value.
+ *
+ * Example:
+ *
+ * 1073741824
  */
 static void do_info_balloon(Monitor *mon, QObject **ret_data)
 {
@@ -1906,7 +1912,7 @@  static void do_info_balloon(Monitor *mon, QObject **ret_data)
     else if (actual == 0)
         qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon");
     else
-        *ret_data = QOBJECT(qint_from_int((int)(actual >> 20)));
+        *ret_data = QOBJECT(qint_from_int(actual));
 }
 
 static qemu_acl *find_acl(Monitor *mon, const char *name)