]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
debian/patches: squash some followup patches and regroup a bit more together
[pve-qemu.git] / debian / patches / pve / 0025-PVE-Allow-version-code-in-machine-type.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Dietmar Maurer <dietmar@proxmox.com>
3 Date: Mon, 6 Apr 2020 12:16:55 +0200
4 Subject: [PATCH] PVE: Allow version code in machine type
5
6 E.g. pc-i440fx-4.0+pve3 would print 'pve3' as version code while
7 selecting pc-i440fx-4.0 as machine type.
8
9 Version is made available as 'pve-version' in query-machines (same as,
10 and only if 'is-current').
11
12 Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
13 ---
14 hw/core/machine-qmp-cmds.c | 6 ++++++
15 include/hw/boards.h | 2 ++
16 qapi/machine.json | 3 ++-
17 softmmu/vl.c | 15 ++++++++++++++-
18 4 files changed, 24 insertions(+), 2 deletions(-)
19
20 diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
21 index 1953633e82..ca8c0dc53d 100644
22 --- a/hw/core/machine-qmp-cmds.c
23 +++ b/hw/core/machine-qmp-cmds.c
24 @@ -234,6 +234,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
25 if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
26 info->has_is_current = true;
27 info->is_current = true;
28 +
29 + // PVE version string only exists for current machine
30 + if (mc->pve_version) {
31 + info->has_pve_version = true;
32 + info->pve_version = g_strdup(mc->pve_version);
33 + }
34 }
35
36 if (mc->default_cpu_type) {
37 diff --git a/include/hw/boards.h b/include/hw/boards.h
38 index fd4d62b501..dd395e9232 100644
39 --- a/include/hw/boards.h
40 +++ b/include/hw/boards.h
41 @@ -170,6 +170,8 @@ struct MachineClass {
42 const char *desc;
43 const char *deprecation_reason;
44
45 + const char *pve_version;
46 +
47 void (*init)(MachineState *state);
48 void (*reset)(MachineState *state);
49 void (*wakeup)(MachineState *state);
50 diff --git a/qapi/machine.json b/qapi/machine.json
51 index f6cf28f9fd..a7f9c79a59 100644
52 --- a/qapi/machine.json
53 +++ b/qapi/machine.json
54 @@ -363,7 +363,8 @@
55 'data': { 'name': 'str', '*alias': 'str',
56 '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
57 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
58 - 'deprecated': 'bool', '*default-cpu-type': 'str' } }
59 + 'deprecated': 'bool', '*default-cpu-type': 'str',
60 + '*pve-version': 'str' } }
61
62 ##
63 # @query-machines:
64 diff --git a/softmmu/vl.c b/softmmu/vl.c
65 index 9de81875fd..8340c4ca53 100644
66 --- a/softmmu/vl.c
67 +++ b/softmmu/vl.c
68 @@ -2300,6 +2300,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
69 {
70 MachineClass *mc;
71 GSList *el;
72 + size_t pvever_index = 0;
73 + gchar *name_clean;
74
75 if (is_help_option(name)) {
76 printf("Supported machines are:\n");
77 @@ -2316,12 +2318,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
78 exit(0);
79 }
80
81 - mc = find_machine(name, machines);
82 + // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
83 + pvever_index = strcspn(name, "+");
84 +
85 + name_clean = g_strndup(name, pvever_index);
86 + mc = find_machine(name_clean, machines);
87 + g_free(name_clean);
88 +
89 if (!mc) {
90 error_report("unsupported machine type");
91 error_printf("Use -machine help to list supported machines\n");
92 exit(1);
93 }
94 +
95 + if (pvever_index < strlen(name)) {
96 + mc->pve_version = &name[pvever_index+1];
97 + }
98 +
99 return mc;
100 }
101