[PATCH 00/33] First Rust update for QEMU 10.2

Paolo Bonzini posted 33 patches 2 weeks, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250908105005.2119297-1-pbonzini@redhat.com
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
MAINTAINERS                                   |  12 +-
docs/devel/rust.rst                           |  93 ++--
configure                                     |   4 +-
meson.build                                   |  10 +-
rust/bql/wrapper.h                            |  27 +
rust/chardev/wrapper.h                        |  28 +
rust/hw/char/pl011/wrapper.h                  |  51 ++
rust/hw/core/wrapper.h                        |  32 ++
rust/{qemu-api => migration}/wrapper.h        |  20 -
rust/qom/wrapper.h                            |  27 +
rust/system/wrapper.h                         |  29 +
rust/util/wrapper.h                           |  32 ++
.gitlab-ci.d/buildtest.yml                    |   6 +-
clippy.toml                                   |   2 +-
python/scripts/vendor.py                      |   4 +-
python/wheels/meson-1.8.1-py3-none-any.whl    | Bin 1013001 -> 0 bytes
python/wheels/meson-1.9.0-py3-none-any.whl    | Bin 0 -> 1029634 bytes
pythondeps.toml                               |   4 +-
rust/Cargo.lock                               | 125 ++++-
rust/Cargo.toml                               |  19 +-
.../src/bindings.rs => bindings/src/lib.rs}   |  12 +-
rust/bits/Cargo.toml                          |   2 +-
rust/bits/meson.build                         |   2 +-
rust/bits/src/lib.rs                          |  13 +-
rust/bql/Cargo.toml                           |  23 +
rust/bql/build.rs                             |   1 +
rust/bql/meson.build                          |  52 ++
rust/bql/src/bindings.rs                      |  25 +
rust/{qemu-api => bql}/src/cell.rs            | 336 ++----------
rust/bql/src/lib.rs                           |  29 +
rust/chardev/Cargo.toml                       |  23 +
rust/chardev/build.rs                         |   1 +
rust/chardev/meson.build                      |  41 ++
rust/chardev/src/bindings.rs                  |  36 ++
rust/{qemu-api => chardev}/src/chardev.rs     |  25 +-
rust/chardev/src/lib.rs                       |   6 +
rust/common/Cargo.toml                        |  20 +
rust/common/meson.build                       |  34 ++
rust/{qemu-api => common}/src/assertions.rs   |  24 +-
rust/{qemu-api => common}/src/bitops.rs       |   1 -
rust/{qemu-api => common}/src/callbacks.rs    |  37 +-
rust/{qemu-api => common}/src/errno.rs        |  19 +-
rust/common/src/lib.rs                        |  22 +
rust/common/src/opaque.rs                     | 236 ++++++++
rust/{qemu-api => common}/src/uninit.rs       |   8 +-
rust/common/src/zeroable.rs                   |  18 +
rust/hw/char/pl011/Cargo.toml                 |  10 +-
rust/hw/char/pl011/build.rs                   |   1 +
rust/hw/char/pl011/meson.build                |  39 +-
rust/hw/char/pl011/src/bindings.rs            |  27 +
rust/hw/char/pl011/src/device.rs              | 195 +++----
rust/hw/char/pl011/src/lib.rs                 |   1 +
rust/hw/char/pl011/src/registers.rs           |   4 +-
rust/hw/core/Cargo.toml                       |  26 +
rust/hw/core/build.rs                         |   1 +
rust/hw/core/meson.build                      |  80 +++
rust/hw/core/src/bindings.rs                  |  41 ++
rust/{qemu-api => hw/core}/src/irq.rs         |  16 +-
rust/hw/core/src/lib.rs                       |  15 +
rust/{qemu-api => hw/core}/src/qdev.rs        | 111 ++--
rust/{qemu-api => hw/core}/src/sysbus.rs      |  24 +-
rust/{qemu-api => hw/core}/tests/tests.rs     |  52 +-
rust/hw/timer/hpet/Cargo.toml                 |   9 +-
rust/hw/timer/hpet/meson.build                |  12 +-
rust/hw/timer/hpet/src/device.rs              | 227 ++++----
rust/hw/timer/hpet/src/fw_cfg.rs              |   6 +-
rust/meson.build                              |  15 +-
rust/migration/Cargo.toml                     |  20 +
rust/migration/build.rs                       |   1 +
rust/migration/meson.build                    |  53 ++
rust/migration/src/bindings.rs                |  48 ++
rust/migration/src/lib.rs                     |   6 +
rust/{qemu-api => migration}/src/vmstate.rs   | 519 +++++++++++-------
rust/qemu-api/.gitignore                      |   2 -
rust/qemu-api/README.md                       |  19 -
rust/qemu-api/meson.build                     | 114 ----
rust/qemu-api/src/lib.rs                      | 174 ------
rust/qemu-api/src/prelude.rs                  |  31 --
rust/qemu-api/src/zeroable.rs                 |  37 --
.../Cargo.toml                                |   2 +-
.../meson.build                               |  10 +-
.../src/bits.rs                               |   0
.../src/lib.rs                                | 170 +++++-
.../src/tests.rs                              | 115 +++-
rust/qom/Cargo.toml                           |  23 +
rust/qom/build.rs                             |   1 +
rust/qom/meson.build                          |  43 ++
rust/qom/src/bindings.rs                      |  25 +
rust/qom/src/lib.rs                           |  13 +
rust/qom/src/prelude.rs                       |  12 +
rust/{qemu-api => qom}/src/qom.rs             |  31 +-
rust/system/Cargo.toml                        |  21 +
rust/system/build.rs                          |   1 +
rust/system/meson.build                       |  42 ++
rust/system/src/bindings.rs                   |  41 ++
rust/system/src/lib.rs                        |   6 +
rust/{qemu-api => system}/src/memory.rs       |  21 +-
rust/tests/Cargo.toml                         |  26 +
rust/tests/meson.build                        |  14 +
.../tests/vmstate_tests.rs                    | 160 +++---
rust/{qemu-api => util}/Cargo.toml            |  14 +-
rust/{qemu-api => util}/build.rs              |  10 +-
rust/util/meson.build                         |  55 ++
rust/util/src/bindings.rs                     |  25 +
rust/{qemu-api => util}/src/error.rs          |   6 +-
rust/util/src/lib.rs                          |   9 +
rust/{qemu-api => util}/src/log.rs            |  16 +-
rust/{qemu-api => util}/src/module.rs         |   2 +-
rust/{qemu-api => util}/src/timer.rs          |  16 +-
109 files changed, 2868 insertions(+), 1569 deletions(-)
create mode 100644 rust/bql/wrapper.h
create mode 100644 rust/chardev/wrapper.h
create mode 100644 rust/hw/char/pl011/wrapper.h
create mode 100644 rust/hw/core/wrapper.h
rename rust/{qemu-api => migration}/wrapper.h (77%)
create mode 100644 rust/qom/wrapper.h
create mode 100644 rust/system/wrapper.h
create mode 100644 rust/util/wrapper.h
delete mode 100644 python/wheels/meson-1.8.1-py3-none-any.whl
create mode 100644 python/wheels/meson-1.9.0-py3-none-any.whl
rename rust/{qemu-api/src/bindings.rs => bindings/src/lib.rs} (89%)
create mode 100644 rust/bql/Cargo.toml
create mode 120000 rust/bql/build.rs
create mode 100644 rust/bql/meson.build
create mode 100644 rust/bql/src/bindings.rs
rename rust/{qemu-api => bql}/src/cell.rs (70%)
create mode 100644 rust/bql/src/lib.rs
create mode 100644 rust/chardev/Cargo.toml
create mode 120000 rust/chardev/build.rs
create mode 100644 rust/chardev/meson.build
create mode 100644 rust/chardev/src/bindings.rs
rename rust/{qemu-api => chardev}/src/chardev.rs (94%)
create mode 100644 rust/chardev/src/lib.rs
create mode 100644 rust/common/Cargo.toml
create mode 100644 rust/common/meson.build
rename rust/{qemu-api => common}/src/assertions.rs (86%)
rename rust/{qemu-api => common}/src/bitops.rs (98%)
rename rust/{qemu-api => common}/src/callbacks.rs (85%)
rename rust/{qemu-api => common}/src/errno.rs (96%)
create mode 100644 rust/common/src/lib.rs
create mode 100644 rust/common/src/opaque.rs
rename rust/{qemu-api => common}/src/uninit.rs (91%)
create mode 100644 rust/common/src/zeroable.rs
create mode 120000 rust/hw/char/pl011/build.rs
create mode 100644 rust/hw/char/pl011/src/bindings.rs
create mode 100644 rust/hw/core/Cargo.toml
create mode 120000 rust/hw/core/build.rs
create mode 100644 rust/hw/core/meson.build
create mode 100644 rust/hw/core/src/bindings.rs
rename rust/{qemu-api => hw/core}/src/irq.rs (93%)
create mode 100644 rust/hw/core/src/lib.rs
rename rust/{qemu-api => hw/core}/src/qdev.rs (82%)
rename rust/{qemu-api => hw/core}/src/sysbus.rs (90%)
rename rust/{qemu-api => hw/core}/tests/tests.rs (78%)
create mode 100644 rust/migration/Cargo.toml
create mode 120000 rust/migration/build.rs
create mode 100644 rust/migration/meson.build
create mode 100644 rust/migration/src/bindings.rs
create mode 100644 rust/migration/src/lib.rs
rename rust/{qemu-api => migration}/src/vmstate.rs (61%)
delete mode 100644 rust/qemu-api/.gitignore
delete mode 100644 rust/qemu-api/README.md
delete mode 100644 rust/qemu-api/meson.build
delete mode 100644 rust/qemu-api/src/lib.rs
delete mode 100644 rust/qemu-api/src/prelude.rs
delete mode 100644 rust/qemu-api/src/zeroable.rs
rename rust/{qemu-api-macros => qemu-macros}/Cargo.toml (94%)
rename rust/{qemu-api-macros => qemu-macros}/meson.build (63%)
rename rust/{qemu-api-macros => qemu-macros}/src/bits.rs (100%)
rename rust/{qemu-api-macros => qemu-macros}/src/lib.rs (54%)
rename rust/{qemu-api-macros => qemu-macros}/src/tests.rs (50%)
create mode 100644 rust/qom/Cargo.toml
create mode 120000 rust/qom/build.rs
create mode 100644 rust/qom/meson.build
create mode 100644 rust/qom/src/bindings.rs
create mode 100644 rust/qom/src/lib.rs
create mode 100644 rust/qom/src/prelude.rs
rename rust/{qemu-api => qom}/src/qom.rs (97%)
create mode 100644 rust/system/Cargo.toml
create mode 120000 rust/system/build.rs
create mode 100644 rust/system/meson.build
create mode 100644 rust/system/src/bindings.rs
create mode 100644 rust/system/src/lib.rs
rename rust/{qemu-api => system}/src/memory.rs (90%)
create mode 100644 rust/tests/Cargo.toml
create mode 100644 rust/tests/meson.build
rename rust/{qemu-api => tests}/tests/vmstate_tests.rs (78%)
rename rust/{qemu-api => util}/Cargo.toml (55%)
rename rust/{qemu-api => util}/build.rs (81%)
create mode 100644 rust/util/meson.build
create mode 100644 rust/util/src/bindings.rs
rename rust/{qemu-api => util}/src/error.rs (98%)
create mode 100644 rust/util/src/lib.rs
rename rust/{qemu-api => util}/src/log.rs (93%)
rename rust/{qemu-api => util}/src/module.rs (97%)
rename rust/{qemu-api => util}/src/timer.rs (91%)
[PATCH 00/33] First Rust update for QEMU 10.2
Posted by Paolo Bonzini 2 weeks, 6 days ago
This includes:
- bumping MSRV to 1.83.0 to support const_refs_to_static
- Zhao's safe, builder-based implementation of migration callbacks
- Manos's qdev properties macro.  While bit-based properties are
  not yet supported, that's a small change overall.
- the Rust crate split from Marc-André
- adding proc macro aliases in individual crates, also from Marc-André

I'm still not convinced about having "bql" depend on "migration",
but I am convinced by the crate split between "util" and "bql",
so we can move the implementation of VMState from "bql" to
"migration" later if needed.

For the purpose of getting this in as an easy-to-use base for future
development, I'm disabling CI from Debian and Ubuntu.  The plan is:
- that Debian will require trixie to enable Rust usage
- that Ubuntu will backport 1.83 to its 22.04 and 24.04 versions
  (https://bugs.launchpad.net/ubuntu/+source/rustc-1.83/+bug/2120318)
- that Marc-André or someone else will add Rust to other CI jobs

Also planned for 10.2 from me is using rustc to link emulators
(already written but requires Meson 1.9.1) and possibly some work on
BQL-free HPET, especially with respect to migration.  I'll probably
resubmit https://lore.kernel.org/qemu-devel/20250717062727.305466-5-pbonzini@redhat.com/
too, since improvements to migration support will likely result in
more procedural macro attributes.

I'll send the next update some time in October, probably once
Ubuntu gets the newer version of the compiler.  I'm now going to
mostly disappear for a week. :)

Paolo

Manos Pitsidianakis (1):
  rust: add qdev Device derive macro

Marc-André Lureau (22):
  docs/rust: update msrv
  rust: remove unused global qemu "allocator"
  rust: add workspace authors
  rust: move vmstate_clock!() to qdev module
  rust: move VMState handling to QOM module
  rust: move Cell vmstate impl
  rust: split Rust-only "common" crate
  rust: make build.rs generic over various ./rust/projects
  rust: split "util" crate
  rust: split "migration" crate
  rust: split "bql" crate
  rust: split "qom" crate
  rust: split "chardev" crate
  rust: split "system" crate
  rust: split "hwcore" crate
  rust: rename qemu_api_macros -> qemu_macros
  rust/hpet: drop now unneeded qemu_api dep
  rust/pl011: drop dependency on qemu_api
  rust: repurpose qemu_api -> tests
  rust: re-export qemu_macros internal helper in "bits"
  rust: re-export qemu macros from common/qom/hwcore
  docs: update rust.rst

Paolo Bonzini (9):
  ci: temporarily remove rust from Debian and Ubuntu
  configure: bump Meson to 1.9.0 for use with Rust
  meson, cargo: require Rust 1.83.0
  rust: add missing const markers for MSRV==1.83.0
  rust: use inline const expressions
  rust: vmstate: use const_refs_to_static
  rust: qdev: const_refs_to_static
  rust: meson: remove unnecessary complication in device crates
  rust: do not inline do_init_io

Zhao Liu (1):
  rust: vmstate: convert to use builder pattern

 MAINTAINERS                                   |  12 +-
 docs/devel/rust.rst                           |  93 ++--
 configure                                     |   4 +-
 meson.build                                   |  10 +-
 rust/bql/wrapper.h                            |  27 +
 rust/chardev/wrapper.h                        |  28 +
 rust/hw/char/pl011/wrapper.h                  |  51 ++
 rust/hw/core/wrapper.h                        |  32 ++
 rust/{qemu-api => migration}/wrapper.h        |  20 -
 rust/qom/wrapper.h                            |  27 +
 rust/system/wrapper.h                         |  29 +
 rust/util/wrapper.h                           |  32 ++
 .gitlab-ci.d/buildtest.yml                    |   6 +-
 clippy.toml                                   |   2 +-
 python/scripts/vendor.py                      |   4 +-
 python/wheels/meson-1.8.1-py3-none-any.whl    | Bin 1013001 -> 0 bytes
 python/wheels/meson-1.9.0-py3-none-any.whl    | Bin 0 -> 1029634 bytes
 pythondeps.toml                               |   4 +-
 rust/Cargo.lock                               | 125 ++++-
 rust/Cargo.toml                               |  19 +-
 .../src/bindings.rs => bindings/src/lib.rs}   |  12 +-
 rust/bits/Cargo.toml                          |   2 +-
 rust/bits/meson.build                         |   2 +-
 rust/bits/src/lib.rs                          |  13 +-
 rust/bql/Cargo.toml                           |  23 +
 rust/bql/build.rs                             |   1 +
 rust/bql/meson.build                          |  52 ++
 rust/bql/src/bindings.rs                      |  25 +
 rust/{qemu-api => bql}/src/cell.rs            | 336 ++----------
 rust/bql/src/lib.rs                           |  29 +
 rust/chardev/Cargo.toml                       |  23 +
 rust/chardev/build.rs                         |   1 +
 rust/chardev/meson.build                      |  41 ++
 rust/chardev/src/bindings.rs                  |  36 ++
 rust/{qemu-api => chardev}/src/chardev.rs     |  25 +-
 rust/chardev/src/lib.rs                       |   6 +
 rust/common/Cargo.toml                        |  20 +
 rust/common/meson.build                       |  34 ++
 rust/{qemu-api => common}/src/assertions.rs   |  24 +-
 rust/{qemu-api => common}/src/bitops.rs       |   1 -
 rust/{qemu-api => common}/src/callbacks.rs    |  37 +-
 rust/{qemu-api => common}/src/errno.rs        |  19 +-
 rust/common/src/lib.rs                        |  22 +
 rust/common/src/opaque.rs                     | 236 ++++++++
 rust/{qemu-api => common}/src/uninit.rs       |   8 +-
 rust/common/src/zeroable.rs                   |  18 +
 rust/hw/char/pl011/Cargo.toml                 |  10 +-
 rust/hw/char/pl011/build.rs                   |   1 +
 rust/hw/char/pl011/meson.build                |  39 +-
 rust/hw/char/pl011/src/bindings.rs            |  27 +
 rust/hw/char/pl011/src/device.rs              | 195 +++----
 rust/hw/char/pl011/src/lib.rs                 |   1 +
 rust/hw/char/pl011/src/registers.rs           |   4 +-
 rust/hw/core/Cargo.toml                       |  26 +
 rust/hw/core/build.rs                         |   1 +
 rust/hw/core/meson.build                      |  80 +++
 rust/hw/core/src/bindings.rs                  |  41 ++
 rust/{qemu-api => hw/core}/src/irq.rs         |  16 +-
 rust/hw/core/src/lib.rs                       |  15 +
 rust/{qemu-api => hw/core}/src/qdev.rs        | 111 ++--
 rust/{qemu-api => hw/core}/src/sysbus.rs      |  24 +-
 rust/{qemu-api => hw/core}/tests/tests.rs     |  52 +-
 rust/hw/timer/hpet/Cargo.toml                 |   9 +-
 rust/hw/timer/hpet/meson.build                |  12 +-
 rust/hw/timer/hpet/src/device.rs              | 227 ++++----
 rust/hw/timer/hpet/src/fw_cfg.rs              |   6 +-
 rust/meson.build                              |  15 +-
 rust/migration/Cargo.toml                     |  20 +
 rust/migration/build.rs                       |   1 +
 rust/migration/meson.build                    |  53 ++
 rust/migration/src/bindings.rs                |  48 ++
 rust/migration/src/lib.rs                     |   6 +
 rust/{qemu-api => migration}/src/vmstate.rs   | 519 +++++++++++-------
 rust/qemu-api/.gitignore                      |   2 -
 rust/qemu-api/README.md                       |  19 -
 rust/qemu-api/meson.build                     | 114 ----
 rust/qemu-api/src/lib.rs                      | 174 ------
 rust/qemu-api/src/prelude.rs                  |  31 --
 rust/qemu-api/src/zeroable.rs                 |  37 --
 .../Cargo.toml                                |   2 +-
 .../meson.build                               |  10 +-
 .../src/bits.rs                               |   0
 .../src/lib.rs                                | 170 +++++-
 .../src/tests.rs                              | 115 +++-
 rust/qom/Cargo.toml                           |  23 +
 rust/qom/build.rs                             |   1 +
 rust/qom/meson.build                          |  43 ++
 rust/qom/src/bindings.rs                      |  25 +
 rust/qom/src/lib.rs                           |  13 +
 rust/qom/src/prelude.rs                       |  12 +
 rust/{qemu-api => qom}/src/qom.rs             |  31 +-
 rust/system/Cargo.toml                        |  21 +
 rust/system/build.rs                          |   1 +
 rust/system/meson.build                       |  42 ++
 rust/system/src/bindings.rs                   |  41 ++
 rust/system/src/lib.rs                        |   6 +
 rust/{qemu-api => system}/src/memory.rs       |  21 +-
 rust/tests/Cargo.toml                         |  26 +
 rust/tests/meson.build                        |  14 +
 .../tests/vmstate_tests.rs                    | 160 +++---
 rust/{qemu-api => util}/Cargo.toml            |  14 +-
 rust/{qemu-api => util}/build.rs              |  10 +-
 rust/util/meson.build                         |  55 ++
 rust/util/src/bindings.rs                     |  25 +
 rust/{qemu-api => util}/src/error.rs          |   6 +-
 rust/util/src/lib.rs                          |   9 +
 rust/{qemu-api => util}/src/log.rs            |  16 +-
 rust/{qemu-api => util}/src/module.rs         |   2 +-
 rust/{qemu-api => util}/src/timer.rs          |  16 +-
 109 files changed, 2868 insertions(+), 1569 deletions(-)
 create mode 100644 rust/bql/wrapper.h
 create mode 100644 rust/chardev/wrapper.h
 create mode 100644 rust/hw/char/pl011/wrapper.h
 create mode 100644 rust/hw/core/wrapper.h
 rename rust/{qemu-api => migration}/wrapper.h (77%)
 create mode 100644 rust/qom/wrapper.h
 create mode 100644 rust/system/wrapper.h
 create mode 100644 rust/util/wrapper.h
 delete mode 100644 python/wheels/meson-1.8.1-py3-none-any.whl
 create mode 100644 python/wheels/meson-1.9.0-py3-none-any.whl
 rename rust/{qemu-api/src/bindings.rs => bindings/src/lib.rs} (89%)
 create mode 100644 rust/bql/Cargo.toml
 create mode 120000 rust/bql/build.rs
 create mode 100644 rust/bql/meson.build
 create mode 100644 rust/bql/src/bindings.rs
 rename rust/{qemu-api => bql}/src/cell.rs (70%)
 create mode 100644 rust/bql/src/lib.rs
 create mode 100644 rust/chardev/Cargo.toml
 create mode 120000 rust/chardev/build.rs
 create mode 100644 rust/chardev/meson.build
 create mode 100644 rust/chardev/src/bindings.rs
 rename rust/{qemu-api => chardev}/src/chardev.rs (94%)
 create mode 100644 rust/chardev/src/lib.rs
 create mode 100644 rust/common/Cargo.toml
 create mode 100644 rust/common/meson.build
 rename rust/{qemu-api => common}/src/assertions.rs (86%)
 rename rust/{qemu-api => common}/src/bitops.rs (98%)
 rename rust/{qemu-api => common}/src/callbacks.rs (85%)
 rename rust/{qemu-api => common}/src/errno.rs (96%)
 create mode 100644 rust/common/src/lib.rs
 create mode 100644 rust/common/src/opaque.rs
 rename rust/{qemu-api => common}/src/uninit.rs (91%)
 create mode 100644 rust/common/src/zeroable.rs
 create mode 120000 rust/hw/char/pl011/build.rs
 create mode 100644 rust/hw/char/pl011/src/bindings.rs
 create mode 100644 rust/hw/core/Cargo.toml
 create mode 120000 rust/hw/core/build.rs
 create mode 100644 rust/hw/core/meson.build
 create mode 100644 rust/hw/core/src/bindings.rs
 rename rust/{qemu-api => hw/core}/src/irq.rs (93%)
 create mode 100644 rust/hw/core/src/lib.rs
 rename rust/{qemu-api => hw/core}/src/qdev.rs (82%)
 rename rust/{qemu-api => hw/core}/src/sysbus.rs (90%)
 rename rust/{qemu-api => hw/core}/tests/tests.rs (78%)
 create mode 100644 rust/migration/Cargo.toml
 create mode 120000 rust/migration/build.rs
 create mode 100644 rust/migration/meson.build
 create mode 100644 rust/migration/src/bindings.rs
 create mode 100644 rust/migration/src/lib.rs
 rename rust/{qemu-api => migration}/src/vmstate.rs (61%)
 delete mode 100644 rust/qemu-api/.gitignore
 delete mode 100644 rust/qemu-api/README.md
 delete mode 100644 rust/qemu-api/meson.build
 delete mode 100644 rust/qemu-api/src/lib.rs
 delete mode 100644 rust/qemu-api/src/prelude.rs
 delete mode 100644 rust/qemu-api/src/zeroable.rs
 rename rust/{qemu-api-macros => qemu-macros}/Cargo.toml (94%)
 rename rust/{qemu-api-macros => qemu-macros}/meson.build (63%)
 rename rust/{qemu-api-macros => qemu-macros}/src/bits.rs (100%)
 rename rust/{qemu-api-macros => qemu-macros}/src/lib.rs (54%)
 rename rust/{qemu-api-macros => qemu-macros}/src/tests.rs (50%)
 create mode 100644 rust/qom/Cargo.toml
 create mode 120000 rust/qom/build.rs
 create mode 100644 rust/qom/meson.build
 create mode 100644 rust/qom/src/bindings.rs
 create mode 100644 rust/qom/src/lib.rs
 create mode 100644 rust/qom/src/prelude.rs
 rename rust/{qemu-api => qom}/src/qom.rs (97%)
 create mode 100644 rust/system/Cargo.toml
 create mode 120000 rust/system/build.rs
 create mode 100644 rust/system/meson.build
 create mode 100644 rust/system/src/bindings.rs
 create mode 100644 rust/system/src/lib.rs
 rename rust/{qemu-api => system}/src/memory.rs (90%)
 create mode 100644 rust/tests/Cargo.toml
 create mode 100644 rust/tests/meson.build
 rename rust/{qemu-api => tests}/tests/vmstate_tests.rs (78%)
 rename rust/{qemu-api => util}/Cargo.toml (55%)
 rename rust/{qemu-api => util}/build.rs (81%)
 create mode 100644 rust/util/meson.build
 create mode 100644 rust/util/src/bindings.rs
 rename rust/{qemu-api => util}/src/error.rs (98%)
 create mode 100644 rust/util/src/lib.rs
 rename rust/{qemu-api => util}/src/log.rs (93%)
 rename rust/{qemu-api => util}/src/module.rs (97%)
 rename rust/{qemu-api => util}/src/timer.rs (91%)

-- 
2.51.0


Re: [PATCH 00/33] First Rust update for QEMU 10.2
Posted by Peter Maydell 2 weeks, 3 days ago
On Mon, 8 Sept 2025 at 11:53, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> This includes:
> - bumping MSRV to 1.83.0 to support const_refs_to_static
> - Zhao's safe, builder-based implementation of migration callbacks
> - Manos's qdev properties macro.  While bit-based properties are
>   not yet supported, that's a small change overall.
> - the Rust crate split from Marc-André
> - adding proc macro aliases in individual crates, also from Marc-André
>
> I'm still not convinced about having "bql" depend on "migration",
> but I am convinced by the crate split between "util" and "bql",
> so we can move the implementation of VMState from "bql" to
> "migration" later if needed.
>
> For the purpose of getting this in as an easy-to-use base for future
> development, I'm disabling CI from Debian and Ubuntu.  The plan is:
> - that Debian will require trixie to enable Rust usage
> - that Ubuntu will backport 1.83 to its 22.04 and 24.04 versions
>   (https://bugs.launchpad.net/ubuntu/+source/rustc-1.83/+bug/2120318)
> - that Marc-André or someone else will add Rust to other CI jobs

How far into the future does moving to 1.83.0 push our
"we can enable rust and make it mandatory" point? I was
hoping we would be able to do that sometime soon but this
sounds like we're going to be still a long way out from that :-(

-- PMM
Re: [PATCH 00/33] First Rust update for QEMU 10.2
Posted by Paolo Bonzini 1 week, 6 days ago
On 9/11/25 12:04, Peter Maydell wrote:
> On Mon, 8 Sept 2025 at 11:53, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> This includes:
>> - bumping MSRV to 1.83.0 to support const_refs_to_static
>> - Zhao's safe, builder-based implementation of migration callbacks
>> - Manos's qdev properties macro.  While bit-based properties are
>>    not yet supported, that's a small change overall.
>> - the Rust crate split from Marc-André
>> - adding proc macro aliases in individual crates, also from Marc-André
>>
>> I'm still not convinced about having "bql" depend on "migration",
>> but I am convinced by the crate split between "util" and "bql",
>> so we can move the implementation of VMState from "bql" to
>> "migration" later if needed.
>>
>> For the purpose of getting this in as an easy-to-use base for future
>> development, I'm disabling CI from Debian and Ubuntu.  The plan is:
>> - that Debian will require trixie to enable Rust usage
>> - that Ubuntu will backport 1.83 to its 22.04 and 24.04 versions
>>    (https://bugs.launchpad.net/ubuntu/+source/rustc-1.83/+bug/2120318)
>> - that Marc-André or someone else will add Rust to other CI jobs
> 
> How far into the future does moving to 1.83.0 push our
> "we can enable rust and make it mandatory" point? I was
> hoping we would be able to do that sometime soon but this
> sounds like we're going to be still a long way out from that :-(
Sorry for not seeing the question, the good news is that it doesn't push 
it by much, if at all.  Debian bookworm has even updated rustc-web last 
month to 1.85.0 (say thanks to Firefox), so the only remaining straggler 
is Ubuntu and they're working on it.

As far as technical blockers go, Marc-André has a couple fixes pending 
in Meson, and of course tracing support is still in flight.  But we 
could enable it for 10.2 in CI and 11.0 in configure.

The bad news is that enabling Rust by default is a bit like a point of 
no return and, in that respect, other factors may matter more than 
distro support:

* Community support: it's a lot of new code to deal with, and we're not 
Linux.

* What's the killer app: DMA support may take a bit longer, so right now 
Rust is limited to very simple devices for which memory safety is not a 
primary issue.  Could it be BQL-free interrupts, where even simpler 
devices like interrupt controllers could benefit from a more picky compiler?

* Dependency on Meson work: this is something that Zhao and I didn't 
have time to go through, but right now adding a Rust device is *a lot* 
more verbose than adding the corresponding Rust device.  For day to day 
work it's not a huge deal, as the verbosity is a minor issue while we 
have a handful of Rust devices.  Furthermore, I have plans to improve 
Meson in that respect, so that it understands more of the Rust 
conventions, and we've already structured a lot of the Rust code with an 
eye towards those future versions of Meson.  The problem is that for the 
most part of 2026 we'll be bumping the minimum supported *Meson* version 
relatively quickly.  Right now we only bump it for --enable-rust, but 
the picture changes if Rust is enabled by default or even hard-required.

Let's talk about it on the community call, since we didn't make it at 
QEMU Summit.

Paolo


Re: [PATCH 00/33] First Rust update for QEMU 10.2
Posted by Daniel P. Berrangé 1 week, 5 days ago
On Mon, Sep 15, 2025 at 04:27:47PM +0200, Paolo Bonzini wrote:
> On 9/11/25 12:04, Peter Maydell wrote:
> > On Mon, 8 Sept 2025 at 11:53, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > > 
> > > This includes:
> > > - bumping MSRV to 1.83.0 to support const_refs_to_static
> > > - Zhao's safe, builder-based implementation of migration callbacks
> > > - Manos's qdev properties macro.  While bit-based properties are
> > >    not yet supported, that's a small change overall.
> > > - the Rust crate split from Marc-André
> > > - adding proc macro aliases in individual crates, also from Marc-André
> > > 
> > > I'm still not convinced about having "bql" depend on "migration",
> > > but I am convinced by the crate split between "util" and "bql",
> > > so we can move the implementation of VMState from "bql" to
> > > "migration" later if needed.
> > > 
> > > For the purpose of getting this in as an easy-to-use base for future
> > > development, I'm disabling CI from Debian and Ubuntu.  The plan is:
> > > - that Debian will require trixie to enable Rust usage
> > > - that Ubuntu will backport 1.83 to its 22.04 and 24.04 versions
> > >    (https://bugs.launchpad.net/ubuntu/+source/rustc-1.83/+bug/2120318)
> > > - that Marc-André or someone else will add Rust to other CI jobs
> > 
> > How far into the future does moving to 1.83.0 push our
> > "we can enable rust and make it mandatory" point? I was
> > hoping we would be able to do that sometime soon but this
> > sounds like we're going to be still a long way out from that :-(
> Sorry for not seeing the question, the good news is that it doesn't push it
> by much, if at all.  Debian bookworm has even updated rustc-web last month
> to 1.85.0 (say thanks to Firefox), so the only remaining straggler is Ubuntu
> and they're working on it.
> 
> As far as technical blockers go, Marc-André has a couple fixes pending in
> Meson, and of course tracing support is still in flight.  But we could
> enable it for 10.2 in CI and 11.0 in configure.
> 
> The bad news is that enabling Rust by default is a bit like a point of no
> return and, in that respect, other factors may matter more than distro
> support:
> 
> * Community support: it's a lot of new code to deal with, and we're not
> Linux.

That is true, but we're already seeing alot of stuff that is directly
adjacent to QEMU that is written in Rust, with some overlaps amongst
contributors. Coconut SVSM, IGVM, Rust VMM, virtiofsd, libbkio, and
more besides.

So if we consider community as "open source virtualization devs" it
looks like there is a reasonable pool of talent with experience that
can cross-pollinate with QEMU.

> * What's the killer app: DMA support may take a bit longer, so right now
> Rust is limited to very simple devices for which memory safety is not a
> primary issue.  Could it be BQL-free interrupts, where even simpler devices
> like interrupt controllers could benefit from a more picky compiler?

I suggest we don't try to over-think this too much, as it'll become
a bit of a chicken and egg problem.

IMHO initial ideas for Rust usage will inevitable be fairly simple,
as that's part of the learning process for all of us, avoiding trying
to bite off too much too quickly. As a result, the initial work will
not look very compelling The more worthwhile and substantial things
will only arrive once use of Rust in QEMU has had time to marinate,
and at least some of them will be things we can't thing of ahead of
time.

   "if you build it, they will come"

Even if QEMU doesn't mandate Rust directly, Rust is already a part of
QEMU indirectly, so on the distro front the point of no return is
pretty much already here unless you want to cut out an increasing
number of interesting features.

eg we see ourselves integrating with libblkio, and igvm, both of which
we do via C shims around the Rust code. There are more of such things
to come - a Rust impl of the EDK vars storage is probable, there are
virtee crates for dealing with low level SEV pieces that have been
proposed before and seem interesting.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH 00/33] First Rust update for QEMU 10.2
Posted by Marc-André Lureau 2 weeks, 3 days ago
Hi

On Thu, Sep 11, 2025 at 2:05 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 8 Sept 2025 at 11:53, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > This includes:
> > - bumping MSRV to 1.83.0 to support const_refs_to_static
> > - Zhao's safe, builder-based implementation of migration callbacks
> > - Manos's qdev properties macro.  While bit-based properties are
> >   not yet supported, that's a small change overall.
> > - the Rust crate split from Marc-André
> > - adding proc macro aliases in individual crates, also from Marc-André
> >
> > I'm still not convinced about having "bql" depend on "migration",
> > but I am convinced by the crate split between "util" and "bql",
> > so we can move the implementation of VMState from "bql" to
> > "migration" later if needed.
> >
> > For the purpose of getting this in as an easy-to-use base for future
> > development, I'm disabling CI from Debian and Ubuntu.  The plan is:
> > - that Debian will require trixie to enable Rust usage
> > - that Ubuntu will backport 1.83 to its 22.04 and 24.04 versions
> >   (https://bugs.launchpad.net/ubuntu/+source/rustc-1.83/+bug/2120318)
> > - that Marc-André or someone else will add Rust to other CI jobs
>
> How far into the future does moving to 1.83.0 push our
> "we can enable rust and make it mandatory" point? I was
> hoping we would be able to do that sometime soon but this
> sounds like we're going to be still a long way out from that :-(

I suppose most distro will want to backport a newer rust in their
stable distro, like ubuntu is doing or debian with rustc-web. With
that, it shouldn't be too long before we could make Rust required.

fwiw, I am working on a series to enable Rust on our various
CI/docker/vm. I am mostly left with issues from windows and macos ..
(btw, if someone can help me investigate the linking issue on mac
https://gitlab.com/marcandre.lureau/qemu/-/jobs/11301499123, perhaps a
temporary ssh somewhere?)


--
Marc-André Lureau
Re: [PATCH 00/33] First Rust update for QEMU 10.2
Posted by Zhao Liu 2 weeks, 2 days ago
On Thu, Sep 11, 2025 at 03:18:44PM +0400, Marc-André Lureau wrote:
> Date: Thu, 11 Sep 2025 15:18:44 +0400
> From: Marc-André Lureau <marcandre.lureau@gmail.com>
> Subject: Re: [PATCH 00/33] First Rust update for QEMU 10.2
> 
> Hi
> 
> On Thu, Sep 11, 2025 at 2:05 PM Peter Maydell <peter.maydell@linaro.org> wrote:
> >
> > On Mon, 8 Sept 2025 at 11:53, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > >
> > > This includes:
> > > - bumping MSRV to 1.83.0 to support const_refs_to_static
> > > - Zhao's safe, builder-based implementation of migration callbacks
> > > - Manos's qdev properties macro.  While bit-based properties are
> > >   not yet supported, that's a small change overall.
> > > - the Rust crate split from Marc-André
> > > - adding proc macro aliases in individual crates, also from Marc-André
> > >
> > > I'm still not convinced about having "bql" depend on "migration",
> > > but I am convinced by the crate split between "util" and "bql",
> > > so we can move the implementation of VMState from "bql" to
> > > "migration" later if needed.
> > >
> > > For the purpose of getting this in as an easy-to-use base for future
> > > development, I'm disabling CI from Debian and Ubuntu.  The plan is:
> > > - that Debian will require trixie to enable Rust usage
> > > - that Ubuntu will backport 1.83 to its 22.04 and 24.04 versions
> > >   (https://bugs.launchpad.net/ubuntu/+source/rustc-1.83/+bug/2120318)
> > > - that Marc-André or someone else will add Rust to other CI jobs
> >
> > How far into the future does moving to 1.83.0 push our
> > "we can enable rust and make it mandatory" point? I was
> > hoping we would be able to do that sometime soon but this
> > sounds like we're going to be still a long way out from that :-(
> 
> I suppose most distro will want to backport a newer rust in their
> stable distro, like ubuntu is doing or debian with rustc-web. With
> that, it shouldn't be too long before we could make Rust required.
> 
> fwiw, I am working on a series to enable Rust on our various
> CI/docker/vm. I am mostly left with issues from windows and macos ..
> (btw, if someone can help me investigate the linking issue on mac
> https://gitlab.com/marcandre.lureau/qemu/-/jobs/11301499123, perhaps a
> temporary ssh somewhere?)

Just a guess...

It seems "-llibqemuutil.a" may tell the linker to search for
liblibqemuutil.a.dylib or liblibqemuutil.a.a [*] :-(

[*]: https://manp.gs/mac/1/ld#l

-Zhao


Re: [PATCH 00/33] First Rust update for QEMU 10.2
Posted by Marc-André Lureau 2 weeks, 2 days ago
Hi Zhao

On Fri, Sep 12, 2025 at 11:20 AM Zhao Liu <zhao1.liu@intel.com> wrote:
>
> On Thu, Sep 11, 2025 at 03:18:44PM +0400, Marc-André Lureau wrote:
> > Date: Thu, 11 Sep 2025 15:18:44 +0400
> > From: Marc-André Lureau <marcandre.lureau@gmail.com>
> > Subject: Re: [PATCH 00/33] First Rust update for QEMU 10.2
> >
> > Hi
> >
> > On Thu, Sep 11, 2025 at 2:05 PM Peter Maydell <peter.maydell@linaro.org> wrote:
> > >
> > > On Mon, 8 Sept 2025 at 11:53, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > > >
> > > > This includes:
> > > > - bumping MSRV to 1.83.0 to support const_refs_to_static
> > > > - Zhao's safe, builder-based implementation of migration callbacks
> > > > - Manos's qdev properties macro.  While bit-based properties are
> > > >   not yet supported, that's a small change overall.
> > > > - the Rust crate split from Marc-André
> > > > - adding proc macro aliases in individual crates, also from Marc-André
> > > >
> > > > I'm still not convinced about having "bql" depend on "migration",
> > > > but I am convinced by the crate split between "util" and "bql",
> > > > so we can move the implementation of VMState from "bql" to
> > > > "migration" later if needed.
> > > >
> > > > For the purpose of getting this in as an easy-to-use base for future
> > > > development, I'm disabling CI from Debian and Ubuntu.  The plan is:
> > > > - that Debian will require trixie to enable Rust usage
> > > > - that Ubuntu will backport 1.83 to its 22.04 and 24.04 versions
> > > >   (https://bugs.launchpad.net/ubuntu/+source/rustc-1.83/+bug/2120318)
> > > > - that Marc-André or someone else will add Rust to other CI jobs
> > >
> > > How far into the future does moving to 1.83.0 push our
> > > "we can enable rust and make it mandatory" point? I was
> > > hoping we would be able to do that sometime soon but this
> > > sounds like we're going to be still a long way out from that :-(
> >
> > I suppose most distro will want to backport a newer rust in their
> > stable distro, like ubuntu is doing or debian with rustc-web. With
> > that, it shouldn't be too long before we could make Rust required.
> >
> > fwiw, I am working on a series to enable Rust on our various
> > CI/docker/vm. I am mostly left with issues from windows and macos ..
> > (btw, if someone can help me investigate the linking issue on mac
> > https://gitlab.com/marcandre.lureau/qemu/-/jobs/11301499123, perhaps a
> > temporary ssh somewhere?)
>
> Just a guess...
>
> It seems "-llibqemuutil.a" may tell the linker to search for
> liblibqemuutil.a.dylib or liblibqemuutil.a.a [*] :-(
>
> [*]: https://manp.gs/mac/1/ld#l

Good guess, the trouble seems to be the usage of -lstatic:+verbatim in meson:

https://github.com/mesonbuild/meson/issues/15020

-- 
Marc-André Lureau