qemu/rust
Paolo Bonzini b4ff3cf34f rust: qemu-api: add bindings to Error
Provide an implementation of std::error::Error that bridges the Rust
anyhow::Error and std::panic::Location types with QEMU's Error*.

It also has several utility methods, analogous to error_propagate(),
that convert a Result into a return value + Error** pair.  One important
difference is that these propagation methods *panic* if *errp is NULL,
unlike error_propagate() which eats subsequent errors[1].  The reason
for this is that in C you have an error_set*() call at the site where
the error is created, and calls to error_propagate() are relatively rare.

In Rust instead, even though these functions do "propagate" a
qemu_api::Error into a C Error**, there is no error_setg() anywhere that
could check for non-NULL errp and call abort().  error_propagate()'s
behavior of ignoring subsequent errors is generally considered weird,
and there would be a bigger risk of triggering it from Rust code.

[1] This is actually a violation of the preconditions of error_propagate(),
    so it should not happen.  But you never know...

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-06-05 20:24:51 +02:00
..
bits rust: add "bits", a custom bitflags implementation 2025-06-03 22:44:40 +02:00
hw rust: pl011: use the bits macro 2025-06-03 22:44:40 +02:00
qemu-api rust: qemu-api: add bindings to Error 2025-06-05 20:24:51 +02:00
qemu-api-macros rust: qemu-api-macros: add from_bits and into_bits to #[derive(TryInto)] 2025-06-03 22:44:40 +02:00
.gitignore rust: add bindgen step as a meson dependency 2024-10-11 12:32:17 +02:00
Cargo.lock rust: qemu-api: add bindings to Error 2025-06-05 20:24:51 +02:00
Cargo.toml rust: qemu-api: add bindings to Error 2025-06-05 20:24:51 +02:00
Kconfig rust: add PL011 device model 2024-11-05 14:18:15 +01:00
meson.build subprojects: add the foreign crate 2025-06-05 20:24:51 +02:00
rustfmt.toml rust: add crate to expose bindings and interfaces 2024-10-11 12:32:17 +02:00
wrapper.h util/error: expose Error definition to Rust code 2025-06-05 20:24:51 +02:00