aboutsummaryrefslogtreecommitdiff
path: root/util/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/module.c')
-rw-r--r--util/module.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/util/module.c b/util/module.c
index e48d9aacc0..32b0547b82 100644
--- a/util/module.c
+++ b/util/module.c
@@ -245,3 +245,70 @@ bool module_load_one(const char *prefix, const char *lib_name)
#endif
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
+ * to rule and the list will not gain that many entries go with a
+ * simple manually maintained list for now.
+ */
+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-pci", "hw-", "display-virtio-gpu" },
+ { "virtio-vga", "hw-", "display-virtio-gpu" },
+ { "vhost-user-gpu-device", "hw-", "display-virtio-gpu" },
+ { "vhost-user-gpu-pci", "hw-", "display-virtio-gpu" },
+ { "vhost-user-vga", "hw-", "display-virtio-gpu" },
+ { "chardev-braille", "chardev-", "baum" },
+};
+
+static bool module_loaded_qom_all;
+
+void module_load_qom_one(const char *type)
+{
+ int i;
+
+ if (module_loaded_qom_all) {
+ 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);
+ return;
+ }
+ }
+}
+
+void module_load_qom_all(void)
+{
+ int i;
+
+ 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 */
+ continue;
+ }
+ module_load_one(qom_modules[i].prefix, qom_modules[i].module);
+ }
+ module_loaded_qom_all = true;
+}