Skip to content

Rust device model patches and misc cleanups

Manos Pitsidianakis qemu-devel 1 version In review

Get series with b4
b4 am [email protected] change-id 20241024-rust-round-2-69fa10c9a0c9

Versions newest first

  1. v1 Latest11 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11Revert "rust: add PL011 device model"MAINTAINERS hw/arm/Kconfig meson.build +34 more+12 -19060 replies
2/11rust: add PL011 device modelMAINTAINERS hw/arm/Kconfig meson.build +34 more+1906 -120 replies
3/11rust/qemu-api-macros: introduce Device proc macrorust/hw/char/pl011/src/device.rs rust/hw/char/pl011/src/device_class.rs rust/hw/char/pl011/src/lib.rs +12 more+902 -4599 replies
4/11rust: add support for migration in device modelsrust/hw/char/pl011/src/device.rs rust/qemu-api-macros/src/device.rs rust/qemu-api-macros/src/lib.rs +5 more+637 -890 replies
5/11rust/pl011: move CLK_NAME static to function scoperust/hw/char/pl011/src/device.rs+2 -30 replies
6/11rust/pl011: add TYPE_PL011_LUMINARY devicerust/hw/char/pl011/src/device.rs rust/hw/char/pl011/src/lib.rs+57 -31 reply
7/11rust/pl011: move pub callback decl to local scoperust/hw/char/pl011/src/device.rs+50 -540 replies
8/11rust/pl011: remove commented out C coderust/hw/char/pl011/src/device.rs+0 -160 replies
9/11rust/pl011: Use correct masks for IBRD and FBRDrust/hw/char/pl011/src/device.rs+2 -20 replies
10/11rust/qemu-api: add log modulerust/qemu-api/meson.build rust/qemu-api/src/lib.rs rust/qemu-api/src/log.rs +1 more+143 -00 replies
11/11rust/pl011: log guest/unimp errorsrust/hw/char/pl011/src/device.rs+31 -60 replies

Reviews trailers per patch

None of the 11 patches has a Reviewed-by or Acked-by.

PatchJunjie MaoPaolo Bonzini
1/11
2/11Co-authored-by Co-authored-by
3/11
4/11
5/11
6/11
7/11
8/11
9/11
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/11] Rust device model patches and misc cleanups

Hello everyone, the pathological corrosion of QEMU code continues.

This series expands the device model harness work performed in the initial Rust work from the previous month. In particular:

- A new derive proc macro, Device, is introduced and the Object derive macro is heavily expanded upon. Many hack-like macros and fixups to declare FFI code for QEMU to consume were removed and now everything is generated by macros in the qemu-api-macros procmacro crate.
- Add support for device migration by allowing device models to declare their VMState description, fields, subsections like in C code. This should also allow new qemu versions to transparently migrate any VMs that used C device models that were afterwards ported to Rust.
- Add a small logging interface in qemu-api crate to allow calling qemu_log() and qemu_log_mask() from Rust code.
- Some minor code cleanups in the Rust pl011 device, and also port of one fix patch and one log prints addition patch that was added in the C pl011.

In the future if we go forward with rewriting device models in Rust, and keep having both of them in-tree while Rust is not required for building QEMU, we could alter checkpatch.pl to produce a warning if a C device model has changes but the corresponding Rust implementation doesn't.

Code and functionality duplication is not fun, and pl011 was mostly done as a proof of concept for a Rust device because of its small complexity. As of this moment we have not decided on a policy for how to handle these things and it is not in **scope for this patch series anyway**.

In the meantime there are lots of TODOs written in my personal notes, my personal repos, in the QEMU wiki, in mailing list threads. I plan on consolidating them all in gitlab issues to streamline things and who-does-what to avoid duplicating work.

---
Manos Pitsidianakis (11):
Revert "rust: add PL011 device model"
rust: add PL011 device model rust/qemu-api-macros: introduce Device proc macro
rust: add support for migration in device models rust/pl011: move CLK_NAME static to function scope rust/pl011: add TYPE_PL011_LUMINARY device rust/pl011: move pub callback decl to local scope rust/pl011: remove commented out C code rust/pl011: Use correct masks for IBRD and FBRD rust/qemu-api: add log module
rust/pl011: log guest/unimp errors

 rust/wrapper.h                                |   1 +
 rust/hw/char/pl011/src/device.rs              | 419 +++++++++++++++++---------
 rust/hw/char/pl011/src/device_class.rs        |  70 -----
 rust/hw/char/pl011/src/lib.rs                 |   2 +-
 rust/qemu-api-macros/src/device.rs            | 370 +++++++++++++++++++++++
 rust/qemu-api-macros/src/lib.rs               |  46 +--
 rust/qemu-api-macros/src/object.rs            | 107 +++++++
 rust/qemu-api-macros/src/symbols.rs           |  57 ++++
 rust/qemu-api-macros/src/utilities.rs         | 152 ++++++++++
 rust/qemu-api-macros/src/vmstate.rs           | 113 +++++++
 rust/qemu-api/meson.build                     |   5 +-
 rust/qemu-api/src/definitions.rs              |  97 ------
 rust/qemu-api/src/device_class.rs             | 128 --------
 rust/qemu-api/src/lib.rs                      |  10 +-
 rust/qemu-api/src/log.rs                      | 140 +++++++++
 rust/qemu-api/src/objects.rs                  |  90 ++++++
 rust/qemu-api/src/tests.rs                    |  49 ---
 rust/qemu-api/src/vmstate.rs                  | 403 +++++++++++++++++++++++++
 subprojects/packagefiles/syn-2-rs/meson.build |   1 +
 19 files changed, 1726 insertions(+), 534 deletions(-)

---
base-commit: 55522f72149fbf95ee3b057f1419da0cad46d0dd
change-id: 20241024-rust-round-2-69fa10c9a0c9

--
γαῖα πυρί μιχθήτω