This was one of the first bindings that I wrote in
https://lore.kernel.org/qemu-devel/20240701145853.1394967-1-pbonz...@redhat.com/T/,
but there were a few obstacles to clear before including them:

1) cleaning up the *foreign*() functions (patches 3-4 from the above
series) or deciding not to use them.  The functions are now part of
their own crate, available on crates.io and imported in this series.
For this series I am including them, but if people prefer to stick
to "normal" Rust FFI I'm open to that as well.

2) cleaning up the "cause" member.  This series uses the anyhow
crate instead of Box<dyn std::error::Error>.

3) cleaning up &error_abort, because Rust does not have a NULL-terminated
filename and does not have an equivalent to __func__ at all.  The
preliminary code did not pass file and line at all, while now I am
using #[track_caller] and making the C code collaborate with Rust
(see patches 5-6 of the series).

The final driver for fixing all this was to enable the removal
of BqlCell<> from HPETState::num_timers.

Integration tests for the new class are still missing.

Markus... this is your first exposure to Rust in QEMU.  You may find some
information at https://www.qemu.org/docs/master/devel/rust.html but just
to be clear, there are no stupid questions, only stupid answers. :)

Paolo

Paolo Bonzini (12):
  rust: make declaration of dependent crates more consistent
  subprojects: add the anyhow crate
  subprojects: add the foreign crate
  util/error: expose Error definition to Rust code
  util/error: allow non-NUL-terminated err->src
  util/error: make func optional
  qemu-api: add bindings to Error
  rust: qdev: support returning errors from realize
  rust/hpet: change timer of num_timers to usize
  hpet: return errors from realize if properties are incorrect
  rust/hpet: return errors from realize if properties are incorrect

Zhao Liu (12):
  rust/hpet: Drop BqlCell wrapper for num_timers

 include/qapi/error-internal.h                 |  27 ++
 rust/wrapper.h                                |   1 +
 hw/timer/hpet.c                               |  15 +-
 util/error.c                                  |  24 +-
 rust/Cargo.lock                               |  17 ++
 rust/Cargo.toml                               |   1 +
 rust/hw/char/pl011/meson.build                |  12 +-
 rust/hw/char/pl011/src/device.rs              |   5 +-
 rust/hw/timer/hpet/src/fw_cfg.rs              |   7 +-
 rust/hw/timer/hpet/src/hpet.rs                |  62 ++--
 rust/meson.build                              |  20 ++
 rust/qemu-api-macros/meson.build              |  14 +-
 rust/qemu-api/Cargo.toml                      |   2 +
 rust/qemu-api/meson.build                     |   5 +-
 rust/qemu-api/src/error.rs                    | 273 ++++++++++++++++++
 rust/qemu-api/src/lib.rs                      |   3 +
 rust/qemu-api/src/qdev.rs                     |  10 +-
 subprojects/.gitignore                        |   2 +
 subprojects/anyhow-1.0-rs.wrap                |   7 +
 subprojects/foreign-0.2-rs.wrap               |   7 +
 .../packagefiles/anyhow-1.0-rs/meson.build    |  33 +++
 .../packagefiles/foreign-0.2-rs/meson.build   |  26 ++
 22 files changed, 488 insertions(+), 85 deletions(-)
 create mode 100644 include/qapi/error-internal.h
 create mode 100644 rust/qemu-api/src/error.rs
 create mode 100644 subprojects/anyhow-1.0-rs.wrap
 create mode 100644 subprojects/foreign-0.2-rs.wrap
 create mode 100644 subprojects/packagefiles/anyhow-1.0-rs/meson.build
 create mode 100644 subprojects/packagefiles/foreign-0.2-rs/meson.build

-- 
2.49.0


Reply via email to