[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side
From: |
Zhao Liu |
Subject: |
Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side |
Date: |
Tue, 17 Dec 2024 11:58:06 +0800 |
> +impl ClassInitImpl<PL011Class> for PL011State {
> + fn class_init(klass: &mut PL011Class) {
> + klass.device_id = DeviceId::ARM;
> + <Self as ClassInitImpl<SysBusDeviceClass>>::class_init(&mut
> klass.parent_class);
This seems a bit of a conflict with the C version of QOM semantics. In C,
class_init is registered in TypeInfo, and then the QOM code will
automatically call the parent's class_init without needing to explicitly
call the parent's in the child's class_init.
However, SysBusDevice (and Device) is a bit different. Its TypeInfo is
registered on the C side, and the class_init method on the Rust side is not
actually a real QOM class_init (because it is not registered on the Rust
side).
Therefore, the call here seems valid from the code logic's perspective.
But, when there is deeper class inheritance, it seems impossible to
prevent class_init from being called both by the C side's QOM code and by
this kind of recursive case on the Rust side.
So, for devices like SysBusDevice that are registered on the C side,
should we not implement class_init and also not call it explicitly?
Or should we distinguish between two different usages of class_init? One
is registered in TypeInfo (only as a callback in rust_class_init) - perhaps
rename it as qom_class_init, and the other is used as a helper for Rust-side
calls (similar to the recursive usage here) - maybe rename it as
class_inter_init.
> + }
> +}
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, (continued)
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Paolo Bonzini, 2024/12/10
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/11
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Paolo Bonzini, 2024/12/11
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/11
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Paolo Bonzini, 2024/12/12
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/13
Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/10
[PATCH 15/26] rust: qom: split ObjectType from ObjectImpl trait, Paolo Bonzini, 2024/12/09
[PATCH 24/26] rust: qom: move device_id to PL011 class side, Paolo Bonzini, 2024/12/09
- Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side,
Zhao Liu <=
- Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Paolo Bonzini, 2024/12/17
- Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Zhao Liu, 2024/12/18
- Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Paolo Bonzini, 2024/12/18
- Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Paolo Bonzini, 2024/12/18
- Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Zhao Liu, 2024/12/18
- Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Paolo Bonzini, 2024/12/18
Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Zhao Liu, 2024/12/18
Re: [PATCH 24/26] rust: qom: move device_id to PL011 class side, Zhao Liu, 2024/12/18
[PATCH 26/26] rust: callbacks: allow passing optional callbacks as (), Paolo Bonzini, 2024/12/09