]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0046-PVE-Allow-version-code-in-machine-type.patch
bump version to 4.1.1-4
[pve-qemu.git] / debian / patches / pve / 0046-PVE-Allow-version-code-in-machine-type.patch
CommitLineData
ac2969b2
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Stefan Reiter <s.reiter@proxmox.com>
3Date: Thu, 14 Nov 2019 17:56:12 +0100
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>
13---
14 hw/core/machine-qmp-cmds.c | 6 ++++++
15 include/hw/boards.h | 2 ++
16 qapi/machine.json | 2 +-
17 vl.c | 15 ++++++++++++++-
18 4 files changed, 23 insertions(+), 2 deletions(-)
19
20diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
21index fd68f9baf8..61fcad138d 100644
22--- a/hw/core/machine-qmp-cmds.c
23+++ b/hw/core/machine-qmp-cmds.c
24@@ -232,6 +232,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 entry = g_malloc0(sizeof(*entry));
37diff --git a/include/hw/boards.h b/include/hw/boards.h
38index a71d1a53a5..952d2add82 100644
39--- a/include/hw/boards.h
40+++ b/include/hw/boards.h
41@@ -178,6 +178,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 (*hot_add_cpu)(MachineState *state, const int64_t id, Error **errp);
50diff --git a/qapi/machine.json b/qapi/machine.json
51index 7b82c5f7f5..11fef6714e 100644
52--- a/qapi/machine.json
53+++ b/qapi/machine.json
54@@ -333,7 +333,7 @@
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' } }
59+ 'deprecated': 'bool', '*pve-version': 'str' } }
60
61 ##
62 # @query-machines:
63diff --git a/vl.c b/vl.c
64index 7ffcd271f1..1305cdaee7 100644
65--- a/vl.c
66+++ b/vl.c
67@@ -2454,6 +2454,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
68 {
69 MachineClass *mc;
70 GSList *el;
71+ size_t pvever_index = 0;
72+ gchar *name_clean;
73
74 if (is_help_option(name)) {
75 printf("Supported machines are:\n");
76@@ -2470,12 +2472,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
77 exit(0);
78 }
79
80- mc = find_machine(name, machines);
81+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
82+ pvever_index = strcspn(name, "+");
83+
84+ name_clean = g_strndup(name, pvever_index);
85+ mc = find_machine(name_clean, machines);
86+ g_free(name_clean);
87+
88 if (!mc) {
89 error_report("unsupported machine type");
90 error_printf("Use -machine help to list supported machines\n");
91 exit(1);
92 }
93+
94+ if (pvever_index < strlen(name)) {
95+ mc->pve_version = &name[pvever_index+1];
96+ }
97+
98 return mc;
99 }
100