mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 02:54:58 -06:00
virtio/migration: Add VMStateDescription to VirtioDeviceClass
Provide a vmsd pointer for VirtIO devices to use instead of the load/save methods. We'll eventually kill off the load/save methods. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
5b2ecabaea
commit
ea43e25987
2 changed files with 18 additions and 0 deletions
|
@ -1635,6 +1635,10 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
|
|||
vdc->save(vdev, f);
|
||||
}
|
||||
|
||||
if (vdc->vmsd) {
|
||||
vmstate_save_state(f, vdc->vmsd, vdev, NULL);
|
||||
}
|
||||
|
||||
/* Subsections */
|
||||
vmstate_save_state(f, &vmstate_virtio, vdev, NULL);
|
||||
}
|
||||
|
@ -1781,6 +1785,13 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
|
|||
}
|
||||
}
|
||||
|
||||
if (vdc->vmsd) {
|
||||
ret = vmstate_load_state(f, vdc->vmsd, vdev, version_id);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Subsections */
|
||||
ret = vmstate_load_state(f, &vmstate_virtio, vdev, 1);
|
||||
if (ret) {
|
||||
|
@ -2118,6 +2129,9 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
|
|||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
|
||||
Error *err = NULL;
|
||||
|
||||
/* Devices should either use vmsd or the load/save methods */
|
||||
assert(!vdc->vmsd || !vdc->load);
|
||||
|
||||
if (vdc->realize != NULL) {
|
||||
vdc->realize(dev, &err);
|
||||
if (err != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue