]> 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 7.1.0
[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>
ac2969b2
TL
14---
15 hw/core/machine-qmp-cmds.c | 6 ++++++
16 include/hw/boards.h | 2 ++
817b7667 17 qapi/machine.json | 4 +++-
ddbf7a87
TL
18 softmmu/vl.c | 25 +++++++++++++++++++++++++
19 4 files changed, 36 insertions(+), 1 deletion(-)
ac2969b2
TL
20
21diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
4567474e 22index 76fff60a6b..ec9201fb9a 100644
ac2969b2
TL
23--- a/hw/core/machine-qmp-cmds.c
24+++ b/hw/core/machine-qmp-cmds.c
4567474e 25@@ -103,6 +103,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
ac2969b2
TL
26 if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
27 info->has_is_current = true;
28 info->is_current = true;
29+
30+ // PVE version string only exists for current machine
31+ if (mc->pve_version) {
32+ info->has_pve_version = true;
33+ info->pve_version = g_strdup(mc->pve_version);
34+ }
35 }
36
6402d961 37 if (mc->default_cpu_type) {
ac2969b2 38diff --git a/include/hw/boards.h b/include/hw/boards.h
5b15e2ec 39index 7b416c9787..8ae15c51aa 100644
ac2969b2
TL
40--- a/include/hw/boards.h
41+++ b/include/hw/boards.h
dc9827a6 42@@ -230,6 +230,8 @@ struct MachineClass {
ac2969b2
TL
43 const char *desc;
44 const char *deprecation_reason;
45
46+ const char *pve_version;
47+
48 void (*init)(MachineState *state);
49 void (*reset)(MachineState *state);
6402d961 50 void (*wakeup)(MachineState *state);
ac2969b2 51diff --git a/qapi/machine.json b/qapi/machine.json
5b15e2ec 52index 555458f785..d868e4d31d 100644
ac2969b2
TL
53--- a/qapi/machine.json
54+++ b/qapi/machine.json
5b15e2ec 55@@ -157,6 +157,8 @@
817b7667
SR
56 #
57 # @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
58 #
59+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
60+#
8dca018b 61 # Since: 1.2
817b7667
SR
62 ##
63 { 'struct': 'MachineInfo',
5b15e2ec 64@@ -164,7 +166,7 @@
ac2969b2
TL
65 '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
66 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
817b7667
SR
67 'deprecated': 'bool', '*default-cpu-type': 'str',
68- '*default-ram-id': 'str' } }
69+ '*default-ram-id': 'str', '*pve-version': 'str' } }
ac2969b2
TL
70
71 ##
72 # @query-machines:
83faa3fe 73diff --git a/softmmu/vl.c b/softmmu/vl.c
5b15e2ec 74index 39f149924e..0d233d55f3 100644
83faa3fe
TL
75--- a/softmmu/vl.c
76+++ b/softmmu/vl.c
5b15e2ec 77@@ -1580,6 +1580,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
f376b2b9 78 static MachineClass *select_machine(QDict *qdict, Error **errp)
ac2969b2 79 {
f376b2b9
SR
80 const char *optarg = qdict_get_try_str(qdict, "type");
81+ const char *pvever = qdict_get_try_str(qdict, "pvever");
82 GSList *machines = object_class_get_list(TYPE_MACHINE, false);
83 MachineClass *machine_class;
84 Error *local_err = NULL;
5b15e2ec 85@@ -1597,6 +1598,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
f376b2b9 86 }
ac2969b2
TL
87 }
88
f376b2b9
SR
89+ if (machine_class) {
90+ machine_class->pve_version = g_strdup(pvever);
91+ qdict_del(qdict, "pvever");
ac2969b2
TL
92+ }
93+
f376b2b9
SR
94 g_slist_free(machines);
95 if (local_err) {
96 error_append_hint(&local_err, "Use -machine help to list supported machines\n");
5b15e2ec 97@@ -3187,12 +3193,31 @@ void qemu_init(int argc, char **argv, char **envp)
f376b2b9
SR
98 case QEMU_OPTION_machine:
99 {
100 bool help;
101+ size_t pvever_index, name_len;
102+ const gchar *name;
103+ gchar *name_clean, *pvever;
ac2969b2 104
f376b2b9
SR
105 keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal);
106 if (help) {
107 machine_help_func(machine_opts_dict);
108 exit(EXIT_SUCCESS);
109 }
110+
111+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
112+ name = qdict_get_try_str(machine_opts_dict, "type");
7cf6b609
FG
113+ if (name != NULL) {
114+ name_len = strlen(name);
115+ pvever_index = strcspn(name, "+");
116+ if (pvever_index < name_len) {
117+ name_clean = g_strndup(name, pvever_index);
118+ pvever = g_strndup(name + pvever_index + 1, name_len - pvever_index - 1);
119+ qdict_put_str(machine_opts_dict, "pvever", pvever);
120+ qdict_put_str(machine_opts_dict, "type", name_clean);
121+ g_free(name_clean);
122+ g_free(pvever);
123+ }
f376b2b9
SR
124+ }
125+
126 break;
127 }
128 case QEMU_OPTION_accel: