From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: zhao1.liu@intel.com, kwolf@redhat.com
Subject: [PATCH v3 0/2] rust: add module to convert between success/-errno and io::Result conventions
Date: Thu, 20 Feb 2025 12:36:57 +0100 [thread overview]
Message-ID: <20250220113659.863332-1-pbonzini@redhat.com> (raw)
Wrap access to errno, for use in the block layer and character device
bindings.
This first version of errno.rs focuses on io::Result. Kevin
suggested allowing conversion from io::Error to negative errno.
For now, I'd rather avoid that to encourage separation between code
that can propagate errors simply with "?", and code at the Rust/C
boundary that needs errno::into_neg_errno(). Since Rust code rarely
passes or returns Error objects that aren't part of a Result, it is
plausible that the same is true of QEMU.
However, if this turns out to be wrong, then it can be changed.
Paolo
Supersedes: <20250212093958.3703269-1-pbonzini@redhat.com>
v2->v3:
- add libc to subprojects/.gitignore
- change subject to reflect the focus to be Result rather than Error
- fix docs
v1->v2:
- use the libc crate
- provide separate From<Errno> implementation for io::ErrorKind
- hide GetErrno trait inside a submodule
- add into_neg_errno() and corresponding tests
- add more doctests
- make Errno field public, so that Errno can have other From<...>
implementations (e.g. going from *mut Error to Errno).
Paolo Bonzini (2):
rust: subprojects: add libc crate
rust: add module to convert between success/-errno and io::Result
docs/devel/rust.rst | 1 +
rust/Cargo.lock | 7 +
rust/qemu-api/Cargo.toml | 1 +
rust/qemu-api/meson.build | 4 +
rust/qemu-api/src/assertions.rs | 28 ++
rust/qemu-api/src/errno.rs | 343 ++++++++++++++++++
rust/qemu-api/src/lib.rs | 1 +
rust/qemu-api/src/prelude.rs | 2 +
scripts/archive-source.sh | 2 +-
scripts/make-release | 2 +-
subprojects/.gitignore | 1 +
subprojects/libc-0.2-rs.wrap | 7 +
.../packagefiles/libc-0.2-rs/meson.build | 37 ++
13 files changed, 434 insertions(+), 2 deletions(-)
create mode 100644 rust/qemu-api/src/errno.rs
create mode 100644 subprojects/libc-0.2-rs.wrap
create mode 100644 subprojects/packagefiles/libc-0.2-rs/meson.build
--
2.48.1
next reply other threads:[~2025-02-20 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 11:36 Paolo Bonzini [this message]
2025-02-20 11:36 ` [PATCH v3 1/2] rust: subprojects: add libc crate Paolo Bonzini
2025-02-20 11:36 ` [PATCH v3 2/2] rust: add module to convert between success/-errno and io::Result Paolo Bonzini
2025-02-21 11:01 ` Zhao Liu
2025-02-25 13:21 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250220113659.863332-1-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).