From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
berrange@redhat.com, "David Hildenbrand" <david@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
armbru@redhat.com, "Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
qemu-s390x@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Samuel Thibault" <samuel.thibault@ens-lyon.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH 1/9] Add module metadata macros, add qxl module annotations
Date: Wed, 2 Jun 2021 11:17:19 +0200 [thread overview]
Message-ID: <20210602091727.1023563-2-kraxel@redhat.com> (raw)
In-Reply-To: <20210602091727.1023563-1-kraxel@redhat.com>
Stealing an idea from the linux kernel: Place module metadata
in an .modinfo elf section. This patch adds macros and qxl module
annotations as example.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/qemu/module.h | 18 ++++++++++++++++++
hw/display/qxl.c | 4 ++++
2 files changed, 22 insertions(+)
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 944d403cbd15..afb9656ba4e7 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -73,4 +73,22 @@ 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);
+/*
+ * objdump -t -s -j .modinfo ${module}.so
+ */
+
+#define ___PASTE(a, b) a##b
+#define __PASTE(a, b) ___PASTE(a, b)
+
+#define modinfo(kind, value) \
+ static const char __PASTE(kind, __LINE__)[] \
+ __attribute__((__used__)) \
+ __attribute__((section(".modinfo"))) \
+ __attribute__((aligned(1))) \
+ = stringify(kind) "=" value
+
+#define module_obj(name) modinfo(obj, name)
+#define module_dep(name) modinfo(dep, name)
+#define module_arch(name) modinfo(arch, name)
+
#endif
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 6e1f8ff1b2a7..84f99088e0a0 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2522,6 +2522,7 @@ static const TypeInfo qxl_primary_info = {
.parent = TYPE_PCI_QXL,
.class_init = qxl_primary_class_init,
};
+module_obj("qxl-vga");
static void qxl_secondary_class_init(ObjectClass *klass, void *data)
{
@@ -2538,6 +2539,7 @@ static const TypeInfo qxl_secondary_info = {
.parent = TYPE_PCI_QXL,
.class_init = qxl_secondary_class_init,
};
+module_obj("qxl");
static void qxl_register_types(void)
{
@@ -2547,3 +2549,5 @@ static void qxl_register_types(void)
}
type_init(qxl_register_types)
+
+module_dep("ui-spice-core");
--
2.31.1
next prev parent reply other threads:[~2021-06-02 9:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 9:17 [PATCH 0/9] [RFC] store module metadata in .modinfo elf section Gerd Hoffmann
2021-06-02 9:17 ` Gerd Hoffmann [this message]
2021-06-02 9:17 ` [PATCH 2/9] add qemu-modinfo utility Gerd Hoffmann
2021-06-02 9:17 ` [PATCH 3/9] virtio-gpu module annotations Gerd Hoffmann
2021-06-02 9:17 ` [PATCH 4/9] chardev " Gerd Hoffmann
2021-06-02 9:17 ` [PATCH 5/9] audio " Gerd Hoffmann
2021-06-02 9:17 ` [PATCH 6/9] usb-redir " Gerd Hoffmann
2021-06-02 9:17 ` [PATCH 7/9] ccid " Gerd Hoffmann
2021-06-02 9:17 ` [PATCH 8/9] ui " Gerd Hoffmann
2021-06-02 9:17 ` [PATCH 9/9] s390x " Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210602091727.1023563-2-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).