diff mbox series

[v4,01/34] modules: add modinfo macros

Message ID 20210624103836.2382472-2-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series modules: add meta-data database | expand

Commit Message

Gerd Hoffmann June 24, 2021, 10:38 a.m. UTC
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>
---
 include/qemu/module.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Eduardo Habkost June 24, 2021, 8:37 p.m. UTC | #1
On Thu, Jun 24, 2021 at 12:38:03PM +0200, Gerd Hoffmann wrote:
> 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.
> 
[...]
> +/* module implements QOM type <name> */
> +#define module_obj(name) modinfo(obj, name)

Can we make OBJECT_DEFINE_TYPE*() use this macro automatically?
Paolo Bonzini July 6, 2021, 5:07 p.m. UTC | #2
On 24/06/21 22:37, Eduardo Habkost wrote:
> On Thu, Jun 24, 2021 at 12:38:03PM +0200, Gerd Hoffmann wrote:
>> 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.
>>
> [...]
>> +/* module implements QOM type <name> */
>> +#define module_obj(name) modinfo(obj, name)
> 
> Can we make OBJECT_DEFINE_TYPE*() use this macro automatically?
> 

Yeah, that's possible.  I would do it as a separate patch though, 
because Gerd is on vacation and he asked me to include it in a pull 
request before soft freeze.

Thanks,

Paolo
diff mbox series

Patch

diff --git a/include/qemu/module.h b/include/qemu/module.h
index 944d403cbd15..81ef086da023 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -73,4 +73,29 @@  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);
 
+/*
+ * module info annotation macros
+ *
+ * scripts/modinfo-collect.py will collect module info,
+ * using the preprocessor and -DQEMU_MODINFO
+ */
+#ifdef QEMU_MODINFO
+# define modinfo(kind, value) \
+    MODINFO_START kind value MODINFO_END
+#else
+# define modinfo(kind, value)
+#endif
+
+/* module implements QOM type <name> */
+#define module_obj(name) modinfo(obj, name)
+
+/* module has a dependency on <name> */
+#define module_dep(name) modinfo(dep, name)
+
+/* module is for target architecture <name> */
+#define module_arch(name) modinfo(arch, name)
+
+/* module registers QemuOpts <name> */
+#define module_opts(name) modinfo(opts, name)
+
 #endif