diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2024-11-29 08:48:07 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-01-10 23:34:43 +0100 |
commit | 22a18f0a98a1ca5d0cd8fff1d81cc74a269083de (patch) | |
tree | 7894cc4e3c9cdd39ff879fdf30b84dc3e5ee125c /rust/qemu-api | |
parent | af68b41d403b81b18de07ebab0ca4c1025c94bf7 (diff) | |
download | qemu-22a18f0a98a1ca5d0cd8fff1d81cc74a269083de.zip qemu-22a18f0a98a1ca5d0cd8fff1d81cc74a269083de.tar.gz qemu-22a18f0a98a1ca5d0cd8fff1d81cc74a269083de.tar.bz2 |
rust: qom: make INSTANCE_POST_INIT take a shared reference
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api')
-rw-r--r-- | rust/qemu-api/src/qom.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/rust/qemu-api/src/qom.rs b/rust/qemu-api/src/qom.rs index b0332ba..97901fb 100644 --- a/rust/qemu-api/src/qom.rs +++ b/rust/qemu-api/src/qom.rs @@ -163,11 +163,7 @@ unsafe extern "C" fn rust_instance_post_init<T: ObjectImpl>(obj: *mut Object) { // SAFETY: obj is an instance of T, since rust_instance_post_init<T> // is called from QOM core as the instance_post_init function // for class T - // - // FIXME: it's not really guaranteed that there are no backpointers to - // obj; it's quite possible that they have been created by instance_init(). - // The receiver should be &self, not &mut self. - T::INSTANCE_POST_INIT.unwrap()(unsafe { &mut *obj.cast::<T>() }) + T::INSTANCE_POST_INIT.unwrap()(unsafe { &*obj.cast::<T>() }) } unsafe extern "C" fn rust_class_init<T: ObjectType + ClassInitImpl<T::Class>>( @@ -463,7 +459,7 @@ pub trait ObjectImpl: ObjectType + ClassInitImpl<Self::Class> { /// Function that is called to finish initialization of an object, once /// `INSTANCE_INIT` functions have been called. - const INSTANCE_POST_INIT: Option<fn(&mut Self)> = None; + const INSTANCE_POST_INIT: Option<fn(&Self)> = None; /// Called on descendent classes after all parent class initialization /// has occurred, but before the class itself is initialized. This |