rust: migration: implement ToMigrationState as part of impl_vmstate_bitsized
This is most likely desirable, and is the easiest way to migrate a bit-sized value without peeking at the innards of the bilge crate. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
67913e95bf
commit
7ee5875d42
1 changed files with 19 additions and 0 deletions
|
|
@ -296,6 +296,25 @@ macro_rules! impl_vmstate_bitsized {
|
|||
as ::bilge::prelude::Number>::UnderlyingType
|
||||
as $crate::vmstate::VMState>::VARRAY_FLAG;
|
||||
}
|
||||
|
||||
impl $crate::migratable::ToMigrationState for $type {
|
||||
type Migrated = <<$type as ::bilge::prelude::Bitsized>::ArbitraryInt
|
||||
as ::bilge::prelude::Number>::UnderlyingType;
|
||||
|
||||
fn snapshot_migration_state(&self, target: &mut Self::Migrated) -> Result<(), $crate::InvalidError> {
|
||||
*target = Self::Migrated::from(*self);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn restore_migrated_state_mut(
|
||||
&mut self,
|
||||
source: Self::Migrated,
|
||||
version_id: u8,
|
||||
) -> Result<(), $crate::InvalidError> {
|
||||
*self = Self::from(source);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue