aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2021-06-24 12:38:17 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-07-09 18:20:27 +0200
commit9f4a0f0978cde9d8e27453b3f2d3679b53623c47 (patch)
tree7e74279aa5f8534089d45c4941c8da663d3770cb /util
parente897b9a73558a345878c132489afcc55ecbec711 (diff)
modules: use modinfo for qom load
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>
Diffstat (limited to 'util')
-rw-r--r--util/module.c77
1 files 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