[PATCH v3 01/24] modules: add modinfo macros

Gerd Hoffmann posted 24 patches 4 years, 7 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Laurent Vivier <lvivier@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Thomas Huth <thuth@redhat.com>, David Hildenbrand <david@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>, Peter Lieven <pl@kamp.de>, Eduardo Habkost <ehabkost@redhat.com>, Max Reitz <mreitz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Cleber Rosa <crosa@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, Christian Borntraeger <borntraeger@de.ibm.com>, Ronnie Sahlberg <ronniesahlberg@gmail.com>, Cornelia Huck <cohuck@redhat.com>
There is a newer version of this series
[PATCH v3 01/24] modules: add modinfo macros
Posted by Gerd Hoffmann 4 years, 7 months ago
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(+)

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
-- 
2.31.1


Re: [PATCH v3 01/24] modules: add modinfo macros
Posted by Paolo Bonzini 4 years, 7 months ago
On 18/06/21 06:53, 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.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   include/qemu/module.h | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
> 
> 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
> 

Let's ensure that the module system is documented in some file of 
docs/devel.

Paolo