]>
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> | |
ddbf7a87 | 13 | Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> |
ac2969b2 TL |
14 | --- |
15 | hw/core/machine-qmp-cmds.c | 6 ++++++ | |
16 | include/hw/boards.h | 2 ++ | |
817b7667 | 17 | qapi/machine.json | 4 +++- |
ddbf7a87 TL |
18 | softmmu/vl.c | 25 +++++++++++++++++++++++++ |
19 | 4 files changed, 36 insertions(+), 1 deletion(-) | |
ac2969b2 TL |
20 | |
21 | diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c | |
4567474e | 22 | index 76fff60a6b..ec9201fb9a 100644 |
ac2969b2 TL |
23 | --- a/hw/core/machine-qmp-cmds.c |
24 | +++ b/hw/core/machine-qmp-cmds.c | |
4567474e | 25 | @@ -103,6 +103,12 @@ MachineInfoList *qmp_query_machines(Error **errp) |
ac2969b2 TL |
26 | if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) { |
27 | info->has_is_current = true; | |
28 | info->is_current = true; | |
29 | + | |
30 | + // PVE version string only exists for current machine | |
31 | + if (mc->pve_version) { | |
32 | + info->has_pve_version = true; | |
33 | + info->pve_version = g_strdup(mc->pve_version); | |
34 | + } | |
35 | } | |
36 | ||
6402d961 | 37 | if (mc->default_cpu_type) { |
ac2969b2 | 38 | diff --git a/include/hw/boards.h b/include/hw/boards.h |
d03e1b3c | 39 | index 90f1dd3aeb..14d60520d9 100644 |
ac2969b2 TL |
40 | --- a/include/hw/boards.h |
41 | +++ b/include/hw/boards.h | |
dc9827a6 | 42 | @@ -230,6 +230,8 @@ struct MachineClass { |
ac2969b2 TL |
43 | const char *desc; |
44 | const char *deprecation_reason; | |
45 | ||
46 | + const char *pve_version; | |
47 | + | |
48 | void (*init)(MachineState *state); | |
d03e1b3c | 49 | void (*reset)(MachineState *state, ShutdownCause reason); |
6402d961 | 50 | void (*wakeup)(MachineState *state); |
ac2969b2 | 51 | diff --git a/qapi/machine.json b/qapi/machine.json |
d03e1b3c | 52 | index 9156103c8f..f4fb1b2c9c 100644 |
ac2969b2 TL |
53 | --- a/qapi/machine.json |
54 | +++ b/qapi/machine.json | |
5b15e2ec | 55 | @@ -157,6 +157,8 @@ |
817b7667 SR |
56 | # |
57 | # @default-ram-id: the default ID of initial RAM memory backend (since 5.2) | |
58 | # | |
59 | +# @pve-version: custom PVE version suffix specified as 'machine+pveN' | |
60 | +# | |
8dca018b | 61 | # Since: 1.2 |
817b7667 SR |
62 | ## |
63 | { 'struct': 'MachineInfo', | |
5b15e2ec | 64 | @@ -164,7 +166,7 @@ |
ac2969b2 TL |
65 | '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int', |
66 | 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool', | |
817b7667 SR |
67 | 'deprecated': 'bool', '*default-cpu-type': 'str', |
68 | - '*default-ram-id': 'str' } } | |
69 | + '*default-ram-id': 'str', '*pve-version': 'str' } } | |
ac2969b2 TL |
70 | |
71 | ## | |
72 | # @query-machines: | |
83faa3fe | 73 | diff --git a/softmmu/vl.c b/softmmu/vl.c |
d03e1b3c | 74 | index 9d737e7914..a64eee2fad 100644 |
83faa3fe TL |
75 | --- a/softmmu/vl.c |
76 | +++ b/softmmu/vl.c | |
d03e1b3c | 77 | @@ -1578,6 +1578,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv, |
f376b2b9 | 78 | static MachineClass *select_machine(QDict *qdict, Error **errp) |
ac2969b2 | 79 | { |
f376b2b9 SR |
80 | const char *optarg = qdict_get_try_str(qdict, "type"); |
81 | + const char *pvever = qdict_get_try_str(qdict, "pvever"); | |
82 | GSList *machines = object_class_get_list(TYPE_MACHINE, false); | |
83 | MachineClass *machine_class; | |
84 | Error *local_err = NULL; | |
d03e1b3c | 85 | @@ -1595,6 +1596,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp) |
f376b2b9 | 86 | } |
ac2969b2 TL |
87 | } |
88 | ||
f376b2b9 SR |
89 | + if (machine_class) { |
90 | + machine_class->pve_version = g_strdup(pvever); | |
91 | + qdict_del(qdict, "pvever"); | |
ac2969b2 TL |
92 | + } |
93 | + | |
f376b2b9 SR |
94 | g_slist_free(machines); |
95 | if (local_err) { | |
96 | error_append_hint(&local_err, "Use -machine help to list supported machines\n"); | |
d03e1b3c | 97 | @@ -3205,12 +3211,31 @@ void qemu_init(int argc, char **argv) |
f376b2b9 SR |
98 | case QEMU_OPTION_machine: |
99 | { | |
100 | bool help; | |
101 | + size_t pvever_index, name_len; | |
102 | + const gchar *name; | |
103 | + gchar *name_clean, *pvever; | |
ac2969b2 | 104 | |
f376b2b9 SR |
105 | keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal); |
106 | if (help) { | |
107 | machine_help_func(machine_opts_dict); | |
108 | exit(EXIT_SUCCESS); | |
109 | } | |
110 | + | |
111 | + // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever | |
112 | + name = qdict_get_try_str(machine_opts_dict, "type"); | |
7cf6b609 FG |
113 | + if (name != NULL) { |
114 | + name_len = strlen(name); | |
115 | + pvever_index = strcspn(name, "+"); | |
116 | + if (pvever_index < name_len) { | |
117 | + name_clean = g_strndup(name, pvever_index); | |
118 | + pvever = g_strndup(name + pvever_index + 1, name_len - pvever_index - 1); | |
119 | + qdict_put_str(machine_opts_dict, "pvever", pvever); | |
120 | + qdict_put_str(machine_opts_dict, "type", name_clean); | |
121 | + g_free(name_clean); | |
122 | + g_free(pvever); | |
123 | + } | |
f376b2b9 SR |
124 | + } |
125 | + | |
126 | break; | |
127 | } | |
128 | case QEMU_OPTION_accel: |