diff options
author | Zhao Liu <zhao1.liu@intel.com> | 2025-03-18 21:02:08 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-03-21 12:56:00 +0100 |
commit | 20797069c71a90582078448b81de28f227a8403b (patch) | |
tree | 8615ff9f93fa40330046650ac6eb7da2c403e94e /rust/qemu-api/src/vmstate.rs | |
parent | c3d80af5ecf4f00db4a8d3ac5eca6edc0c9f061e (diff) | |
download | qemu-20797069c71a90582078448b81de28f227a8403b.zip qemu-20797069c71a90582078448b81de28f227a8403b.tar.gz qemu-20797069c71a90582078448b81de28f227a8403b.tar.bz2 |
rust/vmstate: Fix size field of VMStateField with VMS_ARRAY_OF_POINTER flag
The `size` field of the VMStateField with VMS_ARRAY_OF_POINTER flag
should stores the size of pointer, which depends on platform.
Currently, `*const`, `*mut`, `NonNull`, `Box<>` and their wrapper are
supported, and they have the same size as `usize`.
Store the size (of `usize`) when VMS_ARRAY_OF_POINTER flag is set.
The size may be changed when more smart pointers are supported, but now
the size of "usize" is enough.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250318130219.1799170-5-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api/src/vmstate.rs')
-rw-r--r-- | rust/qemu-api/src/vmstate.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index e323330..e2a1f7a 100644 --- a/rust/qemu-api/src/vmstate.rs +++ b/rust/qemu-api/src/vmstate.rs @@ -256,6 +256,10 @@ impl VMStateField { if (self.flags.0 & VMStateFlags::VMS_POINTER.0) != 0 { self.flags = VMStateFlags(self.flags.0 & !VMStateFlags::VMS_POINTER.0); self.flags = VMStateFlags(self.flags.0 | VMStateFlags::VMS_ARRAY_OF_POINTER.0); + // VMS_ARRAY_OF_POINTER flag stores the size of pointer. + // FIXME: *const, *mut, NonNull and Box<> have the same size as usize. + // Resize if more smart pointers are supported. + self.size = std::mem::size_of::<usize>(); } self.flags = VMStateFlags(self.flags.0 & !VMStateFlags::VMS_SINGLE.0); self.flags = VMStateFlags(self.flags.0 | VMStateFlags::VMS_ARRAY.0); |