[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] rust: pl011: convert pl011_create to safe Rust
From: |
Zhao Liu |
Subject: |
Re: [PATCH] rust: pl011: convert pl011_create to safe Rust |
Date: |
Mon, 10 Feb 2025 17:59:29 +0800 |
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>
- [PATCH] rust: add --rust-target option for bindgen, Paolo Bonzini, 2025/02/06
- [PATCH] rust: pl011: convert pl011_create to safe Rust, Paolo Bonzini, 2025/02/06
- Re: [PATCH] rust: pl011: convert pl011_create to safe Rust,
Zhao Liu <=
- vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Paolo Bonzini, 2025/02/10
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Paolo Bonzini, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Paolo Bonzini, 2025/02/11
- Re: vtables and procedural macros (was Re: [PATCH] rust: pl011: convert pl011_create to safe Rust), Junjie Mao, 2025/02/11
Re: [PATCH] rust: add --rust-target option for bindgen, Philippe Mathieu-Daudé, 2025/02/06