diff mbox series

[2/2] qmp: Expose MachineClass::default_ram_id

Message ID 2dbffbc4e2c0f3a0184daaadf56f94a85aedef58.1590426097.git.mprivozn@redhat.com (mailing list archive)
State New, archived
Headers show
Series qmp: Expose MachineClass::default_ram_id | expand

Commit Message

Michal Privoznik May 25, 2020, 5:03 p.m. UTC
If a management application (like Libvirt) want's to preserve
migration ability and switch to '-machine memory-backend' it
needs to set exactly the same RAM id as QEMU would. Since the id
is machine type dependant, expose it under 'query-machines'
result.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 hw/core/machine-qmp-cmds.c | 1 +
 qapi/machine.json          | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Eduardo Habkost May 25, 2020, 6:06 p.m. UTC | #1
On Mon, May 25, 2020 at 07:03:28PM +0200, Michal Privoznik wrote:
> If a management application (like Libvirt) want's to preserve
> migration ability and switch to '-machine memory-backend' it
> needs to set exactly the same RAM id as QEMU would. Since the id
> is machine type dependant, expose it under 'query-machines'
> result.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

The code looks good, but documentation was a bit confusing:

> ---
[...]
> +# @default-ram-id: the default name of initial RAM memory region (since 5.1)
> +#

Everywhere else in the commit message you call it "id", but here
you say "name".  Also, I don't think we have any references to a
"memory region" abstraction in the docs for the QAPI schema,
-machine options, or memory backend objects.

I had to look it up in the code, to finally understand you were
talking about the memory backend object ID.

To make it consistent with terminology used for -machine and
QAPI, I suggest:

  @default-ram-id: the default ID of initial RAM memory backend (since 5.1)

I can change it before committing, if you agree.



>  # @default-cpu-type: default CPU model typename if none is requested via
>  #                    the -cpu argument. (since 4.2)
>  #
> @@ -361,7 +363,8 @@
>    'data': { 'name': 'str', '*alias': 'str',
>              '*is-default': 'bool', 'cpu-max': 'int',
>              'hotpluggable-cpus': 'bool',  'numa-mem-supported': 'bool',
> -            'deprecated': 'bool', '*default-cpu-type': 'str' } }
> +            'deprecated': 'bool', 'default-ram-id': 'str',
> +            '*default-cpu-type': 'str' } }
>  
>  ##
>  # @query-machines:
> -- 
> 2.26.2
>
Michal Privoznik May 26, 2020, 8:06 a.m. UTC | #2
On 5/25/20 8:06 PM, Eduardo Habkost wrote:
> On Mon, May 25, 2020 at 07:03:28PM +0200, Michal Privoznik wrote:
>> If a management application (like Libvirt) want's to preserve
>> migration ability and switch to '-machine memory-backend' it
>> needs to set exactly the same RAM id as QEMU would. Since the id
>> is machine type dependant, expose it under 'query-machines'
>> result.
>>
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> 
> The code looks good, but documentation was a bit confusing:
> 
>> ---
> [...]
>> +# @default-ram-id: the default name of initial RAM memory region (since 5.1)
>> +#
> 
> Everywhere else in the commit message you call it "id", but here
> you say "name".  Also, I don't think we have any references to a
> "memory region" abstraction in the docs for the QAPI schema,
> -machine options, or memory backend objects.
> 
> I had to look it up in the code, to finally understand you were
> talking about the memory backend object ID.
> 
> To make it consistent with terminology used for -machine and
> QAPI, I suggest:
> 
>    @default-ram-id: the default ID of initial RAM memory backend (since 5.1)
> 
> I can change it before committing, if you agree.

Thanks for the offer, but I will post a v2, because as I was developing 
patches for libvirt to consume this I found out that some machine types 
don't have the attribute set (riscv is one of them). Therefore I will 
have to make this optional.

Michal
diff mbox series

Patch

diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 2c5da8413d..8333e674ce 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -234,6 +234,7 @@  MachineInfoList *qmp_query_machines(Error **errp)
         info->hotpluggable_cpus = mc->has_hotpluggable_cpus;
         info->numa_mem_supported = mc->numa_mem_supported;
         info->deprecated = !!mc->deprecation_reason;
+        info->default_ram_id = g_strdup(mc->default_ram_id);
         if (mc->default_cpu_type) {
             info->default_cpu_type = g_strdup(mc->default_cpu_type);
             info->has_default_cpu_type = true;
diff --git a/qapi/machine.json b/qapi/machine.json
index 39caa1d914..e5647c4031 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -352,6 +352,8 @@ 
 #              in future versions of QEMU according to the QEMU deprecation
 #              policy (since 4.1.0)
 #
+# @default-ram-id: the default name of initial RAM memory region (since 5.1)
+#
 # @default-cpu-type: default CPU model typename if none is requested via
 #                    the -cpu argument. (since 4.2)
 #
@@ -361,7 +363,8 @@ 
   'data': { 'name': 'str', '*alias': 'str',
             '*is-default': 'bool', 'cpu-max': 'int',
             'hotpluggable-cpus': 'bool',  'numa-mem-supported': 'bool',
-            'deprecated': 'bool', '*default-cpu-type': 'str' } }
+            'deprecated': 'bool', 'default-ram-id': 'str',
+            '*default-cpu-type': 'str' } }
 
 ##
 # @query-machines: