[pve-devel] [PATCH 15/31] PVE: qapi: modify query machines

Dietmar Maurer dietmar at proxmox.com
Fri Mar 6 12:29:55 CET 2020


provide '*is-current' in MachineInfo struct

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 hw/core/machine-qmp-cmds.c | 6 ++++++
 qapi/machine.json          | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index eed5aeb2f7..1953633e82 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -230,6 +230,12 @@ 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;
+
+        if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
+            info->has_is_current = true;
+            info->is_current = true;
+        }
+
         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 ca26779f1a..cbdb6f6d66 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -336,6 +336,8 @@
 #
 # @is-default: whether the machine is default
 #
+# @is-current: whether this machine is currently used
+#
 # @cpu-max: maximum number of CPUs supported by the machine type
 #           (since 1.5.0)
 #
@@ -355,7 +357,7 @@
 ##
 { 'struct': 'MachineInfo',
   'data': { 'name': 'str', '*alias': 'str',
-            '*is-default': 'bool', 'cpu-max': 'int',
+            '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
             'hotpluggable-cpus': 'bool',  'numa-mem-supported': 'bool',
             'deprecated': 'bool', '*default-cpu-type': 'str' } }
 
-- 
2.20.1




More information about the pve-devel mailing list