qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] qom: module loading cleanups
@ 2024-10-29 12:26 Paolo Bonzini
  2024-10-29 12:26 ` [PATCH 1/5] qom: remove unused function Paolo Bonzini
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Paolo Bonzini @ 2024-10-29 12:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-10-29 19:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 12:26 [PATCH 0/5] qom: module loading cleanups Paolo Bonzini
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

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).