]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
Update to QEMU 5.2
[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 | 4 +++-
17 softmmu/vl.c | 15 ++++++++++++++-
18 4 files changed, 25 insertions(+), 2 deletions(-)
19
20 diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
21 index 3fcb82ce2f..7868241bd5 100644
22 --- a/hw/core/machine-qmp-cmds.c
23 +++ b/hw/core/machine-qmp-cmds.c
24 @@ -238,6 +238,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 a49e3a6b44..8e0a8c5571 100644
39 --- a/include/hw/boards.h
40 +++ b/include/hw/boards.h
41 @@ -165,6 +165,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 dfc1a49d3c..32fc674042 100644
52 --- a/qapi/machine.json
53 +++ b/qapi/machine.json
54 @@ -337,6 +337,8 @@
55 #
56 # @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
57 #
58 +# @pve-version: custom PVE version suffix specified as 'machine+pveN'
59 +#
60 # Since: 1.2.0
61 ##
62 { 'struct': 'MachineInfo',
63 @@ -344,7 +346,7 @@
64 '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
65 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
66 'deprecated': 'bool', '*default-cpu-type': 'str',
67 - '*default-ram-id': 'str' } }
68 + '*default-ram-id': 'str', '*pve-version': 'str' } }
69
70 ##
71 # @query-machines:
72 diff --git a/softmmu/vl.c b/softmmu/vl.c
73 index da204d24f0..5b5512128e 100644
74 --- a/softmmu/vl.c
75 +++ b/softmmu/vl.c
76 @@ -2325,6 +2325,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
77 {
78 MachineClass *mc;
79 GSList *el;
80 + size_t pvever_index = 0;
81 + gchar *name_clean;
82
83 if (is_help_option(name)) {
84 printf("Supported machines are:\n");
85 @@ -2341,12 +2343,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
86 exit(0);
87 }
88
89 - mc = find_machine(name, machines);
90 + // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
91 + pvever_index = strcspn(name, "+");
92 +
93 + name_clean = g_strndup(name, pvever_index);
94 + mc = find_machine(name_clean, machines);
95 + g_free(name_clean);
96 +
97 if (!mc) {
98 error_report("unsupported machine type");
99 error_printf("Use -machine help to list supported machines\n");
100 exit(1);
101 }
102 +
103 + if (pvever_index < strlen(name)) {
104 + mc->pve_version = &name[pvever_index+1];
105 + }
106 +
107 return mc;
108 }
109