vmstate cleanups and fixes
cover vmstate cleanups and fixes
The new features are going to be used in next series (virtio port to vmstate). I just sent it because the cleanups were needed for other people. This patch is on top of my audio vmstate changes series (but it should be independent).
- fseek + migration has stopped working, just read to a local buffer (Jan).
- macaddr: brown paper bug (Jan fixed it)
- We add support for test function in more types.
- qdev: fix vmstate_unregister call now that it has the right type.
- port all devices that don't need changes to qdev.vmsd (patch is largish, but it is very easy).
- multiply by a constant: this is needed for unsafe buffers, where we have the number of elements, not the full size of the buffer.
You can get it at:
http://repo.or.cz/w/qemu/quintela.git/shortlog/refs/heads/vmstate/cleanup
Later, Juan.
Jan Kiszka (1):
vmstate: Fix info field of VMSTATE_MACADDR
Juan Quintela (11):
vmstate: Avoid seeking
vmstate: fix missing ARRAY_OF_POINTERS support on save state
vmstate: Add support for VBUFFERS
vmstate: Introduce VMSTATE_STRUCT_TEST
vmstate: Introduce VMSTATE_STRUCT_POINTER_TEST
vmstate: Introduce UINT16_TEST support
vmstate: remove usused VMSTATE_STRUCT_ARRAY_SIZE_UINT8
vmstate: Add support for multiplying size for a constant
pci: vmstate_register() already assign consecutive numbers starting
at 0
qdev: enable vmstate_unregister() support
savevm: Port to qdev.vmsd all devices that have qdev
hw/ac97.c | 2 +- hw/cirrus_vga.c | 2 +- hw/cs4231a.c | 2 +- hw/e1000.c | 4 +-- hw/es1370.c | 2 +- hw/gus.c | 2 +- hw/hw.h | 82 +++++++++++++++++++++++++++++++++++++--------------- hw/lance.c | 14 ++++++++- hw/lm832x.c | 2 +- hw/lsi53c895a.c | 2 +- hw/max7310.c | 2 +- hw/ne2000-isa.c | 12 +++++++- hw/ne2000.c | 3 +- hw/pci.c | 4 +-- hw/pckbd.c | 13 ++++++++- hw/pcnet.c | 4 +-- hw/piix_pci.c | 4 +- hw/qdev.c | 2 - hw/rtl8139.c | 4 +-- hw/sb16.c | 2 +- hw/ssd0303.c | 2 +- hw/tmp105.c | 2 +- hw/twl92230.c | 2 +- hw/usb-uhci.c | 3 +- hw/vga-pci.c | 2 +- hw/vmware_vga.c | 2 +- hw/wdt_i6300esb.c | 3 +- hw/wdt_ib700.c | 2 +- hw/wm8750.c | 2 +- savevm.c | 49 ++++++++++++++++++++++++++------ 30 files changed, 159 insertions(+), 74 deletions(-)
PATCH 1/12 vmstate: Avoid seeking
From: Jan Kiszka <[email protected]>
Seeking on vmstate save/load does not work if the underlying file is a stream. We could try to make all QEMUFile* forward-seek-aware, but first attempts in this direction indicated that it's saner to convert the few qemu_fseek-on-vmstates users to plain reads/writes.
This fixes various subtle vmstate corruptions where unused fields were involved.
--- savevm.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)
savevm.c +17 -3
@@ -959,13 +959,27 @@ const VMStateInfo vmstate_info_buffer = {static int get_unused_buffer (QEMUFile *f,void *pv,size_t size) { -qemu_fseek (f, size,SEEK_CUR ); -return 0 ; +uint8_t buf[1024 ]; +int block_len; + +while (size >0 ) { + block_len =MIN (sizeof (buf), size); + size -= block_len; +qemu_get_buffer (f, buf, block_len); + } +return 0 ; }static void put_unused_buffer (QEMUFile *f,void *pv,size_t size) { -qemu_fseek (f, size,SEEK_CUR ); +static const uint8_t buf[1024 ]; +int block_len; + +while (size >0 ) { + block_len =MIN (sizeof (buf), size); + size -= block_len; +qemu_put_buffer (f, buf, block_len); + } }const VMStateInfo vmstate_info_unused_buffer = {
Signature · 1 line
1.6.5.2
PATCH 2/12 vmstate: Fix info field of VMSTATE_MACADDR
In reply to Juan QuintelaFrom: Jan Kiszka <[email protected]>
--- hw/hw.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/hw.h +1 -1
@@ -545,7 +545,7 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_MACADDR (_field, _state) { \ .name = (stringify(_field)), \ .size = sizeof(MACAddr), \ - .info = &vmstate_info_uint8, \ + .info = &vmstate_info_buffer, \ .flags = VMS_BUFFER, \ .offset = vmstate_offset_macaddr(_state, _field), \ }
Signature · 1 line
1.6.5.2
PATCH 3/12 vmstate: fix missing ARRAY_OF_POINTERS support on save state
In reply to Juan Quintela--- savevm.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
savevm.c +3 -0
@@ -1206,6 +1206,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,for (i =0 ; i < n_elems; i++) {void *addr = base_addr + field->size * i; +if (field->flags &VMS_ARRAY_OF_POINTER ) { + addr = *(void **)addr; + }if (field->flags &VMS_STRUCT ) {vmstate_save_state (f, field->vmsd, addr); }else {
Signature · 1 line
1.6.5.2
PATCH 4/12 vmstate: Add support for VBUFFERS
In reply to Juan QuintelaSupport for buffer that are pointed by a pointer (i.e. not embedded) where the size that we want to use is a field in the state. We also need a new place to store where to start in the middle of the buffer, as now it is a pointer, not the offset of the 1st field.
--- hw/hw.h | 20 ++++++++++++++++++++ savevm.c | 20 ++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-)
hw/hw.h +20 -0
@@ -294,14 +294,17 @@ enum VMStateFlags {VMS_BUFFER =0x020 ,/* static sized buffer */ VMS_ARRAY_OF_POINTER =0x040 ,VMS_VARRAY_UINT16 =0x080 ,/* Array with size in uint16_t field */ + VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ }; typedef struct { const char *name; size_t offset; size_t size; + size_t start; int num; size_t num_offset; + size_t size_offset; const VMStateInfo *info; enum VMStateFlags flags; const VMStateDescription *vmsd;
@@ -490,6 +493,17 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = vmstate_offset_buffer(_state, _field) + _start, \ } +#define VMSTATE_VBUFFER (_field, _state, _version, _test, _start, _field_size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ + .info = &vmstate_info_buffer, \ + .flags = VMS_VBUFFER|VMS_POINTER, \ + .offset = offsetof(_state, _field), \ + .start = (_start), \ +} +#define VMSTATE_BUFFER_UNSAFE_INFO (_field, _state, _version, _info, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \
@@ -683,6 +697,12 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_BUFFER_START_MIDDLE (_f, _s, _start) \ VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f))) +#define VMSTATE_PARTIAL_VBUFFER (_f, _s, _size) \ + VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size) + +#define VMSTATE_SUB_VBUFFER (_f, _s, _start, _size) \ + VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size) +#define VMSTATE_BUFFER_TEST (_f, _s, _test) \ VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
savevm.c +14 -6
@@ -1143,7 +1143,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, field->version_id <= version_id)) {void *base_addr = opaque + field->offset;int ret, i, n_elems =1 ; +int size = field->size; +if (field->flags &VMS_VBUFFER ) { + size = *(int32_t *)(opaque+field->size_offset); + }if (field->flags &VMS_ARRAY ) { n_elems = field->num; }else if (field->flags &VMS_VARRAY_INT32 ) {
@@ -1152,10 +1156,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = *(uint16_t *)(opaque+field->num_offset); }if (field->flags &VMS_POINTER ) { - base_addr = *(void **)base_addr; + base_addr = *(void **)base_addr + field->start; }for (i =0 ; i < n_elems; i++) { -void *addr = base_addr + field->size * i; +void *addr = base_addr + size * i;if (field->flags &VMS_ARRAY_OF_POINTER ) { addr = *(void **)addr;
@@ -1163,7 +1167,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,if (field->flags &VMS_STRUCT ) { ret =vmstate_load_state (f, field->vmsd, addr, field->vmsd->version_id); }else { - ret = field->info->get (f, addr, field->size); + ret = field->info->get (f, addr, size); }if (ret <0 ) {
@@ -1192,7 +1196,11 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, field->field_exists(opaque, vmsd->version_id)) {void *base_addr = opaque + field->offset;int i, n_elems =1 ; +int size = field->size; +if (field->flags &VMS_VBUFFER ) { + size = *(int32_t *)(opaque+field->size_offset); + }if (field->flags &VMS_ARRAY ) { n_elems = field->num; }else if (field->flags &VMS_VARRAY_INT32 ) {
@@ -1201,10 +1209,10 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = *(uint16_t *)(opaque+field->num_offset); }if (field->flags &VMS_POINTER ) { - base_addr = *(void **)base_addr; + base_addr = *(void **)base_addr + field->start; }for (i =0 ; i < n_elems; i++) { -void *addr = base_addr + field->size * i; +void *addr = base_addr + size * i;if (field->flags &VMS_ARRAY_OF_POINTER ) { addr = *(void **)addr;
@@ -1212,7 +1220,7 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,if (field->flags &VMS_STRUCT ) {vmstate_save_state (f, field->vmsd, addr); }else { - field->info->put (f, addr, field->size); + field->info->put (f, addr, size); } } }
Signature · 1 line
1.6.5.2
PATCH 5/12 vmstate: Introduce VMSTATE_STRUCT_TEST
In reply to Juan Quintela--- hw/hw.h | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-)
hw/hw.h +11 -7
@@ -436,13 +436,14 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = offsetof(_state, _field), \ } -#define VMSTATE_STRUCT (_field, _state, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, _type), \ +#define VMSTATE_STRUCT_TEST (_field, _state, _test, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, _type), \ }#define VMSTATE_STRUCT_POINTER (_field, _state, _vmsd, _type) { \
@@ -574,6 +575,9 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_SINGLE (_field, _state, _version, _info, _type) \ VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type) +#define VMSTATE_STRUCT (_field, _state, _version, _vmsd, _type) \ + VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type) +#define VMSTATE_INT8_V (_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)#define VMSTATE_INT16_V (_f, _s, _v) \
Signature · 1 line
1.6.5.2
PATCH 6/12 vmstate: Introduce VMSTATE_STRUCT_POINTER_TEST
In reply to Juan Quintela--- hw/hw.h | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
hw/hw.h +10 -6
@@ -446,12 +446,13 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = vmstate_offset_value(_state, _field, _type), \ } -#define VMSTATE_STRUCT_POINTER (_field, _state, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_POINTER, \ - .offset = vmstate_offset_value(_state, _field, _type), \ +#define VMSTATE_STRUCT_POINTER_TEST (_field, _state, _test, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .field_exists = (_test), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_POINTER, \ + .offset = vmstate_offset_value(_state, _field, _type), \ }#define VMSTATE_ARRAY_OF_POINTER (_field, _state, _num, _version, _info, _type) {\
@@ -578,6 +579,9 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_STRUCT (_field, _state, _version, _vmsd, _type) \ VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type) +#define VMSTATE_STRUCT_POINTER (_field, _state, _vmsd, _type) \ + VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type) +#define VMSTATE_INT8_V (_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)#define VMSTATE_INT16_V (_f, _s, _v) \
Signature · 1 line
1.6.5.2
PATCH 7/12 vmstate: Introduce UINT16_TEST support
In reply to Juan Quintela--- hw/hw.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
hw/hw.h +3 -0
@@ -633,6 +633,9 @@ extern const VMStateDescription vmstate_i2c_slave;#define VMSTATE_INT32_LE (_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) +#define VMSTATE_UINT16_TEST (_f, _s, _t) \ + VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t) +#define VMSTATE_UINT32_TEST (_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
Signature · 1 line
1.6.5.2
PATCH 8/12 vmstate: remove usused VMSTATE_STRUCT_ARRAY_SIZE_UINT8
In reply to Juan Quintela--- hw/hw.h | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-)
hw/hw.h +0 -10
@@ -475,16 +475,6 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = vmstate_offset_array(_state, _field, _type, _num), \ } -#define VMSTATE_STRUCT_ARRAY_SIZE_UINT8 (_field, _state, _field__num, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_ARRAY, \ - .offset = vmstate_offset_array(_state, _field, _type, _num), \ -} -#define VMSTATE_STATIC_BUFFER (_field, _state, _version, _test, _start, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \
Signature · 1 line
1.6.5.2
PATCH 9/12 vmstate: Add support for multiplying size for a constant
In reply to Juan QuintelaWhen the size that we want to transmit is in another field, but in an unit different that bytes
--- hw/hw.h | 13 +++++++++++++ savevm.c | 6 ++++++ 2 files changed, 19 insertions(+), 0 deletions(-)
hw/hw.h +13 -0
@@ -295,6 +295,7 @@ enum VMStateFlags {VMS_ARRAY_OF_POINTER =0x040 ,VMS_VARRAY_UINT16 =0x080 ,/* Array with size in uint16_t field */ VMS_VBUFFER =0x100 ,/* Buffer with size in int32_t field */ + VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ }; typedef struct {
@@ -485,6 +486,18 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = vmstate_offset_buffer(_state, _field) + _start, \ } +#define VMSTATE_BUFFER_MULTIPLY (_field, _state, _version, _test, _start, _field_size, _multiply) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ + .size = (_multiply), \ + .info = &vmstate_info_buffer, \ + .flags = VMS_VBUFFER|VMS_MULTIPLY, \ + .offset = offsetof(_state, _field), \ + .start = (_start), \ +} +#define VMSTATE_VBUFFER (_field, _state, _version, _test, _start, _field_size) { \ .name = (stringify(_field)), \ .version_id = (_version), \
savevm.c +6 -0
@@ -1147,6 +1147,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,if (field->flags &VMS_VBUFFER ) { size = *(int32_t *)(opaque+field->size_offset); +if (field->flags &VMS_MULTIPLY ) { + size *= field->size; + } }if (field->flags &VMS_ARRAY ) { n_elems = field->num;
@@ -1200,6 +1203,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,if (field->flags &VMS_VBUFFER ) { size = *(int32_t *)(opaque+field->size_offset); +if (field->flags &VMS_MULTIPLY ) { + size *= field->size; + } }if (field->flags &VMS_ARRAY ) { n_elems = field->num;
Signature · 1 line
1.6.5.2
PATCH 11/12 qdev: enable vmstate_unregister() support
In reply to Juan QuintelaNow vmstate_unregister have the right type
--- hw/qdev.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
hw/qdev.c +0 -2
@@ -296,10 +296,8 @@ void qdev_free(DeviceState *dev) bus =QLIST_FIRST (&dev->child_bus);qbus_free (bus); } -#if 0 /* FIXME: need sane vmstate_unregister function */ if (dev->info->vmsd)vmstate_unregister (dev->info->vmsd, dev); -#endif if (dev->info->exit) dev->info->exit (dev);if (dev->opts)
Signature · 1 line
1.6.5.2
PATCH 10/12 pci: vmstate_register() already assign consecutive numbers starting at 0
In reply to Juan Quintela--- hw/pci.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
hw/pci.c +1 -3
@@ -161,8 +161,6 @@ PCIBus *pci_find_root_bus(int domain)void pci_bus_new_inplace (PCIBus *bus,DeviceState *parent,const char *name,int devfn_min) { -static int nbus =0 ; -qbus_create_inplace (&bus->qbus, &pci_bus_info, parent, name); bus->devfn_min = devfn_min;
@@ -170,7 +168,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,QLIST_INIT (&bus->child);pci_host_bus_register (0 , bus);/* for now only pci domain 0 is supported */ -vmstate_register (nbus++, &vmstate_pcibus, bus); +vmstate_register (-1 , &vmstate_pcibus, bus);qemu_register_reset (pci_bus_reset, bus); }
Signature · 1 line
1.6.5.2
PATCH 12/12 savevm: Port to qdev.vmsd all devices that have qdev
In reply to Juan Quintela--- hw/ac97.c | 2 +- hw/cirrus_vga.c | 2 +- hw/cs4231a.c | 2 +- hw/e1000.c | 4 +--- hw/es1370.c | 2 +- hw/gus.c | 2 +- hw/lance.c | 14 ++++++++++++-- hw/lm832x.c | 2 +- hw/lsi53c895a.c | 2 +- hw/max7310.c | 2 +- hw/ne2000-isa.c | 12 +++++++++++- hw/ne2000.c | 3 +-- hw/pckbd.c | 13 ++++++++++++- hw/pcnet.c | 4 +--- hw/piix_pci.c | 4 ++-- hw/rtl8139.c | 4 +--- hw/sb16.c | 2 +- hw/ssd0303.c | 2 +- hw/tmp105.c | 2 +- hw/twl92230.c | 2 +- hw/usb-uhci.c | 3 ++- hw/vga-pci.c | 2 +- hw/vmware_vga.c | 2 +- hw/wdt_i6300esb.c | 3 +-- hw/wdt_ib700.c | 2 +- hw/wm8750.c | 2 +- 26 files changed, 60 insertions(+), 36 deletions(-)
hw/ac97.c +1 -1
@@ -1319,7 +1319,6 @@ static int ac97_initfn (PCIDevice *dev)pci_register_bar (&s->dev,0 ,256 *4 ,PCI_BASE_ADDRESS_SPACE_IO , ac97_map);pci_register_bar (&s->dev,1 ,64 *4 ,PCI_BASE_ADDRESS_SPACE_IO , ac97_map); -vmstate_register (0 , &vmstate_ac97, s);qemu_register_reset (ac97_on_reset, s);AUD_register_card ("ac97" , &s->card);ac97_on_reset (s);
@@ -1336,6 +1335,7 @@ static PCIDeviceInfo ac97_info = { .qdev.name = "AC97", .qdev.desc = "Intel 82801AA AC97 Audio", .qdev.size = sizeof (AC97LinkState), + .qdev.vmsd = &vmstate_ac97, .init = ac97_initfn, };
hw/cirrus_vga.c +1 -1
@@ -3245,7 +3245,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)pci_register_bar ((PCIDevice *)d,1 ,CIRRUS_PNPMMIO_SIZE ,PCI_BASE_ADDRESS_SPACE_MEMORY , cirrus_pci_mmio_map); } -vmstate_register (0 , &vmstate_pci_cirrus_vga, d);/* ROM BIOS */ rom_add_vga (VGABIOS_CIRRUS_FILENAME );
@@ -3260,6 +3259,7 @@ void pci_cirrus_vga_init(PCIBus *bus)static PCIDeviceInfo cirrus_vga_info = { .qdev.name ="Cirrus VGA" , .qdev.size =sizeof (PCICirrusVGAState), + .qdev.vmsd = &vmstate_pci_cirrus_vga, .init = pci_cirrus_vga_initfn, .config_write = pci_cirrus_write_config, };
hw/cs4231a.c +1 -1
@@ -651,7 +651,6 @@ static int cs4231a_initfn (ISADevice *dev)DMA_register_channel (s->dma, cs_dma_read, s); -vmstate_register (0 , &vmstate_cs4231a, s);qemu_register_reset (cs_reset, s);cs_reset (s);
@@ -669,6 +668,7 @@ static ISADeviceInfo cs4231a_info = { .qdev.name = "cs4231a", .qdev.desc = "Crystal Semiconductor CS4231A", .qdev.size = sizeof (CSState), + .qdev.vmsd = &vmstate_cs4231a, .init = cs4231a_initfn, .qdev.props = (Property []) {DEFINE_PROP_HEX32 ("iobase" , CSState, port,0x534 ),
hw/e1000.c +1 -3
@@ -1051,7 +1051,6 @@ pci_e1000_uninit(PCIDevice *dev)cpu_unregister_io_memory (d->mmio_index);qemu_del_vlan_client (d->vc); -vmstate_unregister (&vmstate_e1000, d);return 0 ; }
@@ -1116,8 +1115,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)qemu_format_nic_info_str (d->vc, macaddr); -vmstate_register (-1 , &vmstate_e1000, d); -if (!pci_dev->qdev.hotplugged) {static int loaded =0 ;if (!loaded) {
@@ -1139,6 +1136,7 @@ static PCIDeviceInfo e1000_info = { .qdev.desc = "Intel Gigabit Ethernet", .qdev.size = sizeof(E1000State), .qdev.reset = qdev_e1000_reset, + .qdev.vmsd = &vmstate_e1000, .init = pci_e1000_init, .exit = pci_e1000_uninit, .qdev.props = (Property []) {
hw/es1370.c +1 -1
@@ -1023,7 +1023,6 @@ static int es1370_initfn (PCIDevice *dev) c[0x3f ] =0x80 ;pci_register_bar (&s->dev,0 ,256 ,PCI_BASE_ADDRESS_SPACE_IO , es1370_map); -vmstate_register (0 , &vmstate_es1370, s);qemu_register_reset (es1370_on_reset, s);AUD_register_card ("es1370" , &s->card);
@@ -1041,6 +1040,7 @@ static PCIDeviceInfo es1370_info = { .qdev.name = "ES1370", .qdev.desc = "ENSONIQ AudioPCI ES1370", .qdev.size = sizeof (ES1370State), + .qdev.vmsd = &vmstate_es1370, .init = es1370_initfn, };
hw/gus.c +1 -1
@@ -287,7 +287,6 @@ static int gus_initfn (ISADevice *dev)AUD_set_active_out (s->voice,1 ); -vmstate_register (0 , &vmstate_gus, s);return 0 ; }
@@ -301,6 +300,7 @@ static ISADeviceInfo gus_info = { .qdev.name = "gus", .qdev.desc = "Gravis Ultrasound GF1", .qdev.size = sizeof (GUSState), + .qdev.vmsd = &vmstate_gus, .init = gus_initfn, .qdev.props = (Property []) {DEFINE_PROP_UINT32 ("freq" , GUSState, freq,44100 ),
hw/lance.c +12 -2
@@ -96,10 +96,20 @@ static void lance_cleanup(VLANClientState *vc) {PCNetState *d = vc->opaque; -vmstate_unregister (&vmstate_pcnet, d);pcnet_common_cleanup (d); } +static const VMStateDescription vmstate_lance = { + .name ="pcnet" , + .version_id =3 , + .minimum_version_id =2 , + .minimum_version_id_old =2 , + .fields = (VMStateField []) { +VMSTATE_STRUCT (state, SysBusPCNetState,0 , vmstate_pcnet, PCNetState), +VMSTATE_END_OF_LIST () + } +}; +static int lance_init (SysBusDevice *dev) {SysBusPCNetState *d =FROM_SYSBUS (SysBusPCNetState, dev);
@@ -117,7 +127,6 @@ static int lance_init(SysBusDevice *dev) s->phys_mem_read = ledma_memory_read; s->phys_mem_write = ledma_memory_write; -vmstate_register (-1 , &vmstate_pcnet, d);return pcnet_common_init (&dev->qdev, s, lance_cleanup); }
@@ -133,6 +142,7 @@ static SysBusDeviceInfo lance_info = { .qdev.name = "lance", .qdev.size = sizeof(SysBusPCNetState), .qdev.reset = lance_reset, + .qdev.vmsd = &vmstate_lance, .qdev.props = (Property []) {DEFINE_PROP_PTR ("dma" , SysBusPCNetState, state.dma_opaque),DEFINE_NIC_PROPERTIES (SysBusPCNetState, state.conf),
hw/lm832x.c +1 -1
@@ -471,7 +471,6 @@ static int lm8323_init(i2c_slave *i2c)lm_kbd_reset (s);qemu_register_reset ((void *) lm_kbd_reset, s); -vmstate_register (-1 , &vmstate_lm_kbd, s);return 0 ; }
@@ -498,6 +497,7 @@ void lm832x_key_event(struct i2c_slave *i2c, int key, int state)static I2CSlaveInfo lm8323_info = { .qdev.name ="lm8323" , .qdev.size =sizeof (LM823KbdState), + .qdev.vmsd = &vmstate_lm_kbd, .init = lm8323_init, .event = lm_i2c_event, .recv = lm_i2c_rx,
hw/lsi53c895a.c +1 -1
@@ -2106,7 +2106,6 @@ static int lsi_scsi_init(PCIDevice *dev)if (!dev->qdev.hotplugged) {scsi_bus_legacy_handle_cmdline (&s->bus); } -vmstate_register (-1 , &vmstate_lsi_scsi, s);return 0 ; }
@@ -2114,6 +2113,7 @@ static PCIDeviceInfo lsi_info = { .qdev.name = "lsi53c895a", .qdev.alias = "lsi", .qdev.size = sizeof(LSIState), + .qdev.vmsd = &vmstate_lsi_scsi, .init = lsi_scsi_init, .exit = lsi_scsi_uninit, };
hw/max7310.c +1 -1
@@ -184,7 +184,6 @@ static int max7310_init(i2c_slave *i2c)max7310_reset (&s->i2c); -vmstate_register (-1 , &vmstate_max7310, s);return 0 ; }
@@ -206,6 +205,7 @@ void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler)static I2CSlaveInfo max7310_info = { .qdev.name ="max7310" , .qdev.size =sizeof (MAX7310State), + .qdev.vmsd = &vmstate_max7310, .init = max7310_init, .event = max7310_event, .recv = max7310_rx,
hw/ne2000-isa.c +11 -1
@@ -42,6 +42,17 @@ static void isa_ne2000_cleanup(VLANClientState *vc) s->vc =NULL ; } +const VMStateDescription vmstate_isa_ne2000 = { + .name ="ne2000" , + .version_id =2 , + .minimum_version_id =0 , + .minimum_version_id_old =0 , + .fields = (VMStateField []) { +VMSTATE_STRUCT (ne2000, ISANE2000State,0 , vmstate_ne2000, NE2000State), +VMSTATE_END_OF_LIST () + } +}; +static int isa_ne2000_initfn (ISADevice *dev) {ISANE2000State *isa =DO_UPCAST (ISANE2000State, dev, dev);
@@ -69,7 +80,6 @@ static int isa_ne2000_initfn(ISADevice *dev) NULL, isa_ne2000_cleanup, s);qemu_format_nic_info_str (s->vc, s->c.macaddr.a); -vmstate_register (-1 , &vmstate_ne2000, s);return 0 ; }
hw/ne2000.c +1 -2
@@ -739,7 +739,6 @@ static int pci_ne2000_init(PCIDevice *pci_dev) } } -vmstate_register (-1 , &vmstate_pci_ne2000, d);return 0 ; }
@@ -748,7 +747,6 @@ static int pci_ne2000_exit(PCIDevice *pci_dev)PCINE2000State *d =DO_UPCAST (PCINE2000State, dev, pci_dev);NE2000State *s = &d->ne2000; -vmstate_unregister (&vmstate_pci_ne2000, s);qemu_del_vlan_client (s->vc);return 0 ; }
@@ -756,6 +754,7 @@ static int pci_ne2000_exit(PCIDevice *pci_dev)static PCIDeviceInfo ne2000_info = { .qdev.name ="ne2k_pci" , .qdev.size =sizeof (PCINE2000State), + .qdev.vmsd = &vmstate_pci_ne2000, .init = pci_ne2000_init, .exit = pci_ne2000_exit, .qdev.props = (Property []) {
hw/pckbd.c +12 -1
@@ -414,6 +414,17 @@ typedef struct ISAKBDState {KBDState kbd; } ISAKBDState; +const VMStateDescription vmstate_kbd_isa = { + .name ="pckbd" , + .version_id =3 , + .minimum_version_id =3 , + .minimum_version_id_old =3 , + .fields = (VMStateField []) { +VMSTATE_STRUCT (kbd, ISAKBDState,0 , vmstate_kbd, KBDState), +VMSTATE_END_OF_LIST () + } +}; +static int i8042_initfn (ISADevice *dev) {KBDState *s = &(DO_UPCAST (ISAKBDState, dev, dev)->kbd);
@@ -421,7 +432,6 @@ static int i8042_initfn(ISADevice *dev)isa_init_irq (dev, &s->irq_kbd,1 );isa_init_irq (dev, &s->irq_mouse,12 ); -vmstate_register (0 , &vmstate_kbd, s);register_ioport_read (0x60 ,1 ,1 , kbd_read_data, s);register_ioport_write (0x60 ,1 ,1 , kbd_write_data, s);register_ioport_read (0x64 ,1 ,1 , kbd_read_status, s);
@@ -439,6 +449,7 @@ static int i8042_initfn(ISADevice *dev)static ISADeviceInfo i8042_info = { .qdev.name ="i8042" , .qdev.size =sizeof (ISAKBDState), + .qdev.vmsd = &vmstate_kbd_isa, .qdev.no_user =1 , .init = i8042_initfn, };
hw/pcnet.c +1 -3
@@ -1957,7 +1957,6 @@ static int pci_pcnet_uninit(PCIDevice *dev)PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, dev);cpu_unregister_io_memory (d->state.mmio_index); -vmstate_unregister (&vmstate_pci_pcnet, d);qemu_del_timer (d->state.poll_timer);qemu_free_timer (d->state.poll_timer);qemu_del_vlan_client (d->state.vc);
@@ -2007,8 +2006,6 @@ static int pci_pcnet_init(PCIDevice *pci_dev) s->phys_mem_read = pci_physical_memory_read; s->phys_mem_write = pci_physical_memory_write; -vmstate_register (-1 , &vmstate_pci_pcnet, d); -if (!pci_dev->qdev.hotplugged) {static int loaded =0 ;if (!loaded) {
@@ -2031,6 +2028,7 @@ static PCIDeviceInfo pcnet_info = { .qdev.name = "pcnet", .qdev.size = sizeof(PCIPCNetState), .qdev.reset = pci_reset, + .qdev.vmsd = &vmstate_pci_pcnet, .init = pci_pcnet_init, .exit = pci_pcnet_uninit, .qdev.props = (Property []) {
hw/piix_pci.c +2 -2
@@ -198,7 +198,6 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[0x72 ] =0x02 ;/* SMRAM */ -vmstate_register (0 , &vmstate_i440fx, d);return 0 ; }
@@ -312,7 +311,6 @@ static int piix3_initfn(PCIDevice *dev)uint8_t *pci_conf;isa_bus_new (&d->dev.qdev); -vmstate_register (0 , &vmstate_piix3, d); pci_conf = d->dev.config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_INTEL );
@@ -330,6 +328,7 @@ static PCIDeviceInfo i440fx_info[] = { .qdev.name = "i440FX", .qdev.desc = "Host bridge", .qdev.size = sizeof(PCII440FXState), + .qdev.vmsd = &vmstate_i440fx, .qdev.no_user = 1, .init = i440fx_initfn, .config_write = i440fx_write_config,
@@ -337,6 +336,7 @@ static PCIDeviceInfo i440fx_info[] = { .qdev.name = "PIIX3", .qdev.desc = "ISA bridge", .qdev.size = sizeof(PIIX3State), + .qdev.vmsd = &vmstate_piix3, .qdev.no_user = 1, .init = piix3_initfn, },{
hw/rtl8139.c +1 -3
@@ -3300,7 +3300,6 @@ static int pci_rtl8139_uninit(PCIDevice *dev)qemu_del_timer (s->timer);qemu_free_timer (s->timer);#endif -vmstate_unregister (&vmstate_rtl8139, s);qemu_del_vlan_client (s->vc);return 0 ; }
@@ -3343,8 +3342,6 @@ static int pci_rtl8139_init(PCIDevice *dev) s->cplus_txbuffer_len =0 ; s->cplus_txbuffer_offset =0 ; -vmstate_register (-1 , &vmstate_rtl8139, s); -#ifdef RTL8139_ONBOARD_TIMER s->timer =qemu_new_timer (vm_clock, rtl8139_timer, s);
@@ -3366,6 +3363,7 @@ static PCIDeviceInfo rtl8139_info = { .qdev.name = "rtl8139", .qdev.size = sizeof(RTL8139State), .qdev.reset = rtl8139_reset, + .qdev.vmsd = &vmstate_rtl8139, .init = pci_rtl8139_init, .exit = pci_rtl8139_uninit, .qdev.props = (Property []) {
hw/sb16.c +1 -1
@@ -1381,7 +1381,6 @@ static int sb16_initfn (ISADevice *dev)DMA_register_channel (s->dma, SB_read_DMA, s); s->can_write =1 ; -vmstate_register (0 , &vmstate_sb16, s);AUD_register_card ("sb16" , &s->card);return 0 ; }
@@ -1396,6 +1395,7 @@ static ISADeviceInfo sb16_info = { .qdev.name = "sb16", .qdev.desc = "Creative Sound Blaster 16", .qdev.size = sizeof (SB16State), + .qdev.vmsd = &vmstate_sb16, .init = sb16_initfn, .qdev.props = (Property []) {DEFINE_PROP_HEX32 ("version" , SB16State, ver,0x0405 ),/* 4.5 */
hw/ssd0303.c +1 -1
@@ -291,13 +291,13 @@ static int ssd0303_init(i2c_slave *i2c) ssd0303_invalidate_display, NULL, NULL, s);qemu_console_resize (s->ds,96 *MAGNIFY ,16 *MAGNIFY ); -vmstate_register (-1 , &vmstate_ssd0303, s);return 0 ; }static I2CSlaveInfo ssd0303_info = { .qdev.name ="ssd0303" , .qdev.size =sizeof (ssd0303_state), + .qdev.vmsd = &vmstate_ssd0303, .init = ssd0303_init, .event = ssd0303_event, .recv = ssd0303_recv,
hw/tmp105.c +1 -1
@@ -228,13 +228,13 @@ static int tmp105_init(i2c_slave *i2c)tmp105_reset (&s->i2c); -vmstate_register (-1 , &vmstate_tmp105, s);return 0 ; }static I2CSlaveInfo tmp105_info = { .qdev.name ="tmp105" , .qdev.size =sizeof (TMP105State), + .qdev.vmsd = &vmstate_tmp105, .init = tmp105_init, .event = tmp105_event, .recv = tmp105_rx,
hw/twl92230.c +1 -1
@@ -855,13 +855,13 @@ static int twl92230_init(i2c_slave *i2c)menelaus_reset (&s->i2c); -vmstate_register (-1 , &vmstate_menelaus, s);return 0 ; }static I2CSlaveInfo twl92230_info = { .qdev.name ="twl92230" , .qdev.size =sizeof (MenelausState), + .qdev.vmsd = &vmstate_menelaus, .init = twl92230_init, .event = menelaus_event, .recv = menelaus_rx,
hw/usb-uhci.c +2 -1
@@ -1086,7 +1086,6 @@ static int usb_uhci_common_initfn(UHCIState *s)pci_register_bar (&s->dev,4 ,0x20 ,PCI_BASE_ADDRESS_SPACE_IO , uhci_map); -vmstate_register (0 , &vmstate_uhci, s);return 0 ; }
@@ -1114,10 +1113,12 @@ static PCIDeviceInfo uhci_info[] = { { .qdev.name = "PIIX3 USB-UHCI", .qdev.size = sizeof(UHCIState), + .qdev.vmsd = &vmstate_uhci, .init = usb_uhci_piix3_initfn, },{ .qdev.name = "PIIX4 USB-UHCI", .qdev.size = sizeof(UHCIState), + .qdev.vmsd = &vmstate_uhci, .init = usb_uhci_piix4_initfn, },{ /* end of list */
hw/vga-pci.c +1 -1
@@ -82,7 +82,6 @@ static int pci_vga_initfn(PCIDevice *dev)// vga + console init vga_common_init (s,VGA_RAM_SIZE );vga_init (s); -vmstate_register (0 , &vmstate_vga_pci, d); s->ds =graphic_console_init (s->update, s->invalidate, s->screen_dump, s->text_update, s);
@@ -128,6 +127,7 @@ int pci_vga_init(PCIBus *bus,static PCIDeviceInfo vga_info = { .qdev.name ="VGA" , .qdev.size =sizeof (PCIVGAState), + .qdev.vmsd = &vmstate_vga_pci, .init = pci_vga_initfn, .config_write = pci_vga_write_config, .qdev.props = (Property []) {
hw/vmware_vga.c +1 -1
@@ -1189,7 +1189,6 @@ static int pci_vmsvga_initfn(PCIDevice *dev)vmsvga_init (&s->chip,VGA_RAM_SIZE ); -vmstate_register (0 , &vmstate_vmware_vga, s);return 0 ; }
@@ -1201,6 +1200,7 @@ void pci_vmsvga_init(PCIBus *bus)static PCIDeviceInfo vmsvga_info = { .qdev.name ="QEMUware SVGA" , .qdev.size =sizeof (struct pci_vmsvga_state_s ), + .qdev.vmsd = &vmstate_vmware_vga, .init = pci_vmsvga_initfn, };
hw/wdt_i6300esb.c +1 -2
@@ -416,8 +416,6 @@ static int i6300esb_init(PCIDevice *dev)pci_register_bar (&d->dev,0 ,0x10 ,PCI_BASE_ADDRESS_SPACE_MEMORY , i6300esb_map); -vmstate_register (-1 , &vmstate_i6300esb, d); -return 0 ; }
@@ -429,6 +427,7 @@ static WatchdogTimerModel model = {static PCIDeviceInfo i6300esb_info = { .qdev.name ="i6300esb" , .qdev.size =sizeof (I6300State), + .qdev.vmsd = &vmstate_i6300esb, .config_read = i6300esb_config_read, .config_write = i6300esb_config_write, .init = i6300esb_init,
hw/wdt_ib700.c +1 -1
@@ -98,7 +98,6 @@ static int wdt_ib700_init(ISADevice *dev)IB700State *s =DO_UPCAST (IB700State, dev, dev); s->timer =qemu_new_timer (vm_clock, ib700_timer_expired, s); -vmstate_register (-1 , &vmstate_ib700, s);register_ioport_write (0x441 ,2 ,1 , ib700_write_disable_reg, s);register_ioport_write (0x443 ,2 ,1 , ib700_write_enable_reg, s);
@@ -113,6 +112,7 @@ static WatchdogTimerModel model = {static ISADeviceInfo wdt_ib700_info = { .qdev.name ="ib700" , .qdev.size =sizeof (IB700State), + .qdev.vmsd = &vmstate_ib700, .init = wdt_ib700_init, };
hw/wm8750.c +1 -1
@@ -622,7 +622,6 @@ static int wm8750_init(i2c_slave *i2c)AUD_register_card (CODEC , &s->card);wm8750_reset (&s->i2c); -vmstate_register (-1 , &vmstate_wm8750, s);return 0 ; }
@@ -699,6 +698,7 @@ void wm8750_set_bclk_in(void *opaque, int new_hz)static I2CSlaveInfo wm8750_info = { .qdev.name ="wm8750" , .qdev.size =sizeof (WM8750State), + .qdev.vmsd = &vmstate_wm8750, .init = wm8750_init, .event = wm8750_event, .recv = wm8750_rx,
Signature · 1 line
1.6.5.2