On Mon, Nov 17, 2025 at 09:47:52AM +0100, Paolo Bonzini wrote:
> Date: Mon, 17 Nov 2025 09:47:52 +0100
> From: Paolo Bonzini <[email protected]>
> Subject: [PATCH 5/5] rust/hpet: Apply Migratable<> wrapper and
>  ToMigrationState
> X-Mailer: git-send-email 2.51.1
> 
> From: Zhao Liu <[email protected]>
> 
> Before using Mutex<> to protect HPETRegisters, it's necessary to apply
> Migratable<> wrapper and ToMigrationState first since there's no
> pre-defined VMState for Mutex<>.
> 
> In addition, this allows to move data from HPETTimerRegisters to
> HPETTimer,

Typo? move data from HPETTimerRegisters' vmstate to HPETTimer's vmstate

> so as to preserve the original migration format of the C
> implementation.  To do that, HPETTimer is wrapped with Migratable<>
> as well but the implementation of ToMigrationStateShared is
> hand-written.
> 
> Note that even though the HPETRegistersMigration struct is
> generated by ToMigrationState macro, its VMState still needs to be
> implemented by hand.
>
> Signed-off-by: Zhao Liu <[email protected]>
> Link: https://lore.kernel.org/r/[email protected]
> [Added HPETTimer implementation and restored compatible migration format. - 
> Paolo]
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---
>  rust/hw/timer/hpet/src/device.rs | 139 +++++++++++++++++++++++--------
>  1 file changed, 102 insertions(+), 37 deletions(-)

yes, the fully hand-written ToMigrationStateShared is really powerful -
it can keep the vmstate layout unchanged even when the struct (
HPETTimerRegisters) has such big changes.

Reviewed-by: Zhao Liu <[email protected]>



Reply via email to