From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [PATCH] rust: pl011: convert pl011_create to safe Rust
Date: Mon, 10 Feb 2025 17:59:29 +0800 [thread overview]
Message-ID: <Z6nOAftJsjQ7KAiS@intel.com> (raw)
In-Reply-To: <20250206111514.2134895-2-pbonzini@redhat.com>
On Thu, Feb 06, 2025 at 12:15:14PM +0100, Paolo Bonzini wrote:
> Date: Thu, 6 Feb 2025 12:15:14 +0100
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH] rust: pl011: convert pl011_create to safe Rust
> X-Mailer: git-send-email 2.48.1
>
> Not a major change but, as a small but significant step in creating
> qdev bindings, show how pl011_create can be written without "unsafe"
> calls (apart from converting pointers to references).
>
> This also provides a starting point for creating Error** bindings.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> rust/hw/char/pl011/src/device.rs | 39 ++++++++++++++++----------------
> rust/qemu-api/src/sysbus.rs | 34 +++++++++++++++++++++++++---
> 2 files changed, 50 insertions(+), 23 deletions(-)
...
> + fn realize(&self) {
What about renaming this as "realize_with_sysbus"?
Elsewhere, the device's own realize method is often used to set
DeviceImpl::REALIZE.
And this realize here is meant to call the realize() method defined on
the C side, so to avoid confusion we can avoid the same name? It's up to
you.
> + // TODO: return an Error
> + assert!(bql_locked());
> + unsafe {
> + bindings::sysbus_realize(self.as_mut_ptr(), addr_of_mut!(bindings::error_fatal));
> + }
> + }
This is a nice patch that shows more about how to use Owned<>!
(BTW, I guess this patch is not the stable material. :-) )
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
next prev parent reply other threads:[~2025-02-10 9:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 11:15 [PATCH] rust: add --rust-target option for bindgen Paolo Bonzini
2025-02-06 11:15 ` [PATCH] rust: pl011: convert pl011_create to safe Rust Paolo Bonzini
2025-02-10 9:59 ` Zhao Liu [this message]
2025-02-10 10:47 ` vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust) Paolo Bonzini
2025-02-11 5:21 ` Junjie Mao
2025-02-11 9:00 ` Paolo Bonzini
2025-02-11 10:31 ` Junjie Mao
2025-02-11 12:16 ` Junjie Mao
2025-02-11 12:27 ` Paolo Bonzini
2025-02-12 1:22 ` Junjie Mao
2025-02-06 11:37 ` [PATCH] rust: add --rust-target option for bindgen Philippe Mathieu-Daudé
2025-02-06 11:38 ` Paolo Bonzini
2025-02-06 11:43 ` Philippe Mathieu-Daudé
2025-02-08 14:03 ` Stefan Hajnoczi
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=Z6nOAftJsjQ7KAiS@intel.com \
--to=zhao1.liu@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
--cc=qemu-stable@nongnu.org \
/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).