diff mbox series

[v3,4/9] qapi/misc: Restrict balloon-related commands to machine code

Message ID 20200525150640.30879-5-philmd@redhat.com
State New
Headers show
Series user-mode: Prune build dependencies (part 2) | expand

Commit Message

Philippe Mathieu-Daudé May 25, 2020, 3:06 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 qapi/machine.json          | 90 ++++++++++++++++++++++++++++++++++++++
 qapi/misc.json             | 90 --------------------------------------
 include/sysemu/balloon.h   |  2 +-
 balloon.c                  |  2 +-
 hw/virtio/virtio-balloon.c |  2 +-
 monitor/hmp-cmds.c         |  1 +
 6 files changed, 94 insertions(+), 93 deletions(-)

Comments

David Hildenbrand May 26, 2020, 7:35 a.m. UTC | #1
On 25.05.20 17:06, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  qapi/machine.json          | 90 ++++++++++++++++++++++++++++++++++++++
>  qapi/misc.json             | 90 --------------------------------------
>  include/sysemu/balloon.h   |  2 +-
>  balloon.c                  |  2 +-
>  hw/virtio/virtio-balloon.c |  2 +-
>  monitor/hmp-cmds.c         |  1 +
>  6 files changed, 94 insertions(+), 93 deletions(-)
> 
> diff --git a/qapi/machine.json b/qapi/machine.json
> index ca7d58f0c9..ae42d69495 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -921,3 +921,93 @@
>    'data': 'NumaOptions',
>    'allow-preconfig': true
>  }
> +
> +##
> +# @balloon:
> +#
> +# Request the balloon driver to change its balloon size.
> +#
> +# @value: the target logical size of the VM in bytes
> +#         We can deduce the size of the balloon using this formula:
> +#            logical_vm_size = vm_ram_size - balloon_size
> +#         From it we have: balloon_size = vm_ram_size - @value
> +#
> +# 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": {} }
> +#
> +# With a 2.5GiB guest this command inflated the ballon to 3GiB.
> +#
> +##
> +{ 'command': 'balloon', 'data': {'value': 'int'} }
> +
> +##
> +# @BalloonInfo:
> +#
> +# Information about the guest balloon device.
> +#
> +# @actual: the logical size of the VM in bytes
> +#          Formula used: 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: the logical size of the VM in bytes
> +#          Formula used: logical_vm_size = vm_ram_size - balloon_size
> +#
> +# 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 446fc8ff83..26b5115638 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -186,65 +186,6 @@
>  { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'],
>    'allow-preconfig': true }
>  
> -##
> -# @BalloonInfo:
> -#
> -# Information about the guest balloon device.
> -#
> -# @actual: the logical size of the VM in bytes
> -#          Formula used: 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: the logical size of the VM in bytes
> -#          Formula used: logical_vm_size = vm_ram_size - balloon_size
> -#
> -# 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:
>  #
> @@ -753,37 +694,6 @@
>  ##
>  { 'command': 'inject-nmi' }
>  
> -##
> -# @balloon:
> -#
> -# Request the balloon driver to change its balloon size.
> -#
> -# @value: the target logical size of the VM in bytes
> -#         We can deduce the size of the balloon using this formula:
> -#            logical_vm_size = vm_ram_size - balloon_size
> -#         From it we have: balloon_size = vm_ram_size - @value
> -#
> -# 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": {} }
> -#
> -# With a 2.5GiB guest this command inflated the ballon to 3GiB.
> -#
> -##
> -{ '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 065cd450f1..ec3aac1e80 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 9c61e769ca..376590c073 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"
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

I yet have to craft a patch to fixup the wrong documentation :)
David Hildenbrand May 26, 2020, 7:36 a.m. UTC | #2
On 26.05.20 09:35, David Hildenbrand wrote:
> On 25.05.20 17:06, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  qapi/machine.json          | 90 ++++++++++++++++++++++++++++++++++++++
>>  qapi/misc.json             | 90 --------------------------------------
>>  include/sysemu/balloon.h   |  2 +-
>>  balloon.c                  |  2 +-
>>  hw/virtio/virtio-balloon.c |  2 +-
>>  monitor/hmp-cmds.c         |  1 +
>>  6 files changed, 94 insertions(+), 93 deletions(-)
>>
>> diff --git a/qapi/machine.json b/qapi/machine.json
>> index ca7d58f0c9..ae42d69495 100644
>> --- a/qapi/machine.json
>> +++ b/qapi/machine.json
>> @@ -921,3 +921,93 @@
>>    'data': 'NumaOptions',
>>    'allow-preconfig': true
>>  }
>> +
>> +##
>> +# @balloon:
>> +#
>> +# Request the balloon driver to change its balloon size.
>> +#
>> +# @value: the target logical size of the VM in bytes
>> +#         We can deduce the size of the balloon using this formula:
>> +#            logical_vm_size = vm_ram_size - balloon_size
>> +#         From it we have: balloon_size = vm_ram_size - @value
>> +#
>> +# 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": {} }
>> +#
>> +# With a 2.5GiB guest this command inflated the ballon to 3GiB.
>> +#
>> +##
>> +{ 'command': 'balloon', 'data': {'value': 'int'} }
>> +
>> +##
>> +# @BalloonInfo:
>> +#
>> +# Information about the guest balloon device.
>> +#
>> +# @actual: the logical size of the VM in bytes
>> +#          Formula used: 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: the logical size of the VM in bytes
>> +#          Formula used: logical_vm_size = vm_ram_size - balloon_size
>> +#
>> +# 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 446fc8ff83..26b5115638 100644
>> --- a/qapi/misc.json
>> +++ b/qapi/misc.json
>> @@ -186,65 +186,6 @@
>>  { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'],
>>    'allow-preconfig': true }
>>  
>> -##
>> -# @BalloonInfo:
>> -#
>> -# Information about the guest balloon device.
>> -#
>> -# @actual: the logical size of the VM in bytes
>> -#          Formula used: 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: the logical size of the VM in bytes
>> -#          Formula used: logical_vm_size = vm_ram_size - balloon_size
>> -#
>> -# 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:
>>  #
>> @@ -753,37 +694,6 @@
>>  ##
>>  { 'command': 'inject-nmi' }
>>  
>> -##
>> -# @balloon:
>> -#
>> -# Request the balloon driver to change its balloon size.
>> -#
>> -# @value: the target logical size of the VM in bytes
>> -#         We can deduce the size of the balloon using this formula:
>> -#            logical_vm_size = vm_ram_size - balloon_size
>> -#         From it we have: balloon_size = vm_ram_size - @value
>> -#
>> -# 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": {} }
>> -#
>> -# With a 2.5GiB guest this command inflated the ballon to 3GiB.
>> -#
>> -##
>> -{ '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 065cd450f1..ec3aac1e80 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 9c61e769ca..376590c073 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"
>>
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
> 
> I yet have to craft a patch to fixup the wrong documentation :)
> 

Oh, I see you already included a fixup, nice!
Markus Armbruster May 26, 2020, 7:38 a.m. UTC | #3
Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

A brief note on why restricting "to machine code" is useful would be
nice.  Same for the other patches.

Acked-by: Markus Armbruster <armbru@redhat.com>
Philippe Mathieu-Daudé May 26, 2020, 8:04 a.m. UTC | #4
On 5/26/20 9:38 AM, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> A brief note on why restricting "to machine code" is useful would be
> nice.  Same for the other patches.
> 
> Acked-by: Markus Armbruster <armbru@redhat.com>
> 

What about this?

"QEMU can do system-mode and user-mode emulation.
Only system mode emulate a machine.
Remove this feature from the user-mode emulation."
Markus Armbruster May 26, 2020, 9:04 a.m. UTC | #5
Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 5/26/20 9:38 AM, Markus Armbruster wrote:
>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>> 
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> 
>> A brief note on why restricting "to machine code" is useful would be
>> nice.  Same for the other patches.
>> 
>> Acked-by: Markus Armbruster <armbru@redhat.com>
>> 
>
> What about this?
>
> "QEMU can do system-mode and user-mode emulation.
> Only system mode emulate a machine.
> Remove this feature from the user-mode emulation."

Is is a feature of user-mode emulation before the patch?  Or is it just
dead code?

Hint: QMP commands tend to be dead code when the program doesn't expose
a QMP monitor :)
Philippe Mathieu-Daudé May 26, 2020, 9:31 a.m. UTC | #6
+Laurent

On 5/26/20 11:04 AM, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> 
>> On 5/26/20 9:38 AM, Markus Armbruster wrote:
>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>
>>> A brief note on why restricting "to machine code" is useful would be
>>> nice.  Same for the other patches.
>>>
>>> Acked-by: Markus Armbruster <armbru@redhat.com>
>>>
>>
>> What about this?
>>
>> "QEMU can do system-mode and user-mode emulation.
>> Only system mode emulate a machine.
>> Remove this feature from the user-mode emulation."
> 
> Is is a feature of user-mode emulation before the patch?  Or is it just
> dead code?
> 
> Hint: QMP commands tend to be dead code when the program doesn't expose
> a QMP monitor :)

Maybe a 'corollary' question, "How user-mode users use QMP?"
Philippe Mathieu-Daudé May 26, 2020, 3:36 p.m. UTC | #7
On 5/26/20 11:31 AM, Philippe Mathieu-Daudé wrote:
> +Laurent
> 
> On 5/26/20 11:04 AM, Markus Armbruster wrote:
>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>
>>> On 5/26/20 9:38 AM, Markus Armbruster wrote:
>>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>>
>>>> A brief note on why restricting "to machine code" is useful would be
>>>> nice.  Same for the other patches.
>>>>
>>>> Acked-by: Markus Armbruster <armbru@redhat.com>
>>>>
>>>
>>> What about this?
>>>
>>> "QEMU can do system-mode and user-mode emulation.
>>> Only system mode emulate a machine.
>>> Remove this feature from the user-mode emulation."
>>
>> Is is a feature of user-mode emulation before the patch?  Or is it just
>> dead code?
>>
>> Hint: QMP commands tend to be dead code when the program doesn't expose
>> a QMP monitor :)
> 
> Maybe a 'corollary' question, "How user-mode users use QMP?"
> 

I can't find a way to start a user-mode process with a QMP socket, is
there one?
Markus Armbruster May 27, 2020, 4:49 a.m. UTC | #8
Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 5/26/20 11:31 AM, Philippe Mathieu-Daudé wrote:
>> +Laurent
>> 
>> On 5/26/20 11:04 AM, Markus Armbruster wrote:
>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>>
>>>> On 5/26/20 9:38 AM, Markus Armbruster wrote:
>>>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>>>>
>>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>>>
>>>>> A brief note on why restricting "to machine code" is useful would be
>>>>> nice.  Same for the other patches.
>>>>>
>>>>> Acked-by: Markus Armbruster <armbru@redhat.com>
>>>>>
>>>>
>>>> What about this?
>>>>
>>>> "QEMU can do system-mode and user-mode emulation.
>>>> Only system mode emulate a machine.
>>>> Remove this feature from the user-mode emulation."
>>>
>>> Is is a feature of user-mode emulation before the patch?  Or is it just
>>> dead code?
>>>
>>> Hint: QMP commands tend to be dead code when the program doesn't expose
>>> a QMP monitor :)
>> 
>> Maybe a 'corollary' question, "How user-mode users use QMP?"
>> 
>
> I can't find a way to start a user-mode process with a QMP socket, is
> there one?

As far as I can tell, only qemu-system-FOO and qemu-storage-daemon
provide QMP monitors:

* Monitors need to be initialized with monitor_init().  Two callers:
  monitor_init_hmp(), monitor_init_qmp().

* monitor_init() calls both, and is the common wat to create a monitor.
  Called by vl.c via monitor_init_opts(), and by qemu-storage-daemon.

* monitor_init_hmp() has additional callers, but HMP doesn't matter
  here.
Philippe Mathieu-Daudé May 27, 2020, 7:31 a.m. UTC | #9
On 5/27/20 6:49 AM, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
> 
>> On 5/26/20 11:31 AM, Philippe Mathieu-Daudé wrote:
>>> +Laurent
>>>
>>> On 5/26/20 11:04 AM, Markus Armbruster wrote:
>>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>>>
>>>>> On 5/26/20 9:38 AM, Markus Armbruster wrote:
>>>>>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>>>>>
>>>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>>>>
>>>>>> A brief note on why restricting "to machine code" is useful would be
>>>>>> nice.  Same for the other patches.
>>>>>>
>>>>>> Acked-by: Markus Armbruster <armbru@redhat.com>
>>>>>>
>>>>>
>>>>> What about this?
>>>>>
>>>>> "QEMU can do system-mode and user-mode emulation.
>>>>> Only system mode emulate a machine.
>>>>> Remove this feature from the user-mode emulation."
>>>>
>>>> Is is a feature of user-mode emulation before the patch?  Or is it just
>>>> dead code?
>>>>
>>>> Hint: QMP commands tend to be dead code when the program doesn't expose
>>>> a QMP monitor :)
>>>
>>> Maybe a 'corollary' question, "How user-mode users use QMP?"
>>>
>>
>> I can't find a way to start a user-mode process with a QMP socket, is
>> there one?
> 
> As far as I can tell, only qemu-system-FOO and qemu-storage-daemon
> provide QMP monitors:
> 
> * Monitors need to be initialized with monitor_init().  Two callers:
>   monitor_init_hmp(), monitor_init_qmp().
> 
> * monitor_init() calls both, and is the common wat to create a monitor.
>   Called by vl.c via monitor_init_opts(), and by qemu-storage-daemon.
> 
> * monitor_init_hmp() has additional callers, but HMP doesn't matter
>   here.
> 

OK good to know. I'll reword the patch description, but also check if
there isn't a simpler way to avoid pulling QMP code in user-mode builds
first.

Thanks!

Phil.
diff mbox series

Patch

diff --git a/qapi/machine.json b/qapi/machine.json
index ca7d58f0c9..ae42d69495 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -921,3 +921,93 @@ 
   'data': 'NumaOptions',
   'allow-preconfig': true
 }
+
+##
+# @balloon:
+#
+# Request the balloon driver to change its balloon size.
+#
+# @value: the target logical size of the VM in bytes
+#         We can deduce the size of the balloon using this formula:
+#            logical_vm_size = vm_ram_size - balloon_size
+#         From it we have: balloon_size = vm_ram_size - @value
+#
+# 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": {} }
+#
+# With a 2.5GiB guest this command inflated the ballon to 3GiB.
+#
+##
+{ 'command': 'balloon', 'data': {'value': 'int'} }
+
+##
+# @BalloonInfo:
+#
+# Information about the guest balloon device.
+#
+# @actual: the logical size of the VM in bytes
+#          Formula used: 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: the logical size of the VM in bytes
+#          Formula used: logical_vm_size = vm_ram_size - balloon_size
+#
+# 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 446fc8ff83..26b5115638 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -186,65 +186,6 @@ 
 { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'],
   'allow-preconfig': true }
 
-##
-# @BalloonInfo:
-#
-# Information about the guest balloon device.
-#
-# @actual: the logical size of the VM in bytes
-#          Formula used: 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: the logical size of the VM in bytes
-#          Formula used: logical_vm_size = vm_ram_size - balloon_size
-#
-# 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:
 #
@@ -753,37 +694,6 @@ 
 ##
 { 'command': 'inject-nmi' }
 
-##
-# @balloon:
-#
-# Request the balloon driver to change its balloon size.
-#
-# @value: the target logical size of the VM in bytes
-#         We can deduce the size of the balloon using this formula:
-#            logical_vm_size = vm_ram_size - balloon_size
-#         From it we have: balloon_size = vm_ram_size - @value
-#
-# 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": {} }
-#
-# With a 2.5GiB guest this command inflated the ballon to 3GiB.
-#
-##
-{ '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 065cd450f1..ec3aac1e80 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 9c61e769ca..376590c073 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"