[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 15/18] modules: use modinfo for qom load
From: |
Gerd Hoffmann |
Subject: |
[PATCH v2 15/18] modules: use modinfo for qom load |
Date: |
Thu, 10 Jun 2021 07:57:52 +0200 |
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>
---
util/module.c | 83 +++++++++++++++++++--------------------------------
1 file changed, 30 insertions(+), 53 deletions(-)
diff --git a/util/module.c b/util/module.c
index fd5fc059e14a..46bec1cfbec7 100644
--- a/util/module.c
+++ b/util/module.c
@@ -333,80 +333,57 @@ 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;
+ ModuleInfoList *modlist;
+ strList *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;
+
+ module_load_path_init();
+ module_load_modinfo();
+
+ for (modlist = modinfo->list; modlist != NULL; modlist = modlist->next) {
+ if (!modlist->value->has_objs) {
+ continue;
+ }
+ for (sl = modlist->value->objs; sl != NULL; sl = sl->next) {
+ if (strcmp(type, sl->value) == 0) {
+ module_load_one("", modlist->value->name, false);
+ }
}
}
}
void module_load_qom_all(void)
{
- int i;
+ ModuleInfoList *modlist;
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 */
+
+ module_load_path_init();
+ module_load_modinfo();
+
+ for (modlist = modinfo->list; modlist != NULL; modlist = modlist->next) {
+ if (!modlist->value->has_objs) {
continue;
}
- module_load_one(qom_modules[i].prefix, qom_modules[i].module, true);
+ module_load_one("", modlist->value->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
- [PATCH v2 04/18] modules: add virtio-gpu module annotations, (continued)
- [PATCH v2 04/18] modules: add virtio-gpu module annotations, Gerd Hoffmann, 2021/06/10
- [PATCH v2 06/18] modules: add audio module annotations, Gerd Hoffmann, 2021/06/10
- [PATCH v2 07/18] modules: add usb-redir module annotations, Gerd Hoffmann, 2021/06/10
- [PATCH v2 09/18] modules: add ui module annotations, Gerd Hoffmann, 2021/06/10
- [PATCH v2 08/18] modules: add ccid module annotations, Gerd Hoffmann, 2021/06/10
- [PATCH v2 10/18] modules: add s390x module annotations, Gerd Hoffmann, 2021/06/10
- [PATCH v2 11/18] modules: add block module annotations, Gerd Hoffmann, 2021/06/10
- [PATCH v2 12/18] modules: add module_load_path_init helper, Gerd Hoffmann, 2021/06/10
- [PATCH v2 13/18] modules: load modinfo.json, Gerd Hoffmann, 2021/06/10
- [PATCH v2 14/18] modules: use modinfo for dependencies, Gerd Hoffmann, 2021/06/10
- [PATCH v2 15/18] modules: use modinfo for qom load,
Gerd Hoffmann <=
- [PATCH v2 17/18] modules: check arch and block load on mismatch, Gerd Hoffmann, 2021/06/10
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Daniel P . Berrangé, 2021/06/10
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Gerd Hoffmann, 2021/06/10
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Daniel P . Berrangé, 2021/06/10
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Gerd Hoffmann, 2021/06/10
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Claudio Fontana, 2021/06/14
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Gerd Hoffmann, 2021/06/14
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Daniel P . Berrangé, 2021/06/14
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Gerd Hoffmann, 2021/06/14
- Re: [PATCH v2 17/18] modules: check arch and block load on mismatch, Claudio Fontana, 2021/06/14