diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2010-05-15 13:32:41 +0200 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2010-05-15 14:32:51 +0000 |
commit | 1cc9f5143936d381366bdd55a9b28d4dfb891e08 (patch) | |
tree | ee728a674145d22c108604b49712b049727f2228 | |
parent | 4d2ffa08b601bdd40d9ccf225480c0a7e90ca078 (diff) | |
download | hqemu-1cc9f5143936d381366bdd55a9b28d4dfb891e08.zip hqemu-1cc9f5143936d381366bdd55a9b28d4dfb891e08.tar.gz |
serial: Register vmstate via qdev
At least for isa-serial, we can already let qdev do the vmstate
registration for us. It just takes wrapping vmstate for the
encapsulating ISASerialState and defining the proper instance ID
aliases.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r-- | hw/serial.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/hw/serial.c b/hw/serial.c index 90213c4..9102edb 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -771,7 +771,7 @@ static int serial_isa_initfn(ISADevice *dev) s->baudbase = 115200; isa_init_irq(dev, &s->irq, isa->isairq); serial_init_core(s); - vmstate_register(isa->iobase, &vmstate_serial, s); + qdev_set_legacy_instance_id(&dev->qdev, isa->iobase, 3); register_ioport_write(isa->iobase, 8, 1, serial_ioport_write, s); register_ioport_read(isa->iobase, 8, 1, serial_ioport_read, s); @@ -790,6 +790,16 @@ SerialState *serial_isa_init(int index, CharDriverState *chr) return &DO_UPCAST(ISASerialState, dev, dev)->state; } +static const VMStateDescription vmstate_isa_serial = { + .name = "serial", + .version_id = 3, + .minimum_version_id = 2, + .fields = (VMStateField []) { + VMSTATE_STRUCT(state, ISASerialState, 0, vmstate_serial, SerialState), + VMSTATE_END_OF_LIST() + } +}; + SerialState *serial_init(int base, qemu_irq irq, int baudbase, CharDriverState *chr) { @@ -956,6 +966,7 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift, static ISADeviceInfo serial_isa_info = { .qdev.name = "isa-serial", .qdev.size = sizeof(ISASerialState), + .qdev.vmsd = &vmstate_isa_serial, .init = serial_isa_initfn, .qdev.props = (Property[]) { DEFINE_PROP_UINT32("index", ISASerialState, index, -1), |