[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/48] modules: use modinfo for qom load
From: |
Paolo Bonzini |
Subject: |
[PULL 19/48] modules: use modinfo for qom load |
Date: |
Thu, 8 Jul 2021 17:17:19 +0200 |
From: Gerd Hoffmann <kraxel@redhat.com>
Use module database to figure which module implements a given QOM type.
Drop hard-coded object list.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Jose R. Ziviani <jziviani@suse.de>
Message-Id: <20210624103836.2382472-16-kraxel@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
util/module.c | 77 ++++++++++++++++-----------------------------------
1 file changed, 24 insertions(+), 53 deletions(-)
diff --git a/util/module.c b/util/module.c
index 7d7b69cbda..745ae0fb20 100644
--- a/util/module.c
+++ b/util/module.c
@@ -280,80 +280,51 @@ bool module_load_one(const char *prefix, const char
*lib_name, bool mayfail)
return success;
}
-/*
- * Building devices and other qom objects modular is mostly useful in
- * case they have dependencies to external shared libraries, so we can
- * cut down the core qemu library dependencies. Which is the case for
- * only a very few devices & objects.
- *
- * So with the expectation that this will be rather the exception than
- * the rule and the list will not gain that many entries, go with a
- * simple manually maintained list for now.
- *
- * The list must be sorted by module (module_load_qom_all() needs this).
- */
-static struct {
- const char *type;
- const char *prefix;
- const char *module;
-} const qom_modules[] = {
- { "ccid-card-passthru", "hw-", "usb-smartcard" },
- { "ccid-card-emulated", "hw-", "usb-smartcard" },
- { "usb-redir", "hw-", "usb-redirect" },
- { "qxl-vga", "hw-", "display-qxl" },
- { "qxl", "hw-", "display-qxl" },
- { "virtio-gpu-device", "hw-", "display-virtio-gpu" },
- { "virtio-gpu-gl-device", "hw-", "display-virtio-gpu-gl" },
- { "vhost-user-gpu", "hw-", "display-virtio-gpu" },
- { "virtio-gpu-pci-base", "hw-", "display-virtio-gpu-pci" },
- { "virtio-gpu-pci", "hw-", "display-virtio-gpu-pci" },
- { "virtio-gpu-gl-pci", "hw-", "display-virtio-gpu-pci-gl" },
- { "vhost-user-gpu-pci", "hw-", "display-virtio-gpu-pci" },
- { "virtio-gpu-ccw", "hw-", "s390x-virtio-gpu-ccw" },
- { "virtio-vga-base", "hw-", "display-virtio-vga" },
- { "virtio-vga", "hw-", "display-virtio-vga" },
- { "virtio-vga-gl", "hw-", "display-virtio-vga-gl" },
- { "vhost-user-vga", "hw-", "display-virtio-vga" },
- { "chardev-braille", "chardev-", "baum" },
- { "chardev-spicevmc", "chardev-", "spice" },
- { "chardev-spiceport", "chardev-", "spice" },
-};
+#ifdef CONFIG_MODULES
static bool module_loaded_qom_all;
void module_load_qom_one(const char *type)
{
- int i;
+ const QemuModinfo *modinfo;
+ const char **sl;
if (!type) {
return;
}
- for (i = 0; i < ARRAY_SIZE(qom_modules); i++) {
- if (strcmp(qom_modules[i].type, type) == 0) {
- module_load_one(qom_modules[i].prefix,
- qom_modules[i].module,
- false);
- return;
+
+ for (modinfo = module_info; modinfo->name != NULL; modinfo++) {
+ if (!modinfo->objs) {
+ continue;
+ }
+ for (sl = modinfo->objs; *sl != NULL; sl++) {
+ if (strcmp(type, *sl) == 0) {
+ module_load_one("", modinfo->name, false);
+ }
}
}
}
void module_load_qom_all(void)
{
- int i;
+ const QemuModinfo *modinfo;
if (module_loaded_qom_all) {
return;
}
- for (i = 0; i < ARRAY_SIZE(qom_modules); i++) {
- if (i > 0 && (strcmp(qom_modules[i - 1].module,
- qom_modules[i].module) == 0 &&
- strcmp(qom_modules[i - 1].prefix,
- qom_modules[i].prefix) == 0)) {
- /* one module implementing multiple types -> load only once */
+
+ for (modinfo = module_info; modinfo->name != NULL; modinfo++) {
+ if (!modinfo->objs) {
continue;
}
- module_load_one(qom_modules[i].prefix, qom_modules[i].module, true);
+ module_load_one("", modinfo->name, false);
}
module_loaded_qom_all = true;
}
+
+#else
+
+void module_load_qom_one(const char *type) {}
+void module_load_qom_all(void) {}
+
+#endif
--
2.31.1
- [PULL 09/48] modules: add qxl module annotations, (continued)
- [PULL 09/48] modules: add qxl module annotations, Paolo Bonzini, 2021/07/08
- [PULL 13/48] modules: add usb-redir module annotations, Paolo Bonzini, 2021/07/08
- [PULL 14/48] modules: add ccid module annotations, Paolo Bonzini, 2021/07/08
- [PULL 08/48] modules: check if all dependencies can be satisfied, Paolo Bonzini, 2021/07/08
- [PULL 11/48] modules: add chardev module annotations, Paolo Bonzini, 2021/07/08
- [PULL 15/48] modules: add ui module annotations, Paolo Bonzini, 2021/07/08
- [PULL 16/48] modules: add s390x module annotations, Paolo Bonzini, 2021/07/08
- [PULL 17/48] modules: add block module annotations, Paolo Bonzini, 2021/07/08
- [PULL 18/48] modules: use modinfo for dependencies, Paolo Bonzini, 2021/07/08
- [PULL 23/48] modules: check arch on qom lookup, Paolo Bonzini, 2021/07/08
- [PULL 19/48] modules: use modinfo for qom load,
Paolo Bonzini <=
- [PULL 20/48] modules: use modinfo for qemu opts load, Paolo Bonzini, 2021/07/08
- [PULL 27/48] modules: module.h kerneldoc annotations, Paolo Bonzini, 2021/07/08
- [PULL 24/48] modules: target-specific module build infrastructure, Paolo Bonzini, 2021/07/08
- [PULL 25/48] modules: add documentation for module sourcesets, Paolo Bonzini, 2021/07/08
- [PULL 21/48] modules: add tracepoints, Paolo Bonzini, 2021/07/08
- [PULL 22/48] modules: check arch and block load on mismatch, Paolo Bonzini, 2021/07/08
- [PULL 29/48] accel: autoload modules, Paolo Bonzini, 2021/07/08
- [PULL 28/48] modules: hook up modules.h to docs build, Paolo Bonzini, 2021/07/08
- [PULL 30/48] accel: add qtest module annotations, Paolo Bonzini, 2021/07/08
- [PULL 32/48] accel: add tcg module annotations, Paolo Bonzini, 2021/07/08