On 22 February 2016 at 10:28, hitmoon <zxq_yx_...@163.com> wrote: > 在 2016年02月22日 17:24, Peter Maydell 写道: >> Just noticed this won't work as it is -- the vmstate >> struct is for the M48t59State*, but the ISA and >> Sysbus wrappers have their own structs which are >> what the dc->vmsd will be wanting to operate on. >> You'd need extra VMState structs I think and >> somebody who knows migration better than me to say >> whether that is a migration compat break.
> It seems that the old code also use the same vmstate structure. Maybe it's a > common structure which will not be used at the same time. The old code passes vmstate_register() a pointer to the M48t59State, and so the offsets in the vmstate line up correctly with the fields it wants to access. If you use dc->vmsd then the pointer that is (implicitly) used is the pointer to the device structure itself, which is not the same address as the M48t59State embedded inside that struct. You'd basically need to have extra VMState structures for the devices themselves which just said "inside this M48txxISAState is an M48t59State", and "inside this M48txxSysBusState is a M48t59State" and referred to the existing vmstate for the M48t59State. thanks -- PMM