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>
master
Dr. David Alan Gilbert 2016-07-14 18:22:53 +01:00 committed by Michael S. Tsirkin
parent 18e0e5b240
commit 428d2ed2c8
1 changed files with 6 additions and 20 deletions

View File

@ -217,26 +217,14 @@ static void virtio_input_reset(VirtIODevice *vdev)
} }
} }
static void virtio_input_save(QEMUFile *f, void *opaque) static int virtio_input_load(QEMUFile *f, void *opaque, size_t size)
{
VirtIOInput *vinput = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(vinput);
virtio_save(vdev, f);
}
static int virtio_input_load(QEMUFile *f, void *opaque, int version_id)
{ {
VirtIOInput *vinput = opaque; VirtIOInput *vinput = opaque;
VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(vinput); VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(vinput);
VirtIODevice *vdev = VIRTIO_DEVICE(vinput); VirtIODevice *vdev = VIRTIO_DEVICE(vinput);
int ret; int ret;
if (version_id != VIRTIO_INPUT_VM_VERSION) { ret = virtio_load(vdev, f, VIRTIO_INPUT_VM_VERSION);
return -EINVAL;
}
ret = virtio_load(vdev, f, version_id);
if (ret) { if (ret) {
return ret; return ret;
} }
@ -280,20 +268,14 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp)
vinput->cfg_size); vinput->cfg_size);
vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt); vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt);
vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts); 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) static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
{ {
VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev); VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOInput *vinput = VIRTIO_INPUT(dev);
Error *local_err = NULL; Error *local_err = NULL;
unregister_savevm(dev, "virtio-input", vinput);
if (vic->unrealize) { if (vic->unrealize) {
vic->unrealize(dev, &local_err); vic->unrealize(dev, &local_err);
if (local_err) { if (local_err) {
@ -304,6 +286,9 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
virtio_cleanup(vdev); virtio_cleanup(vdev);
} }
VMSTATE_VIRTIO_DEVICE(input, VIRTIO_INPUT_VM_VERSION, virtio_input_load,
virtio_vmstate_save);
static Property virtio_input_properties[] = { static Property virtio_input_properties[] = {
DEFINE_PROP_STRING("serial", VirtIOInput, serial), DEFINE_PROP_STRING("serial", VirtIOInput, serial),
DEFINE_PROP_END_OF_LIST(), 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); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->props = virtio_input_properties; dc->props = virtio_input_properties;
dc->vmsd = &vmstate_virtio_input;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories); set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
vdc->realize = virtio_input_device_realize; vdc->realize = virtio_input_device_realize;
vdc->unrealize = virtio_input_device_unrealize; vdc->unrealize = virtio_input_device_unrealize;