qemu-rust
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 8/9] rust/hpet: Support migration


From: Paolo Bonzini
Subject: Re: [PATCH 8/9] rust/hpet: Support migration
Date: Tue, 15 Apr 2025 19:43:00 +0200

On Tue, Apr 15, 2025 at 4:21 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> > An additional difficult case is vmsd(). Passing the raw VMStateDescription
> > looks not good, while passing the VMStateDescription<> wrapper requires
> > bounding DeviceImpl with 'static. Ultimately, I added an extra
> > StaticVMStateDescription trait to successfully compile...
>
> Hmm I cannot fully understand it so I'll check it out later.

So the problem is that, in a "&'a Foo<T>", T must also be "T: 'a".
One solution is for vmsd() to return an
Option<VMStateDescription<Self>>, and do Box::into_raw(Box::new(vmsd))
in the class_init method. Once we have const_refs_static, "fn vmsd()"
can become a const and the Box is not needed anymore.

Also please turn get_vmsd_ptr() into get_vmsd_ref() so that we get
more checks that things are not copied behind our back (leaving behind
a dangling pointer)

I attach the conversion I did of the other devices and tests. I am not
sure if it's possible to avoid having a huge patch to do everything at
once (except HPET since that can be added separately).

Paolo

Attachment: 0001-convert-everything-to-VMStateBuilder.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]