From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: [PATCH 0/5] qom: module loading cleanups
Date: Tue, 29 Oct 2024 13:26:04 +0100 [thread overview]
Message-ID: <20241029122609.514347-1-pbonzini@redhat.com> (raw)
While looking at possible Rust APIs for object_new/qdev_new (one of the
functions that rust/hw/char/pl011 uses via FFI) I noticed that the support
for modules in QOM APIs is quite random.
In particular, loading modules is done by object_initialize() and
qdev_new(), but not by object_new(); furthermore, the loading code is
duplicated between object_initialize() and module_object_class_by_name().
This series fixes that.
Patches 1-2 are small cleanups.
Patches 3-4 let object_new() use a module if the type is not present,
like object_initialize() already does. To get there, all calls to
type_get_by_name() are changed to either type_get_by_name_noload() (the
old function) or type_get_or_load_by_name() (which looks at modules
like object_initialize() and module_object_class_by_name() do).
This is enough to let Rust code use a single function object_new() to create
QOM objects; the function can be wrapped to allow writing something like
"PL011State::new()" instead of object_new(TYPE_PL011) as *mut PL011State".
Patch 5 finally allows modularized user-creatable classes, which are
not allowed just because the code uses the non-module-friendly
object_class_by_name(). While there are no modularized user-creatable
classes right now, there is no real difference between them and
character devices (which do allow modularization). This patch could
be left out if desired.
Paolo
Paolo Bonzini (5):
qom: remove unused function
qom: use object_new_with_class when possible
qom: centralize module-loading functionality
qom: let object_new use a module if the type is not present
qom: allow user-creatable classes to be in modules
include/qom/object.h | 8 -----
hw/core/qdev.c | 21 ++---------
qom/object.c | 80 +++++++++++++++++++----------------------
qom/object_interfaces.c | 4 +--
qom/qom-qmp-cmds.c | 4 +--
5 files changed, 43 insertions(+), 74 deletions(-)
--
2.47.0
next reply other threads:[~2024-10-29 12:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 12:26 Paolo Bonzini [this message]
2024-10-29 12:26 ` [PATCH 1/5] qom: remove unused function Paolo Bonzini
2024-10-29 12:35 ` Daniel P. Berrangé
2024-10-29 12:26 ` [PATCH 2/5] qom: use object_new_with_class when possible Paolo Bonzini
2024-10-29 19:51 ` Philippe Mathieu-Daudé
2024-10-29 12:26 ` [PATCH 3/5] qom: centralize module-loading functionality Paolo Bonzini
2024-10-29 12:26 ` [PATCH 4/5] qom: let object_new use a module if the type is not present Paolo Bonzini
2024-10-29 12:26 ` [PATCH 5/5] qom: allow user-creatable classes to be in modules Paolo Bonzini
2024-10-29 17:05 ` [PATCH 0/5] qom: module loading cleanups Richard Henderson
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=20241029122609.514347-1-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).