On 05/08/2017 08:37 PM, Dr. David Alan Gilbert wrote:
> * Halil Pasic ([email protected]) wrote:
>>
>>
>> On 05/08/2017 07:27 PM, Dr. David Alan Gilbert wrote:
>>> * Halil Pasic ([email protected]) wrote:
>>>> Turn on migration for the channel subsystem and the new scheme for
>>>> migrating virtio-ccw proxy devices (instead of letting the transport
>>>> independent child device migrate it's proxy, use the usual
>>>> DeviceClass.vmsd mechanism) for future machine versions.
>>
>> [..]
>>
>>>> @@ -1365,6 +1373,11 @@ static void virtio_ccw_device_plugged(DeviceState
>>>> *d, Error **errp)
>>>> sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
>>>>
>>>>
>>>> + /* Avoid generating unknown section for legacy migration target. */
>>>> + if (!css_migration_enabled()) {
>>>> + DEVICE_GET_CLASS(ccw_dev)->vmsd = NULL;
>>>> + }
>>>> +
>>>
>>> That's a very odd thing to do; can't you use a .needed at the
>>> top level of the vmstate_virtio_ccw_dev to avoid having to
>>> set it to NULL like this?
>>>
>>
>> I agree it's odd. As far as I remember I can't use .needed but
>> I will double check.
>
> You can have top level .needed's - both vmstate_globalstate in
> migration.c and colo's colo_state use them.
>
Works like charm. I'm really happy to get rid of this ugly hunk. Thanks
a lot!
I was probably confused by the fact that I want to use the same vmsd with
vmstate_save_state when the needed is false. That works, but I have probably
blindly assumed (back then) it does not. Of course it does make sense to
ignore .needed in that function, because for a vmsd coming from a
recursive call while processing a filed then the non-presence of a field
should be indicated by field_exists.
I wonder if adding a comment at the definition site would be helpful.
Something like:
struct VMStateDescription {
....
void (*pre_save)(void *opaque);
+ /* Controls the existence of sections and subsections, but not fields. */
bool (*needed)(void *opaque);
VMStateField *fields;
const VMStateDescription **subsections;
};
Halil
> Dave
>
>> Many thanks for your review!
>>
>> Halil
>>
> --
> Dr. David Alan Gilbert / [email protected] / Manchester, UK
>