qemu/rust/qemu-api/Cargo.toml
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

28 lines
551 B
TOML

[package]
name = "qemu_api"
version = "0.1.0"
authors = ["Manos Pitsidianakis <manos.pitsidianakis@linaro.org>"]
description = "Rust bindings for QEMU"
readme = "README.md"
resolver = "2"
publish = false
edition.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
[dependencies]
qemu_api_macros = { path = "../qemu-api-macros" }
anyhow = "~1.0"
libc = "0.2.162"
foreign = "~0.3.1"
[features]
default = ["debug_cell"]
allocator = []
debug_cell = []
[lints]
workspace = true