summary refs log tree commit diff stats
path: root/include/qemu/module.h
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2021-06-24 12:38:03 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-07-09 18:20:22 +0200
commit22524c10c489ed7c20be2f5878157a64095e5734 (patch)
treef6b6e3e6d043cbf084c5f2dc9ceb35a90dc4daa0 /include/qemu/module.h
parent7db492a1b65699ee6384874844cb87ff7200a811 (diff)
downloadfocaccia-qemu-22524c10c489ed7c20be2f5878157a64095e5734.tar.gz
focaccia-qemu-22524c10c489ed7c20be2f5878157a64095e5734.zip
modules: add modinfo macros
Add macros for module info annotations.

Instead of having that module meta-data stored in lists in util/module.c
place directly in the module source code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jose R. Ziviani <jziviani@suse.de>
Message-Id: <20210624103836.2382472-2-kraxel@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/module.h')
-rw-r--r--include/qemu/module.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 944d403cbd..b595f15975 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -73,4 +73,65 @@ bool module_load_one(const char *prefix, const char *lib_name, bool mayfail);
 void module_load_qom_one(const char *type);
 void module_load_qom_all(void);
 
+/**
+ * DOC: module info annotation macros
+ *
+ * `scripts/modinfo-collect.py` will collect module info,
+ * using the preprocessor and -DQEMU_MODINFO.
+ *
+ * `scripts/modinfo-generate.py` will create a module meta-data database
+ * from the collected information so qemu knows about module
+ * dependencies and QOM objects implemented by modules.
+ *
+ * See `*.modinfo` and `modinfo.c` in the build directory to check the
+ * script results.
+ */
+#ifdef QEMU_MODINFO
+# define modinfo(kind, value) \
+    MODINFO_START kind value MODINFO_END
+#else
+# define modinfo(kind, value)
+#endif
+
+/**
+ * module_obj
+ *
+ * @name: QOM type.
+ *
+ * This module implements QOM type @name.
+ */
+#define module_obj(name) modinfo(obj, name)
+
+/**
+ * module_dep
+ *
+ * @name: module name
+ *
+ * This module depends on module @name.
+ */
+#define module_dep(name) modinfo(dep, name)
+
+/**
+ * module_arch
+ *
+ * @name: target architecture
+ *
+ * This module is for target architecture @arch.
+ *
+ * Note that target-dependent modules are tagged automatically, so
+ * this is only needed in case target-independent modules should be
+ * restricted.  Use case example: the ccw bus is implemented by s390x
+ * only.
+ */
+#define module_arch(name) modinfo(arch, name)
+
+/**
+ * module_opts
+ *
+ * @name: QemuOpts name
+ *
+ * This module registers QemuOpts @name.
+ */
+#define module_opts(name) modinfo(opts, name)
+
 #endif