diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2016-07-14 18:22:53 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2016-07-21 20:44:20 +0300 |
commit | 428d2ed2c84d71fa7cb25d12e409ee9b7f0a953c (patch) | |
tree | 342f29e67010dfacb58b8d0aa9458c3a678cc610 /hw | |
parent | 18e0e5b240ae865554863fa35e8b9af9580f971b (diff) |
virtio-input: 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')
-rw-r--r-- | hw/input/virtio-input.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index edf69903a6..a87fd6862e 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -217,26 +217,14 @@ static void virtio_input_reset(VirtIODevice *vdev) } } -static void virtio_input_save(QEMUFile *f, void *opaque) -{ - VirtIOInput *vinput = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(vinput); - - virtio_save(vdev, f); -} - -static int virtio_input_load(QEMUFile *f, void *opaque, int version_id) +static int virtio_input_load(QEMUFile *f, void *opaque, size_t size) { VirtIOInput *vinput = opaque; VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(vinput); VirtIODevice *vdev = VIRTIO_DEVICE(vinput); int ret; - if (version_id != VIRTIO_INPUT_VM_VERSION) { - return -EINVAL; - } - - ret = virtio_load(vdev, f, version_id); + ret = virtio_load(vdev, f, VIRTIO_INPUT_VM_VERSION); if (ret) { return ret; } @@ -280,20 +268,14 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp) vinput->cfg_size); vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt); vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts); - - register_savevm(dev, "virtio-input", -1, VIRTIO_INPUT_VM_VERSION, - virtio_input_save, virtio_input_load, vinput); } static void virtio_input_device_unrealize(DeviceState *dev, Error **errp) { VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev); VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VirtIOInput *vinput = VIRTIO_INPUT(dev); Error *local_err = NULL; - unregister_savevm(dev, "virtio-input", vinput); - if (vic->unrealize) { vic->unrealize(dev, &local_err); if (local_err) { @@ -304,6 +286,9 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp) virtio_cleanup(vdev); } +VMSTATE_VIRTIO_DEVICE(input, VIRTIO_INPUT_VM_VERSION, virtio_input_load, + virtio_vmstate_save); + static Property virtio_input_properties[] = { DEFINE_PROP_STRING("serial", VirtIOInput, serial), DEFINE_PROP_END_OF_LIST(), @@ -315,6 +300,7 @@ static void virtio_input_class_init(ObjectClass *klass, void *data) VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); dc->props = virtio_input_properties; + dc->vmsd = &vmstate_virtio_input; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); vdc->realize = virtio_input_device_realize; vdc->unrealize = virtio_input_device_unrealize; |