Hi Paolo,

I'm not familiar with how migration works under the hood, but this
data transformation design looks very clean and neat to me.

On Sat, Sep 6, 2025 at 9:45 AM Paolo Bonzini <[email protected]> wrote:
>
> Hi,
>
> based on the low-level sketch in Zhao and my presentation,
> I would like to propose this more high-level implementation
> of pre/post migration callbacks.
>
> Instead of dealing with pre/post callbacks, devices implement a
> snapshot/restore mechanism; this way, C code sees a simplified
> picture and does not have to deal with Rust concepts such as
> Mutex<>.
>
> Using it is very easy, you can just declare your state like:
>
>      regs: Migratable<Mutex<MyDeviceRegisters>>
>

Hm it's a shame we cannot do this with a trait since it requires state
storage for migration_state.

A suggestion: we could declare a "mirror" struct to hold
`migration_state` with a Derive macro. This is what the `rkyv` crate
does with its `Archive` derive macro and trait
<https://docs.rs/rkyv/latest/rkyv/trait.Archive.html>

Reply via email to