提交 ea43e259 编写于 作者: D Dr. David Alan Gilbert 提交者: Michael S. Tsirkin

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: NDr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 5b2ecaba
...@@ -1635,6 +1635,10 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) ...@@ -1635,6 +1635,10 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
vdc->save(vdev, f); vdc->save(vdev, f);
} }
if (vdc->vmsd) {
vmstate_save_state(f, vdc->vmsd, vdev, NULL);
}
/* Subsections */ /* Subsections */
vmstate_save_state(f, &vmstate_virtio, vdev, NULL); vmstate_save_state(f, &vmstate_virtio, vdev, NULL);
} }
...@@ -1781,6 +1785,13 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) ...@@ -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 */ /* Subsections */
ret = vmstate_load_state(f, &vmstate_virtio, vdev, 1); ret = vmstate_load_state(f, &vmstate_virtio, vdev, 1);
if (ret) { if (ret) {
...@@ -2118,6 +2129,9 @@ static void virtio_device_realize(DeviceState *dev, Error **errp) ...@@ -2118,6 +2129,9 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
Error *err = NULL; Error *err = NULL;
/* Devices should either use vmsd or the load/save methods */
assert(!vdc->vmsd || !vdc->load);
if (vdc->realize != NULL) { if (vdc->realize != NULL) {
vdc->realize(dev, &err); vdc->realize(dev, &err);
if (err != NULL) { if (err != NULL) {
......
...@@ -125,8 +125,12 @@ typedef struct VirtioDeviceClass { ...@@ -125,8 +125,12 @@ typedef struct VirtioDeviceClass {
* must mask in frontend instead. * must mask in frontend instead.
*/ */
void (*guest_notifier_mask)(VirtIODevice *vdev, int n, bool mask); void (*guest_notifier_mask)(VirtIODevice *vdev, int n, bool mask);
/* Saving and loading of a device; trying to deprecate save/load
* use vmsd for new devices.
*/
void (*save)(VirtIODevice *vdev, QEMUFile *f); void (*save)(VirtIODevice *vdev, QEMUFile *f);
int (*load)(VirtIODevice *vdev, QEMUFile *f, int version_id); int (*load)(VirtIODevice *vdev, QEMUFile *f, int version_id);
const VMStateDescription *vmsd;
} VirtioDeviceClass; } VirtioDeviceClass;
void virtio_instance_init_common(Object *proxy_obj, void *data, void virtio_instance_init_common(Object *proxy_obj, void *data,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册