]> git.proxmox.com Git - pve-qemu.git/blobdiff - debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
drop patch force-disabling smm
[pve-qemu.git] / debian / patches / pve / 0024-PVE-Allow-version-code-in-machine-type.patch
diff --git a/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch b/debian/patches/pve/0024-PVE-Allow-version-code-in-machine-type.patch
new file mode 100644 (file)
index 0000000..4f8518b
--- /dev/null
@@ -0,0 +1,109 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Dietmar Maurer <dietmar@proxmox.com>
+Date: Mon, 6 Apr 2020 12:16:55 +0200
+Subject: [PATCH] PVE: Allow version code in machine type
+
+E.g. pc-i440fx-4.0+pve3 would print 'pve3' as version code while
+selecting pc-i440fx-4.0 as machine type.
+
+Version is made available as 'pve-version' in query-machines (same as,
+and only if 'is-current').
+
+Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
+---
+ hw/core/machine-qmp-cmds.c |  6 ++++++
+ include/hw/boards.h        |  2 ++
+ qapi/machine.json          |  4 +++-
+ softmmu/vl.c               | 15 ++++++++++++++-
+ 4 files changed, 25 insertions(+), 2 deletions(-)
+
+diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
+index 76195de9e0..e622f65bca 100644
+--- a/hw/core/machine-qmp-cmds.c
++++ b/hw/core/machine-qmp-cmds.c
+@@ -104,6 +104,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
+         if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
+             info->has_is_current = true;
+             info->is_current = true;
++
++            // PVE version string only exists for current machine
++            if (mc->pve_version) {
++                info->has_pve_version = true;
++                info->pve_version = g_strdup(mc->pve_version);
++            }
+         }
+         if (mc->default_cpu_type) {
+diff --git a/include/hw/boards.h b/include/hw/boards.h
+index ad6c8fd537..00ee74c5eb 100644
+--- a/include/hw/boards.h
++++ b/include/hw/boards.h
+@@ -206,6 +206,8 @@ struct MachineClass {
+     const char *desc;
+     const char *deprecation_reason;
++    const char *pve_version;
++
+     void (*init)(MachineState *state);
+     void (*reset)(MachineState *state);
+     void (*wakeup)(MachineState *state);
+diff --git a/qapi/machine.json b/qapi/machine.json
+index 6e7e93d68f..7f5ba02c95 100644
+--- a/qapi/machine.json
++++ b/qapi/machine.json
+@@ -160,6 +160,8 @@
+ #
+ # @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
+ #
++# @pve-version: custom PVE version suffix specified as 'machine+pveN'
++#
+ # Since: 1.2
+ ##
+ { 'struct': 'MachineInfo',
+@@ -167,7 +169,7 @@
+             '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
+             'hotpluggable-cpus': 'bool',  'numa-mem-supported': 'bool',
+             'deprecated': 'bool', '*default-cpu-type': 'str',
+-            '*default-ram-id': 'str' } }
++            '*default-ram-id': 'str', '*pve-version': 'str' } }
+ ##
+ # @query-machines:
+diff --git a/softmmu/vl.c b/softmmu/vl.c
+index 12ec053422..a3c7ef0ab4 100644
+--- a/softmmu/vl.c
++++ b/softmmu/vl.c
+@@ -1537,6 +1537,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
+ {
+     MachineClass *mc;
+     GSList *el;
++    size_t pvever_index = 0;
++    gchar *name_clean;
+     if (is_help_option(name)) {
+         printf("Supported machines are:\n");
+@@ -1553,12 +1555,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
+         exit(0);
+     }
+-    mc = find_machine(name, machines);
++    // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
++    pvever_index = strcspn(name, "+");
++
++    name_clean = g_strndup(name, pvever_index);
++    mc = find_machine(name_clean, machines);
++    g_free(name_clean);
++
+     if (!mc) {
+         error_report("unsupported machine type");
+         error_printf("Use -machine help to list supported machines\n");
+         exit(1);
+     }
++
++    if (pvever_index < strlen(name)) {
++        mc->pve_version = &name[pvever_index+1];
++    }
++
+     return mc;
+ }