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