render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0002-qemu-config-load-modules-when-instantiating-option-g.patch

Paolo Bonzini d9c8b5
From 7b861d20e22278fc5915f03d77b83e07ba44d440 Mon Sep 17 00:00:00 2001
Paolo Bonzini d9c8b5
From: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini d9c8b5
Date: Tue, 18 May 2021 09:15:42 -0400
Paolo Bonzini d9c8b5
Subject: [PATCH 2/5] qemu-config: load modules when instantiating option
Paolo Bonzini d9c8b5
 groups
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
Right now the SPICE module is special cased to be loaded when processing
Paolo Bonzini d9c8b5
of the -spice command line option.  However, the spice option group
Paolo Bonzini d9c8b5
can also be brought in via -readconfig, in which case the module is
Paolo Bonzini d9c8b5
not loaded.
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
Add a generic hook to load modules that provide a QemuOpts group,
Paolo Bonzini d9c8b5
and use it for the "spice" and "iscsi" groups.
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
Fixes: #194
Paolo Bonzini d9c8b5
Fixes: https://bugs.launchpad.net/qemu/+bug/1910696
Paolo Bonzini d9c8b5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini d9c8b5
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Paolo Bonzini d9c8b5
Message-Id: <20210518131542.2941207-1-pbonzini@redhat.com>
Paolo Bonzini d9c8b5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini d9c8b5
---
Paolo Bonzini d9c8b5
 include/qemu/config-file.h |  2 +-
Paolo Bonzini d9c8b5
 softmmu/vl.c               | 21 +++++++++++++++++----
Paolo Bonzini d9c8b5
 stubs/meson.build          |  1 +
Paolo Bonzini d9c8b5
 stubs/module-opts.c        |  6 ++++++
Paolo Bonzini d9c8b5
 util/qemu-config.c         |  1 +
Paolo Bonzini d9c8b5
 5 files changed, 26 insertions(+), 5 deletions(-)
Paolo Bonzini d9c8b5
 create mode 100644 stubs/module-opts.c
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h
Paolo Bonzini d9c8b5
index 8d3e53a..0500b36 100644
Paolo Bonzini d9c8b5
--- a/include/qemu/config-file.h
Paolo Bonzini d9c8b5
+++ b/include/qemu/config-file.h
Paolo Bonzini d9c8b5
@@ -1,7 +1,7 @@
Paolo Bonzini d9c8b5
 #ifndef QEMU_CONFIG_FILE_H
Paolo Bonzini d9c8b5
 #define QEMU_CONFIG_FILE_H
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
-
Paolo Bonzini d9c8b5
+void qemu_load_module_for_opts(const char *group);
Paolo Bonzini d9c8b5
 QemuOptsList *qemu_find_opts(const char *group);
Paolo Bonzini d9c8b5
 QemuOptsList *qemu_find_opts_err(const char *group, Error **errp);
Paolo Bonzini d9c8b5
 QemuOpts *qemu_find_opts_singleton(const char *group);
Paolo Bonzini d9c8b5
diff --git a/softmmu/vl.c b/softmmu/vl.c
Paolo Bonzini d9c8b5
index 29d6415..4641f08 100644
Paolo Bonzini d9c8b5
--- a/softmmu/vl.c
Paolo Bonzini d9c8b5
+++ b/softmmu/vl.c
Paolo Bonzini d9c8b5
@@ -2613,6 +2613,23 @@ void qmp_x_exit_preconfig(Error **errp)
Paolo Bonzini d9c8b5
     }
Paolo Bonzini d9c8b5
 }
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
+#ifdef CONFIG_MODULES
Paolo Bonzini d9c8b5
+void qemu_load_module_for_opts(const char *group)
Paolo Bonzini d9c8b5
+{
Paolo Bonzini d9c8b5
+    static bool spice_tried = false;
Paolo Bonzini d9c8b5
+    if (g_str_equal(group, "spice") && !spice_tried) {
Paolo Bonzini d9c8b5
+        ui_module_load_one("spice-core");
Paolo Bonzini d9c8b5
+        spice_tried = true;
Paolo Bonzini d9c8b5
+    }
Paolo Bonzini d9c8b5
+
Paolo Bonzini d9c8b5
+    static bool iscsi_tried = false;
Paolo Bonzini d9c8b5
+    if (g_str_equal(group, "iscsi") && !iscsi_tried) {
Paolo Bonzini d9c8b5
+        block_module_load_one("iscsi");
Paolo Bonzini d9c8b5
+        iscsi_tried = true;
Paolo Bonzini d9c8b5
+    }
Paolo Bonzini d9c8b5
+}
Paolo Bonzini d9c8b5
+#endif
Paolo Bonzini d9c8b5
+
Paolo Bonzini d9c8b5
 void qemu_init(int argc, char **argv, char **envp)
Paolo Bonzini d9c8b5
 {
Paolo Bonzini d9c8b5
     QemuOpts *opts;
Paolo Bonzini d9c8b5
@@ -3372,10 +3389,6 @@ void qemu_init(int argc, char **argv, char **envp)
Paolo Bonzini d9c8b5
                 break;
Paolo Bonzini d9c8b5
             case QEMU_OPTION_spice:
Paolo Bonzini d9c8b5
                 olist = qemu_find_opts_err("spice", NULL);
Paolo Bonzini d9c8b5
-                if (!olist) {
Paolo Bonzini d9c8b5
-                    ui_module_load_one("spice-core");
Paolo Bonzini d9c8b5
-                    olist = qemu_find_opts("spice");
Paolo Bonzini d9c8b5
-                }
Paolo Bonzini d9c8b5
                 if (!olist) {
Paolo Bonzini d9c8b5
                     error_report("spice support is disabled");
Paolo Bonzini d9c8b5
                     exit(1);
Paolo Bonzini d9c8b5
diff --git a/stubs/meson.build b/stubs/meson.build
Paolo Bonzini d9c8b5
index be6f6d6..5555b69 100644
Paolo Bonzini d9c8b5
--- a/stubs/meson.build
Paolo Bonzini d9c8b5
+++ b/stubs/meson.build
Paolo Bonzini d9c8b5
@@ -22,6 +22,7 @@ stub_ss.add(files('isa-bus.c'))
Paolo Bonzini d9c8b5
 stub_ss.add(files('is-daemonized.c'))
Paolo Bonzini d9c8b5
 stub_ss.add(when: 'CONFIG_LINUX_AIO', if_true: files('linux-aio.c'))
Paolo Bonzini d9c8b5
 stub_ss.add(files('migr-blocker.c'))
Paolo Bonzini d9c8b5
+stub_ss.add(files('module-opts.c'))
Paolo Bonzini d9c8b5
 stub_ss.add(files('monitor.c'))
Paolo Bonzini d9c8b5
 stub_ss.add(files('monitor-core.c'))
Paolo Bonzini d9c8b5
 stub_ss.add(files('pci-bus.c'))
Paolo Bonzini d9c8b5
diff --git a/stubs/module-opts.c b/stubs/module-opts.c
Paolo Bonzini d9c8b5
new file mode 100644
Paolo Bonzini d9c8b5
index 0000000..a7d0e4a
Paolo Bonzini d9c8b5
--- /dev/null
Paolo Bonzini d9c8b5
+++ b/stubs/module-opts.c
Paolo Bonzini d9c8b5
@@ -0,0 +1,6 @@
Paolo Bonzini d9c8b5
+#include "qemu/osdep.h"
Paolo Bonzini d9c8b5
+#include "qemu/config-file.h"
Paolo Bonzini d9c8b5
+
Paolo Bonzini d9c8b5
+void qemu_load_module_for_opts(const char *group)
Paolo Bonzini d9c8b5
+{
Paolo Bonzini d9c8b5
+}
Paolo Bonzini d9c8b5
diff --git a/util/qemu-config.c b/util/qemu-config.c
Paolo Bonzini d9c8b5
index 670bd6e..34974c4 100644
Paolo Bonzini d9c8b5
--- a/util/qemu-config.c
Paolo Bonzini d9c8b5
+++ b/util/qemu-config.c
Paolo Bonzini d9c8b5
@@ -16,6 +16,7 @@ static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
Paolo Bonzini d9c8b5
 {
Paolo Bonzini d9c8b5
     int i;
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
+    qemu_load_module_for_opts(group);
Paolo Bonzini d9c8b5
     for (i = 0; lists[i] != NULL; i++) {
Paolo Bonzini d9c8b5
         if (strcmp(lists[i]->name, group) == 0)
Paolo Bonzini d9c8b5
             break;
Paolo Bonzini d9c8b5
-- 
Paolo Bonzini d9c8b5
2.31.1
Paolo Bonzini d9c8b5