mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
rust/vmstate: Relax array check when build varray in vmstate_struct
The varry of structure created by vmstate_struct is different with vmstate_of. This is because vmstate_struct uses the `vmsd` to traverse the vmstates of structure's fields, rather than treating the structure directly as a well-defined vmstate. Therefore, there's no need to check array flag when building varray by vmstate_struct. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250318130219.1799170-9-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
e5655e92a8
commit
5006e39cfa
1 changed files with 9 additions and 3 deletions
|
@ -275,14 +275,20 @@ impl VMStateField {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_varray_flag(mut self, flag: VMStateFlags) -> VMStateField {
|
pub const fn with_varray_flag_unchecked(mut self, flag: VMStateFlags) -> VMStateField {
|
||||||
assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
|
|
||||||
self.flags = VMStateFlags(self.flags.0 & !VMStateFlags::VMS_ARRAY.0);
|
self.flags = VMStateFlags(self.flags.0 & !VMStateFlags::VMS_ARRAY.0);
|
||||||
self.flags = VMStateFlags(self.flags.0 | flag.0);
|
self.flags = VMStateFlags(self.flags.0 | flag.0);
|
||||||
self.num = 0; // varray uses num_offset instead of num.
|
self.num = 0; // varray uses num_offset instead of num.
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
pub const fn with_varray_flag(mut self, flag: VMStateFlags) -> VMStateField {
|
||||||
|
assert!((self.flags.0 & VMStateFlags::VMS_ARRAY.0) != 0);
|
||||||
|
self.with_varray_flag_unchecked(flag)
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn with_varray_multiply(mut self, num: u32) -> VMStateField {
|
pub const fn with_varray_multiply(mut self, num: u32) -> VMStateField {
|
||||||
assert!(num <= 0x7FFF_FFFFu32);
|
assert!(num <= 0x7FFF_FFFFu32);
|
||||||
|
@ -454,7 +460,7 @@ macro_rules! vmstate_struct {
|
||||||
flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
|
flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
|
||||||
vmsd: $vmsd,
|
vmsd: $vmsd,
|
||||||
..$crate::zeroable::Zeroable::ZERO
|
..$crate::zeroable::Zeroable::ZERO
|
||||||
} $(.with_varray_flag(
|
} $(.with_varray_flag_unchecked(
|
||||||
$crate::call_func_with_field!(
|
$crate::call_func_with_field!(
|
||||||
$crate::vmstate::vmstate_varray_flag,
|
$crate::vmstate::vmstate_varray_flag,
|
||||||
$struct_name,
|
$struct_name,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue