mbox series

[RFC,00/10] rust: remaining part of qdev bindings

Message ID 20250117194003.1173231-1-pbonzini@redhat.com (mailing list archive)
Headers show
Series rust: remaining part of qdev bindings | expand

Message

Paolo Bonzini Jan. 17, 2025, 7:39 p.m. UTC
This is what I have left for qdev bindings, including 1) reference
counting and object creation 2) clocks 3) Resettable 4) MemoryRegionOps.
I have no rush for this series, and I expect HPET to be merged before it.
The documentation is not yet complete (will be fixed) and the API is
limited to what is needed for pl011 (which I am not considering a bug,
since the QEMU API is so large), but I think it's already ready for an
initial review.

The most interesting part is perhaps the usage of the builder pattern
for MemoryRegionOps:

    static PL011_OPS: MemoryRegionOps<PL011State> = MemoryRegionOpsBuilder::<PL011State>::new()
        .read(&PL011State::read) 
        .write(&PL011State::write)   
        .native_endian()
        .impl_sizes(4, 4)
        .build();

The code is getting closer to the synopsis at
https://lists.nongnu.org/archive/html/qemu-rust/2024-12/msg00006.html,
except that it works (at least as far as CI is concerned) instead of just
compiling. :)  And since I'm citing it, a reminder that it may still be
worth asking your Rust questions as replies to that message.

You can find the code in the rust-next branch of
https://gitlab.com/bonzini/qemu/, where it passed CI.

Paolo

Paolo Bonzini (9):
  rust: qom: add reference counting functionality
  rust: qom: add object creation functionality
  rust: callbacks: allow passing optional callbacks as ()
  rust: qdev: add clock creation
  rust: qom: allow initializing interface vtables
  rust: qdev: make ObjectImpl a supertrait of DeviceImpl
  rust: qdev: switch from legacy reset to Resettable
  rust: bindings: add Sync markers to types referred to by
    MemoryRegionOps
  rust: bindings for MemoryRegionOps

Zhao Liu (1):
  rust: qemu-api: add sub-subclass to the integration tests

 meson.build                          |   1 +
 rust/hw/char/pl011/src/device.rs     |  88 ++++++++--------
 rust/hw/char/pl011/src/lib.rs        |   1 -
 rust/hw/char/pl011/src/memory_ops.rs |  36 -------
 rust/qemu-api/meson.build            |   1 +
 rust/qemu-api/src/bindings.rs        |  19 +++-
 rust/qemu-api/src/callbacks.rs       |  97 ++++++++++++++++++
 rust/qemu-api/src/irq.rs             |   3 +
 rust/qemu-api/src/lib.rs             |   1 +
 rust/qemu-api/src/memory.rs          | 191 +++++++++++++++++++++++++++++++++++
 rust/qemu-api/src/prelude.rs         |   4 +
 rust/qemu-api/src/qdev.rs            | 188 +++++++++++++++++++++++++++++-----
 rust/qemu-api/src/qom.rs             | 181 ++++++++++++++++++++++++++++++++-
 rust/qemu-api/src/sysbus.rs          |   7 +-
 rust/qemu-api/src/vmstate.rs         |  10 +-
 rust/qemu-api/src/zeroable.rs        |  12 +++
 rust/qemu-api/tests/tests.rs         |  87 ++++++++++++----
 17 files changed, 793 insertions(+), 134 deletions(-)
 delete mode 100644 rust/hw/char/pl011/src/memory_ops.rs
 create mode 100644 rust/qemu-api/src/memory.rs