RustInQemu: Difference between revisions

From QEMU
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
== Active effort ==
== Active effort ==


* [[ChangeLog/10.0#Rust|Current state]]
* [https://lore.kernel.org/qemu-devel/d3d1944e-2482-4aa7-b621-596246a08107@gnu.org/ Current state]
* [https://www.qemu.org/docs/master/devel/rust.html Documentation]
* [https://www.qemu.org/docs/master/devel/rust.html Documentation]
* Roadmap: [https://lore.kernel.org/qemu-devel/d3d1944e-2482-4aa7-b621-596246a08107@gnu.org/ April 2025] | [https://lore.kernel.org/qemu-devel/17ad81c3-98fc-44c2-8f65-f5e2cc07030b@gnu.org/ January 2025] |  [https://lore.kernel.org/all/cc40943e-dec1-4890-a1d9-579350ce296f@pbonzini.local/ November 2024]
* Past updates: [https://lore.kernel.org/qemu-devel/17ad81c3-98fc-44c2-8f65-f5e2cc07030b@gnu.org/ January 2025] |  [https://lore.kernel.org/all/cc40943e-dec1-4890-a1d9-579350ce296f@pbonzini.local/ November 2024]
 


== Past efforts ==
== Past efforts ==
Line 15: Line 14:
== Work in progress ==
== Work in progress ==
=== Paolo ===
=== Paolo ===
* Waiting for Meson 1.8.1: "objects:", rustdoc,
* Improving Cargo support in Meson
* Later: pinned_init... maybe use MaybeUninit as a first step?


=== Manos ===
=== Manos ===
* generate qdev properties via macros
=== Zhao ===
=== Zhao ===
* vm-memory?


=== Kevin ===
=== Kevin ===
Line 30: Line 31:


== Possible project targets ==
== Possible project targets ==
=== Projects with some code ===
* visitors/QOM properties, could be interesting for <code>hw/sensor/tmp105.c</code>...
** https://lore.kernel.org/qemu-devel/20250605101124.367270-1-pbonzini@redhat.com/
* complete vmstate bindings (needs const_refs_static in Rust 1.83.0, Zhao+Paolo have a prototype)
** https://lore.kernel.org/qemu-devel/20250505100854.73936-1-pbonzini@redhat.com/
=== Cleanups ===
* split qemu_api into multiple crates


=== Nice things to have ===
=== Nice things to have ===
Line 36: Line 46:
** Run code checks a la "meson test --suite codecheck"? (clippy and rustfmt)
** Run code checks a la "meson test --suite codecheck"? (clippy and rustfmt)
* Place rustdoc output for master somewhere?
* Place rustdoc output for master somewhere?
* split qemu_api into multiple crates
* distros need dynamically linked libstd
* distros need dynamically linked libstd
** rewrite all main()s in Rust and use [https://github.com/mesonbuild/meson/issues/14224 -C prefer-dynamic]?
** rewrite all main()s in Rust and use [https://github.com/mesonbuild/meson/issues/14224 -C prefer-dynamic]?
Line 46: Line 55:
** generate parts of TypeInfo?
** generate parts of TypeInfo?
** monomorphization of <tt>T: IsA&lt;Class&gt;</tt> to <tt>&T</tt> (like the momo crate)
** monomorphization of <tt>T: IsA&lt;Class&gt;</tt> to <tt>&T</tt> (like the momo crate)
* feature parity for pl011
* safe object creation with [https://docs.rs/pinned-init/ pinned_init, originating from Linux])
* safe object creation with [https://docs.rs/pinned-init/ pinned_init, originating from Linux])
* Generic Rust<->C interop, Error (https://github.com/bonzini/rust-qemu)
* DMA (investigate vm-memory?)
* DMA (investigate vm-memory?)
* Trace/log (Summer of Code)
** https://lore.kernel.org/qemu-devel/aCysct2L8Bosqy0N@intel.com/
* feature parity for pl011
** Trace/log (Summer of Code)


== Ideas for improved clippy coverage in CI? ==
=== Improved clippy coverage in CI? ===
* run clippy as part of "make check"
* run clippy as part of "make check"
* add to CI a fallible job that runs on nightly clippy with <tt>-Dclippy::complexity -Dclippy::perf -Dclippy::suspicious -Dclippy::style -Dunknown_lints</tt>. the job should generally pass, and if a new lint triggers it probably should be added to Cargo.toml as either "allow" (rare) or "deny" (possibly after adding #[allow()] to the source).
* add to CI a fallible job that runs on nightly clippy with <tt>-Dclippy::complexity -Dclippy::perf -Dclippy::suspicious -Dclippy::style -Dunknown_lints</tt>. the job should generally pass, and if a new lint triggers it probably should be added to Cargo.toml as either "allow" (rare) or "deny" (possibly after adding #[allow()] to the source).
Line 59: Line 68:


* <code>qemu-bridge-helper.c</code> Re-write SUID C executable with useful features.
* <code>qemu-bridge-helper.c</code> Re-write SUID C executable with useful features.
=== Bindings ===
* visitors/QOM properties, could be interesting for <code>hw/sensor/tmp105.c</code>...
* complete vmstate bindings (needs const_refs_static in Rust 1.83.0, Zhao+Paolo have a prototype)


=== Devices  ===
=== Devices  ===

Latest revision as of 13:35, 5 June 2025

For the old RustInQemu page, see RustInQemu/2022

Active effort

Past efforts

  • [RFC v3 00/32] Rust binding for QAPI and qemu-ga QMP handler examples
    on patchew on lore
  • Subject: [RFC 0/6] scripts: Rewrite simpletrace printer in Rust
    Date: Mon, 27 May 2024 16:14:15 +0800
    RFC v1

Work in progress

Paolo

  • Improving Cargo support in Meson

Manos

  • generate qdev properties via macros

Zhao

  • vm-memory?

Kevin

Bugs

Possible project targets

Projects with some code

Cleanups

  • split qemu_api into multiple crates

Nice things to have

  • Remove need for manual "meson subprojects update --reset" when updating packagefiles/
  • Improve tool integration
    • Run code checks a la "meson test --suite codecheck"? (clippy and rustfmt)
  • Place rustdoc output for master somewhere?
  • distros need dynamically linked libstd
    • rewrite all main()s in Rust and use -C prefer-dynamic?
    • or should Meson be able to link C programs with rlibs?

New code to write

Improved clippy coverage in CI?

  • run clippy as part of "make check"
  • add to CI a fallible job that runs on nightly clippy with -Dclippy::complexity -Dclippy::perf -Dclippy::suspicious -Dclippy::style -Dunknown_lints. the job should generally pass, and if a new lint triggers it probably should be added to Cargo.toml as either "allow" (rare) or "deny" (possibly after adding #[allow()] to the source).

Miscellanea

  • qemu-bridge-helper.c Re-write SUID C executable with useful features.

Devices

  • hw/block/pflash_cfi01.c, hw/block/pflash_cfi02.c (claimed, WIP)
    • needs block bindings
  • hw/timer/i8254.c (claimed, WIP)
  • hw/mem/nvdimm.c (suggested by Manos)