]> git.proxmox.com Git - pve-qemu.git/blobdiff - debian/patches/pve/0025-PVE-Allow-version-code-in-machine-type.patch
update submodule and patches to QEMU 8.1.2
[pve-qemu.git] / debian / patches / pve / 0025-PVE-Allow-version-code-in-machine-type.patch
index e160f5cdd63f1a7378220a46737756c6759f068b..5ec00c1001ee3d2401f1b1a17f9a2976a6669002 100644 (file)
@@ -10,92 +10,120 @@ 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>
+Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+[FE: adapt to QAPI changes]
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
 ---
- hw/core/machine-qmp-cmds.c |  6 ++++++
+ hw/core/machine-qmp-cmds.c |  +++++
  include/hw/boards.h        |  2 ++
- qapi/machine.json          |  ++-
- softmmu/vl.c               | 15 ++++++++++++++-
- 4 files changed, 24 insertions(+), 2 deletions(-)
+ qapi/machine.json          |  4 +++-
+ softmmu/vl.c               | 25 +++++++++++++++++++++++++
+ 4 files changed, 35 insertions(+), 1 deletion(-)
 
 diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
-index 1953633e82..ca8c0dc53d 100644
+index 40821e2317..ee93ddd69a 100644
 --- a/hw/core/machine-qmp-cmds.c
 +++ b/hw/core/machine-qmp-cmds.c
-@@ -234,6 +234,12 @@ MachineInfoList *qmp_query_machines(Error **errp)
+@@ -95,6 +95,11 @@ MachineInfoList *qmp_query_machines(Error **errp)
          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);
 +            }
          }
  
          if (mc->default_cpu_type) {
 diff --git a/include/hw/boards.h b/include/hw/boards.h
-index fd4d62b501..dd395e9232 100644
+index ed83360198..f8b88cd86a 100644
 --- a/include/hw/boards.h
 +++ b/include/hw/boards.h
-@@ -170,6 +170,8 @@ struct MachineClass {
+@@ -235,6 +235,8 @@ struct MachineClass {
      const char *desc;
      const char *deprecation_reason;
  
 +    const char *pve_version;
 +
      void (*init)(MachineState *state);
-     void (*reset)(MachineState *state);
+     void (*reset)(MachineState *state, ShutdownCause reason);
      void (*wakeup)(MachineState *state);
 diff --git a/qapi/machine.json b/qapi/machine.json
-index f6cf28f9fd..a7f9c79a59 100644
+index fbb61f18e4..7da3c519ba 100644
 --- a/qapi/machine.json
 +++ b/qapi/machine.json
-@@ -363,7 +363,8 @@
-   'data': { 'name': 'str', '*alias': 'str',
+@@ -161,6 +161,8 @@
+ #
+ # @acpi: machine type supports ACPI (since 8.0)
+ #
++# @pve-version: custom PVE version suffix specified as 'machine+pveN'
++#
+ # Since: 1.2
+ ##
+ { 'struct': 'MachineInfo',
+@@ -168,7 +170,7 @@
              '*is-default': 'bool', '*is-current': 'bool', 'cpu-max': 'int',
              'hotpluggable-cpus': 'bool',  'numa-mem-supported': 'bool',
--            'deprecated': 'bool', '*default-cpu-type': 'str' } }
-+            'deprecated': 'bool', '*default-cpu-type': 'str',
-+            '*pve-version': 'str' } }
+             'deprecated': 'bool', '*default-cpu-type': 'str',
+-            '*default-ram-id': 'str', 'acpi': 'bool' } }
++            '*default-ram-id': 'str', 'acpi': 'bool', '*pve-version': 'str' } }
  
  ##
  # @query-machines:
 diff --git a/softmmu/vl.c b/softmmu/vl.c
-index 9de81875fd..8340c4ca53 100644
+index 1b63ffd33d..20ba2c5c87 100644
 --- a/softmmu/vl.c
 +++ b/softmmu/vl.c
-@@ -2300,6 +2300,8 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
+@@ -1597,6 +1597,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
+ static MachineClass *select_machine(QDict *qdict, Error **errp)
  {
-     MachineClass *mc;
-     GSList *el;
-+    size_t pvever_index = 0;
-+    gchar *name_clean;
-     if (is_help_option(name)) {
-         printf("Supported machines are:\n");
-@@ -2316,12 +2318,23 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
-         exit(0);
+     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;
+@@ -1614,6 +1615,11 @@ static MachineClass *select_machine(QDict *qdict, Error **errp)
+         }
      }
  
--    mc = find_machine(name, machines);
-+    // PVE version is specified with '+' as seperator, e.g. pc-i440fx+pvever
-+    pvever_index = strcspn(name, "+");
-+
-+    name_clean = g_strndup(name, pvever_index);
-+    mc = find_machine(name_clean, machines);
-+    g_free(name_clean);
-+
-     if (!mc) {
-         error_report("unsupported machine type");
-         error_printf("Use -machine help to list supported machines\n");
-         exit(1);
-     }
-+
-+    if (pvever_index < strlen(name)) {
-+        mc->pve_version = &name[pvever_index+1];
++    if (machine_class) {
++        machine_class->pve_version = g_strdup(pvever);
++        qdict_del(qdict, "pvever");
 +    }
 +
-     return mc;
- }
+     g_slist_free(machines);
+     if (local_err) {
+         error_append_hint(&local_err, "Use -machine help to list supported machines\n");
+@@ -3244,12 +3250,31 @@ void qemu_init(int argc, char **argv)
+             case QEMU_OPTION_machine:
+                 {
+                     bool help;
++                    size_t pvever_index, name_len;
++                    const gchar *name;
++                    gchar *name_clean, *pvever;
  
+                     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");
++                    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);
++                        }
++                    }
++
+                     break;
+                 }
+             case QEMU_OPTION_accel: