]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
update submodule and patches to QEMU 8.1.5
[pve-qemu.git] / debian / patches / pve / 0025-PVE-Allow-version-code-in-machine-type.patch
CommitLineData
ac2969b2 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
6402d961 2From: Dietmar Maurer <dietmar@proxmox.com>
83faa3fe
TL
3Date: Mon, 6 Apr 2020 12:16:55 +0200
4Subject: [PATCH] PVE: Allow version code in machine type
ac2969b2
TL
5
6E.g. pc-i440fx-4.0+pve3 would print 'pve3' as version code while
7selecting pc-i440fx-4.0 as machine type.
8
9Version is made available as 'pve-version' in query-machines (same as,
10and only if 'is-current').
11
12Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
ddbf7a87 13Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
bf251437
FE
14[FE: adapt to QAPI changes]
15Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
ac2969b2 16---
bf251437 17 hw/core/machine-qmp-cmds.c | 5 +++++
ac2969b2 18 include/hw/boards.h | 2 ++
817b7667 19 qapi/machine.json | 4 +++-
ddbf7a87 20 softmmu/vl.c | 25 +++++++++++++++++++++++++
bf251437 21 4 files changed, 35 insertions(+), 1 deletion(-)
ac2969b2
TL
22
23diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
10e10933 24index 40821e2317..ee93ddd69a 100644
ac2969b2
TL
25--- a/hw/core/machine-qmp-cmds.c
26+++ b/hw/core/machine-qmp-cmds.c
10e10933 27@@ -95,6 +95,11 @@ MachineInfoList *qmp_query_machines(Error **errp)
ac2969b2
TL
28 if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
29 info->has_is_current = true;
30 info->is_current = true;
31+
32+ // PVE version string only exists for current machine
33+ if (mc->pve_version) {
ac2969b2
TL
34+ info->pve_version = g_strdup(mc->pve_version);
35+ }
36 }
37
6402d961 38 if (mc->default_cpu_type) {
ac2969b2 39diff --git a/include/hw/boards.h b/include/hw/boards.h
10e10933 40index ed83360198..f8b88cd86a 100644
ac2969b2
TL
41--- a/include/hw/boards.h
42+++ b/include/hw/boards.h
10e10933 43@@ -235,6 +235,8 @@ struct MachineClass {
ac2969b2
TL
44 const char *desc;
45 const char *deprecation_reason;
46
47+ const char *pve_version;
48+
49 void (*init)(MachineState *state);
d03e1b3c 50 void (*reset)(MachineState *state, ShutdownCause reason);
6402d961 51 void (*wakeup)(MachineState *state);
ac2969b2 52diff --git a/qapi/machine.json b/qapi/machine.json
10e10933 53index fbb61f18e4..7da3c519ba 100644
ac2969b2
TL
54--- a/qapi/machine.json
55+++ b/qapi/machine.json
10e10933 56@@ -161,6 +161,8 @@
817b7667 57 #
bf251437 58 # @acpi: machine type supports ACPI (since 8.0)
817b7667
SR
59 #
60+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
61+#
8dca018b 62 # Since: 1.2
817b7667
SR
63 ##
64 { 'struct': 'MachineInfo',
10e10933 65@@ -168,7 +170,7 @@
ac2969b2
TL
66 '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
67 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
817b7667 68 'deprecated': 'bool', '*default-cpu-type': 'str',
bf251437
FE
69- '*default-ram-id': 'str', 'acpi': 'bool' } }
70+ '*default-ram-id': 'str', 'acpi': 'bool', '*pve-version': 'str' } }
ac2969b2
TL
71
72 ##
73 # @query-machines:
83faa3fe 74diff --git a/softmmu/vl.c b/softmmu/vl.c
4b7975e7 75index 1a3b9cc4b8..e9b5f62cc3 100644
83faa3fe
TL
76--- a/softmmu/vl.c
77+++ b/softmmu/vl.c
10e10933 78@@ -1597,6 +1597,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
f376b2b9 79 static MachineClass *select_machine(QDict *qdict, Error **errp)
ac2969b2 80 {
f376b2b9
SR
81 const char *optarg = qdict_get_try_str(qdict, "type");
82+ const char *pvever = qdict_get_try_str(qdict, "pvever");
83 GSList *machines = object_class_get_list(TYPE_MACHINE, false);
84 MachineClass *machine_class;
85 Error *local_err = NULL;
10e10933 86@@ -1614,6 +1615,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
f376b2b9 87 }
ac2969b2
TL
88 }
89
f376b2b9
SR
90+ if (machine_class) {
91+ machine_class->pve_version = g_strdup(pvever);
92+ qdict_del(qdict, "pvever");
ac2969b2
TL
93+ }
94+
f376b2b9
SR
95 g_slist_free(machines);
96 if (local_err) {
97 error_append_hint(&local_err, "Use -machine help to list supported machines\n");
4b7975e7 98@@ -3248,12 +3254,31 @@ void qemu_init(int argc, char **argv)
f376b2b9
SR
99 case QEMU_OPTION_machine:
100 {
101 bool help;
102+ size_t pvever_index, name_len;
103+ const gchar *name;
104+ gchar *name_clean, *pvever;
ac2969b2 105
f376b2b9
SR
106 keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal);
107 if (help) {
108 machine_help_func(machine_opts_dict);
109 exit(EXIT_SUCCESS);
110 }
111+
112+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
113+ name = qdict_get_try_str(machine_opts_dict, "type");
7cf6b609
FG
114+ if (name != NULL) {
115+ name_len = strlen(name);
116+ pvever_index = strcspn(name, "+");
117+ if (pvever_index < name_len) {
118+ name_clean = g_strndup(name, pvever_index);
119+ pvever = g_strndup(name + pvever_index + 1, name_len - pvever_index - 1);
120+ qdict_put_str(machine_opts_dict, "pvever", pvever);
121+ qdict_put_str(machine_opts_dict, "type", name_clean);
122+ g_free(name_clean);
123+ g_free(pvever);
124+ }
f376b2b9
SR
125+ }
126+
127 break;
128 }
129 case QEMU_OPTION_accel: