qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] rust: bindings for Error
@ 2025-05-26 14:22 Paolo Bonzini
  2025-05-26 14:24 ` [PATCH 01/12] rust: make declaration of dependent crates more consistent Paolo Bonzini
                   ` (11 more replies)
  0 siblings, 12 replies; 32+ messages in thread
From: Paolo Bonzini @ 2025-05-26 14:22 UTC (permalink / raw)
  To: qemu-devel

This was one of the first bindings that I wrote in
https://lore.kernel.org/qemu-devel/20240701145853.1394967-1-pbonzini@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



^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2025-05-29  8:58 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-26 14:22 [PATCH 00/12] rust: bindings for Error Paolo Bonzini
2025-05-26 14:24 ` [PATCH 01/12] rust: make declaration of dependent crates more consistent Paolo Bonzini
2025-05-27  9:35   ` Zhao Liu
2025-05-26 14:24 ` [PATCH 02/12] subprojects: add the anyhow crate Paolo Bonzini
2025-05-27  9:45   ` Zhao Liu
2025-05-27  9:52     ` Paolo Bonzini
2025-05-26 14:24 ` [PATCH 03/12] subprojects: add the foreign crate Paolo Bonzini
2025-05-29  8:13   ` Zhao Liu
2025-05-26 14:24 ` [PATCH 04/12] util/error: expose Error definition to Rust code Paolo Bonzini
2025-05-27 13:33   ` Markus Armbruster
2025-05-26 14:24 ` [PATCH 05/12] util/error: allow non-NUL-terminated err->src Paolo Bonzini
2025-05-27 13:42   ` Markus Armbruster
2025-05-27 14:34     ` Paolo Bonzini
2025-05-28 10:44       ` Markus Armbruster
2025-05-26 14:24 ` [PATCH 06/12] util/error: make func optional Paolo Bonzini
2025-05-28  8:20   ` Zhao Liu
2025-05-26 14:24 ` [PATCH 07/12] qemu-api: add bindings to Error Paolo Bonzini
2025-05-28  9:49   ` Markus Armbruster
2025-05-28 10:45     ` Paolo Bonzini
2025-05-28 13:12       ` Markus Armbruster
2025-05-26 14:24 ` [PATCH 08/12] rust: qdev: support returning errors from realize Paolo Bonzini
2025-05-29  9:18   ` Zhao Liu
2025-05-26 14:24 ` [PATCH 09/12] rust/hpet: change timer of num_timers to usize Paolo Bonzini
2025-05-29  9:11   ` Zhao Liu
2025-05-26 14:24 ` [PATCH 10/12] hpet: return errors from realize if properties are incorrect Paolo Bonzini
2025-05-27 14:01   ` Markus Armbruster
2025-05-29  8:39   ` Zhao Liu
2025-05-26 14:24 ` [PATCH 11/12] rust/hpet: " Paolo Bonzini
2025-05-29  9:15   ` Zhao Liu
2025-05-29  8:56     ` Paolo Bonzini
2025-05-26 14:24 ` [PATCH 12/12] rust/hpet: Drop BqlCell wrapper for num_timers Paolo Bonzini
2025-05-29  9:17   ` Zhao Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).