2019-11-25 11:12:41 +03:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-03-10 17:12:50 +03:00
|
|
|
From: Dietmar Maurer <dietmar@proxmox.com>
|
2020-04-07 17:53:19 +03:00
|
|
|
Date: Mon, 6 Apr 2020 12:16:55 +0200
|
|
|
|
Subject: [PATCH] PVE: Allow version code in machine type
|
2019-11-25 11:12:41 +03:00
|
|
|
|
|
|
|
E.g. pc-i440fx-4.0+pve3 would print 'pve3' as version code while
|
|
|
|
selecting pc-i440fx-4.0 as machine type.
|
|
|
|
|
|
|
|
Version is made available as 'pve-version' in query-machines (same as,
|
|
|
|
and only if 'is-current').
|
|
|
|
|
|
|
|
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
|
2022-01-13 12:34:33 +03:00
|
|
|
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
2019-11-25 11:12:41 +03:00
|
|
|
---
|
|
|
|
hw/core/machine-qmp-cmds.c | 6 ++++++
|
|
|
|
include/hw/boards.h | 2 ++
|
2021-02-11 19:11:11 +03:00
|
|
|
qapi/machine.json | 4 +++-
|
2022-01-13 12:34:33 +03:00
|
|
|
softmmu/vl.c | 25 +++++++++++++++++++++++++
|
|
|
|
4 files changed, 36 insertions(+), 1 deletion(-)
|
2019-11-25 11:12:41 +03:00
|
|
|
|
|
|
|
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
|
2022-02-11 12:24:33 +03:00
|
|
|
index 76fff60a6b..ec9201fb9a 100644
|
2019-11-25 11:12:41 +03:00
|
|
|
--- a/hw/core/machine-qmp-cmds.c
|
|
|
|
+++ b/hw/core/machine-qmp-cmds.c
|
2022-02-11 12:24:33 +03:00
|
|
|
@@ -103,6 +103,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
2019-11-25 11:12:41 +03:00
|
|
|
if (strcmp(mc->name, MACHINE_GET_CLASS(current_machine)->name) == 0) {
|
|
|
|
info->has_is_current = true;
|
|
|
|
info->is_current = true;
|
|
|
|
+
|
|
|
|
+ // PVE version string only exists for current machine
|
|
|
|
+ if (mc->pve_version) {
|
|
|
|
+ info->has_pve_version = true;
|
|
|
|
+ info->pve_version = g_strdup(mc->pve_version);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
2020-03-10 17:12:50 +03:00
|
|
|
if (mc->default_cpu_type) {
|
2019-11-25 11:12:41 +03:00
|
|
|
diff --git a/include/hw/boards.h b/include/hw/boards.h
|
2022-12-14 17:16:32 +03:00
|
|
|
index 90f1dd3aeb..14d60520d9 100644
|
2019-11-25 11:12:41 +03:00
|
|
|
--- a/include/hw/boards.h
|
|
|
|
+++ b/include/hw/boards.h
|
2022-06-27 14:05:40 +03:00
|
|
|
@@ -230,6 +230,8 @@ struct MachineClass {
|
2019-11-25 11:12:41 +03:00
|
|
|
const char *desc;
|
|
|
|
const char *deprecation_reason;
|
|
|
|
|
|
|
|
+ const char *pve_version;
|
|
|
|
+
|
|
|
|
void (*init)(MachineState *state);
|
2022-12-14 17:16:32 +03:00
|
|
|
void (*reset)(MachineState *state, ShutdownCause reason);
|
2020-03-10 17:12:50 +03:00
|
|
|
void (*wakeup)(MachineState *state);
|
2019-11-25 11:12:41 +03:00
|
|
|
diff --git a/qapi/machine.json b/qapi/machine.json
|
2022-12-14 17:16:32 +03:00
|
|
|
index 9156103c8f..f4fb1b2c9c 100644
|
2019-11-25 11:12:41 +03:00
|
|
|
--- a/qapi/machine.json
|
|
|
|
+++ b/qapi/machine.json
|
update submodule and patches to 7.1.0
Notable changes:
* The only big change is the switch to using a custom QIOChannel for
savevm-async, because the previously used QEMUFileOps was dropped.
Changes to the current implementation:
* Switch to vector based methods as required for an IO channel. For
short reads the passed-in IO vector is stuffed with zeroes at the
end, just to be sure.
* For reading: The documentation in include/io/channel.h states that
at least one byte should be read, so also error out when whe are
at the very end instead of returning 0.
* For reading: Fix off-by-one error when request goes beyond end.
The wrong code piece was:
if ((pos + size) > maxlen) {
size = maxlen - pos - 1;
}
Previously, the last byte would not be read. It's actually
possible to get a snapshot .raw file that has content all the way
up the final 512 byte (= BDRV_SECTOR_SIZE) boundary without any
trailing zero bytes (I wrote a script to do it).
Luckily, it didn't cause a real issue, because qemu_loadvm_state()
is not interested in the final (i.e. QEMU_VM_VMDESCRIPTION)
section. The buffer for reading it is simply freed up afterwards
and the function will assume that it read the whole section, even
if that's not the case.
* For writing: Make use of the generated blk_pwritev() wrapper
instead of manually wrapping the coroutine to simplify and save a
few lines.
* Adapt to changed interfaces for blk_{pread,pwrite}:
* a9262f551e ("block: Change blk_{pread,pwrite}() param order")
* 3b35d4542c ("block: Add a 'flags' param to blk_pread()")
* bf5b16fa40 ("block: Make blk_{pread,pwrite}() return 0 on success")
Those changes especially affected the qemu-img dd patches, because
the context also changed, but also some of our block drivers used
the functions.
* Drop qemu-common.h include: it got renamed after essentially
everything was moved to other headers. The only remaining user I
could find for things dropped from the header between 7.0 and 7.1
was qemu_get_vm_name() in the iscsi-initiatorname patch, but it
already includes the header to which the function was moved.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-10-14 15:07:13 +03:00
|
|
|
@@ -157,6 +157,8 @@
|
2021-02-11 19:11:11 +03:00
|
|
|
#
|
|
|
|
# @default-ram-id: the default ID of initial RAM memory backend (since 5.2)
|
|
|
|
#
|
|
|
|
+# @pve-version: custom PVE version suffix specified as 'machine+pveN'
|
|
|
|
+#
|
2021-05-27 13:43:32 +03:00
|
|
|
# Since: 1.2
|
2021-02-11 19:11:11 +03:00
|
|
|
##
|
|
|
|
{ 'struct': 'MachineInfo',
|
update submodule and patches to 7.1.0
Notable changes:
* The only big change is the switch to using a custom QIOChannel for
savevm-async, because the previously used QEMUFileOps was dropped.
Changes to the current implementation:
* Switch to vector based methods as required for an IO channel. For
short reads the passed-in IO vector is stuffed with zeroes at the
end, just to be sure.
* For reading: The documentation in include/io/channel.h states that
at least one byte should be read, so also error out when whe are
at the very end instead of returning 0.
* For reading: Fix off-by-one error when request goes beyond end.
The wrong code piece was:
if ((pos + size) > maxlen) {
size = maxlen - pos - 1;
}
Previously, the last byte would not be read. It's actually
possible to get a snapshot .raw file that has content all the way
up the final 512 byte (= BDRV_SECTOR_SIZE) boundary without any
trailing zero bytes (I wrote a script to do it).
Luckily, it didn't cause a real issue, because qemu_loadvm_state()
is not interested in the final (i.e. QEMU_VM_VMDESCRIPTION)
section. The buffer for reading it is simply freed up afterwards
and the function will assume that it read the whole section, even
if that's not the case.
* For writing: Make use of the generated blk_pwritev() wrapper
instead of manually wrapping the coroutine to simplify and save a
few lines.
* Adapt to changed interfaces for blk_{pread,pwrite}:
* a9262f551e ("block: Change blk_{pread,pwrite}() param order")
* 3b35d4542c ("block: Add a 'flags' param to blk_pread()")
* bf5b16fa40 ("block: Make blk_{pread,pwrite}() return 0 on success")
Those changes especially affected the qemu-img dd patches, because
the context also changed, but also some of our block drivers used
the functions.
* Drop qemu-common.h include: it got renamed after essentially
everything was moved to other headers. The only remaining user I
could find for things dropped from the header between 7.0 and 7.1
was qemu_get_vm_name() in the iscsi-initiatorname patch, but it
already includes the header to which the function was moved.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-10-14 15:07:13 +03:00
|
|
|
@@ -164,7 +166,7 @@
|
2019-11-25 11:12:41 +03:00
|
|
|
'*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
|
|
|
|
'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool',
|
2021-02-11 19:11:11 +03:00
|
|
|
'deprecated': 'bool', '*default-cpu-type': 'str',
|
|
|
|
- '*default-ram-id': 'str' } }
|
|
|
|
+ '*default-ram-id': 'str', '*pve-version': 'str' } }
|
2019-11-25 11:12:41 +03:00
|
|
|
|
|
|
|
##
|
|
|
|
# @query-machines:
|
2020-04-07 17:53:19 +03:00
|
|
|
diff --git a/softmmu/vl.c b/softmmu/vl.c
|
2022-12-14 17:16:32 +03:00
|
|
|
index 9d737e7914..a64eee2fad 100644
|
2020-04-07 17:53:19 +03:00
|
|
|
--- a/softmmu/vl.c
|
|
|
|
+++ b/softmmu/vl.c
|
2022-12-14 17:16:32 +03:00
|
|
|
@@ -1578,6 +1578,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
|
2021-10-11 14:55:34 +03:00
|
|
|
static MachineClass *select_machine(QDict *qdict, Error **errp)
|
2019-11-25 11:12:41 +03:00
|
|
|
{
|
2021-10-11 14:55:34 +03:00
|
|
|
const char *optarg = qdict_get_try_str(qdict, "type");
|
|
|
|
+ const char *pvever = qdict_get_try_str(qdict, "pvever");
|
|
|
|
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
|
|
|
|
MachineClass *machine_class;
|
|
|
|
Error *local_err = NULL;
|
2022-12-14 17:16:32 +03:00
|
|
|
@@ -1595,6 +1596,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
|
2021-10-11 14:55:34 +03:00
|
|
|
}
|
2019-11-25 11:12:41 +03:00
|
|
|
}
|
|
|
|
|
2021-10-11 14:55:34 +03:00
|
|
|
+ if (machine_class) {
|
|
|
|
+ machine_class->pve_version = g_strdup(pvever);
|
|
|
|
+ qdict_del(qdict, "pvever");
|
2019-11-25 11:12:41 +03:00
|
|
|
+ }
|
|
|
|
+
|
2021-10-11 14:55:34 +03:00
|
|
|
g_slist_free(machines);
|
|
|
|
if (local_err) {
|
|
|
|
error_append_hint(&local_err, "Use -machine help to list supported machines\n");
|
2022-12-14 17:16:32 +03:00
|
|
|
@@ -3205,12 +3211,31 @@ void qemu_init(int argc, char **argv)
|
2021-10-11 14:55:34 +03:00
|
|
|
case QEMU_OPTION_machine:
|
|
|
|
{
|
|
|
|
bool help;
|
|
|
|
+ size_t pvever_index, name_len;
|
|
|
|
+ const gchar *name;
|
|
|
|
+ gchar *name_clean, *pvever;
|
2019-11-25 11:12:41 +03:00
|
|
|
|
2021-10-11 14:55:34 +03:00
|
|
|
keyval_parse_into(machine_opts_dict, optarg, "type", &help, &error_fatal);
|
|
|
|
if (help) {
|
|
|
|
machine_help_func(machine_opts_dict);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
|
|
|
|
+ name = qdict_get_try_str(machine_opts_dict, "type");
|
2021-11-17 12:41:17 +03:00
|
|
|
+ if (name != NULL) {
|
|
|
|
+ name_len = strlen(name);
|
|
|
|
+ pvever_index = strcspn(name, "+");
|
|
|
|
+ if (pvever_index < name_len) {
|
|
|
|
+ name_clean = g_strndup(name, pvever_index);
|
|
|
|
+ pvever = g_strndup(name + pvever_index + 1, name_len - pvever_index - 1);
|
|
|
|
+ qdict_put_str(machine_opts_dict, "pvever", pvever);
|
|
|
|
+ qdict_put_str(machine_opts_dict, "type", name_clean);
|
|
|
|
+ g_free(name_clean);
|
|
|
|
+ g_free(pvever);
|
|
|
|
+ }
|
2021-10-11 14:55:34 +03:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case QEMU_OPTION_accel:
|