diff mbox series

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

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

Commit Message

Michal Prívozník May 26, 2020, 8:25 a.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. Some machine types don't have the attribute set (riscv
family for example), therefore the QMP attribute must be
optional.

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

Comments

Igor Mammedov May 26, 2020, 1:15 p.m. UTC | #1
On Tue, 26 May 2020 10:25:35 +0200
Michal Privoznik <mprivozn@redhat.com> 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. Some machine types don't have the attribute set (riscv
> family for example), therefore the QMP attribute must be
> optional.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  hw/core/machine-qmp-cmds.c | 4 ++++
>  qapi/machine.json          | 5 ++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
> index 2c5da8413d..3e11a740c9 100644
> --- a/hw/core/machine-qmp-cmds.c
> +++ b/hw/core/machine-qmp-cmds.c
> @@ -238,6 +238,10 @@ MachineInfoList *qmp_query_machines(Error **errp)
>              info->default_cpu_type = g_strdup(mc->default_cpu_type);
>              info->has_default_cpu_type = true;
>          }
> +        if (mc->default_ram_id) {
> +            info->default_ram_id = g_strdup(mc->default_ram_id);
> +            info->has_default_ram_id = true;
> +        }
>  
>          entry = g_malloc0(sizeof(*entry));
>          entry->value = info;
> diff --git a/qapi/machine.json b/qapi/machine.json
> index 39caa1d914..76c1606390 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -355,13 +355,16 @@
>  # @default-cpu-type: default CPU model typename if none is requested via
>  #                    the -cpu argument. (since 4.2)
>  #
> +# @default-ram-id: the default ID of initial RAM memory backend (since 5.1)
> +#
>  # Since: 1.2.0
>  ##
>  { 'struct': 'MachineInfo',
>    '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-cpu-type': 'str',
> +            '*default-ram-id': 'str' } }
>  
>  ##
>  # @query-machines:
Igor Mammedov May 26, 2020, 1:17 p.m. UTC | #2
On Tue, 26 May 2020 10:25:35 +0200
Michal Privoznik <mprivozn@redhat.com> 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. Some machine types don't have the attribute set (riscv
> family for example), therefore the QMP attribute must be
> optional.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/core/machine-qmp-cmds.c | 4 ++++
>  qapi/machine.json          | 5 ++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
> index 2c5da8413d..3e11a740c9 100644
> --- a/hw/core/machine-qmp-cmds.c
> +++ b/hw/core/machine-qmp-cmds.c
> @@ -238,6 +238,10 @@ MachineInfoList *qmp_query_machines(Error **errp)
>              info->default_cpu_type = g_strdup(mc->default_cpu_type);
>              info->has_default_cpu_type = true;
>          }
> +        if (mc->default_ram_id) {
> +            info->default_ram_id = g_strdup(mc->default_ram_id);
> +            info->has_default_ram_id = true;
> +        }
>  
>          entry = g_malloc0(sizeof(*entry));
>          entry->value = info;
> diff --git a/qapi/machine.json b/qapi/machine.json
> index 39caa1d914..76c1606390 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -355,13 +355,16 @@
>  # @default-cpu-type: default CPU model typename if none is requested via
>  #                    the -cpu argument. (since 4.2)
>  #
> +# @default-ram-id: the default ID of initial RAM memory backend (since 5.1)
> +#
>  # Since: 1.2.0
>  ##
>  { 'struct': 'MachineInfo',
>    '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-cpu-type': 'str',
> +            '*default-ram-id': 'str' } }
>  
>  ##
>  # @query-machines:
diff mbox series

Patch

diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 2c5da8413d..3e11a740c9 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -238,6 +238,10 @@  MachineInfoList *qmp_query_machines(Error **errp)
             info->default_cpu_type = g_strdup(mc->default_cpu_type);
             info->has_default_cpu_type = true;
         }
+        if (mc->default_ram_id) {
+            info->default_ram_id = g_strdup(mc->default_ram_id);
+            info->has_default_ram_id = true;
+        }
 
         entry = g_malloc0(sizeof(*entry));
         entry->value = info;
diff --git a/qapi/machine.json b/qapi/machine.json
index 39caa1d914..76c1606390 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -355,13 +355,16 @@ 
 # @default-cpu-type: default CPU model typename if none is requested via
 #                    the -cpu argument. (since 4.2)
 #
+# @default-ram-id: the default ID of initial RAM memory backend (since 5.1)
+#
 # Since: 1.2.0
 ##
 { 'struct': 'MachineInfo',
   '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-cpu-type': 'str',
+            '*default-ram-id': 'str' } }
 
 ##
 # @query-machines: