]> git.proxmox.com Git - pve-qemu.git/blame_incremental - debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
bump version to 9.0.0-2
[pve-qemu.git] / debian / patches / pve / 0025-PVE-Allow-version-code-in-machine-type.patch
... / ...
CommitLineData
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Dietmar Maurer <dietmar@proxmox.com>
3Date: Mon, 6 Apr 2020 12:16:55 +0200
4Subject: [PATCH] PVE: Allow version code in machine type
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>
13Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
14[FE: adapt to QAPI changes]
15Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
16---
17 hw/core/machine-qmp-cmds.c | 5 +++++
18 include/hw/boards.h | 2 ++
19 qapi/machine.json | 4 +++-
20 softmmu/vl.c | 25 +++++++++++++++++++++++++
21 4 files changed, 35 insertions(+), 1 deletion(-)
22
23diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
24index 40821e2317..ee93ddd69a 100644
25--- a/hw/core/machine-qmp-cmds.c
26+++ b/hw/core/machine-qmp-cmds.c
27@@ -95,6 +95,11 @@ MachineInfoList *qmp_query_machines(Error **errp)
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) {
34+ info->pve_version = g_strdup(mc->pve_version);
35+ }
36 }
37
38 if (mc->default_cpu_type) {
39diff --git a/include/hw/boards.h b/include/hw/boards.h
40index ed83360198..f8b88cd86a 100644
41--- a/include/hw/boards.h
42+++ b/include/hw/boards.h
43@@ -235,6 +235,8 @@ struct MachineClass {
44 const char *desc;
45 const char *deprecation_reason;
46
47+ const char *pve_version;
48+
49 void (*init)(MachineState *state);
50 void (*reset)(MachineState *state, ShutdownCause reason);
51 void (*wakeup)(MachineState *state);
52diff --git a/qapi/machine.json b/qapi/machine.json
53index fbb61f18e4..7da3c519ba 100644
54--- a/qapi/machine.json
55+++ b/qapi/machine.json
56@@ -161,6 +161,8 @@
57 #
58 # @acpi: machine type supports ACPI (since 8.0)
59 #
60+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
61+#
62 # Since: 1.2
63 ##
64 { 'struct': 'MachineInfo',
65@@ -168,7 +170,7 @@
66 '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
67 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
68 'deprecated': 'bool', '*default-cpu-type': 'str',
69- '*default-ram-id': 'str', 'acpi': 'bool' } }
70+ '*default-ram-id': 'str', 'acpi': 'bool', '*pve-version': 'str' } }
71
72 ##
73 # @query-machines:
74diff --git a/softmmu/vl.c b/softmmu/vl.c
75index 3ee90b3b94..4b6d0b82fd 100644
76--- a/softmmu/vl.c
77+++ b/softmmu/vl.c
78@@ -1597,6 +1597,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
79 static MachineClass *select_machine(QDict *qdict, Error **errp)
80 {
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;
86@@ -1614,6 +1615,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
87 }
88 }
89
90+ if (machine_class) {
91+ machine_class->pve_version = g_strdup(pvever);
92+ qdict_del(qdict, "pvever");
93+ }
94+
95 g_slist_free(machines);
96 if (local_err) {
97 error_append_hint(&local_err, "Use -machine help to list supported machines\n");
98@@ -3250,12 +3256,31 @@ void qemu_init(int argc, char **argv)
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;
105
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");
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+ }
125+ }
126+
127 break;
128 }
129 case QEMU_OPTION_accel: