diff mbox series

[v2,3/8] qapi/misc: Restrict balloon-related commands to machine code

Message ID 20200316000348.29692-4-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series user-mode: Prune build dependencies (part 2) | expand

Commit Message

Philippe Mathieu-Daudé March 16, 2020, 12:03 a.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 qapi/machine.json          | 83 ++++++++++++++++++++++++++++++++++++++
 qapi/misc.json             | 83 --------------------------------------
 include/sysemu/balloon.h   |  2 +-
 balloon.c                  |  2 +-
 hw/virtio/virtio-balloon.c |  2 +-
 monitor/hmp-cmds.c         |  1 +
 6 files changed, 87 insertions(+), 86 deletions(-)

Comments

David Hildenbrand March 16, 2020, 9:05 a.m. UTC | #1
On 16.03.20 01:03, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  qapi/machine.json          | 83 ++++++++++++++++++++++++++++++++++++++
>  qapi/misc.json             | 83 --------------------------------------
>  include/sysemu/balloon.h   |  2 +-
>  balloon.c                  |  2 +-
>  hw/virtio/virtio-balloon.c |  2 +-
>  monitor/hmp-cmds.c         |  1 +
>  6 files changed, 87 insertions(+), 86 deletions(-)
> 
> diff --git a/qapi/machine.json b/qapi/machine.json
> index 07ffc07ba2..c096efbea3 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -915,3 +915,86 @@
>    'data': 'NumaOptions',
>    'allow-preconfig': true
>  }
> +
> +##
> +# @balloon:
> +#
> +# Request the balloon driver to change its balloon size.
> +#
> +# @value: the target size of the balloon in bytes

Not related to your patch. The description of most of this stuff is wrong.

It's not the target size of the balloon, it's the target logical size of
the VM (logical_vm_size = vm_ram_size - balloon_size)

-> balloon_size = vm_ram_size - @value

E.g., "balloon 1024" with a 3G guest means "please inflate the balloon
to 2048"

> +#
> +# Returns: - Nothing on success
> +#          - If the balloon driver is enabled but not functional because the KVM
> +#            kernel module cannot support it, KvmMissingCap
> +#          - If no balloon device is present, DeviceNotActive
> +#
> +# Notes: This command just issues a request to the guest.  When it returns,
> +#        the balloon size may not have changed.  A guest can change the balloon
> +#        size independent of this command.
> +#
> +# Since: 0.14.0
> +#
> +# Example:
> +#
> +# -> { "execute": "balloon", "arguments": { "value": 536870912 } }
> +# <- { "return": {} }
> +#
> +##
> +{ 'command': 'balloon', 'data': {'value': 'int'} }
> +
> +##
> +# @BalloonInfo:
> +#
> +# Information about the guest balloon device.
> +#
> +# @actual: the number of bytes the balloon currently contains

Dito

@actual is the logical size of the VM (logical_vm_size = vm_ram_size -
balloon_size)

> +#
> +# Since: 0.14.0
> +#
> +##
> +{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
> +
> +##
> +# @query-balloon:
> +#
> +# Return information about the balloon device.
> +#
> +# Returns: - @BalloonInfo on success
> +#          - If the balloon driver is enabled but not functional because the KVM
> +#            kernel module cannot support it, KvmMissingCap
> +#          - If no balloon device is present, DeviceNotActive
> +#
> +# Since: 0.14.0
> +#
> +# Example:
> +#
> +# -> { "execute": "query-balloon" }
> +# <- { "return": {
> +#          "actual": 1073741824,
> +#       }
> +#    }
> +#
> +##
> +{ 'command': 'query-balloon', 'returns': 'BalloonInfo' }
> +
> +##
> +# @BALLOON_CHANGE:
> +#
> +# Emitted when the guest changes the actual BALLOON level. This value is
> +# equivalent to the @actual field return by the 'query-balloon' command
> +#
> +# @actual: actual level of the guest memory balloon in bytes

Dito

@actual is the logical size of the VM (vm_ram_size - balloon_size)


Most probably we want to pull this description fix out. #badinterface
Philippe Mathieu-Daudé March 17, 2020, 11:03 a.m. UTC | #2
Hi David,

On 3/16/20 10:05 AM, David Hildenbrand wrote:
> On 16.03.20 01:03, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>   qapi/machine.json          | 83 ++++++++++++++++++++++++++++++++++++++
>>   qapi/misc.json             | 83 --------------------------------------
>>   include/sysemu/balloon.h   |  2 +-
>>   balloon.c                  |  2 +-
>>   hw/virtio/virtio-balloon.c |  2 +-
>>   monitor/hmp-cmds.c         |  1 +
>>   6 files changed, 87 insertions(+), 86 deletions(-)
>>
>> diff --git a/qapi/machine.json b/qapi/machine.json
>> index 07ffc07ba2..c096efbea3 100644
>> --- a/qapi/machine.json
>> +++ b/qapi/machine.json
>> @@ -915,3 +915,86 @@
>>     'data': 'NumaOptions',
>>     'allow-preconfig': true
>>   }
>> +
>> +##
>> +# @balloon:
>> +#
>> +# Request the balloon driver to change its balloon size.
>> +#
>> +# @value: the target size of the balloon in bytes
> 
> Not related to your patch. The description of most of this stuff is wrong.
> 
> It's not the target size of the balloon, it's the target logical size of
> the VM (logical_vm_size = vm_ram_size - balloon_size)
> 
> -> balloon_size = vm_ram_size - @value
> 
> E.g., "balloon 1024" with a 3G guest means "please inflate the balloon
> to 2048"
> 
>> +#
>> +# Returns: - Nothing on success
>> +#          - If the balloon driver is enabled but not functional because the KVM
>> +#            kernel module cannot support it, KvmMissingCap
>> +#          - If no balloon device is present, DeviceNotActive
>> +#
>> +# Notes: This command just issues a request to the guest.  When it returns,
>> +#        the balloon size may not have changed.  A guest can change the balloon
>> +#        size independent of this command.
>> +#
>> +# Since: 0.14.0
>> +#
>> +# Example:
>> +#
>> +# -> { "execute": "balloon", "arguments": { "value": 536870912 } }
>> +# <- { "return": {} }
>> +#
>> +##
>> +{ 'command': 'balloon', 'data': {'value': 'int'} }
>> +
>> +##
>> +# @BalloonInfo:
>> +#
>> +# Information about the guest balloon device.
>> +#
>> +# @actual: the number of bytes the balloon currently contains
> 
> Dito
> 
> @actual is the logical size of the VM (logical_vm_size = vm_ram_size -
> balloon_size)
> 
>> +#
>> +# Since: 0.14.0
>> +#
>> +##
>> +{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
>> +
>> +##
>> +# @query-balloon:
>> +#
>> +# Return information about the balloon device.
>> +#
>> +# Returns: - @BalloonInfo on success
>> +#          - If the balloon driver is enabled but not functional because the KVM
>> +#            kernel module cannot support it, KvmMissingCap
>> +#          - If no balloon device is present, DeviceNotActive
>> +#
>> +# Since: 0.14.0
>> +#
>> +# Example:
>> +#
>> +# -> { "execute": "query-balloon" }
>> +# <- { "return": {
>> +#          "actual": 1073741824,
>> +#       }
>> +#    }
>> +#
>> +##
>> +{ 'command': 'query-balloon', 'returns': 'BalloonInfo' }
>> +
>> +##
>> +# @BALLOON_CHANGE:
>> +#
>> +# Emitted when the guest changes the actual BALLOON level. This value is
>> +# equivalent to the @actual field return by the 'query-balloon' command
>> +#
>> +# @actual: actual level of the guest memory balloon in bytes
> 
> Dito
> 
> @actual is the logical size of the VM (vm_ram_size - balloon_size)
> 
> 
> Most probably we want to pull this description fix out. #badinterface

Since you understand how ballooning works, do you mind sending a patch 
with description fixed? :)

Thanks,

Phil.
David Hildenbrand March 17, 2020, 11:04 a.m. UTC | #3
On 17.03.20 12:03, Philippe Mathieu-Daudé wrote:
> Hi David,
> 
> On 3/16/20 10:05 AM, David Hildenbrand wrote:
>> On 16.03.20 01:03, Philippe Mathieu-Daudé wrote:
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>>   qapi/machine.json          | 83 ++++++++++++++++++++++++++++++++++++++
>>>   qapi/misc.json             | 83 --------------------------------------
>>>   include/sysemu/balloon.h   |  2 +-
>>>   balloon.c                  |  2 +-
>>>   hw/virtio/virtio-balloon.c |  2 +-
>>>   monitor/hmp-cmds.c         |  1 +
>>>   6 files changed, 87 insertions(+), 86 deletions(-)
>>>
>>> diff --git a/qapi/machine.json b/qapi/machine.json
>>> index 07ffc07ba2..c096efbea3 100644
>>> --- a/qapi/machine.json
>>> +++ b/qapi/machine.json
>>> @@ -915,3 +915,86 @@
>>>     'data': 'NumaOptions',
>>>     'allow-preconfig': true
>>>   }
>>> +
>>> +##
>>> +# @balloon:
>>> +#
>>> +# Request the balloon driver to change its balloon size.
>>> +#
>>> +# @value: the target size of the balloon in bytes
>>
>> Not related to your patch. The description of most of this stuff is wrong.
>>
>> It's not the target size of the balloon, it's the target logical size of
>> the VM (logical_vm_size = vm_ram_size - balloon_size)
>>
>> -> balloon_size = vm_ram_size - @value
>>
>> E.g., "balloon 1024" with a 3G guest means "please inflate the balloon
>> to 2048"
>>
>>> +#
>>> +# Returns: - Nothing on success
>>> +#          - If the balloon driver is enabled but not functional because the KVM
>>> +#            kernel module cannot support it, KvmMissingCap
>>> +#          - If no balloon device is present, DeviceNotActive
>>> +#
>>> +# Notes: This command just issues a request to the guest.  When it returns,
>>> +#        the balloon size may not have changed.  A guest can change the balloon
>>> +#        size independent of this command.
>>> +#
>>> +# Since: 0.14.0
>>> +#
>>> +# Example:
>>> +#
>>> +# -> { "execute": "balloon", "arguments": { "value": 536870912 } }
>>> +# <- { "return": {} }
>>> +#
>>> +##
>>> +{ 'command': 'balloon', 'data': {'value': 'int'} }
>>> +
>>> +##
>>> +# @BalloonInfo:
>>> +#
>>> +# Information about the guest balloon device.
>>> +#
>>> +# @actual: the number of bytes the balloon currently contains
>>
>> Dito
>>
>> @actual is the logical size of the VM (logical_vm_size = vm_ram_size -
>> balloon_size)
>>
>>> +#
>>> +# Since: 0.14.0
>>> +#
>>> +##
>>> +{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
>>> +
>>> +##
>>> +# @query-balloon:
>>> +#
>>> +# Return information about the balloon device.
>>> +#
>>> +# Returns: - @BalloonInfo on success
>>> +#          - If the balloon driver is enabled but not functional because the KVM
>>> +#            kernel module cannot support it, KvmMissingCap
>>> +#          - If no balloon device is present, DeviceNotActive
>>> +#
>>> +# Since: 0.14.0
>>> +#
>>> +# Example:
>>> +#
>>> +# -> { "execute": "query-balloon" }
>>> +# <- { "return": {
>>> +#          "actual": 1073741824,
>>> +#       }
>>> +#    }
>>> +#
>>> +##
>>> +{ 'command': 'query-balloon', 'returns': 'BalloonInfo' }
>>> +
>>> +##
>>> +# @BALLOON_CHANGE:
>>> +#
>>> +# Emitted when the guest changes the actual BALLOON level. This value is
>>> +# equivalent to the @actual field return by the 'query-balloon' command
>>> +#
>>> +# @actual: actual level of the guest memory balloon in bytes
>>
>> Dito
>>
>> @actual is the logical size of the VM (vm_ram_size - balloon_size)
>>
>>
>> Most probably we want to pull this description fix out. #badinterface
> 
> Since you understand how ballooning works, do you mind sending a patch 
> with description fixed? :)

Will add it to my todo list, so your patch can go in first :)

Thanks
diff mbox series

Patch

diff --git a/qapi/machine.json b/qapi/machine.json
index 07ffc07ba2..c096efbea3 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -915,3 +915,86 @@ 
   'data': 'NumaOptions',
   'allow-preconfig': true
 }
+
+##
+# @balloon:
+#
+# Request the balloon driver to change its balloon size.
+#
+# @value: the target size of the balloon in bytes
+#
+# Returns: - Nothing on success
+#          - If the balloon driver is enabled but not functional because the KVM
+#            kernel module cannot support it, KvmMissingCap
+#          - If no balloon device is present, DeviceNotActive
+#
+# Notes: This command just issues a request to the guest.  When it returns,
+#        the balloon size may not have changed.  A guest can change the balloon
+#        size independent of this command.
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "balloon", "arguments": { "value": 536870912 } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'balloon', 'data': {'value': 'int'} }
+
+##
+# @BalloonInfo:
+#
+# Information about the guest balloon device.
+#
+# @actual: the number of bytes the balloon currently contains
+#
+# Since: 0.14.0
+#
+##
+{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
+
+##
+# @query-balloon:
+#
+# Return information about the balloon device.
+#
+# Returns: - @BalloonInfo on success
+#          - If the balloon driver is enabled but not functional because the KVM
+#            kernel module cannot support it, KvmMissingCap
+#          - If no balloon device is present, DeviceNotActive
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "query-balloon" }
+# <- { "return": {
+#          "actual": 1073741824,
+#       }
+#    }
+#
+##
+{ 'command': 'query-balloon', 'returns': 'BalloonInfo' }
+
+##
+# @BALLOON_CHANGE:
+#
+# Emitted when the guest changes the actual BALLOON level. This value is
+# equivalent to the @actual field return by the 'query-balloon' command
+#
+# @actual: actual level of the guest memory balloon in bytes
+#
+# Note: this event is rate-limited.
+#
+# Since: 1.2
+#
+# Example:
+#
+# <- { "event": "BALLOON_CHANGE",
+#      "data": { "actual": 944766976 },
+#      "timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
+#
+##
+{ 'event': 'BALLOON_CHANGE',
+  'data': { 'actual': 'int' } }
diff --git a/qapi/misc.json b/qapi/misc.json
index 2725d835ad..ed28e41229 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -186,63 +186,6 @@ 
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'],
   'allow-preconfig': true }
 
-##
-# @BalloonInfo:
-#
-# Information about the guest balloon device.
-#
-# @actual: the number of bytes the balloon currently contains
-#
-# Since: 0.14.0
-#
-##
-{ 'struct': 'BalloonInfo', 'data': {'actual': 'int' } }
-
-##
-# @query-balloon:
-#
-# Return information about the balloon device.
-#
-# Returns: - @BalloonInfo on success
-#          - If the balloon driver is enabled but not functional because the KVM
-#            kernel module cannot support it, KvmMissingCap
-#          - If no balloon device is present, DeviceNotActive
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "query-balloon" }
-# <- { "return": {
-#          "actual": 1073741824,
-#       }
-#    }
-#
-##
-{ 'command': 'query-balloon', 'returns': 'BalloonInfo' }
-
-##
-# @BALLOON_CHANGE:
-#
-# Emitted when the guest changes the actual BALLOON level. This value is
-# equivalent to the @actual field return by the 'query-balloon' command
-#
-# @actual: actual level of the guest memory balloon in bytes
-#
-# Note: this event is rate-limited.
-#
-# Since: 1.2
-#
-# Example:
-#
-# <- { "event": "BALLOON_CHANGE",
-#      "data": { "actual": 944766976 },
-#      "timestamp": { "seconds": 1267020223, "microseconds": 435656 } }
-#
-##
-{ 'event': 'BALLOON_CHANGE',
-  'data': { 'actual': 'int' } }
-
 ##
 # @PciMemoryRange:
 #
@@ -751,32 +694,6 @@ 
 ##
 { 'command': 'inject-nmi' }
 
-##
-# @balloon:
-#
-# Request the balloon driver to change its balloon size.
-#
-# @value: the target size of the balloon in bytes
-#
-# Returns: - Nothing on success
-#          - If the balloon driver is enabled but not functional because the KVM
-#            kernel module cannot support it, KvmMissingCap
-#          - If no balloon device is present, DeviceNotActive
-#
-# Notes: This command just issues a request to the guest.  When it returns,
-#        the balloon size may not have changed.  A guest can change the balloon
-#        size independent of this command.
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "balloon", "arguments": { "value": 536870912 } }
-# <- { "return": {} }
-#
-##
-{ 'command': 'balloon', 'data': {'value': 'int'} }
-
 ##
 # @human-monitor-command:
 #
diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h
index aea0c44985..b3de4b92b9 100644
--- a/include/sysemu/balloon.h
+++ b/include/sysemu/balloon.h
@@ -15,7 +15,7 @@ 
 #define QEMU_BALLOON_H
 
 #include "exec/cpu-common.h"
-#include "qapi/qapi-types-misc.h"
+#include "qapi/qapi-types-machine.h"
 
 typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target);
 typedef void (QEMUBalloonStatus)(void *opaque, BalloonInfo *info);
diff --git a/balloon.c b/balloon.c
index f104b42961..ee9c59252d 100644
--- a/balloon.c
+++ b/balloon.c
@@ -30,7 +30,7 @@ 
 #include "sysemu/balloon.h"
 #include "trace-root.h"
 #include "qapi/error.h"
-#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-machine.h"
 #include "qapi/qmp/qerror.h"
 
 static QEMUBalloonEvent *balloon_event_fn;
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index a4729f7fc9..07ad36b143 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -24,7 +24,7 @@ 
 #include "hw/virtio/virtio-balloon.h"
 #include "exec/address-spaces.h"
 #include "qapi/error.h"
-#include "qapi/qapi-events-misc.h"
+#include "qapi/qapi-events-machine.h"
 #include "qapi/visitor.h"
 #include "trace.h"
 #include "qemu/error-report.h"
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 58724031ea..97cd340b2e 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -32,6 +32,7 @@ 
 #include "qapi/qapi-commands-block.h"
 #include "qapi/qapi-commands-char.h"
 #include "qapi/qapi-commands-control.h"
+#include "qapi/qapi-commands-machine.h"
 #include "qapi/qapi-commands-migration.h"
 #include "qapi/qapi-commands-misc.h"
 #include "qapi/qapi-commands-net.h"