diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2025-02-12 11:49:32 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-02-25 16:18:12 +0100 |
commit | 4551f342fed66af7f5e2b099fa06f4007db356e6 (patch) | |
tree | 10d74c69e2399c3d508f40a0878425b22243fce4 /rust/hw/timer/hpet | |
parent | 3212da0033530ae896d31d90d5e81a772fc37088 (diff) | |
download | qemu-4551f342fed66af7f5e2b099fa06f4007db356e6.zip qemu-4551f342fed66af7f5e2b099fa06f4007db356e6.tar.gz qemu-4551f342fed66af7f5e2b099fa06f4007db356e6.tar.bz2 |
rust: qom: add ObjectImpl::CLASS_INIT
As shown in the PL011 device, the orphan rules required a manual
implementation of ClassInitImpl for anything not in the qemu_api crate;
this gets in the way of moving system emulation-specific code (including
DeviceClass, which as a blanket ClassInitImpl<DeviceClass> implementation)
into its own crate.
Make ClassInitImpl optional, at the cost of having to specify the CLASS_INIT
member by hand in every implementation of ObjectImpl. The next commits will
get rid of it, replacing all the "impl<T> ClassInitImpl<Class> for T" blocks
with a generic class_init<T> method on Class.
Right now the definition is always the same, but do not provide a default
as that will not be true once ClassInitImpl goes away.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/hw/timer/hpet')
-rw-r--r-- | rust/hw/timer/hpet/src/hpet.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/rust/hw/timer/hpet/src/hpet.rs b/rust/hw/timer/hpet/src/hpet.rs index b4ffccf..e01b4b6 100644 --- a/rust/hw/timer/hpet/src/hpet.rs +++ b/rust/hw/timer/hpet/src/hpet.rs @@ -21,7 +21,7 @@ use qemu_api::{ }, prelude::*, qdev::{DeviceImpl, DeviceMethods, DeviceState, Property, ResetType, ResettablePhasesImpl}, - qom::{ObjectImpl, ObjectType, ParentField}, + qom::{ClassInitImpl, ObjectImpl, ObjectType, ParentField}, qom_isa, sysbus::{SysBusDevice, SysBusDeviceImpl}, timer::{Timer, CLOCK_VIRTUAL}, @@ -836,6 +836,7 @@ impl ObjectImpl for HPETState { const INSTANCE_INIT: Option<unsafe fn(&mut Self)> = Some(Self::init); const INSTANCE_POST_INIT: Option<fn(&Self)> = Some(Self::post_init); + const CLASS_INIT: fn(&mut Self::Class) = <Self as ClassInitImpl<Self::Class>>::class_init; } // TODO: Make these properties user-configurable! |