]>
Commit | Line | Data |
---|---|---|
ac2969b2 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
6402d961 | 2 | From: Dietmar Maurer <dietmar@proxmox.com> |
83faa3fe TL |
3 | Date: Mon, 6 Apr 2020 12:16:55 +0200 |
4 | Subject: [PATCH] PVE: Allow version code in machine type | |
ac2969b2 TL |
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 ++ | |
6402d961 | 16 | qapi/machine.json | 3 ++- |
83faa3fe | 17 | softmmu/vl.c | 15 ++++++++++++++- |
6402d961 | 18 | 4 files changed, 24 insertions(+), 2 deletions(-) |
ac2969b2 TL |
19 | |
20 | diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c | |
6402d961 | 21 | index 1953633e82..ca8c0dc53d 100644 |
ac2969b2 TL |
22 | --- a/hw/core/machine-qmp-cmds.c |
23 | +++ b/hw/core/machine-qmp-cmds.c | |
6402d961 | 24 | @@ -234,6 +234,12 @@ MachineInfoList *qmp_query_machines(Error **errp) |
ac2969b2 TL |
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 | ||
6402d961 | 36 | if (mc->default_cpu_type) { |
ac2969b2 | 37 | diff --git a/include/hw/boards.h b/include/hw/boards.h |
83faa3fe | 38 | index fd4d62b501..dd395e9232 100644 |
ac2969b2 TL |
39 | --- a/include/hw/boards.h |
40 | +++ b/include/hw/boards.h | |
83faa3fe | 41 | @@ -170,6 +170,8 @@ struct MachineClass { |
ac2969b2 TL |
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); | |
6402d961 | 49 | void (*wakeup)(MachineState *state); |
ac2969b2 | 50 | diff --git a/qapi/machine.json b/qapi/machine.json |
83faa3fe | 51 | index f6cf28f9fd..a7f9c79a59 100644 |
ac2969b2 TL |
52 | --- a/qapi/machine.json |
53 | +++ b/qapi/machine.json | |
83faa3fe | 54 | @@ -363,7 +363,8 @@ |
ac2969b2 TL |
55 | 'data': { 'name': 'str', '*alias': 'str', |
56 | '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int', | |
57 | 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool', | |
6402d961 TL |
58 | - 'deprecated': 'bool', '*default-cpu-type': 'str' } } |
59 | + 'deprecated': 'bool', '*default-cpu-type': 'str', | |
60 | + '*pve-version': 'str' } } | |
ac2969b2 TL |
61 | |
62 | ## | |
63 | # @query-machines: | |
83faa3fe | 64 | diff --git a/softmmu/vl.c b/softmmu/vl.c |
b7e851a5 | 65 | index 9de81875fd..8340c4ca53 100644 |
83faa3fe TL |
66 | --- a/softmmu/vl.c |
67 | +++ b/softmmu/vl.c | |
68 | @@ -2300,6 +2300,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines) | |
ac2969b2 TL |
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"); | |
83faa3fe | 77 | @@ -2316,12 +2318,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines) |
ac2969b2 TL |
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 |