diff options
author | Juan Quintela <quintela@redhat.com> | 2009-09-10 03:04:40 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-09-11 11:10:08 -0500 |
commit | bcb58d9ac97b2bbb73711e071c75772b43d23def (patch) | |
tree | 923d0001e4a45f2df0058d98935d0078fc2b0dba /hw/vmmouse.c | |
parent | 7b5045c555d4861fb8e4744a3357166896caf6d9 (diff) |
vmstate: port vmmouse device
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/vmmouse.c')
-rw-r--r-- | hw/vmmouse.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/hw/vmmouse.c b/hw/vmmouse.c index c70e825d4..c207bb2b2 100644 --- a/hw/vmmouse.c +++ b/hw/vmmouse.c @@ -53,6 +53,7 @@ typedef struct _VMMouseState { uint32_t queue[VMMOUSE_QUEUE_SIZE]; + int32_t queue_size; uint16_t nb_queue; uint16_t status; uint8_t absolute; @@ -234,40 +235,30 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr) return data[0]; } -static void vmmouse_save(QEMUFile *f, void *opaque) +static int vmmouse_post_load(void *opaque) { VMMouseState *s = opaque; - int i; - - qemu_put_be32(f, VMMOUSE_QUEUE_SIZE); - for (i = 0; i < VMMOUSE_QUEUE_SIZE; i++) - qemu_put_be32s(f, &s->queue[i]); - qemu_put_be16s(f, &s->nb_queue); - qemu_put_be16s(f, &s->status); - qemu_put_8s(f, &s->absolute); -} - -static int vmmouse_load(QEMUFile *f, void *opaque, int version_id) -{ - VMMouseState *s = opaque; - int i; - - if (version_id != 0) - return -EINVAL; - - if (qemu_get_be32(f) != VMMOUSE_QUEUE_SIZE) - return -EINVAL; - for (i = 0; i < VMMOUSE_QUEUE_SIZE; i++) - qemu_get_be32s(f, &s->queue[i]); - qemu_get_be16s(f, &s->nb_queue); - qemu_get_be16s(f, &s->status); - qemu_get_8s(f, &s->absolute); vmmouse_update_handler(s); - return 0; } +static const VMStateDescription vmstate_vmmouse = { + .name = "vmmouse", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .post_load = vmmouse_post_load, + .fields = (VMStateField []) { + VMSTATE_INT32_EQUAL(queue_size, VMMouseState), + VMSTATE_UINT32_ARRAY(queue, VMMouseState, VMMOUSE_QUEUE_SIZE), + VMSTATE_UINT16(nb_queue, VMMouseState), + VMSTATE_UINT16(status, VMMouseState), + VMSTATE_UINT8(absolute, VMMouseState), + VMSTATE_END_OF_LIST() + } +}; + void *vmmouse_init(void *m) { VMMouseState *s = NULL; @@ -278,11 +269,12 @@ void *vmmouse_init(void *m) s->status = 0xffff; s->ps2_mouse = m; + s->queue_size = VMMOUSE_QUEUE_SIZE; vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s); vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s); vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s); - register_savevm("vmmouse", 0, 0, vmmouse_save, vmmouse_load, s); + vmstate_register(0, &vmstate_vmmouse, s); return s; } |