diff options
author | Dr. David Alan Gilbert | 2016-07-14 19:22:50 +0200 |
---|---|---|
committer | Michael S. Tsirkin | 2016-07-21 19:44:20 +0200 |
commit | 290c2428453632502249df3bb4b99f1b3625137c (patch) | |
tree | 70ce9f5934ef4fe292d28a1a3390a1e94f54f067 /hw/net/virtio-net.c | |
parent | virtio-balloon: Wrap in vmstate (diff) | |
download | qemu-290c2428453632502249df3bb4b99f1b3625137c.tar.gz qemu-290c2428453632502249df3bb4b99f1b3625137c.tar.xz qemu-290c2428453632502249df3bb4b99f1b3625137c.zip |
virtio-net: Wrap in vmstate
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/net/virtio-net.c')
-rw-r--r-- | hw/net/virtio-net.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 550db30930..bb311c4587 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1492,7 +1492,7 @@ static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue) virtio_net_set_queues(n); } -static void virtio_net_save(QEMUFile *f, void *opaque) +static void virtio_net_save(QEMUFile *f, void *opaque, size_t size) { VirtIONet *n = opaque; VirtIODevice *vdev = VIRTIO_DEVICE(n); @@ -1538,15 +1538,12 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f) } } -static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) +static int virtio_net_load(QEMUFile *f, void *opaque, size_t size) { VirtIONet *n = opaque; VirtIODevice *vdev = VIRTIO_DEVICE(n); - if (version_id != VIRTIO_NET_VM_VERSION) - return -EINVAL; - - return virtio_load(vdev, f, version_id); + return virtio_load(vdev, f, VIRTIO_NET_VM_VERSION); } static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, @@ -1790,8 +1787,6 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) nc->rxfilter_notify_enabled = 1; n->qdev = dev; - register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION, - virtio_net_save, virtio_net_load, n); } static void virtio_net_device_unrealize(DeviceState *dev, Error **errp) @@ -1803,8 +1798,6 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp) /* This will stop vhost backend if appropriate. */ virtio_net_set_status(vdev, 0); - unregister_savevm(dev, "virtio-net", n); - g_free(n->netclient_name); n->netclient_name = NULL; g_free(n->netclient_type); @@ -1839,6 +1832,9 @@ static void virtio_net_instance_init(Object *obj) DEVICE(n), NULL); } +VMSTATE_VIRTIO_DEVICE(net, VIRTIO_NET_VM_VERSION, virtio_net_load, + virtio_net_save); + static Property virtio_net_properties[] = { DEFINE_PROP_BIT("csum", VirtIONet, host_features, VIRTIO_NET_F_CSUM, true), DEFINE_PROP_BIT("guest_csum", VirtIONet, host_features, @@ -1893,6 +1889,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); dc->props = virtio_net_properties; + dc->vmsd = &vmstate_virtio_net; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); vdc->realize = virtio_net_device_realize; vdc->unrealize = virtio_net_device_unrealize; |