mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
rust: move vmstate_clock!() to qdev module
This will allow to split vmstate to a standalone crate next. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Link: https://lore.kernel.org/r/20250827104147.717203-8-marcandre.lureau@redhat.com Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
d85df9a8e2
commit
88cf78e917
@@ -17,6 +17,7 @@ use crate::{
|
||||
cell::{bql_locked, Opaque},
|
||||
chardev::Chardev,
|
||||
error::{Error, Result},
|
||||
impl_vmstate_c_struct,
|
||||
irq::InterruptSource,
|
||||
prelude::*,
|
||||
qom::{ObjectClass, ObjectImpl, Owned, ParentInit},
|
||||
@@ -455,3 +456,5 @@ unsafe impl ObjectType for Clock {
|
||||
unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_CLOCK) };
|
||||
}
|
||||
qom_isa!(Clock: Object);
|
||||
|
||||
impl_vmstate_c_struct!(Clock, bindings::vmstate_clock);
|
||||
|
||||
@@ -41,7 +41,6 @@ use crate::{
|
||||
callbacks::FnCall,
|
||||
errno::{into_neg_errno, Errno},
|
||||
prelude::*,
|
||||
qdev,
|
||||
qom::Owned,
|
||||
zeroable::Zeroable,
|
||||
};
|
||||
@@ -318,21 +317,20 @@ impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY_UINT32);
|
||||
impl_vmstate_scalar!(vmstate_info_uint64, u64);
|
||||
impl_vmstate_scalar!(vmstate_info_timer, crate::timer::Timer);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_vmstate_c_struct {
|
||||
($type:ty, $vmsd:expr) => {
|
||||
unsafe impl VMState for $type {
|
||||
const BASE: VMStateField = $crate::bindings::VMStateField {
|
||||
vmsd: addr_of!($vmsd),
|
||||
size: mem::size_of::<$type>(),
|
||||
flags: VMStateFlags::VMS_STRUCT,
|
||||
..Zeroable::ZERO
|
||||
const BASE: $crate::bindings::VMStateField = $crate::bindings::VMStateField {
|
||||
vmsd: ::std::ptr::addr_of!($vmsd),
|
||||
size: ::std::mem::size_of::<$type>(),
|
||||
flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
|
||||
..$crate::zeroable::Zeroable::ZERO
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_vmstate_c_struct!(qdev::Clock, bindings::vmstate_clock);
|
||||
|
||||
// Pointer types using the underlying type's VMState plus VMS_POINTER
|
||||
// Note that references are not supported, though references to cells
|
||||
// could be allowed.
|
||||
|
||||
Reference in New Issue
Block a user