On 06/06/2016 11:32 PM, Michael Rolnik wrote:
> Hi Richard,
>
> /Consider making the vm save state reflect the actual hardware format. That
> way you can change the qemu internal format while retaining migration
> compatibility./
>
> How it can be done? how can I modify a value passed to VMSTATE_UINT32?
There are two different ways. You can see both of them in use in target-i386.
The first is to manually describe the field, using custom get and put fields.
For example:
static const VMStateInfo vmstate_fpreg = {
.name = "fpreg",
.get = get_fpreg,
.put = put_fpreg,
};
The second is to reserve extra space for the external representation and then
use the pre_save / post_load hooks. For i386, see the cpu_pre_save, where we
take the fpus, fpstt, and fptags fields and store them into the fpus_vmstate
field. It is then the vmstate field that is mentioned in vmstate_x86_cpu.
I personally prefer the get/put fields, but I admit they can be tricky to use.
r~