Skip to content

Commit 3baf82e

Browse files
trueptolemybonzini
authored andcommitted
rust/vmstate: Re-implement VMState trait for timer binding
At present, Rust side has a timer binding "timer::Timer", so the vmstate for timer should base on that binding instead of the raw "binding::QEMUTimer". It's possible to apply impl_vmstate_transparent for cell::Opaque and then impl_vmstate_forward for timer::Timer. But binding::QEMUTimer shouldn't be used directly, so that vmstate for such raw timer type is useless. Thus, apply impl_vmstate_scalar for timer::Timer. And since Opaque<> is useful, apply impl_vmstate_transparent for cell::Opaque as well. Signed-off-by: Zhao Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 5006e39 commit 3baf82e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

rust/qemu-api/src/vmstate.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@
2727
use core::{marker::PhantomData, mem, ptr::NonNull};
2828

2929
pub use crate::bindings::{VMStateDescription, VMStateField};
30-
use crate::{
31-
bindings::{self, VMStateFlags},
32-
prelude::*,
33-
qom::Owned,
34-
zeroable::Zeroable,
35-
};
30+
use crate::{bindings::VMStateFlags, prelude::*, qom::Owned, zeroable::Zeroable};
3631

3732
/// This macro is used to call a function with a generic argument bound
3833
/// to the type of a field. The function must take a
@@ -344,6 +339,7 @@ impl_vmstate_transparent!(std::cell::UnsafeCell<T> where T: VMState);
344339
impl_vmstate_transparent!(std::pin::Pin<T> where T: VMState);
345340
impl_vmstate_transparent!(crate::cell::BqlCell<T> where T: VMState);
346341
impl_vmstate_transparent!(crate::cell::BqlRefCell<T> where T: VMState);
342+
impl_vmstate_transparent!(crate::cell::Opaque<T> where T: VMState);
347343

348344
#[macro_export]
349345
macro_rules! impl_vmstate_bitsized {
@@ -390,7 +386,7 @@ impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY_UINT8);
390386
impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY_UINT16);
391387
impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY_UINT32);
392388
impl_vmstate_scalar!(vmstate_info_uint64, u64);
393-
impl_vmstate_scalar!(vmstate_info_timer, bindings::QEMUTimer);
389+
impl_vmstate_scalar!(vmstate_info_timer, crate::timer::Timer);
394390

395391
// Pointer types using the underlying type's VMState plus VMS_POINTER
396392
// Note that references are not supported, though references to cells

0 commit comments

Comments
 (0)