[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 04/12] rust: qdev: add clock creation
From: |
Zhao Liu |
Subject: |
Re: [PATCH 04/12] rust: qdev: add clock creation |
Date: |
Mon, 10 Feb 2025 22:40:23 +0800 |
On Fri, Feb 07, 2025 at 11:16:15AM +0100, Paolo Bonzini wrote:
> Date: Fri, 7 Feb 2025 11:16:15 +0100
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH 04/12] rust: qdev: add clock creation
> X-Mailer: git-send-email 2.48.1
>
> Add a Rust version of qdev_init_clock_in, which can be used in
> instance_init. There are a couple differences with the C
> version:
>
> - in Rust the object keeps its own reference to the clock (in addition to
> the one embedded in the NamedClockList), and the reference is dropped
> automatically by instance_finalize(); this is encoded in the signature
> of DeviceClassMethods::init_clock_in, which makes the lifetime of the
> clock independent of that of the object it holds. This goes unnoticed
> in the C version and is due to the existence of aliases.
>
> - also, anything that happens during instance_init uses the pinned_init
> framework to operate on a partially initialized object, and is done
> through class methods (i.e. through DeviceClassMethods rather than
> DeviceMethods) because the device does not exist yet. Therefore, Rust
> code *must* create clocks from instance_init, which is stricter than C.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> rust/hw/char/pl011/src/device.rs | 43 +++++-------
> rust/qemu-api/src/prelude.rs | 2 +
> rust/qemu-api/src/qdev.rs | 109 ++++++++++++++++++++++++++++++-
> rust/qemu-api/src/vmstate.rs | 4 +-
> 4 files changed, 127 insertions(+), 31 deletions(-)
>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
- [PATCH 00/12] rust: remaining parts of qdev bindings, Paolo Bonzini, 2025/02/07
- [PATCH 02/12] rust: qom: add object creation functionality, Paolo Bonzini, 2025/02/07
- [PATCH 04/12] rust: qdev: add clock creation, Paolo Bonzini, 2025/02/07
- Re: [PATCH 04/12] rust: qdev: add clock creation,
Zhao Liu <=
- [PATCH 01/12] rust: qom: add reference counting functionality, Paolo Bonzini, 2025/02/07
- [PATCH 03/12] rust: callbacks: allow passing optional callbacks as (), Paolo Bonzini, 2025/02/07
- [PATCH 07/12] rust: qdev: switch from legacy reset to Resettable, Paolo Bonzini, 2025/02/07
- [PATCH 05/12] rust: qom: allow initializing interface vtables, Paolo Bonzini, 2025/02/07
- [PATCH 06/12] rust: qdev: make ObjectImpl a supertrait of DeviceImpl, Paolo Bonzini, 2025/02/07
- [PATCH 10/12] rust: irq: define ObjectType for IRQState, Paolo Bonzini, 2025/02/07