On Mon, Nov 03, 2025 at 06:25:26PM +0800, Zhao Liu wrote:
> Date: Mon, 3 Nov 2025 18:25:26 +0800
> From: Zhao Liu <[email protected]>
> Subject: Re: [PATCH 08/11] rust: qemu-macros: add ToMigrationState derive
>  macro
> 
> Hi Paolo,
> 
> >  /// # use std::sync::Mutex;
> > -/// # use migration::Migratable;
> > +/// # use migration::{Migratable, ToMigrationState, VMState, VMStateField};
> >  ///
> > +/// #[derive(ToMigrationState)]
> >  /// pub struct DeviceRegs {
> >  ///     status: u32,
> >  /// }
> > +/// # unsafe impl VMState for DeviceRegsMigration {
> > +/// #     const BASE: VMStateField = ::common::Zeroable::ZERO;
> > +/// # }
> 
> did you miss something like the following?
> 
> 
> diff --git a/rust/qemu-macros/src/migration_state.rs 
> b/rust/qemu-macros/src/migration_state.rs
> index 5edf0efe687f..2064bb73a6f0 100644
> --- a/rust/qemu-macros/src/migration_state.rs
> +++ b/rust/qemu-macros/src/migration_state.rs
> @@ -236,6 +236,16 @@ pub struct #name {
>          }
>      }
> 
> +    fn generate_vmstate_impl(&self) -> TokenStream {
> +        let name = self.migration_state_name();
> +
> +        quote! {
> +            unsafe impl ::migration::VMState for #name {
> +                const BASE: ::migration::VMStateField = 
> ::common::Zeroable::ZERO;

It seems the generated migration_state_struct needs a complete VMSD:
collect all its fields and build a VMSD.

And then apply impl_vmstate_struct! to this  migration_state_struct.

If we zero the BASE, then `vmstate_of!(Self, migration_state)` seems
can't migrate its fields.

Thanks,
Zhao


Reply via email to