[Qemu-devel] [RFC PATCH 10/56] hmp: Make balloon's argument unsigned

Markus Armbruster posted 56 patches 8 years, 6 months ago
[Qemu-devel] [RFC PATCH 10/56] hmp: Make balloon's argument unsigned
Posted by Markus Armbruster 8 years, 6 months ago
The previous commit made it unsigned in QMP.  Switch HMP's args_type
from 'M' to 'o'.  Loses support for expressions (QEMU pocket
calculator), gains support for units other than mebibytes.  Negative
values are no longer accepted and interpreted modulo 2^64.  Instead,
values between 2^63 and 2^64-1 are now accepted.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hmp-commands.hx | 2 +-
 hmp.c           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 1941e19..46ce79c 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1433,7 +1433,7 @@ ETEXI
 
     {
         .name       = "balloon",
-        .args_type  = "value:M",
+        .args_type  = "value:o",
         .params     = "target",
         .help       = "request VM to change its memory allocation (in MB)",
         .cmd        = hmp_balloon,
diff --git a/hmp.c b/hmp.c
index 4556045..1932a11 100644
--- a/hmp.c
+++ b/hmp.c
@@ -781,7 +781,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
         return;
     }
 
-    monitor_printf(mon, "balloon: actual=%" PRIu64 "\n", info->actual >> 20);
+    monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
 
     qapi_free_BalloonInfo(info);
 }
@@ -1178,7 +1178,7 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdict)
 
 void hmp_balloon(Monitor *mon, const QDict *qdict)
 {
-    int64_t value = qdict_get_int(qdict, "value");
+    uint64_t value = qdict_get_uint(qdict, "value");
     Error *err = NULL;
 
     qmp_balloon(value, &err);
-- 
2.7.5


Re: [Qemu-devel] [RFC PATCH 10/56] hmp: Make balloon's argument unsigned
Posted by Dr. David Alan Gilbert 8 years, 6 months ago
* Markus Armbruster (armbru@redhat.com) wrote:
> The previous commit made it unsigned in QMP.  Switch HMP's args_type
> from 'M' to 'o'.  Loses support for expressions (QEMU pocket
> calculator), gains support for units other than mebibytes.  Negative
> values are no longer accepted and interpreted modulo 2^64.  Instead,
> values between 2^63 and 2^64-1 are now accepted.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hmp-commands.hx | 2 +-
>  hmp.c           | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 1941e19..46ce79c 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1433,7 +1433,7 @@ ETEXI
>  
>      {
>          .name       = "balloon",
> -        .args_type  = "value:M",
> +        .args_type  = "value:o",
>          .params     = "target",
>          .help       = "request VM to change its memory allocation (in MB)",
>          .cmd        = hmp_balloon,
> diff --git a/hmp.c b/hmp.c
> index 4556045..1932a11 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -781,7 +781,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
>          return;
>      }
>  
> -    monitor_printf(mon, "balloon: actual=%" PRIu64 "\n", info->actual >> 20);
> +    monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);

That looks like a partial reversion of the last patch ?

Dave

>      qapi_free_BalloonInfo(info);
>  }
> @@ -1178,7 +1178,7 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdict)
>  
>  void hmp_balloon(Monitor *mon, const QDict *qdict)
>  {
> -    int64_t value = qdict_get_int(qdict, "value");
> +    uint64_t value = qdict_get_uint(qdict, "value");
>      Error *err = NULL;
>  
>      qmp_balloon(value, &err);
> -- 
> 2.7.5
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [RFC PATCH 10/56] hmp: Make balloon's argument unsigned
Posted by Markus Armbruster 8 years, 6 months ago
"Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:

> * Markus Armbruster (armbru@redhat.com) wrote:
>> The previous commit made it unsigned in QMP.  Switch HMP's args_type
>> from 'M' to 'o'.  Loses support for expressions (QEMU pocket
>> calculator), gains support for units other than mebibytes.  Negative
>> values are no longer accepted and interpreted modulo 2^64.  Instead,
>> values between 2^63 and 2^64-1 are now accepted.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  hmp-commands.hx | 2 +-
>>  hmp.c           | 4 ++--
>>  2 files changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/hmp-commands.hx b/hmp-commands.hx
>> index 1941e19..46ce79c 100644
>> --- a/hmp-commands.hx
>> +++ b/hmp-commands.hx
>> @@ -1433,7 +1433,7 @@ ETEXI
>>  
>>      {
>>          .name       = "balloon",
>> -        .args_type  = "value:M",
>> +        .args_type  = "value:o",
>>          .params     = "target",
>>          .help       = "request VM to change its memory allocation (in MB)",
>>          .cmd        = hmp_balloon,
>> diff --git a/hmp.c b/hmp.c
>> index 4556045..1932a11 100644
>> --- a/hmp.c
>> +++ b/hmp.c
>> @@ -781,7 +781,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict)
>>          return;
>>      }
>>  
>> -    monitor_printf(mon, "balloon: actual=%" PRIu64 "\n", info->actual >> 20);
>> +    monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
>
> That looks like a partial reversion of the last patch ?

Accident, will fix, thanks!

[...]