All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive)
@ 2014-04-07  3:20 Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 01/97] savevm: Ignore minimum_version_id_old if there is no load_state_old Juan Quintela
                   ` (98 more replies)
  0 siblings, 99 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Hi

  Look at the diffstat.  Almost all the additions are at
test-vmstate.c. That is the reason why it is called a simplification.

What this series does:
- peter removal of version_minimum_id_old field when not needed (Peter)
- cleanup: based on the previous one, I removed all the unneeded
  the uses on the tree.  This should make your compiles
  a couple of nanoseconds faster.
- once there, fixed the indentation of the .fields line, to a canonical
    .fields = (VMStateField[])
- mst simplifications for vmstate engine

And now, the big cleanup.
- Patches only do one thing, to make easy the review.

- Added test for all VMSTATE_FOO() definitions
  (well, I am lying, VMSTATE_STRUCT* are still missing, will come soon)
- We had two ways to make a field optional
   VMSTATE_INT64_V(field, state, version)
  and
   VMSTATE_INT64_TEST(field, state, test)

  We can do the version one with one test like:

static inline bool vmstate_5_plus(void *opaque, int version_id)
{
    return version_id >= 5;
}

  and then change:
  VMSTATE_INT64_V(field, state, 5);

  into
  VMSTATE_INT64_TEST(field, state, vmstate_5_plus);

  The functions until version 15 are already defined on the tree.
  All the users on the tree are changed to this new schema.  Actually we used
  to have:
  VMSTATE_FOO()
  VMSTATE_FOO_V()
  VMSTATE_FOO_TEST()

  Where some of them where defined.  After all the changes, only exst
  VMSTATE_FOO()
  VMSTATE_FOO_TEST()   (When needed)

- When all the changes are done, removal from version_id at the
  FieldLevel is removed.  Notice that from the toplevel, all the
  versions work the same at the section level, the only thing that has
  changed is at the field level.

- Doing the tests, I found a bug (tests have some utility after all)

  When the incoming migration stream stoped for any reason, we setup
  an error, but until we don't end a section, we never check for one
  error, so it could take a lot until we found it.  Now we check after
  each field read.

- You can see that all the tests share a lot of the boilerplate code.
  If you have any good idea about how to refactor it to not repeat so
  much code, let me know.

- Remove all the VMSTATE_FOO* that had no users

- Create new ones for things that were opencoded

  VMSTATE_SYNTHETIC(): fields that don't exist on the state struct and
  are generated It was already opencoded, just created a macro and
  used it where needed.

  VMSTATE_OPENCODED_UNSAFE: There are a couple of cases where a non
  vmstate field is needed from vmstate.  We can cheat and declare that
  as an struct, but that is not vmstate.  There were already users on
  the tree, so create it.

If you ever wanted to know more about VMState, this is your
opportunity.  As the tests are aded one field at a time, you can see
how the things on the wire change each time to add a new field.

ToDo:
- Finish the tests for the STRUCTS and ARRAYS of STRUCTS of several kinds
- synthetic fields: we can do even better/easier.  We can add a hook
  for the cases where we want to compute the value in a different way.

  This could be used for the validate stuff that Michael requested on
  its patches, while allowing to simplify even more tests.

- port the _vmstate fields to the new synthetic framework.

Thanks for reading until here.

Later, Juan.

The following changes since commit 466e6e9d13d56bbb6da1d2396d7d6347df483af0:

  target-i386: reorder fields in cpu/msr_hyperv_hypercall subsection (2014-04-05 10:49:05 +0100)

are available in the git repository at:

  git://github.com/juanquintela/qemu.git tags/vmstate-simplification-v1/20140407

for you to fetch changes up to 965f5c4b7b0f87a6c326d968ebd2b5f6022a962d:

  vmstate: Test for VMSTATE_VBUFFER_UINT32 (2014-04-07 04:35:22 +0200)

----------------------------------------------------------------
vmstate-simplification-v1/next for 20140407

----------------------------------------------------------------
Juan Quintela (94):
      savevm: Remove all the unneded version_minimum_id_old (Massive)
      vmstate: return error in case of error
      vmstate: refactor opening of files
      vmstate: Refactor & increase tests for primitive types
      vmstate: create test functions for versions until 15
      vmstate: Remove VMSTATE_UINTL_EQUAL_V
      vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST
      vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V
      vmstate: Test for VMSTATE_BOOL_TEST
      vmstate: Test for VMSTATE_INT8_TEST
      vmstate: Test for VMSTATE_INT16_TEST
      vmstate: Test for VMSTATE_INT32_TEST
      vmstate: test for VMSTATE_INT64_TEST
      vmstate: Test for VMSTATE_UINT8_TEST
      vmstate: Test for VMSTATE_UINT16_TEST
      vmstate: Test for VMSTATE_UINT32_TEST
      vmstate: Test for VMSTATE_UINT64_TEST
      vmstate: Test for VMSTATE_FLOAT64
      vmstate: Test for VMSTATE_UNUSED
      vmstate: Test for VMSTATE_BITMAP
      vmstate: Test for VMSTATE_UINT8_EQUAL
      vmstate: Test for VMSTATE_UINT16_EQUAL
      vmstate: Test for VMSTATE_UINT32_EQUAL
      vmstate: Test for VMSTATE_UINT64_EQUAL
      vmstate: Test for VMSTATE_INT32_EQUAL
      vmstate: Test for VMSTATE_INT32_LE
      vmstate: Move VMSTATE_TIMER_V to VMSTATE_TIMER_TEST
      vmstate: Test for VMSTATE_ARRAY_BOOL_TEST
      vmstate: Test for VMSTATE_UINT8_ARRAY
      vmstate: Test for VMSTATE_UINT16_ARRAY
      vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST}
      vmstate: Test for VMSTATE_UINT64_ARRAY{_TEST}
      vmstate: Test for VMSTATE_INT16_ARRAY
      vmstate: Test for VMSTATE_INT32_ARRAY{_TEST}
      vmstate: Test for VMSTATE_INT64_ARRAY
      vmstate: Test for VMSTATE_FLOAT64_ARRAY
      vmstate: Test for VMSTATE_UINT8_2DARRAY
      vmstate: Test for VMSTATE_UINT16_2DARRAY.
      vmstate: Test for VMSTATE_UINT32_2DARRAY
      vmstate: Remove unused VMSTATE_BUFFER_V
      vmstate: Remove version from VMSTATE_BUFFER_UNSAFE
      vmstate: Remove unused version fields from ARM
      vmstate: All ptimers users were at least at version 1 or more
      vmstate: remove version from all variants of VMSTATE_STRUCT_POINTER*
      vmstate: Port last 3 users of VMSTATE_ARRAY to VMSTATE_ARRAY_TEST
      vmstate: Port last user of VMSTATE_SINGLE to VMSTATE_SINGLE_TEST
      vmstate: Remove unused VMSTATE_POINTER
      vmstate: Rename VMSTATE_SINGLE_TEST to VMSTATE_SINGLE
      vmstate: Move VMSTATE_2DARRAY to use _test
      vmstate: Rename VMSTATE_POINTER_TEST without _TEST
      vmstate: Rename VMSTATE_ARRAY_TEST to VMSTATE_ARRAY
      vmstate: Remove version_id from VMSTATE_VBUFFER
      vmstate: Remove version_id fields that were not used
      vmstate: Remove version_id from VMSTATE_SUB_ARRAY
      vmstate: Remove version parameter from VMSTATE_VARRAY_INT32
      vmstate: Remove version_id from VMSTATE_VARRAY_UINT16_UNSAFE
      vmstate: VMSTATE_ARRAY_OF_POINTER didn't used the version_id field
      vmstate: remove version parameter from VMSTATE_BUFFER_POINTER_UNSAFE
      vmstate: Remove version, test and start parameter from VMSTATE_VBUFFER_UINT32
      vmstate: Remove version paramenter from VMSTATE_ARRAY_OF_POINTER_TO_STRUCT
      vmstate: Remove VMSTATE_BUFFER_MULTIPLY
      vmstate: Remove version parameter from VMSTATE_STATIC_BUFFER
      vmstate: Remove version field from VMSTATE_STRUCT_VARRAY_UINT32
      vmstate: Move all users of versioning of VMSTATE_STRUCT_ARRAY to _TEST
      vmstate: Remove version paramenter from VMSTATE_STRUCT_ARRAY
      vmstate: Remove version parameter from VMSTATE_STRUCT_ARRAY_TEST
      vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_INT32
      vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_UINT8
      vmstate: Introduce VMSTATE_VARRAY_UINT32_TEST
      vmstate: Remove version parameter from VMSTATE_VARRAY_UINT32
      vmstate: Remove version parameter from VMSTATE_STRUCT_TEST
      vmstate: Move all users of versioning to VMSTATE_STRUCT_TEST
      vmstate: Remove version from all VMSTATE_STRUCT calls
      vmstate: Create VMSTATE_VARRAY macro
      vmstate: Create VMSTATE_POINTER_UNSAFE
      vmstate: Create VMSTATE_OPENCODED_UNSAFE
      vmstate: Create VMSTATE_SYNTHETIC
      vmstate: version_id is gone from fields
      vmstate: Test for VMSTATE_SYNTHETIC
      vmstate: Test for VMSTATE_UINT8_SUB_ARRAY
      vmstate: Test for VMSTATE_UINT32_SUB_ARRAY
      vmstate: Test for VMSTATE_BUFFER
      vmstate: Test for VMSTATE_PARTIAL_BUFFER
      vmstate: Test for VMSTATE_BUFFER_START_MIDDLE
      vmstate: Add tests for VMSTATE_BUFFER_TEST
      vmstate: Use VMSTATE_UINT8_2DARRAY instead of VMSTATE_BUFFER_TEST
      vmstate: Test for VMSTATE_BUFFER_UNSAFE
      vmstate: Remove unused VMSTATE_SUB_VBUFFER
      vmstate: Remove unused VMSTATE_PARTIAL_VBUFFER_UINT32
      vmstate: Test for VMSTATE_PARTIAL_VBUFFER
      vmstate: ename VMSTATE_PARTIAL_VBUFFER to VMSTATE_VBUFFER_INT32
      vmstate: Create VMS_VBUFFER_UINT32
      vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency
      vmstate: Test for VMSTATE_VBUFFER_UINT32

Michael S. Tsirkin (2):
      vmstate: reduce code duplication
      vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/

Peter Maydell (1):
      savevm: Ignore minimum_version_id_old if there is no load_state_old

 audio/audio.c                      |    3 +-
 cpus.c                             |    5 +-
 docs/migration.txt                 |   20 +-
 exec.c                             |    3 +-
 hw/acpi/ich9.c                     |   12 +-
 hw/acpi/pcihp.c                    |    3 +-
 hw/acpi/piix4.c                    |   29 +-
 hw/arm/highbank.c                  |    1 -
 hw/arm/musicpal.c                  |   10 +-
 hw/arm/pxa2xx.c                    |   19 +-
 hw/arm/pxa2xx_gpio.c               |    3 +-
 hw/arm/pxa2xx_pic.c                |    1 -
 hw/arm/spitz.c                     |   14 +-
 hw/arm/stellaris.c                 |   14 +-
 hw/arm/strongarm.c                 |    6 -
 hw/arm/z2.c                        |    2 -
 hw/audio/ac97.c                    |    8 +-
 hw/audio/cs4231.c                  |    3 +-
 hw/audio/cs4231a.c                 |    3 +-
 hw/audio/es1370.c                  |    8 +-
 hw/audio/gus.c                     |    3 +-
 hw/audio/hda-codec.c               |   10 +-
 hw/audio/intel-hda.c               |    7 +-
 hw/audio/lm4549.c                  |    5 +-
 hw/audio/marvell_88w8618.c         |    1 -
 hw/audio/milkymist-ac97.c          |    3 +-
 hw/audio/pl041.c                   |   25 +-
 hw/audio/sb16.c                    |    3 +-
 hw/audio/wm8750.c                  |    3 +-
 hw/block/ecc.c                     |    3 +-
 hw/block/fdc.c                     |   24 +-
 hw/block/m25p80.c                  |    1 -
 hw/block/nand.c                    |    3 +-
 hw/block/onenand.c                 |    5 +-
 hw/char/cadence_uart.c             |    1 -
 hw/char/digic-uart.c               |    1 -
 hw/char/escc.c                     |   10 +-
 hw/char/exynos4210_uart.c          |    6 +-
 hw/char/imx_serial.c               |    1 -
 hw/char/ipoctal232.c               |   13 +-
 hw/char/lm32_juart.c               |    3 +-
 hw/char/lm32_uart.c                |    3 +-
 hw/char/milkymist-uart.c           |    3 +-
 hw/char/pl011.c                    |    3 +-
 hw/char/sclpconsole-lm.c           |    3 +-
 hw/char/sclpconsole.c              |    3 +-
 hw/char/serial-isa.c               |    2 +-
 hw/char/serial-pci.c               |    8 +-
 hw/char/serial.c                   |    6 +-
 hw/char/spapr_vty.c                |    3 +-
 hw/core/ptimer.c                   |    3 +-
 hw/display/ads7846.c               |    3 +-
 hw/display/cg3.c                   |    2 +-
 hw/display/cirrus_vga.c            |    8 +-
 hw/display/exynos4210_fimd.c       |    6 +-
 hw/display/g364fb.c                |    7 +-
 hw/display/jazz_led.c              |    1 -
 hw/display/milkymist-tmu2.c        |    3 +-
 hw/display/milkymist-vgafb.c       |    3 +-
 hw/display/pl110.c                 |    2 +-
 hw/display/pxa2xx_lcd.c            |    8 +-
 hw/display/qxl.c                   |    8 +-
 hw/display/ssd0303.c               |    3 +-
 hw/display/tcx.c                   |    3 +-
 hw/display/vga-pci.c               |    5 +-
 hw/display/vga.c                   |    3 +-
 hw/display/vmware_vga.c            |   10 +-
 hw/dma/i82374.c                    |    2 +-
 hw/dma/i8257.c                     |    8 +-
 hw/dma/pl080.c                     |    2 +-
 hw/dma/pl330.c                     |   25 +-
 hw/dma/pxa2xx_dma.c                |    2 -
 hw/dma/sparc32_dma.c               |    3 +-
 hw/dma/sun4m_iommu.c               |    3 +-
 hw/gpio/max7310.c                  |    3 +-
 hw/gpio/pl061.c                    |    2 +-
 hw/gpio/zaurus.c                   |    3 +-
 hw/i2c/core.c                      |    6 +-
 hw/i2c/smbus_ich9.c                |    1 -
 hw/i386/acpi-build.c               |    3 +-
 hw/i386/kvm/clock.c                |    1 -
 hw/i386/kvmvapic.c                 |    9 +-
 hw/i386/pc.c                       |    3 +-
 hw/ide/ahci.c                      |    6 +-
 hw/ide/core.c                      |   20 +-
 hw/ide/ich.c                       |    2 +-
 hw/ide/internal.h                  |    7 +-
 hw/ide/isa.c                       |    3 +-
 hw/ide/macio.c                     |    3 +-
 hw/ide/microdrive.c                |    3 +-
 hw/ide/mmio.c                      |    3 +-
 hw/ide/pci.c                       |   15 +-
 hw/input/adb.c                     |    6 +-
 hw/input/hid.c                     |    2 +-
 hw/input/lm832x.c                  |    3 +-
 hw/input/milkymist-softusb.c       |    3 +-
 hw/input/pckbd.c                   |    8 +-
 hw/input/ps2.c                     |   18 +-
 hw/input/pxa2xx_keypad.c           |    3 +-
 hw/input/stellaris_input.c         |    8 +-
 hw/input/vmmouse.c                 |    3 +-
 hw/intc/allwinner-a10-pic.c        |    1 -
 hw/intc/arm_gic_common.c           |    2 +-
 hw/intc/armv7m_nvic.c              |    3 +-
 hw/intc/exynos4210_combiner.c      |    4 +-
 hw/intc/exynos4210_gic.c           |    3 +-
 hw/intc/heathrow_pic.c             |    8 +-
 hw/intc/i8259_common.c             |    1 -
 hw/intc/imx_avic.c                 |    1 -
 hw/intc/ioapic_common.c            |    6 +-
 hw/intc/lm32_pic.c                 |    3 +-
 hw/intc/slavio_intctl.c            |    8 +-
 hw/intc/xics.c                     |    9 +-
 hw/ipack/ipack.c                   |    3 +-
 hw/ipack/tpci200.c                 |    3 +-
 hw/isa/apm.c                       |    1 -
 hw/isa/lpc_ich9.c                  |    5 +-
 hw/isa/piix4.c                     |    3 +-
 hw/isa/vt82c686.c                  |    8 +-
 hw/misc/arm_sysctl.c               |   18 +-
 hw/misc/eccmemctl.c                |    3 +-
 hw/misc/exynos4210_pmu.c           |    2 +-
 hw/misc/imx_ccm.c                  |    1 -
 hw/misc/lm32_sys.c                 |    3 +-
 hw/misc/macio/cuda.c               |    8 +-
 hw/misc/macio/mac_dbdma.c          |    8 +-
 hw/misc/max111x.c                  |    3 +-
 hw/misc/milkymist-hpdmc.c          |    3 +-
 hw/misc/milkymist-pfpu.c           |    3 +-
 hw/misc/mst_fpga.c                 |   11 +-
 hw/misc/slavio_misc.c              |    3 +-
 hw/misc/tmp105.c                   |    3 +-
 hw/misc/zynq_slcr.c                |    3 +-
 hw/net/allwinner_emac.c            |    4 +-
 hw/net/cadence_gem.c               |    3 +-
 hw/net/e1000.c                     |    6 +-
 hw/net/eepro100.c                  |    3 +-
 hw/net/lan9118.c                   |   20 +-
 hw/net/lance.c                     |    5 +-
 hw/net/milkymist-minimac2.c        |    8 +-
 hw/net/mipsnet.c                   |    3 +-
 hw/net/ne2000-isa.c                |    5 +-
 hw/net/ne2000.c                    |   10 +-
 hw/net/pcnet-pci.c                 |    5 +-
 hw/net/pcnet.c                     |    3 +-
 hw/net/rtl8139.c                   |   13 +-
 hw/net/smc91c111.c                 |    4 +-
 hw/net/spapr_llan.c                |    3 +-
 hw/net/vmxnet3.c                   |   13 +-
 hw/net/xgmac.c                     |    4 +-
 hw/nvram/ds1225y.c                 |    3 +-
 hw/nvram/eeprom93xx.c              |   14 +-
 hw/nvram/fw_cfg.c                  |    7 +-
 hw/nvram/mac_nvram.c               |    5 +-
 hw/pci-bridge/ioh3420.c            |    3 +-
 hw/pci-bridge/xio3130_downstream.c |    3 +-
 hw/pci-bridge/xio3130_upstream.c   |    3 +-
 hw/pci-host/bonito.c               |    3 +-
 hw/pci-host/piix.c                 |   11 +-
 hw/pci-host/ppce500.c              |   13 +-
 hw/pci-host/q35.c                  |    3 +-
 hw/pci/msix.c                      |   10 +-
 hw/pci/pci.c                       |   26 +-
 hw/pci/pcie_aer.c                  |    6 +-
 hw/ppc/ppc4xx_pci.c                |   19 +-
 hw/ppc/spapr.c                     |    3 +-
 hw/ppc/spapr_iommu.c               |    6 +-
 hw/ppc/spapr_pci.c                 |   13 +-
 hw/ppc/spapr_vio.c                 |    3 +-
 hw/s390x/event-facility.c          |    3 +-
 hw/s390x/sclpquiesce.c             |    3 +-
 hw/scsi/esp-pci.c                  |    5 +-
 hw/scsi/esp.c                      |    6 +-
 hw/scsi/lsi53c895a.c               |    7 +-
 hw/scsi/megasas.c                  |    3 +-
 hw/scsi/scsi-bus.c                 |   14 +-
 hw/scsi/scsi-disk.c                |    1 -
 hw/scsi/spapr_vscsi.c              |    6 +-
 hw/scsi/vmw_pvscsi.c               |    3 +-
 hw/sd/milkymist-memcard.c          |    3 +-
 hw/sd/sd.c                         |    4 +-
 hw/sd/sdhci.c                      |    4 +-
 hw/ssi/pl022.c                     |    3 +-
 hw/ssi/ssi.c                       |    3 +-
 hw/ssi/xilinx_spi.c                |    1 -
 hw/ssi/xilinx_spips.c              |    1 -
 hw/timer/a9gtimer.c                |    2 +-
 hw/timer/allwinner-a10-pit.c       |    1 -
 hw/timer/arm_mptimer.c             |    2 +-
 hw/timer/arm_timer.c               |    6 +-
 hw/timer/cadence_ttc.c             |    5 +-
 hw/timer/digic-timer.c             |    1 -
 hw/timer/ds1338.c                  |    3 +-
 hw/timer/exynos4210_mct.c          |   19 +-
 hw/timer/exynos4210_pwm.c          |    6 +-
 hw/timer/exynos4210_rtc.c          |    1 -
 hw/timer/hpet.c                    |   13 +-
 hw/timer/i8254_common.c            |    9 +-
 hw/timer/imx_epit.c                |    3 +-
 hw/timer/imx_gpt.c                 |    3 +-
 hw/timer/lm32_timer.c              |    3 +-
 hw/timer/m48t59.c                  |    5 +-
 hw/timer/mc146818rtc.c             |   17 +-
 hw/timer/milkymist-sysctl.c        |    3 +-
 hw/timer/pxa2xx_timer.c            |   13 +-
 hw/timer/slavio_timer.c            |    8 +-
 hw/timer/twl92230.c                |   14 +-
 hw/usb/bus.c                       |    2 +-
 hw/usb/dev-hid.c                   |    4 +-
 hw/usb/dev-hub.c                   |    6 +-
 hw/usb/dev-smartcard-reader.c      |    6 +-
 hw/usb/dev-storage.c               |    2 +-
 hw/usb/hcd-ehci-pci.c              |    5 +-
 hw/usb/hcd-ehci-sysbus.c           |    5 +-
 hw/usb/hcd-ehci.c                  |    6 +-
 hw/usb/hcd-uhci.c                  |   12 +-
 hw/usb/hcd-xhci.c                  |   10 +-
 hw/usb/redirect.c                  |   40 +-
 hw/watchdog/wdt_i6300esb.c         |   14 +-
 hw/watchdog/wdt_ib700.c            |    3 +-
 hw/xen/xen_platform.c              |    3 +-
 include/hw/acpi/pcihp.h            |    2 +-
 include/hw/hw.h                    |   31 +-
 include/hw/ipack/ipack.h           |    2 +-
 include/hw/pci/shpc.h              |    2 +-
 include/hw/ppc/spapr_vio.h         |    2 +-
 include/hw/ptimer.h                |    4 +-
 include/migration/vmstate.h        |  475 ++++++--------
 target-alpha/machine.c             |   20 +-
 target-arm/machine.c               |   29 +-
 target-i386/machine.c              |  155 ++---
 target-lm32/machine.c              |    8 +-
 target-moxie/machine.c             |    3 +-
 target-openrisc/machine.c          |    4 +-
 target-ppc/machine.c               |   52 +-
 tests/test-vmstate.c               | 1220 +++++++++++++++++++++++++++++++++---
 util/fifo8.c                       |    5 +-
 vmstate.c                          |  116 ++--
 238 files changed, 2035 insertions(+), 1432 deletions(-)

^ permalink raw reply	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 01/97] savevm: Ignore minimum_version_id_old if there is no load_state_old
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive) Juan Quintela
                   ` (97 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Michael S. Tsirkin

From: Peter Maydell <peter.maydell@linaro.org>

At the moment we require vmstate definitions to set minimum_version_id_old
to the same value as minimum_version_id if they do not provide a
load_state_old handler. Since the load_state_old functionality is
required only for a handful of devices that need to retain migration
compatibility with a pre-vmstate implementation, this means the bulk
of devices have pointless boilerplate. Relax the definition so that
minimum_version_id_old is ignored if there is no load_state_old handler.

Note that under the old scheme we would segfault if the vmstate
specified a minimum_version_id_old that was less than minimum_version_id
but did not provide a load_state_old function, and the incoming state
specified a version number between minimum_version_id_old and
minimum_version_id. Under the new scheme this will just result in
our failing the migration.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 docs/migration.txt | 12 +++++-------
 vmstate.c          |  9 +++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/docs/migration.txt b/docs/migration.txt
index 0e0a1d4..fe1f2bb 100644
--- a/docs/migration.txt
+++ b/docs/migration.txt
@@ -139,7 +139,6 @@ static const VMStateDescription vmstate_kbd = {
     .name = "pckbd",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
     .fields      = (VMStateField []) {
         VMSTATE_UINT8(write_cmd, KBDState),
         VMSTATE_UINT8(status, KBDState),
@@ -168,12 +167,13 @@ You can see that there are several version fields:
 - minimum_version_id: the minimum version_id that VMState is able to understand
   for that device.
 - minimum_version_id_old: For devices that were not able to port to vmstate, we can
-  assign a function that knows how to read this old state.
+  assign a function that knows how to read this old state. This field is
+  ignored if there is no load_state_old handler.

 So, VMState is able to read versions from minimum_version_id to
-version_id.  And the function load_state_old() is able to load state
-from minimum_version_id_old to minimum_version_id.  This function is
-deprecated and will be removed when no more users are left.
+version_id.  And the function load_state_old() (if present) is able to
+load state from minimum_version_id_old to minimum_version_id.  This
+function is deprecated and will be removed when no more users are left.

 ===  Massaging functions ===

@@ -255,7 +255,6 @@ const VMStateDescription vmstate_ide_drive_pio_state = {
     .name = "ide_drive/pio_state",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = ide_drive_pio_pre_save,
     .post_load = ide_drive_pio_post_load,
     .fields      = (VMStateField []) {
@@ -275,7 +274,6 @@ const VMStateDescription vmstate_ide_drive = {
     .name = "ide_drive",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = ide_drive_post_load,
     .fields      = (VMStateField []) {
         .... several fields ....
diff --git a/vmstate.c b/vmstate.c
index b689f2f..bfa34cc 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -19,11 +19,12 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
     if (version_id > vmsd->version_id) {
         return -EINVAL;
     }
-    if (version_id < vmsd->minimum_version_id_old) {
-        return -EINVAL;
-    }
     if  (version_id < vmsd->minimum_version_id) {
-        return vmsd->load_state_old(f, opaque, version_id);
+        if (vmsd->load_state_old &&
+            version_id >= vmsd->minimum_version_id_old) {
+            return vmsd->load_state_old(f, opaque, version_id);
+        }
+        return -EINVAL;
     }
     if (vmsd->pre_load) {
         int ret = vmsd->pre_load(opaque);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 01/97] savevm: Ignore minimum_version_id_old if there is no load_state_old Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07 11:00   ` Peter Maydell
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 03/97] vmstate: return error in case of error Juan Quintela
                   ` (96 subsequent siblings)
  98 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

After previous Peter patch, they are redundant.  This way we don't asign them
except when needed.  Once there, there were lots of case where the ".fields"
indentation was wrong:

     .fields = (VMStateField []) {
and
     .fields =      (VMStateField []) {

Change all the combinations to:

     .fields = (VMStateField[]){

The biggest problem (appart of aesthetics) was that checkpatch complained
when we copy&pasted the code from one place to another.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 audio/audio.c                      |  3 +-
 cpus.c                             |  3 +-
 docs/migration.txt                 |  6 ++--
 exec.c                             |  3 +-
 hw/acpi/ich9.c                     |  1 -
 hw/acpi/pcihp.c                    |  3 +-
 hw/acpi/piix4.c                    |  8 ++----
 hw/arm/highbank.c                  |  1 -
 hw/arm/musicpal.c                  |  8 ------
 hw/arm/pxa2xx.c                    | 19 ++++---------
 hw/arm/pxa2xx_gpio.c               |  3 +-
 hw/arm/pxa2xx_pic.c                |  1 -
 hw/arm/spitz.c                     | 12 +++-----
 hw/arm/stellaris.c                 | 12 +++-----
 hw/arm/strongarm.c                 |  6 ----
 hw/arm/z2.c                        |  2 --
 hw/audio/ac97.c                    |  6 ++--
 hw/audio/cs4231.c                  |  3 +-
 hw/audio/cs4231a.c                 |  3 +-
 hw/audio/es1370.c                  |  6 ++--
 hw/audio/gus.c                     |  3 +-
 hw/audio/hda-codec.c               |  4 +--
 hw/audio/intel-hda.c               |  4 +--
 hw/audio/lm4549.c                  |  5 ++--
 hw/audio/marvell_88w8618.c         |  1 -
 hw/audio/milkymist-ac97.c          |  3 +-
 hw/audio/pl041.c                   |  9 ++----
 hw/audio/sb16.c                    |  3 +-
 hw/audio/wm8750.c                  |  3 +-
 hw/block/ecc.c                     |  3 +-
 hw/block/fdc.c                     | 16 ++++-------
 hw/block/m25p80.c                  |  1 -
 hw/block/nand.c                    |  3 +-
 hw/block/onenand.c                 |  1 -
 hw/char/cadence_uart.c             |  1 -
 hw/char/digic-uart.c               |  1 -
 hw/char/escc.c                     |  6 ++--
 hw/char/exynos4210_uart.c          |  2 --
 hw/char/imx_serial.c               |  1 -
 hw/char/ipoctal232.c               |  9 ++----
 hw/char/lm32_juart.c               |  3 +-
 hw/char/lm32_uart.c                |  3 +-
 hw/char/milkymist-uart.c           |  3 +-
 hw/char/pl011.c                    |  3 +-
 hw/char/sclpconsole-lm.c           |  3 +-
 hw/char/sclpconsole.c              |  3 +-
 hw/char/serial-pci.c               |  4 +--
 hw/char/serial.c                   |  2 +-
 hw/char/spapr_vty.c                |  3 +-
 hw/core/ptimer.c                   |  3 +-
 hw/display/ads7846.c               |  3 +-
 hw/display/cg3.c                   |  2 +-
 hw/display/cirrus_vga.c            |  6 ++--
 hw/display/exynos4210_fimd.c       |  4 +--
 hw/display/g364fb.c                |  1 -
 hw/display/jazz_led.c              |  1 -
 hw/display/milkymist-tmu2.c        |  3 +-
 hw/display/milkymist-vgafb.c       |  3 +-
 hw/display/pxa2xx_lcd.c            |  6 ++--
 hw/display/ssd0303.c               |  3 +-
 hw/display/tcx.c                   |  3 +-
 hw/display/vga-pci.c               |  3 +-
 hw/display/vga.c                   |  3 +-
 hw/display/vmware_vga.c            |  6 ++--
 hw/dma/i8257.c                     |  6 ++--
 hw/dma/pl330.c                     |  5 ----
 hw/dma/pxa2xx_dma.c                |  2 --
 hw/dma/sparc32_dma.c               |  3 +-
 hw/dma/sun4m_iommu.c               |  3 +-
 hw/gpio/max7310.c                  |  3 +-
 hw/gpio/zaurus.c                   |  3 +-
 hw/i2c/core.c                      |  6 ++--
 hw/i2c/smbus_ich9.c                |  1 -
 hw/i386/acpi-build.c               |  3 +-
 hw/i386/kvm/clock.c                |  1 -
 hw/i386/kvmvapic.c                 |  3 --
 hw/i386/pc.c                       |  3 +-
 hw/ide/ahci.c                      |  6 ++--
 hw/ide/core.c                      | 16 ++++-------
 hw/ide/ich.c                       |  2 +-
 hw/ide/isa.c                       |  3 +-
 hw/ide/macio.c                     |  3 +-
 hw/ide/microdrive.c                |  3 +-
 hw/ide/mmio.c                      |  3 +-
 hw/ide/pci.c                       | 12 +++-----
 hw/input/adb.c                     |  6 ++--
 hw/input/lm832x.c                  |  3 +-
 hw/input/milkymist-softusb.c       |  3 +-
 hw/input/pckbd.c                   |  6 ++--
 hw/input/ps2.c                     | 12 +++-----
 hw/input/pxa2xx_keypad.c           |  3 +-
 hw/input/stellaris_input.c         |  6 ++--
 hw/input/vmmouse.c                 |  3 +-
 hw/intc/allwinner-a10-pic.c        |  1 -
 hw/intc/armv7m_nvic.c              |  3 +-
 hw/intc/exynos4210_combiner.c      |  2 --
 hw/intc/exynos4210_gic.c           |  1 -
 hw/intc/heathrow_pic.c             |  6 ++--
 hw/intc/i8259_common.c             |  1 -
 hw/intc/imx_avic.c                 |  1 -
 hw/intc/ioapic_common.c            |  1 -
 hw/intc/lm32_pic.c                 |  3 +-
 hw/intc/slavio_intctl.c            |  6 ++--
 hw/intc/xics.c                     |  9 ++----
 hw/ipack/ipack.c                   |  3 +-
 hw/ipack/tpci200.c                 |  3 +-
 hw/isa/apm.c                       |  1 -
 hw/isa/lpc_ich9.c                  |  1 -
 hw/isa/piix4.c                     |  3 +-
 hw/isa/vt82c686.c                  |  6 ++--
 hw/misc/eccmemctl.c                |  3 +-
 hw/misc/exynos4210_pmu.c           |  2 +-
 hw/misc/imx_ccm.c                  |  1 -
 hw/misc/lm32_sys.c                 |  3 +-
 hw/misc/macio/cuda.c               |  6 ++--
 hw/misc/macio/mac_dbdma.c          |  6 ++--
 hw/misc/max111x.c                  |  3 +-
 hw/misc/milkymist-hpdmc.c          |  3 +-
 hw/misc/milkymist-pfpu.c           |  3 +-
 hw/misc/mst_fpga.c                 | 11 ++++----
 hw/misc/slavio_misc.c              |  3 +-
 hw/misc/tmp105.c                   |  3 +-
 hw/misc/zynq_slcr.c                |  3 +-
 hw/net/cadence_gem.c               |  3 +-
 hw/net/e1000.c                     |  6 ++--
 hw/net/eepro100.c                  |  3 +-
 hw/net/lance.c                     |  3 +-
 hw/net/milkymist-minimac2.c        |  6 ++--
 hw/net/mipsnet.c                   |  3 +-
 hw/net/ne2000-isa.c                |  3 +-
 hw/net/ne2000.c                    |  6 ++--
 hw/net/pcnet-pci.c                 |  3 +-
 hw/net/pcnet.c                     |  3 +-
 hw/net/rtl8139.c                   |  9 ++----
 hw/net/smc91c111.c                 |  2 +-
 hw/net/spapr_llan.c                |  3 +-
 hw/net/vmxnet3.c                   |  4 +--
 hw/net/xgmac.c                     |  2 +-
 hw/nvram/ds1225y.c                 |  1 -
 hw/nvram/eeprom93xx.c              |  3 +-
 hw/nvram/fw_cfg.c                  |  3 +-
 hw/nvram/mac_nvram.c               |  3 +-
 hw/pci-bridge/ioh3420.c            |  1 -
 hw/pci-bridge/xio3130_downstream.c |  1 -
 hw/pci-bridge/xio3130_upstream.c   |  1 -
 hw/pci-host/bonito.c               |  3 +-
 hw/pci-host/piix.c                 |  7 ++---
 hw/pci-host/ppce500.c              |  9 ++----
 hw/pci-host/q35.c                  |  3 +-
 hw/pci/pci.c                       |  9 ++----
 hw/pci/pcie_aer.c                  |  6 ++--
 hw/ppc/ppc4xx_pci.c                |  9 ++----
 hw/ppc/spapr.c                     |  3 +-
 hw/ppc/spapr_iommu.c               |  3 +-
 hw/ppc/spapr_pci.c                 |  9 ++----
 hw/ppc/spapr_vio.c                 |  3 +-
 hw/s390x/event-facility.c          |  3 +-
 hw/s390x/sclpquiesce.c             |  3 +-
 hw/scsi/esp-pci.c                  |  1 -
 hw/scsi/esp.c                      |  4 +--
 hw/scsi/lsi53c895a.c               |  3 +-
 hw/scsi/megasas.c                  |  3 +-
 hw/scsi/scsi-bus.c                 |  4 +--
 hw/scsi/scsi-disk.c                |  1 -
 hw/scsi/spapr_vscsi.c              |  6 ++--
 hw/scsi/vmw_pvscsi.c               |  3 +-
 hw/sd/milkymist-memcard.c          |  3 +-
 hw/sd/sdhci.c                      |  2 +-
 hw/ssi/pl022.c                     |  3 +-
 hw/ssi/ssi.c                       |  3 +-
 hw/ssi/xilinx_spi.c                |  1 -
 hw/ssi/xilinx_spips.c              |  1 -
 hw/timer/allwinner-a10-pit.c       |  1 -
 hw/timer/arm_timer.c               |  6 ++--
 hw/timer/cadence_ttc.c             |  2 --
 hw/timer/digic-timer.c             |  1 -
 hw/timer/ds1338.c                  |  1 -
 hw/timer/exynos4210_mct.c          |  6 ----
 hw/timer/exynos4210_pwm.c          |  2 --
 hw/timer/exynos4210_rtc.c          |  1 -
 hw/timer/hpet.c                    |  9 ++----
 hw/timer/i8254_common.c            |  1 -
 hw/timer/imx_epit.c                |  3 +-
 hw/timer/imx_gpt.c                 |  3 +-
 hw/timer/lm32_timer.c              |  3 +-
 hw/timer/m48t59.c                  |  3 +-
 hw/timer/mc146818rtc.c             |  3 +-
 hw/timer/milkymist-sysctl.c        |  3 +-
 hw/timer/pxa2xx_timer.c            |  3 --
 hw/timer/slavio_timer.c            |  6 ++--
 hw/timer/twl92230.c                |  6 ++--
 hw/usb/bus.c                       |  2 +-
 hw/usb/dev-hid.c                   |  4 +--
 hw/usb/dev-hub.c                   |  4 +--
 hw/usb/dev-storage.c               |  2 +-
 hw/usb/hcd-ehci-pci.c              |  2 +-
 hw/usb/hcd-ehci-sysbus.c           |  2 +-
 hw/usb/hcd-ehci.c                  |  2 +-
 hw/usb/hcd-uhci.c                  |  6 ++--
 hw/watchdog/wdt_i6300esb.c         | 14 +++++-----
 hw/watchdog/wdt_ib700.c            |  3 +-
 hw/xen/xen_platform.c              |  3 +-
 target-alpha/machine.c             |  2 --
 target-arm/machine.c               |  5 ----
 target-i386/machine.c              | 57 +++++++++++++-------------------------
 target-lm32/machine.c              |  6 ++--
 target-moxie/machine.c             |  3 +-
 target-openrisc/machine.c          |  2 --
 target-ppc/machine.c               | 38 +++++++++----------------
 tests/test-vmstate.c               |  9 ++----
 util/fifo8.c                       |  3 +-
 211 files changed, 289 insertions(+), 621 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index fc77511..9d018e9 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1812,8 +1812,7 @@ static const VMStateDescription vmstate_audio = {
     .name = "audio",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/cpus.c b/cpus.c
index 1104d61..c510052 100644
--- a/cpus.c
+++ b/cpus.c
@@ -430,8 +430,7 @@ static const VMStateDescription vmstate_timers = {
     .name = "timer",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT64(cpu_ticks_offset, TimersState),
         VMSTATE_INT64(dummy, TimersState),
         VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
diff --git a/docs/migration.txt b/docs/migration.txt
index fe1f2bb..0492a45 100644
--- a/docs/migration.txt
+++ b/docs/migration.txt
@@ -139,7 +139,7 @@ static const VMStateDescription vmstate_kbd = {
     .name = "pckbd",
     .version_id = 3,
     .minimum_version_id = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(write_cmd, KBDState),
         VMSTATE_UINT8(status, KBDState),
         VMSTATE_UINT8(mode, KBDState),
@@ -257,7 +257,7 @@ const VMStateDescription vmstate_ide_drive_pio_state = {
     .minimum_version_id = 1,
     .pre_save = ide_drive_pio_pre_save,
     .post_load = ide_drive_pio_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(req_nb_sectors, IDEState),
         VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 1,
                              vmstate_info_uint8, uint8_t),
@@ -275,7 +275,7 @@ const VMStateDescription vmstate_ide_drive = {
     .version_id = 3,
     .minimum_version_id = 0,
     .post_load = ide_drive_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         .... several fields ....
         VMSTATE_END_OF_LIST()
     },
diff --git a/exec.c b/exec.c
index 91513c6..a87774e 100644
--- a/exec.c
+++ b/exec.c
@@ -429,9 +429,8 @@ const VMStateDescription vmstate_cpu_common = {
     .name = "cpu_common",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = cpu_common_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(halted, CPUState),
         VMSTATE_UINT32(interrupt_request, CPUState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 0afac42..407ae89 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -143,7 +143,6 @@ const VMStateDescription vmstate_ich9_pm = {
     .name = "ich9_pm",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = ich9_pm_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT16(acpi_regs.pm1.evt.sts, ICH9LPCPMRegs),
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index f80c480..d807cf1 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -322,8 +322,7 @@ const VMStateDescription vmstate_acpi_pcihp_pci_status = {
     .name = "acpi_pcihp_pci_status",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(up, AcpiPciHpPciStatus),
         VMSTATE_UINT32(down, AcpiPciHpPciStatus),
         VMSTATE_END_OF_LIST()
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 67dc075..252bbf2 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -177,8 +177,7 @@ static const VMStateDescription vmstate_gpe = {
     .name = "gpe",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_GPE_ARRAY(sts, ACPIGPE),
         VMSTATE_GPE_ARRAY(en, ACPIGPE),
         VMSTATE_END_OF_LIST()
@@ -189,8 +188,7 @@ static const VMStateDescription vmstate_pci_status = {
     .name = "pci_status",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(up, struct AcpiPciHpPciStatus),
         VMSTATE_UINT32(down, struct AcpiPciHpPciStatus),
         VMSTATE_END_OF_LIST()
@@ -259,7 +257,7 @@ static const VMStateDescription vmstate_acpi = {
     .minimum_version_id_old = 1,
     .load_state_old = acpi_load_old,
     .post_load = vmstate_acpi_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PIIX4PMState),
         VMSTATE_UINT16(ar.pm1.evt.sts, PIIX4PMState),
         VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState),
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index 46b9f1e..24231e5 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -134,7 +134,6 @@ static VMStateDescription vmstate_highbank_regs = {
     .name = "highbank-regs",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, HighbankRegsState, NUM_REGS),
         VMSTATE_END_OF_LIST(),
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index de54201..2a27a19 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -405,7 +405,6 @@ static const VMStateDescription mv88w8618_eth_vmsd = {
     .name = "mv88w8618_eth",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(smir, mv88w8618_eth_state),
         VMSTATE_UINT32(icr, mv88w8618_eth_state),
@@ -642,7 +641,6 @@ static const VMStateDescription musicpal_lcd_vmsd = {
     .name = "musicpal_lcd",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(brightness, musicpal_lcd_state),
         VMSTATE_UINT32(mode, musicpal_lcd_state),
@@ -769,7 +767,6 @@ static const VMStateDescription mv88w8618_pic_vmsd = {
     .name = "mv88w8618_pic",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(level, mv88w8618_pic_state),
         VMSTATE_UINT32(enabled, mv88w8618_pic_state),
@@ -940,7 +937,6 @@ static const VMStateDescription mv88w8618_timer_vmsd = {
     .name = "timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PTIMER(ptimer, mv88w8618_timer_state),
         VMSTATE_UINT32(limit, mv88w8618_timer_state),
@@ -952,7 +948,6 @@ static const VMStateDescription mv88w8618_pit_vmsd = {
     .name = "mv88w8618_pit",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(timer, mv88w8618_pit_state, 4, 1,
                              mv88w8618_timer_vmsd, mv88w8618_timer_state),
@@ -1041,7 +1036,6 @@ static const VMStateDescription mv88w8618_flashcfg_vmsd = {
     .name = "mv88w8618_flashcfg",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(cfgr0, mv88w8618_flashcfg_state),
         VMSTATE_END_OF_LIST()
@@ -1381,7 +1375,6 @@ static const VMStateDescription musicpal_gpio_vmsd = {
     .name = "musicpal_gpio",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(lcd_brightness, musicpal_gpio_state),
         VMSTATE_UINT32(out_state, musicpal_gpio_state),
@@ -1548,7 +1541,6 @@ static const VMStateDescription musicpal_key_vmsd = {
     .name = "musicpal_key",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(kbd_extended, musicpal_key_state),
         VMSTATE_UINT32(pressed_keys, musicpal_key_state),
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 0429148..6b7f99b 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -148,8 +148,7 @@ static const VMStateDescription vmstate_pxa2xx_pm = {
     .name = "pxa2xx_pm",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(pm_regs, PXA2xxState, 0x40),
         VMSTATE_END_OF_LIST()
     }
@@ -215,8 +214,7 @@ static const VMStateDescription vmstate_pxa2xx_cm = {
     .name = "pxa2xx_cm",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(cm_regs, PXA2xxState, 4),
         VMSTATE_UINT32(clkcfg, PXA2xxState),
         VMSTATE_UINT32(pmnc, PXA2xxState),
@@ -440,8 +438,7 @@ static const VMStateDescription vmstate_pxa2xx_mm = {
     .name = "pxa2xx_mm",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(mm_regs, PXA2xxState, 0x1a),
         VMSTATE_END_OF_LIST()
     }
@@ -1168,7 +1165,6 @@ static const VMStateDescription vmstate_pxa2xx_rtc_regs = {
     .name = "pxa2xx_rtc",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .pre_save = pxa2xx_rtc_pre_save,
     .post_load = pxa2xx_rtc_post_load,
     .fields = (VMStateField[]) {
@@ -1432,8 +1428,7 @@ static const VMStateDescription vmstate_pxa2xx_i2c_slave = {
     .name = "pxa2xx_i2c_slave",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_I2C_SLAVE(parent_obj, PXA2xxI2CSlaveState),
         VMSTATE_END_OF_LIST()
     }
@@ -1443,8 +1438,7 @@ static const VMStateDescription vmstate_pxa2xx_i2c = {
     .name = "pxa2xx_i2c",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(control, PXA2xxI2CState),
         VMSTATE_UINT16(status, PXA2xxI2CState),
         VMSTATE_UINT8(ibmr, PXA2xxI2CState),
@@ -1701,8 +1695,7 @@ static const VMStateDescription vmstate_pxa2xx_i2s = {
     .name = "pxa2xx_i2s",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(control, PXA2xxI2SState, 2),
         VMSTATE_UINT32(status, PXA2xxI2SState),
         VMSTATE_UINT32(mask, PXA2xxI2SState),
diff --git a/hw/arm/pxa2xx_gpio.c b/hw/arm/pxa2xx_gpio.c
index 0727428..7f75f05 100644
--- a/hw/arm/pxa2xx_gpio.c
+++ b/hw/arm/pxa2xx_gpio.c
@@ -313,8 +313,7 @@ static const VMStateDescription vmstate_pxa2xx_gpio_regs = {
     .name = "pxa2xx-gpio",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(lines, PXA2xxGPIOInfo),
         VMSTATE_UINT32_ARRAY(ilevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_UINT32_ARRAY(olevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
index d37fb54..9cfc714 100644
--- a/hw/arm/pxa2xx_pic.c
+++ b/hw/arm/pxa2xx_pic.c
@@ -296,7 +296,6 @@ static VMStateDescription vmstate_pxa2xx_pic_regs = {
     .name = "pxa2xx_pic",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = pxa2xx_pic_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(int_enabled, PXA2xxPICState, 2),
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index 392ca84..a179c1d 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -1006,8 +1006,7 @@ static VMStateDescription vmstate_sl_nand_info = {
     .name = "sl-nand",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(ctl, SLNANDState),
         VMSTATE_STRUCT(ecc, SLNANDState, 0, vmstate_ecc_state, ECCState),
         VMSTATE_END_OF_LIST(),
@@ -1041,9 +1040,8 @@ static VMStateDescription vmstate_spitz_kbd = {
     .name = "spitz-keyboard",
     .version_id = 1,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = spitz_keyboard_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(sense_state, SpitzKeyboardState),
         VMSTATE_UINT16(strobe_state, SpitzKeyboardState),
         VMSTATE_UNUSED_TEST(is_version_0, 5),
@@ -1076,8 +1074,7 @@ static const VMStateDescription vmstate_corgi_ssp_regs = {
     .name = "corgi-ssp",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_SSI_SLAVE(ssidev, CorgiSSPState),
         VMSTATE_UINT32_ARRAY(enable, CorgiSSPState, 3),
         VMSTATE_END_OF_LIST(),
@@ -1105,8 +1102,7 @@ static const VMStateDescription vmstate_spitz_lcdtg_regs = {
     .name = "spitz-lcdtg",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_SSI_SLAVE(ssidev, SpitzLCDTG),
         VMSTATE_UINT32(bl_intensity, SpitzLCDTG),
         VMSTATE_UINT32(bl_power, SpitzLCDTG),
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index d6cc77b..c7de9cf 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -286,8 +286,7 @@ static const VMStateDescription vmstate_stellaris_gptm = {
     .name = "stellaris_gptm",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(config, gptm_state),
         VMSTATE_UINT32_ARRAY(mode, gptm_state, 2),
         VMSTATE_UINT32(control, gptm_state),
@@ -643,9 +642,8 @@ static const VMStateDescription vmstate_stellaris_sys = {
     .name = "stellaris_sys",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = stellaris_sys_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(pborctl, ssys_state),
         VMSTATE_UINT32(ldopctl, ssys_state),
         VMSTATE_UINT32(int_mask, ssys_state),
@@ -851,8 +849,7 @@ static const VMStateDescription vmstate_stellaris_i2c = {
     .name = "stellaris_i2c",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(msa, stellaris_i2c_state),
         VMSTATE_UINT32(mcs, stellaris_i2c_state),
         VMSTATE_UINT32(mdr, stellaris_i2c_state),
@@ -1121,8 +1118,7 @@ static const VMStateDescription vmstate_stellaris_adc = {
     .name = "stellaris_adc",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(actss, stellaris_adc_state),
         VMSTATE_UINT32(ris, stellaris_adc_state),
         VMSTATE_UINT32(im, stellaris_adc_state),
diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c
index 170d0ce..0da9015 100644
--- a/hw/arm/strongarm.c
+++ b/hw/arm/strongarm.c
@@ -199,7 +199,6 @@ static VMStateDescription vmstate_strongarm_pic_regs = {
     .name = "strongarm_pic",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = strongarm_pic_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(pending, StrongARMPICState),
@@ -424,7 +423,6 @@ static const VMStateDescription vmstate_strongarm_rtc_regs = {
     .name = "strongarm-rtc",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .pre_save = strongarm_rtc_pre_save,
     .post_load = strongarm_rtc_post_load,
     .fields = (VMStateField[]) {
@@ -670,7 +668,6 @@ static const VMStateDescription vmstate_strongarm_gpio_regs = {
     .name = "strongarm-gpio",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ilevel, StrongARMGPIOInfo),
         VMSTATE_UINT32(olevel, StrongARMGPIOInfo),
@@ -842,7 +839,6 @@ static const VMStateDescription vmstate_strongarm_ppc_regs = {
     .name = "strongarm-ppc",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ilevel, StrongARMPPCInfo),
         VMSTATE_UINT32(olevel, StrongARMPPCInfo),
@@ -1293,7 +1289,6 @@ static const VMStateDescription vmstate_strongarm_uart_regs = {
     .name = "strongarm-uart",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = strongarm_uart_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(utcr0, StrongARMUARTState),
@@ -1553,7 +1548,6 @@ static const VMStateDescription vmstate_strongarm_ssp_regs = {
     .name = "strongarm-ssp",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = strongarm_ssp_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT16_ARRAY(sscr, StrongARMSSPState, 2),
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 67c1be8..5df014b 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -164,7 +164,6 @@ static VMStateDescription vmstate_zipit_lcd_state = {
     .name = "zipit-lcd",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .fields = (VMStateField[]) {
         VMSTATE_SSI_SLAVE(ssidev, ZipitLCD),
         VMSTATE_INT32(selected, ZipitLCD),
@@ -275,7 +274,6 @@ static VMStateDescription vmstate_aer915_state = {
     .name = "aer915",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(len, AER915State),
         VMSTATE_BUFFER(buf, AER915State),
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index 03f4846..45cb118 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -1163,8 +1163,7 @@ static const VMStateDescription vmstate_ac97_bm_regs = {
     .name = "ac97_bm_regs",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32 (bdbar, AC97BusMasterRegs),
         VMSTATE_UINT8 (civ, AC97BusMasterRegs),
         VMSTATE_UINT8 (lvi, AC97BusMasterRegs),
@@ -1211,9 +1210,8 @@ static const VMStateDescription vmstate_ac97 = {
     .name = "ac97",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = ac97_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE (dev, AC97LinkState),
         VMSTATE_UINT32 (glob_cnt, AC97LinkState),
         VMSTATE_UINT32 (glob_sta, AC97LinkState),
diff --git a/hw/audio/cs4231.c b/hw/audio/cs4231.c
index d19195a..6325a8c 100644
--- a/hw/audio/cs4231.c
+++ b/hw/audio/cs4231.c
@@ -137,8 +137,7 @@ static const VMStateDescription vmstate_cs4231 = {
     .name ="cs4231",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, CSState, CS_REGS),
         VMSTATE_UINT8_ARRAY(dregs, CSState, CS_DREGS),
         VMSTATE_END_OF_LIST()
diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index a0ec17a..f96f561 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -621,10 +621,9 @@ static const VMStateDescription vmstate_cs4231a = {
     .name = "cs4231a",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_load = cs4231a_pre_load,
     .post_load = cs4231a_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY (regs, CSState, CS_REGS),
         VMSTATE_BUFFER (dregs, CSState),
         VMSTATE_INT32 (dma_running, CSState),
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 1ec7ace..5dbf803 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -953,8 +953,7 @@ static const VMStateDescription vmstate_es1370_channel = {
     .name = "es1370_channel",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32 (shift, struct chan),
         VMSTATE_UINT32 (leftover, struct chan),
         VMSTATE_UINT32 (scount, struct chan),
@@ -997,9 +996,8 @@ static const VMStateDescription vmstate_es1370 = {
     .name = "es1370",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = es1370_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE (dev, ES1370State),
         VMSTATE_STRUCT_ARRAY (chan, ES1370State, NB_CHANNELS, 2,
                               vmstate_es1370_channel, struct chan),
diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index e29a571..bba6840 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -222,8 +222,7 @@ static const VMStateDescription vmstate_gus = {
     .name = "gus",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32 (pos, GUSState),
         VMSTATE_INT32 (left, GUSState),
         VMSTATE_INT32 (shift, GUSState),
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index a67ca91..09559ef 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -580,7 +580,7 @@ static void hda_audio_reset(DeviceState *dev)
 static const VMStateDescription vmstate_hda_audio_stream = {
     .name = "hda-audio-stream",
     .version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(stream, HDAAudioStream),
         VMSTATE_UINT32(channel, HDAAudioStream),
         VMSTATE_UINT32(format, HDAAudioStream),
@@ -598,7 +598,7 @@ static const VMStateDescription vmstate_hda_audio = {
     .name = "hda-audio",
     .version_id = 2,
     .post_load = hda_audio_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(st, HDAAudioState, 4, 0,
                              vmstate_hda_audio_stream,
                              HDAAudioStream),
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index d41f82c..1c660a4 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -1175,7 +1175,7 @@ static int intel_hda_post_load(void *opaque, int version)
 static const VMStateDescription vmstate_intel_hda_stream = {
     .name = "intel-hda-stream",
     .version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctl, IntelHDAStream),
         VMSTATE_UINT32(lpib, IntelHDAStream),
         VMSTATE_UINT32(cbl, IntelHDAStream),
@@ -1191,7 +1191,7 @@ static const VMStateDescription vmstate_intel_hda = {
     .name = "intel-hda",
     .version_id = 1,
     .post_load = intel_hda_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(pci, IntelHDAState),

         /* registers */
diff --git a/hw/audio/lm4549.c b/hw/audio/lm4549.c
index d75f7ec..380ef60 100644
--- a/hw/audio/lm4549.c
+++ b/hw/audio/lm4549.c
@@ -324,9 +324,8 @@ const VMStateDescription vmstate_lm4549_state = {
     .name = "lm4549_state",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .post_load = &lm4549_post_load,
-    .fields      = (VMStateField[]) {
+    .post_load = lm4549_post_load,
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(voice_is_active, lm4549_state),
         VMSTATE_UINT16_ARRAY(regfile, lm4549_state, 128),
         VMSTATE_UINT16_ARRAY(buffer, lm4549_state, LM4549_BUFFER_SIZE),
diff --git a/hw/audio/marvell_88w8618.c b/hw/audio/marvell_88w8618.c
index cdce238..8699267 100644
--- a/hw/audio/marvell_88w8618.c
+++ b/hw/audio/marvell_88w8618.c
@@ -259,7 +259,6 @@ static const VMStateDescription mv88w8618_audio_vmsd = {
     .name = "mv88w8618_audio",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(playback_mode, mv88w8618_audio_state),
         VMSTATE_UINT32(status, mv88w8618_audio_state),
diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c
index 9c0f7a0..28f55e8 100644
--- a/hw/audio/milkymist-ac97.c
+++ b/hw/audio/milkymist-ac97.c
@@ -316,9 +316,8 @@ static const VMStateDescription vmstate_milkymist_ac97 = {
     .name = "milkymist-ac97",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = ac97_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistAC97State, R_MAX),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/audio/pl041.c b/hw/audio/pl041.c
index ed82be5..19982f2 100644
--- a/hw/audio/pl041.c
+++ b/hw/audio/pl041.c
@@ -561,8 +561,7 @@ static const VMStateDescription vmstate_pl041_regfile = {
     .name = "pl041_regfile",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
 #define REGISTER(name, offset) VMSTATE_UINT32(name, pl041_regfile),
         #include "pl041.hx"
 #undef REGISTER
@@ -574,8 +573,7 @@ static const VMStateDescription vmstate_pl041_fifo = {
     .name = "pl041_fifo",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(level, pl041_fifo),
         VMSTATE_UINT32_ARRAY(data, pl041_fifo, MAX_FIFO_DEPTH),
         VMSTATE_END_OF_LIST()
@@ -586,8 +584,7 @@ static const VMStateDescription vmstate_pl041_channel = {
     .name = "pl041_channel",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(tx_fifo, pl041_channel, 0,
                        vmstate_pl041_fifo, pl041_fifo),
         VMSTATE_UINT8(tx_enabled, pl041_channel),
diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index bb24e00..60c4b3b 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -1289,9 +1289,8 @@ static const VMStateDescription vmstate_sb16 = {
     .name = "sb16",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = sb16_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32 (irq, SB16State),
         VMSTATE_UINT32 (dma, SB16State),
         VMSTATE_UINT32 (hdma, SB16State),
diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c
index c18f245..b50b331 100644
--- a/hw/audio/wm8750.c
+++ b/hw/audio/wm8750.c
@@ -583,10 +583,9 @@ static const VMStateDescription vmstate_wm8750 = {
     .name = CODEC,
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .pre_save = wm8750_pre_save,
     .post_load = wm8750_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8_ARRAY(i2c_data, WM8750State, 2),
         VMSTATE_INT32(i2c_len, WM8750State),
         VMSTATE_INT32(enable, WM8750State),
diff --git a/hw/block/ecc.c b/hw/block/ecc.c
index 8c888cc..10bb233 100644
--- a/hw/block/ecc.c
+++ b/hw/block/ecc.c
@@ -81,8 +81,7 @@ VMStateDescription vmstate_ecc_state = {
     .name = "ecc-state",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(cp, ECCState),
         VMSTATE_UINT16_ARRAY(lp, ECCState, 2),
         VMSTATE_UINT16(count, ECCState),
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 1651007..490d127 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -672,8 +672,7 @@ static const VMStateDescription vmstate_fdrive_media_changed = {
     .name = "fdrive/media_changed",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(media_changed, FDrive),
         VMSTATE_END_OF_LIST()
     }
@@ -690,8 +689,7 @@ static const VMStateDescription vmstate_fdrive_media_rate = {
     .name = "fdrive/media_rate",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(media_rate, FDrive),
         VMSTATE_END_OF_LIST()
     }
@@ -701,8 +699,7 @@ static const VMStateDescription vmstate_fdrive = {
     .name = "fdrive",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(head, FDrive),
         VMSTATE_UINT8(track, FDrive),
         VMSTATE_UINT8(sect, FDrive),
@@ -741,10 +738,9 @@ static const VMStateDescription vmstate_fdc = {
     .name = "fdc",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .pre_save = fdc_pre_save,
     .post_load = fdc_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         /* Controller State */
         VMSTATE_UINT8(sra, FDCtrl),
         VMSTATE_UINT8(srb, FDCtrl),
@@ -2209,7 +2205,7 @@ static const VMStateDescription vmstate_isa_fdc ={
     .name = "fdc",
     .version_id = 2,
     .minimum_version_id = 2,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(state, FDCtrlISABus, 0, vmstate_fdc, FDCtrl),
         VMSTATE_END_OF_LIST()
     }
@@ -2251,7 +2247,7 @@ static const VMStateDescription vmstate_sysbus_fdc ={
     .name = "fdc",
     .version_id = 2,
     .minimum_version_id = 2,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index e29a738..4076114 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -653,7 +653,6 @@ static const VMStateDescription vmstate_m25p80 = {
     .name = "xilinx_spi",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = m25p80_pre_save,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(state, Flash),
diff --git a/hw/block/nand.c b/hw/block/nand.c
index 6d7c804..38eefd4 100644
--- a/hw/block/nand.c
+++ b/hw/block/nand.c
@@ -346,10 +346,9 @@ static const VMStateDescription vmstate_nand = {
     .name = "nand",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = nand_pre_save,
     .post_load = nand_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(cle, NANDFlashState),
         VMSTATE_UINT8(ale, NANDFlashState),
         VMSTATE_UINT8(ce, NANDFlashState),
diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index aae9ee7..60d5311 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -169,7 +169,6 @@ static const VMStateDescription vmstate_onenand = {
     .name = "onenand",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = onenand_pre_save,
     .post_load = onenand_post_load,
     .fields = (VMStateField[]) {
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index 1012f1a..bf0c853 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -504,7 +504,6 @@ static const VMStateDescription vmstate_cadence_uart = {
     .name = "cadence_uart",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = cadence_uart_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(r, UartState, R_MAX),
diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c
index fd8e077..8abe944 100644
--- a/hw/char/digic-uart.c
+++ b/hw/char/digic-uart.c
@@ -162,7 +162,6 @@ static const VMStateDescription vmstate_digic_uart = {
     .name = "digic-uart",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(reg_rx, DigicUartState),
         VMSTATE_UINT32(reg_st, DigicUartState),
diff --git a/hw/char/escc.c b/hw/char/escc.c
index 6397f6f..4875a2b 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -658,8 +658,7 @@ static const VMStateDescription vmstate_escc_chn = {
     .name ="escc_chn",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(vmstate_dummy, ChannelState),
         VMSTATE_UINT32(reg, ChannelState),
         VMSTATE_UINT32(rxint, ChannelState),
@@ -678,8 +677,7 @@ static const VMStateDescription vmstate_escc = {
     .name ="escc",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(chn, ESCCState, 2, 2, vmstate_escc_chn,
                              ChannelState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 19b59cc..7614e58 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -560,7 +560,6 @@ static const VMStateDescription vmstate_exynos4210_uart_fifo = {
     .name = "exynos4210.uart.fifo",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(sp, Exynos4210UartFIFO),
         VMSTATE_UINT32(rp, Exynos4210UartFIFO),
@@ -573,7 +572,6 @@ static const VMStateDescription vmstate_exynos4210_uart = {
     .name = "exynos4210.uart",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(rx, Exynos4210UartState, 1,
                        vmstate_exynos4210_uart_fifo, Exynos4210UartFIFO),
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
index 7f16835..f3fbc77 100644
--- a/hw/char/imx_serial.c
+++ b/hw/char/imx_serial.c
@@ -76,7 +76,6 @@ static const VMStateDescription vmstate_imx_serial = {
     .name = "imx-serial",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(readbuff, IMXSerialState),
         VMSTATE_UINT32(usr1, IMXSerialState),
diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c
index f9c388e..c8d5cdb 100644
--- a/hw/char/ipoctal232.c
+++ b/hw/char/ipoctal232.c
@@ -124,8 +124,7 @@ static const VMStateDescription vmstate_scc2698_channel = {
     .name = "scc2698_channel",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_BOOL(rx_enabled, SCC2698Channel),
         VMSTATE_UINT8_ARRAY(mr, SCC2698Channel, 2),
         VMSTATE_UINT8(mr_idx, SCC2698Channel),
@@ -141,8 +140,7 @@ static const VMStateDescription vmstate_scc2698_block = {
     .name = "scc2698_block",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(imr, SCC2698Block),
         VMSTATE_UINT8(isr, SCC2698Block),
         VMSTATE_END_OF_LIST()
@@ -153,8 +151,7 @@ static const VMStateDescription vmstate_ipoctal = {
     .name = "ipoctal232",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_IPACK_DEVICE(parent_obj, IPOctalState),
         VMSTATE_STRUCT_ARRAY(ch, IPOctalState, N_CHANNELS, 1,
                              vmstate_scc2698_channel, SCC2698Channel),
diff --git a/hw/char/lm32_juart.c b/hw/char/lm32_juart.c
index 380cb5d..628a86f 100644
--- a/hw/char/lm32_juart.c
+++ b/hw/char/lm32_juart.c
@@ -129,8 +129,7 @@ static const VMStateDescription vmstate_lm32_juart = {
     .name = "lm32-juart",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(jtx, LM32JuartState),
         VMSTATE_UINT32(jrx, LM32JuartState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/char/lm32_uart.c b/hw/char/lm32_uart.c
index 84c2549..4f20966 100644
--- a/hw/char/lm32_uart.c
+++ b/hw/char/lm32_uart.c
@@ -270,8 +270,7 @@ static const VMStateDescription vmstate_lm32_uart = {
     .name = "lm32-uart",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, LM32UartState, R_MAX),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/char/milkymist-uart.c b/hw/char/milkymist-uart.c
index da51f82..d05b825 100644
--- a/hw/char/milkymist-uart.c
+++ b/hw/char/milkymist-uart.c
@@ -221,8 +221,7 @@ static const VMStateDescription vmstate_milkymist_uart = {
     .name = "milkymist-uart",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistUartState, R_MAX),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
index 644aad7..0a45115 100644
--- a/hw/char/pl011.c
+++ b/hw/char/pl011.c
@@ -251,8 +251,7 @@ static const VMStateDescription vmstate_pl011 = {
     .name = "pl011",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(readbuff, PL011State),
         VMSTATE_UINT32(flags, PL011State),
         VMSTATE_UINT32(lcr, PL011State),
diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
index a2dc1c6..80dd0a9 100644
--- a/hw/char/sclpconsole-lm.c
+++ b/hw/char/sclpconsole-lm.c
@@ -291,8 +291,7 @@ static const VMStateDescription vmstate_sclplmconsole = {
     .name = "sclplmconsole",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_BOOL(event.event_pending, SCLPConsoleLM),
         VMSTATE_UINT32(write_errors, SCLPConsoleLM),
         VMSTATE_UINT32(length, SCLPConsoleLM),
diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c
index ce40673..fca105d 100644
--- a/hw/char/sclpconsole.c
+++ b/hw/char/sclpconsole.c
@@ -185,8 +185,7 @@ static const VMStateDescription vmstate_sclpconsole = {
     .name = "sclpconsole",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_BOOL(event.event_pending, SCLPConsole),
         VMSTATE_UINT8_ARRAY(iov, SCLPConsole, SIZE_BUFFER_VT220),
         VMSTATE_UINT32(iov_sclp, SCLPConsole),
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 991c99f..44f50c3 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -155,7 +155,7 @@ static const VMStateDescription vmstate_pci_serial = {
     .name = "pci-serial",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCISerialState),
         VMSTATE_STRUCT(state, PCISerialState, 0, vmstate_serial, SerialState),
         VMSTATE_END_OF_LIST()
@@ -166,7 +166,7 @@ static const VMStateDescription vmstate_pci_multi_serial = {
     .name = "pci-serial-multi",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCIMultiSerialState),
         VMSTATE_STRUCT_ARRAY(state, PCIMultiSerialState, PCI_SERIAL_MAX_PORTS,
                              0, vmstate_serial, SerialState),
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 6d3b5af..16646d0 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -600,7 +600,7 @@ const VMStateDescription vmstate_serial = {
     .minimum_version_id = 2,
     .pre_save = serial_pre_save,
     .post_load = serial_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16_V(divider, SerialState, 2),
         VMSTATE_UINT8(rbr, SerialState),
         VMSTATE_UINT8(ier, SerialState),
diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c
index f8a4981..0adf096 100644
--- a/hw/char/spapr_vty.c
+++ b/hw/char/spapr_vty.c
@@ -148,8 +148,7 @@ static const VMStateDescription vmstate_spapr_vty = {
     .name = "spapr_vty",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_SPAPR_VIO(sdev, VIOsPAPRVTYDevice),

         VMSTATE_UINT32(in, VIOsPAPRVTYDevice),
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
index 3036bde..466e543 100644
--- a/hw/core/ptimer.c
+++ b/hw/core/ptimer.c
@@ -206,8 +206,7 @@ const VMStateDescription vmstate_ptimer = {
     .name = "ptimer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(enabled, ptimer_state),
         VMSTATE_UINT64(limit, ptimer_state),
         VMSTATE_UINT64(delta, ptimer_state),
diff --git a/hw/display/ads7846.c b/hw/display/ads7846.c
index 85252a2..3f35369 100644
--- a/hw/display/ads7846.c
+++ b/hw/display/ads7846.c
@@ -121,9 +121,8 @@ static const VMStateDescription vmstate_ads7846 = {
     .name = "ads7846",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = ads7856_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_SSI_SLAVE(ssidev, ADS7846State),
         VMSTATE_INT32_ARRAY(input, ADS7846State, 8),
         VMSTATE_INT32(noise, ADS7846State),
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index a042b9e..f5a8299 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -324,7 +324,7 @@ static const VMStateDescription vmstate_cg3 = {
     .version_id = 1,
     .minimum_version_id = 1,
     .post_load = vmstate_cg3_post_load,
-    .fields    = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(height, CG3State),
         VMSTATE_UINT16(width, CG3State),
         VMSTATE_UINT16(depth, CG3State),
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 0d3127d..55449a6 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2702,9 +2702,8 @@ static const VMStateDescription vmstate_cirrus_vga = {
     .name = "cirrus_vga",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = cirrus_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(vga.latch, CirrusVGAState),
         VMSTATE_UINT8(vga.sr_index, CirrusVGAState),
         VMSTATE_BUFFER(vga.sr, CirrusVGAState),
@@ -2742,8 +2741,7 @@ static const VMStateDescription vmstate_pci_cirrus_vga = {
     .name = "cirrus_vga",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCICirrusVGAState),
         VMSTATE_STRUCT(cirrus_vga, PCICirrusVGAState, 0,
                        vmstate_cirrus_vga, CirrusVGAState),
diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index 9750330..45c62af 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -1845,7 +1845,7 @@ static const VMStateDescription exynos4210_fimd_window_vmstate = {
     .name = "exynos4210.fimd_window",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(wincon, Exynos4210fimdWindow),
         VMSTATE_UINT32_ARRAY(buf_start, Exynos4210fimdWindow, 3),
         VMSTATE_UINT32_ARRAY(buf_end, Exynos4210fimdWindow, 3),
@@ -1875,7 +1875,7 @@ static const VMStateDescription exynos4210_fimd_vmstate = {
     .version_id = 1,
     .minimum_version_id = 1,
     .post_load = exynos4210_fimd_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(vidcon, Exynos4210fimdState, 4),
         VMSTATE_UINT32_ARRAY(vidtcon, Exynos4210fimdState, 4),
         VMSTATE_UINT32(shadowcon, Exynos4210fimdState),
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 5c6a2d3..46f7b41 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -459,7 +459,6 @@ static const VMStateDescription vmstate_g364fb = {
     .name = "g364fb",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = g364fb_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(vram, G364State, 1, NULL, 0, vram_size),
diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c
index f9e7d7c..e9bb005 100644
--- a/hw/display/jazz_led.c
+++ b/hw/display/jazz_led.c
@@ -250,7 +250,6 @@ static const VMStateDescription vmstate_jazz_led = {
     .name = "jazz-led",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = jazz_led_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(segments, LedState),
diff --git a/hw/display/milkymist-tmu2.c b/hw/display/milkymist-tmu2.c
index b2a5fba..3e1d0b9 100644
--- a/hw/display/milkymist-tmu2.c
+++ b/hw/display/milkymist-tmu2.c
@@ -463,8 +463,7 @@ static const VMStateDescription vmstate_milkymist_tmu2 = {
     .name = "milkymist-tmu2",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistTMU2State, R_MAX),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/display/milkymist-vgafb.c b/hw/display/milkymist-vgafb.c
index 603537a..9b35e76 100644
--- a/hw/display/milkymist-vgafb.c
+++ b/hw/display/milkymist-vgafb.c
@@ -305,9 +305,8 @@ static const VMStateDescription vmstate_milkymist_vgafb = {
     .name = "milkymist-vgafb",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = vgafb_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistVgafbState, R_MAX),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
index 09cdf17..80edb70 100644
--- a/hw/display/pxa2xx_lcd.c
+++ b/hw/display/pxa2xx_lcd.c
@@ -932,8 +932,7 @@ static const VMStateDescription vmstate_dma_channel = {
     .name = "dma_channel",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(branch, struct DMAChannel),
         VMSTATE_UINT8(up, struct DMAChannel),
         VMSTATE_BUFFER(pbuffer, struct DMAChannel),
@@ -959,9 +958,8 @@ static const VMStateDescription vmstate_pxa2xx_lcdc = {
     .name = "pxa2xx_lcdc",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = pxa2xx_lcdc_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(irqlevel, PXA2xxLCDState),
         VMSTATE_INT32(transp, PXA2xxLCDState),
         VMSTATE_UINT32_ARRAY(control, PXA2xxLCDState, 6),
diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c
index c2eea04..f6804fb 100644
--- a/hw/display/ssd0303.c
+++ b/hw/display/ssd0303.c
@@ -272,8 +272,7 @@ static const VMStateDescription vmstate_ssd0303 = {
     .name = "ssd0303_oled",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(row, ssd0303_state),
         VMSTATE_INT32(col, ssd0303_state),
         VMSTATE_INT32(start_line, ssd0303_state),
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index 2b37ffa..2551b67 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -416,9 +416,8 @@ static const VMStateDescription vmstate_tcx = {
     .name ="tcx",
     .version_id = 4,
     .minimum_version_id = 4,
-    .minimum_version_id_old = 4,
     .post_load = vmstate_tcx_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(height, TCXState),
         VMSTATE_UINT16(width, TCXState),
         VMSTATE_UINT16(depth, TCXState),
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index 574ea0e..a2a9ca1 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -54,8 +54,7 @@ static const VMStateDescription vmstate_vga_pci = {
     .name = "vga",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCIVGAState),
         VMSTATE_STRUCT(vga, PCIVGAState, 0, vmstate_vga_common, VGACommonState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 063319d..9e35dd2 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2210,9 +2210,8 @@ const VMStateDescription vmstate_vga_common = {
     .name = "vga",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = vga_common_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(latch, VGACommonState),
         VMSTATE_UINT8(sr_index, VGACommonState),
         VMSTATE_PARTIAL_BUFFER(sr, VGACommonState, 8),
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 6ae3348..00bb385 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1152,9 +1152,8 @@ static const VMStateDescription vmstate_vmware_vga_internal = {
     .name = "vmware_vga_internal",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = vmsvga_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s),
         VMSTATE_INT32(enable, struct vmsvga_state_s),
         VMSTATE_INT32(config, struct vmsvga_state_s),
@@ -1179,8 +1178,7 @@ static const VMStateDescription vmstate_vmware_vga = {
     .name = "vmware_vga",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, struct pci_vmsvga_state_s),
         VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0,
                        vmstate_vmware_vga_internal, struct vmsvga_state_s),
diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index 4490372..dd370ed 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -551,8 +551,7 @@ static const VMStateDescription vmstate_dma_regs = {
     .name = "dma_regs",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_ARRAY(now, struct dma_regs, 2),
         VMSTATE_UINT16_ARRAY(base, struct dma_regs, 2),
         VMSTATE_UINT8(mode, struct dma_regs),
@@ -575,9 +574,8 @@ static const VMStateDescription vmstate_dma = {
     .name = "dma",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = dma_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(command, struct dma_cont),
         VMSTATE_UINT8(mask, struct dma_cont),
         VMSTATE_UINT8(flip_flop, struct dma_cont),
diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index 608a58c..6b6eaae 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -138,7 +138,6 @@ static const VMStateDescription vmstate_pl330_chan = {
     .name = "pl330_chan",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(src, PL330Chan),
         VMSTATE_UINT32(dst, PL330Chan),
@@ -170,7 +169,6 @@ static const VMStateDescription vmstate_pl330_fifo = {
     .name = "pl330_chan",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(buf, PL330Fifo, 1, NULL, 0, buf_size),
         VMSTATE_VBUFFER_UINT32(tag, PL330Fifo, 1, NULL, 0, buf_size),
@@ -195,7 +193,6 @@ static const VMStateDescription vmstate_pl330_queue_entry = {
     .name = "pl330_queue_entry",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(addr, PL330QueueEntry),
         VMSTATE_UINT32(len, PL330QueueEntry),
@@ -218,7 +215,6 @@ static const VMStateDescription vmstate_pl330_queue = {
     .name = "pl330_queue",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT_VARRAY_UINT32(queue, PL330Queue, queue_size, 1,
                                  vmstate_pl330_queue_entry, PL330QueueEntry),
@@ -279,7 +275,6 @@ static const VMStateDescription vmstate_pl330 = {
     .name = "pl330",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(manager, PL330State, 0, vmstate_pl330_chan, PL330Chan),
         VMSTATE_STRUCT_VARRAY_UINT32(chan, PL330State, num_chnls, 0,
diff --git a/hw/dma/pxa2xx_dma.c b/hw/dma/pxa2xx_dma.c
index c013abb..d4501fb 100644
--- a/hw/dma/pxa2xx_dma.c
+++ b/hw/dma/pxa2xx_dma.c
@@ -514,7 +514,6 @@ static VMStateDescription vmstate_pxa2xx_dma_chan = {
     .name = "pxa2xx_dma_chan",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(descr, PXA2xxDMAChannel),
         VMSTATE_UINT32(src, PXA2xxDMAChannel),
@@ -530,7 +529,6 @@ static VMStateDescription vmstate_pxa2xx_dma = {
     .name = "pxa2xx_dma",
     .version_id = 1,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .fields = (VMStateField[]) {
         VMSTATE_UNUSED_TEST(is_version_0, 4),
         VMSTATE_UINT32(stopintr, PXA2xxDMAState),
diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c
index eac338f..e6a453c 100644
--- a/hw/dma/sparc32_dma.c
+++ b/hw/dma/sparc32_dma.c
@@ -263,8 +263,7 @@ static const VMStateDescription vmstate_dma = {
     .name ="sparc32_dma",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(dmaregs, DMAState, DMA_REGS),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/dma/sun4m_iommu.c b/hw/dma/sun4m_iommu.c
index 899d454..ec7c2ef 100644
--- a/hw/dma/sun4m_iommu.c
+++ b/hw/dma/sun4m_iommu.c
@@ -327,8 +327,7 @@ static const VMStateDescription vmstate_iommu = {
     .name ="iommu",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, IOMMUState, IOMMU_NREGS),
         VMSTATE_UINT64(iostart, IOMMUState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index cfcd89c..7fbf313 100644
--- a/hw/gpio/max7310.c
+++ b/hw/gpio/max7310.c
@@ -152,8 +152,7 @@ static const VMStateDescription vmstate_max7310 = {
     .name = "max7310",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(i2c_command_byte, MAX7310State),
         VMSTATE_INT32(len, MAX7310State),
         VMSTATE_UINT8(level, MAX7310State),
diff --git a/hw/gpio/zaurus.c b/hw/gpio/zaurus.c
index dc79a8b..658eac2 100644
--- a/hw/gpio/zaurus.c
+++ b/hw/gpio/zaurus.c
@@ -207,9 +207,8 @@ static const VMStateDescription vmstate_scoop_regs = {
     .name = "scoop",
     .version_id = 1,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = scoop_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(status, ScoopInfo),
         VMSTATE_UINT16(power, ScoopInfo),
         VMSTATE_UINT32(gpio_level, ScoopInfo),
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index efd8b4f..5a64026 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -52,10 +52,9 @@ static const VMStateDescription vmstate_i2c_bus = {
     .name = "i2c_bus",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = i2c_bus_pre_save,
     .post_load = i2c_bus_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(saved_address, I2CBus),
         VMSTATE_END_OF_LIST()
     }
@@ -194,9 +193,8 @@ const VMStateDescription vmstate_i2c_slave = {
     .name = "I2CSlave",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = i2c_slave_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(address, I2CSlave),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
index 295b62e..0803dc4 100644
--- a/hw/i2c/smbus_ich9.c
+++ b/hw/i2c/smbus_ich9.c
@@ -48,7 +48,6 @@ static const VMStateDescription vmstate_ich9_smbus = {
     .name = "ich9_smb",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a5d3fbf..0bc8895 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1497,8 +1497,7 @@ static const VMStateDescription vmstate_acpi_build = {
     .name = "acpi_build",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(patched, AcpiBuildState),
         VMSTATE_END_OF_LIST()
     },
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index 892aa02..07b9c0e 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -102,7 +102,6 @@ static const VMStateDescription kvmclock_vmsd = {
     .name = "kvmclock",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT64(clock, KVMClockState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index a1c3d1c..a730f4b 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -773,7 +773,6 @@ static const VMStateDescription vmstate_handlers = {
     .name = "kvmvapic-handlers",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(set_tpr, VAPICHandlers),
         VMSTATE_UINT32(set_tpr_eax, VAPICHandlers),
@@ -787,7 +786,6 @@ static const VMStateDescription vmstate_guest_rom = {
     .name = "kvmvapic-guest-rom",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UNUSED(8),     /* signature */
         VMSTATE_UINT32(vaddr, GuestROMState),
@@ -807,7 +805,6 @@ static const VMStateDescription vmstate_vapic = {
     .name = "kvm-tpr-opt",      /* compatible with qemu-kvm VAPIC */
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = vapic_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(rom_state, VAPICROMState, 0, vmstate_guest_rom,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 14f0d91..5155393 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -502,8 +502,7 @@ static const VMStateDescription vmstate_port92_isa = {
     .name = "port92",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(outport, Port92State),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index bfe633f..a225181 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1225,7 +1225,7 @@ void ahci_reset(AHCIState *s)
 static const VMStateDescription vmstate_ahci_device = {
     .name = "ahci port",
     .version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_IDE_BUS(port, AHCIDevice),
         VMSTATE_UINT32(port_state, AHCIDevice),
         VMSTATE_UINT32(finished, AHCIDevice),
@@ -1284,7 +1284,7 @@ const VMStateDescription vmstate_ahci = {
     .name = "ahci",
     .version_id = 1,
     .post_load = ahci_state_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_VARRAY_POINTER_INT32(dev, AHCIState, ports,
                                      vmstate_ahci_device, AHCIDevice),
         VMSTATE_UINT32(control_regs.cap, AHCIState),
@@ -1313,7 +1313,7 @@ typedef struct SysbusAHCIState {
 static const VMStateDescription vmstate_sysbus_ahci = {
     .name = "sysbus-ahci",
     .unmigratable = 1, /* Still buggy under I/O load */
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_AHCI(ahci, SysbusAHCIState),
         VMSTATE_END_OF_LIST()
     },
diff --git a/hw/ide/core.c b/hw/ide/core.c
index e1dfe54..ade1b89 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2342,8 +2342,7 @@ static const VMStateDescription vmstate_ide_atapi_gesn_state = {
     .name ="ide_drive/atapi/gesn_state",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_BOOL(events.new_media, IDEState),
         VMSTATE_BOOL(events.eject_request, IDEState),
         VMSTATE_END_OF_LIST()
@@ -2354,7 +2353,6 @@ static const VMStateDescription vmstate_ide_tray_state = {
     .name = "ide_drive/tray_state",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_BOOL(tray_open, IDEState),
         VMSTATE_BOOL(tray_locked, IDEState),
@@ -2366,10 +2364,9 @@ static const VMStateDescription vmstate_ide_drive_pio_state = {
     .name = "ide_drive/pio_state",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = ide_drive_pio_pre_save,
     .post_load = ide_drive_pio_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(req_nb_sectors, IDEState),
         VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 1,
 			     vmstate_info_uint8, uint8_t),
@@ -2386,9 +2383,8 @@ const VMStateDescription vmstate_ide_drive = {
     .name = "ide_drive",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = ide_drive_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(mult_sectors, IDEState),
         VMSTATE_INT32(identify_set, IDEState),
         VMSTATE_BUFFER_TEST(identify_data, IDEState, is_identify_set),
@@ -2431,8 +2427,7 @@ static const VMStateDescription vmstate_ide_error_status = {
     .name ="ide_bus/error",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(error_status, IDEBus),
         VMSTATE_END_OF_LIST()
     }
@@ -2442,8 +2437,7 @@ const VMStateDescription vmstate_ide_bus = {
     .name = "ide_bus",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(cmd, IDEBus),
         VMSTATE_UINT8(unit, IDEBus),
         VMSTATE_END_OF_LIST()
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 1c7c058..a2f1639 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -83,7 +83,7 @@ static const VMStateDescription vmstate_ich9_ahci = {
     .name = "ich9_ahci",
     .unmigratable = 1, /* Still buggy under I/O load */
     .version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, AHCIPCIState),
         VMSTATE_AHCI(ahci, AHCIPCIState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index d2cabc1..4cbcb1c 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -57,8 +57,7 @@ static const VMStateDescription vmstate_ide_isa = {
     .name = "isa-ide",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_IDE_BUS(bus, ISAIDEState),
         VMSTATE_IDE_DRIVES(bus.ifs, ISAIDEState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index da94580..1c20616 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -480,8 +480,7 @@ static const VMStateDescription vmstate_pmac = {
     .name = "ide",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_IDE_BUS(bus, MACIOIDEState),
         VMSTATE_IDE_DRIVES(bus.ifs, MACIOIDEState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index 21d6495..f24946d 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -332,8 +332,7 @@ static const VMStateDescription vmstate_microdrive = {
     .name = "microdrive",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(opt, MicroDriveState),
         VMSTATE_UINT8(stat, MicroDriveState),
         VMSTATE_UINT8(pins, MicroDriveState),
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index 9f66a52..01c1d0e 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -109,8 +109,7 @@ static const VMStateDescription vmstate_ide_mmio = {
     .name = "mmio-ide",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_IDE_BUS(bus, MMIOState),
         VMSTATE_IDE_DRIVES(bus.ifs, MMIOState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index d8b1157..6257a21 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -411,8 +411,7 @@ static const VMStateDescription vmstate_bmdma_current = {
     .name = "ide bmdma_current",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(cur_addr, BMDMAState),
         VMSTATE_UINT32(cur_prd_last, BMDMAState),
         VMSTATE_UINT32(cur_prd_addr, BMDMAState),
@@ -425,8 +424,7 @@ static const VMStateDescription vmstate_bmdma_status = {
     .name ="ide bmdma/status",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(status, BMDMAState),
         VMSTATE_END_OF_LIST()
     }
@@ -436,9 +434,8 @@ static const VMStateDescription vmstate_bmdma = {
     .name = "ide bmdma",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .pre_save  = ide_bmdma_pre_save,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(cmd, BMDMAState),
         VMSTATE_UINT8(migration_compat_status, BMDMAState),
         VMSTATE_UINT32(addr, BMDMAState),
@@ -479,9 +476,8 @@ const VMStateDescription vmstate_ide_pci = {
     .name = "ide",
     .version_id = 3,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = ide_pci_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIIDEState),
         VMSTATE_STRUCT_ARRAY(bmdma, PCIIDEState, 2, 0,
                              vmstate_bmdma, BMDMAState),
diff --git a/hw/input/adb.c b/hw/input/adb.c
index a75d3fd..34c8058 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -303,8 +303,7 @@ static const VMStateDescription vmstate_adb_kbd = {
     .name = "adb_kbd",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_BUFFER(data, KBDState),
         VMSTATE_INT32(rptr, KBDState),
         VMSTATE_INT32(wptr, KBDState),
@@ -518,8 +517,7 @@ static const VMStateDescription vmstate_adb_mouse = {
     .name = "adb_mouse",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(buttons_state, MouseState),
         VMSTATE_INT32(last_buttons_state, MouseState),
         VMSTATE_INT32(dx, MouseState),
diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c
index 4ae1cd9..9eb68e8 100644
--- a/hw/input/lm832x.c
+++ b/hw/input/lm832x.c
@@ -432,9 +432,8 @@ static const VMStateDescription vmstate_lm_kbd = {
     .name = "LM8323",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = lm_kbd_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_I2C_SLAVE(parent_obj, LM823KbdState),
         VMSTATE_UINT8(i2c_dir, LM823KbdState),
         VMSTATE_UINT8(i2c_cycle, LM823KbdState),
diff --git a/hw/input/milkymist-softusb.c b/hw/input/milkymist-softusb.c
index ecde33c..53ba714 100644
--- a/hw/input/milkymist-softusb.c
+++ b/hw/input/milkymist-softusb.c
@@ -295,8 +295,7 @@ static const VMStateDescription vmstate_milkymist_softusb = {
     .name = "milkymist-softusb",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistSoftUsbState, R_MAX),
         VMSTATE_HID_KEYBOARD_DEVICE(hid_kbd, MilkymistSoftUsbState),
         VMSTATE_HID_POINTER_DEVICE(hid_mouse, MilkymistSoftUsbState),
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index 29af3d7..ca1cffc 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -373,8 +373,7 @@ static const VMStateDescription vmstate_kbd = {
     .name = "pckbd",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(write_cmd, KBDState),
         VMSTATE_UINT8(status, KBDState),
         VMSTATE_UINT8(mode, KBDState),
@@ -462,8 +461,7 @@ static const VMStateDescription vmstate_kbd_isa = {
     .name = "pckbd",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(kbd, ISAKBDState, 0, vmstate_kbd, KBDState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 3412079..0a0bd80 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -559,8 +559,7 @@ static const VMStateDescription vmstate_ps2_common = {
     .name = "PS2 Common State",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(write_cmd, PS2State),
         VMSTATE_INT32(queue.rptr, PS2State),
         VMSTATE_INT32(queue.wptr, PS2State),
@@ -589,9 +588,8 @@ static const VMStateDescription vmstate_ps2_keyboard_ledstate = {
     .name = "ps2kbd/ledstate",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = ps2_kbd_ledstate_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(ledstate, PS2KbdState),
         VMSTATE_END_OF_LIST()
     }
@@ -610,9 +608,8 @@ static const VMStateDescription vmstate_ps2_keyboard = {
     .name = "ps2kbd",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = ps2_kbd_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(common, PS2KbdState, 0, vmstate_ps2_common, PS2State),
         VMSTATE_INT32(scan_enabled, PS2KbdState),
         VMSTATE_INT32(translate, PS2KbdState),
@@ -633,8 +630,7 @@ static const VMStateDescription vmstate_ps2_mouse = {
     .name = "ps2mouse",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(common, PS2MouseState, 0, vmstate_ps2_common, PS2State),
         VMSTATE_UINT8(mouse_status, PS2MouseState),
         VMSTATE_UINT8(mouse_resolution, PS2MouseState),
diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c
index b90b0ba..8501114 100644
--- a/hw/input/pxa2xx_keypad.c
+++ b/hw/input/pxa2xx_keypad.c
@@ -291,8 +291,7 @@ static const VMStateDescription vmstate_pxa2xx_keypad = {
     .name = "pxa2xx_keypad",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(kpc, PXA2xxKeyPadState),
         VMSTATE_UINT32(kpdk, PXA2xxKeyPadState),
         VMSTATE_UINT32(kprec, PXA2xxKeyPadState),
diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
index 4e40792..0609e80 100644
--- a/hw/input/stellaris_input.c
+++ b/hw/input/stellaris_input.c
@@ -51,8 +51,7 @@ static const VMStateDescription vmstate_stellaris_button = {
     .name = "stellaris_button",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(pressed, gamepad_button),
         VMSTATE_END_OF_LIST()
     }
@@ -62,8 +61,7 @@ static const VMStateDescription vmstate_stellaris_gamepad = {
     .name = "stellaris_gamepad",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(extension, gamepad_state),
         VMSTATE_STRUCT_VARRAY_INT32(buttons, gamepad_state, num_buttons, 0,
                               vmstate_stellaris_button, gamepad_button),
diff --git a/hw/input/vmmouse.c b/hw/input/vmmouse.c
index 6a50533..d7b1c76 100644
--- a/hw/input/vmmouse.c
+++ b/hw/input/vmmouse.c
@@ -240,9 +240,8 @@ 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 []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(queue_size, VMMouseState),
         VMSTATE_UINT32_ARRAY(queue, VMMouseState, VMMOUSE_QUEUE_SIZE),
         VMSTATE_UINT16(nb_queue, VMMouseState),
diff --git a/hw/intc/allwinner-a10-pic.c b/hw/intc/allwinner-a10-pic.c
index 407d563..2db411d 100644
--- a/hw/intc/allwinner-a10-pic.c
+++ b/hw/intc/allwinner-a10-pic.c
@@ -129,7 +129,6 @@ static const VMStateDescription vmstate_aw_a10_pic = {
     .name = "a10.pic",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(vector, AwA10PICState),
         VMSTATE_UINT32(base_addr, AwA10PICState),
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 6066fa6..980eaab 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -443,8 +443,7 @@ static const VMStateDescription vmstate_nvic = {
     .name = "armv7m_nvic",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(systick.control, nvic_state),
         VMSTATE_UINT32(systick.reload, nvic_state),
         VMSTATE_INT64(systick.tick, nvic_state),
diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c
index 3287479..a6b7028 100644
--- a/hw/intc/exynos4210_combiner.c
+++ b/hw/intc/exynos4210_combiner.c
@@ -77,7 +77,6 @@ static const VMStateDescription vmstate_exynos4210_combiner_group_state = {
     .name = "exynos4210.combiner.groupstate",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(src_mask, CombinerGroupState),
         VMSTATE_UINT8(src_pending, CombinerGroupState),
@@ -89,7 +88,6 @@ static const VMStateDescription vmstate_exynos4210_combiner = {
     .name = "exynos4210.combiner",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(group, Exynos4210CombinerState, IIC_NGRP, 0,
                 vmstate_exynos4210_combiner_group_state, CombinerGroupState),
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
index 5b913f7..0590d5d 100644
--- a/hw/intc/exynos4210_gic.c
+++ b/hw/intc/exynos4210_gic.c
@@ -394,7 +394,6 @@ static const VMStateDescription vmstate_exynos4210_irq_gate = {
     .name = "exynos4210.irq_gate",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, 1, NULL, 0, n_in),
         VMSTATE_END_OF_LIST()
diff --git a/hw/intc/heathrow_pic.c b/hw/intc/heathrow_pic.c
index 9818f24..9ff3119 100644
--- a/hw/intc/heathrow_pic.c
+++ b/hw/intc/heathrow_pic.c
@@ -159,8 +159,7 @@ static const VMStateDescription vmstate_heathrow_pic_one = {
     .name = "heathrow_pic_one",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(events, HeathrowPIC),
         VMSTATE_UINT32(mask, HeathrowPIC),
         VMSTATE_UINT32(levels, HeathrowPIC),
@@ -173,8 +172,7 @@ static const VMStateDescription vmstate_heathrow_pic = {
     .name = "heathrow_pic",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(pics, HeathrowPICS, 2, 1,
                              vmstate_heathrow_pic_one, HeathrowPIC),
         VMSTATE_END_OF_LIST()
diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c
index 61381c4..fbf26e5 100644
--- a/hw/intc/i8259_common.c
+++ b/hw/intc/i8259_common.c
@@ -98,7 +98,6 @@ static const VMStateDescription vmstate_pic_common = {
     .name = "i8259",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = pic_dispatch_pre_save,
     .post_load = pic_dispatch_post_load,
     .fields = (VMStateField[]) {
diff --git a/hw/intc/imx_avic.c b/hw/intc/imx_avic.c
index fb00e91..ec5f9ad 100644
--- a/hw/intc/imx_avic.c
+++ b/hw/intc/imx_avic.c
@@ -77,7 +77,6 @@ static const VMStateDescription vmstate_imx_avic = {
     .name = "imx-avic",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT64(pending, IMXAVICState),
         VMSTATE_UINT64(enabled, IMXAVICState),
diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c
index 4d3d309..8b7d118 100644
--- a/hw/intc/ioapic_common.c
+++ b/hw/intc/ioapic_common.c
@@ -86,7 +86,6 @@ static const VMStateDescription vmstate_ioapic_common = {
     .name = "ioapic",
     .version_id = 3,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = ioapic_dispatch_pre_save,
     .post_load = ioapic_dispatch_post_load,
     .fields = (VMStateField[]) {
diff --git a/hw/intc/lm32_pic.c b/hw/intc/lm32_pic.c
index 32d009f..72fc9ef 100644
--- a/hw/intc/lm32_pic.c
+++ b/hw/intc/lm32_pic.c
@@ -169,8 +169,7 @@ static const VMStateDescription vmstate_lm32_pic = {
     .name = "lm32-pic",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(im, LM32PicState),
         VMSTATE_UINT32(ip, LM32PicState),
         VMSTATE_UINT32(irq_state, LM32PicState),
diff --git a/hw/intc/slavio_intctl.c b/hw/intc/slavio_intctl.c
index b10fb66..f22aba0 100644
--- a/hw/intc/slavio_intctl.c
+++ b/hw/intc/slavio_intctl.c
@@ -381,8 +381,7 @@ static const VMStateDescription vmstate_intctl_cpu = {
     .name ="slavio_intctl_cpu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(intreg_pending, SLAVIO_CPUINTCTLState),
         VMSTATE_END_OF_LIST()
     }
@@ -392,9 +391,8 @@ static const VMStateDescription vmstate_intctl = {
     .name ="slavio_intctl",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = vmstate_intctl_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(slaves, SLAVIO_INTCTLState, MAX_CPUS, 1,
                              vmstate_intctl_cpu, SLAVIO_CPUINTCTLState),
         VMSTATE_UINT32(intregm_pending, SLAVIO_INTCTLState),
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 64aabe7..76dd6f5 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -330,10 +330,9 @@ static const VMStateDescription vmstate_icp_server = {
     .name = "icp/server",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = icp_dispatch_pre_save,
     .post_load = icp_dispatch_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         /* Sanity check */
         VMSTATE_UINT32(xirr, ICPState),
         VMSTATE_UINT8(pending_priority, ICPState),
@@ -566,8 +565,7 @@ static const VMStateDescription vmstate_ics_irq = {
     .name = "ics/irq",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(server, ICSIRQState),
         VMSTATE_UINT8(priority, ICSIRQState),
         VMSTATE_UINT8(saved_priority, ICSIRQState),
@@ -580,10 +578,9 @@ static const VMStateDescription vmstate_ics = {
     .name = "ics",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = ics_dispatch_pre_save,
     .post_load = ics_dispatch_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         /* Sanity check */
         VMSTATE_UINT32_EQUAL(nr_irqs, ICSState),

diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c
index ed63d2a..ef032e6 100644
--- a/hw/ipack/ipack.c
+++ b/hw/ipack/ipack.c
@@ -89,8 +89,7 @@ const VMStateDescription vmstate_ipack_device = {
     .name = "ipack_device",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(slot, IPackDevice),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/ipack/tpci200.c b/hw/ipack/tpci200.c
index e1b69b4..42ca923 100644
--- a/hw/ipack/tpci200.c
+++ b/hw/ipack/tpci200.c
@@ -629,8 +629,7 @@ static const VMStateDescription vmstate_tpci200 = {
     .name = "tpci200",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, TPCI200State),
         VMSTATE_BOOL_ARRAY(big_endian, TPCI200State, 3),
         VMSTATE_UINT8_ARRAY(ctrl, TPCI200State, N_MODULES),
diff --git a/hw/isa/apm.c b/hw/isa/apm.c
index f97e7a0..054d529 100644
--- a/hw/isa/apm.c
+++ b/hw/isa/apm.c
@@ -72,7 +72,6 @@ const VMStateDescription vmstate_apm = {
     .name = "APM State",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(apmc, APMState),
         VMSTATE_UINT8(apms, APMState),
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 51ce12d..97f69d6 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -616,7 +616,6 @@ static const VMStateDescription vmstate_ich9_lpc = {
     .name = "ICH9LPC",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = ich9_lpc_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(d, ICH9LPCState),
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 492cd22..1aa17d7 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -76,8 +76,7 @@ static const VMStateDescription vmstate_piix4 = {
     .name = "PIIX4",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PIIX4State),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 1a93afd..e0c235c 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -230,9 +230,8 @@ static const VMStateDescription vmstate_acpi = {
     .name = "vt82c686b_pm",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = vmstate_acpi_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, VT686PMState),
         VMSTATE_UINT16(ar.pm1.evt.sts, VT686PMState),
         VMSTATE_UINT16(ar.pm1.evt.en, VT686PMState),
@@ -418,8 +417,7 @@ static const VMStateDescription vmstate_via = {
     .name = "vt82c686b",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, VT82C686BState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/misc/eccmemctl.c b/hw/misc/eccmemctl.c
index 549431c..8bad6f6 100644
--- a/hw/misc/eccmemctl.c
+++ b/hw/misc/eccmemctl.c
@@ -266,8 +266,7 @@ static const VMStateDescription vmstate_ecc = {
     .name ="ECC",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, ECCState, ECC_NREGS),
         VMSTATE_BUFFER(diag, ECCState),
         VMSTATE_UINT32(version, ECCState),
diff --git a/hw/misc/exynos4210_pmu.c b/hw/misc/exynos4210_pmu.c
index 5ec14d1..2b118c7 100644
--- a/hw/misc/exynos4210_pmu.c
+++ b/hw/misc/exynos4210_pmu.c
@@ -471,7 +471,7 @@ static const VMStateDescription exynos4210_pmu_vmstate = {
     .name = "exynos4210.pmu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(reg, Exynos4210PmuState, PMU_NUM_OF_REGISTERS),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/misc/imx_ccm.c b/hw/misc/imx_ccm.c
index 63e33a4..750b906 100644
--- a/hw/misc/imx_ccm.c
+++ b/hw/misc/imx_ccm.c
@@ -57,7 +57,6 @@ static const VMStateDescription vmstate_imx_ccm = {
     .name = "imx-ccm",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(ccmr, IMXCCMState),
         VMSTATE_UINT32(pdr0, IMXCCMState),
diff --git a/hw/misc/lm32_sys.c b/hw/misc/lm32_sys.c
index e394f2e..778eb6e 100644
--- a/hw/misc/lm32_sys.c
+++ b/hw/misc/lm32_sys.c
@@ -141,8 +141,7 @@ static const VMStateDescription vmstate_lm32_sys = {
     .name = "lm32-sys",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, LM32SysState, R_MAX),
         VMSTATE_BUFFER(testname, LM32SysState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index bc71aa7..ff6051d 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -617,8 +617,7 @@ static const VMStateDescription vmstate_cuda_timer = {
     .name = "cuda_timer",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(latch, CUDATimer),
         VMSTATE_UINT16(counter_value, CUDATimer),
         VMSTATE_INT64(load_time, CUDATimer),
@@ -632,8 +631,7 @@ static const VMStateDescription vmstate_cuda = {
     .name = "cuda",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(a, CUDAState),
         VMSTATE_UINT8(b, CUDAState),
         VMSTATE_UINT8(dira, CUDAState),
diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
index f47a736..3335476 100644
--- a/hw/misc/macio/mac_dbdma.c
+++ b/hw/misc/macio/mac_dbdma.c
@@ -719,8 +719,7 @@ static const VMStateDescription vmstate_dbdma_channel = {
     .name = "dbdma_channel",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, struct DBDMA_channel, DBDMA_REGS),
         VMSTATE_END_OF_LIST()
     }
@@ -730,8 +729,7 @@ static const VMStateDescription vmstate_dbdma = {
     .name = "dbdma",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(channels, DBDMAState, DBDMA_CHANNELS, 1,
                              vmstate_dbdma_channel, DBDMA_channel),
         VMSTATE_END_OF_LIST()
diff --git a/hw/misc/max111x.c b/hw/misc/max111x.c
index bba87c2..bef3651 100644
--- a/hw/misc/max111x.c
+++ b/hw/misc/max111x.c
@@ -110,8 +110,7 @@ static const VMStateDescription vmstate_max111x = {
     .name = "max111x",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_SSI_SLAVE(parent_obj, MAX111xState),
         VMSTATE_UINT8(tb1, MAX111xState),
         VMSTATE_UINT8(rb2, MAX111xState),
diff --git a/hw/misc/milkymist-hpdmc.c b/hw/misc/milkymist-hpdmc.c
index aef135e..f5f4c1b 100644
--- a/hw/misc/milkymist-hpdmc.c
+++ b/hw/misc/milkymist-hpdmc.c
@@ -143,8 +143,7 @@ static const VMStateDescription vmstate_milkymist_hpdmc = {
     .name = "milkymist-hpdmc",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistHpdmcState, R_MAX),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/misc/milkymist-pfpu.c b/hw/misc/milkymist-pfpu.c
index b3b2143..609f33f 100644
--- a/hw/misc/milkymist-pfpu.c
+++ b/hw/misc/milkymist-pfpu.c
@@ -513,8 +513,7 @@ static const VMStateDescription vmstate_milkymist_pfpu = {
     .name = "milkymist-pfpu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistPFPUState, R_MAX),
         VMSTATE_UINT32_ARRAY(gp_regs, MilkymistPFPUState, 128),
         VMSTATE_UINT32_ARRAY(microcode, MilkymistPFPUState, MICROCODE_WORDS),
diff --git a/hw/misc/mst_fpga.c b/hw/misc/mst_fpga.c
index c96810f..d509079 100644
--- a/hw/misc/mst_fpga.c
+++ b/hw/misc/mst_fpga.c
@@ -219,12 +219,11 @@ static int mst_fpga_init(SysBusDevice *sbd)
 }

 static VMStateDescription vmstate_mst_fpga_regs = {
-	.name = "mainstone_fpga",
-	.version_id = 0,
-	.minimum_version_id = 0,
-	.minimum_version_id_old = 0,
-	.post_load = mst_fpga_post_load,
-	.fields = (VMStateField []) {
+    .name = "mainstone_fpga",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .post_load = mst_fpga_post_load,
+    .fields = (VMStateField[]) {
 		VMSTATE_UINT32(prev_level, mst_irq_state),
 		VMSTATE_UINT32(leddat1, mst_irq_state),
 		VMSTATE_UINT32(leddat2, mst_irq_state),
diff --git a/hw/misc/slavio_misc.c b/hw/misc/slavio_misc.c
index 767544e..5098595 100644
--- a/hw/misc/slavio_misc.c
+++ b/hw/misc/slavio_misc.c
@@ -400,8 +400,7 @@ static const VMStateDescription vmstate_misc = {
     .name ="slavio_misc",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(dummy, MiscState),
         VMSTATE_UINT8(config, MiscState),
         VMSTATE_UINT8(aux1, MiscState),
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
index 63aa3d6..7eab802 100644
--- a/hw/misc/tmp105.c
+++ b/hw/misc/tmp105.c
@@ -197,9 +197,8 @@ static const VMStateDescription vmstate_tmp105 = {
     .name = "TMP105",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = tmp105_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(len, TMP105State),
         VMSTATE_UINT8_ARRAY(buf, TMP105State, 2),
         VMSTATE_UINT8(pointer, TMP105State),
diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c
index d1cc233..84310bb 100644
--- a/hw/misc/zynq_slcr.c
+++ b/hw/misc/zynq_slcr.c
@@ -512,8 +512,7 @@ static const VMStateDescription vmstate_zynq_slcr = {
     .name = "zynq_slcr",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8_ARRAY(data, ZynqSLCRState, 0x1000),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 92dc2f2..f8f7b12 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -1257,8 +1257,7 @@ static const VMStateDescription vmstate_cadence_gem = {
     .name = "cadence_gem",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, GemState, GEM_MAXREG),
         VMSTATE_UINT16_ARRAY(phy_regs, GemState, 32),
         VMSTATE_UINT8(phy_loop, GemState),
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 8387443..a13b8c3 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1341,8 +1341,7 @@ static const VMStateDescription vmstate_e1000_mit_state = {
     .name = "e1000/mit_state",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields    = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(mac_reg[RDTR], E1000State),
         VMSTATE_UINT32(mac_reg[RADV], E1000State),
         VMSTATE_UINT32(mac_reg[TADV], E1000State),
@@ -1356,10 +1355,9 @@ static const VMStateDescription vmstate_e1000 = {
     .name = "e1000",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = e1000_pre_save,
     .post_load = e1000_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, E1000State),
         VMSTATE_UNUSED_TEST(is_version_1, 4), /* was instance id */
         VMSTATE_UNUSED(4), /* Was mmio_base.  */
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index 3b891ca..aaa3ff2 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -1784,8 +1784,7 @@ static ssize_t nic_receive(NetClientState *nc, const uint8_t * buf, size_t size)
 static const VMStateDescription vmstate_eepro100 = {
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, EEPRO100State),
         VMSTATE_UNUSED(32),
         VMSTATE_BUFFER(mult, EEPRO100State),
diff --git a/hw/net/lance.c b/hw/net/lance.c
index fe18564..7811a9e 100644
--- a/hw/net/lance.c
+++ b/hw/net/lance.c
@@ -110,8 +110,7 @@ static const VMStateDescription vmstate_lance = {
     .name = "pcnet",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(state, SysBusPCNetState, 0, vmstate_pcnet, PCNetState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c
index 1e92379..c023351 100644
--- a/hw/net/milkymist-minimac2.c
+++ b/hw/net/milkymist-minimac2.c
@@ -492,8 +492,7 @@ static const VMStateDescription vmstate_milkymist_minimac2_mdio = {
     .name = "milkymist-minimac2-mdio",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(last_clk, MilkymistMinimac2MdioState),
         VMSTATE_INT32(count, MilkymistMinimac2MdioState),
         VMSTATE_UINT32(data, MilkymistMinimac2MdioState),
@@ -509,8 +508,7 @@ static const VMStateDescription vmstate_milkymist_minimac2 = {
     .name = "milkymist-minimac2",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistMinimac2State, R_MAX),
         VMSTATE_UINT16_ARRAY(phy_regs, MilkymistMinimac2State, R_PHY_MAX),
         VMSTATE_STRUCT(mdio, MilkymistMinimac2State, 0,
diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c
index e421b86..b26c369 100644
--- a/hw/net/mipsnet.c
+++ b/hw/net/mipsnet.c
@@ -198,8 +198,7 @@ static const VMStateDescription vmstate_mipsnet = {
     .name = "mipsnet",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(busy, MIPSnetState),
         VMSTATE_UINT32(rx_count, MIPSnetState),
         VMSTATE_UINT32(rx_read, MIPSnetState),
diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index c660e58..8740844 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -59,8 +59,7 @@ static const VMStateDescription vmstate_isa_ne2000 = {
     .name = "ne2000",
     .version_id = 2,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(ne2000, ISANE2000State, 0, vmstate_ne2000, NE2000State),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 4c32e9e..d558b8c 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -615,9 +615,8 @@ const VMStateDescription vmstate_ne2000 = {
     .name = "ne2000",
     .version_id = 2,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = ne2000_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8_V(rxcr, NE2000State, 2),
         VMSTATE_UINT8(cmd, NE2000State),
         VMSTATE_UINT32(start, NE2000State),
@@ -645,8 +644,7 @@ static const VMStateDescription vmstate_pci_ne2000 = {
     .name = "ne2000",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCINE2000State),
         VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
         VMSTATE_END_OF_LIST()
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index 6a5d806..b25d789 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -241,8 +241,7 @@ static const VMStateDescription vmstate_pci_pcnet = {
     .name = "pcnet",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIPCNetState),
         VMSTATE_STRUCT(state, PCIPCNetState, 0, vmstate_pcnet, PCNetState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index 7cb47b3..8c54692 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -1701,8 +1701,7 @@ const VMStateDescription vmstate_pcnet = {
     .name = "pcnet",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(rap, PCNetState),
         VMSTATE_INT32(isr, PCNetState),
         VMSTATE_INT32(lnkst, PCNetState),
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 5329f44..90bc5ec 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -1358,8 +1358,7 @@ static const VMStateDescription vmstate_tally_counters = {
     .name = "tally_counters",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(TxOk, RTL8139TallyCounters),
         VMSTATE_UINT64(RxOk, RTL8139TallyCounters),
         VMSTATE_UINT64(TxERR, RTL8139TallyCounters),
@@ -3271,8 +3270,7 @@ static const VMStateDescription vmstate_rtl8139_hotplug_ready ={
     .name = "rtl8139/hotplug_ready",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_END_OF_LIST()
     }
 };
@@ -3293,10 +3291,9 @@ static const VMStateDescription vmstate_rtl8139 = {
     .name = "rtl8139",
     .version_id = 4,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
     .post_load = rtl8139_post_load,
     .pre_save  = rtl8139_pre_save,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, RTL8139State),
         VMSTATE_PARTIAL_BUFFER(phys, RTL8139State, 6),
         VMSTATE_BUFFER(mult, RTL8139State),
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index a8e29b3..d1dca8f 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -54,7 +54,7 @@ static const VMStateDescription vmstate_smc91c111 = {
     .name = "smc91c111",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(tcr, smc91c111_state),
         VMSTATE_UINT16(rcr, smc91c111_state),
         VMSTATE_UINT16(cr, smc91c111_state),
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index c433337..2d47df6 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -509,8 +509,7 @@ static const VMStateDescription vmstate_spapr_llan = {
     .name = "spapr_llan",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_SPAPR_VIO(sdev, VIOsPAPRVLANDevice),
         /* LLAN state */
         VMSTATE_BOOL(isopen, VIOsPAPRVLANDevice),
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 5be807c..781b06a 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2174,7 +2174,6 @@ static const VMStateDescription vmxstate_vmxnet3_mcast_list = {
     .name = "vmxnet3/mcast_list",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_load = vmxnet3_mcast_list_pre_load,
     .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(mcast_list, VMXNET3State, 0, NULL, 0,
@@ -2381,10 +2380,9 @@ static const VMStateDescription vmstate_vmxnet3 = {
     .name = "vmxnet3",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = vmxnet3_pre_save,
     .post_load = vmxnet3_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
             VMSTATE_PCI_DEVICE(parent_obj, VMXNET3State),
             VMSTATE_BOOL(rx_packets_compound, VMXNET3State),
             VMSTATE_BOOL(rx_vlan_stripping, VMXNET3State),
diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
index 9384fa0..8619491 100644
--- a/hw/net/xgmac.c
+++ b/hw/net/xgmac.c
@@ -156,7 +156,7 @@ const VMStateDescription vmstate_rxtx_stats = {
     .name = "xgmac_stats",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(rx_bytes, RxTxStats),
         VMSTATE_UINT64(tx_bytes, RxTxStats),
         VMSTATE_UINT64(rx, RxTxStats),
diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
index f9a700b..332598b 100644
--- a/hw/nvram/ds1225y.c
+++ b/hw/nvram/ds1225y.c
@@ -95,7 +95,6 @@ static const VMStateDescription vmstate_nvram = {
     .name = "nvram",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .post_load = nvram_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_VARRAY_UINT32(contents, NvRamState, chip_size, 0,
diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
index a98f924..0af4d67 100644
--- a/hw/nvram/eeprom93xx.c
+++ b/hw/nvram/eeprom93xx.c
@@ -125,8 +125,7 @@ static const VMStateDescription vmstate_eeprom = {
     .name = "eeprom",
     .version_id = EEPROM_VERSION,
     .minimum_version_id = OLD_EEPROM_VERSION,
-    .minimum_version_id_old = OLD_EEPROM_VERSION,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(tick, eeprom_t),
         VMSTATE_UINT8(address, eeprom_t),
         VMSTATE_UINT8(command, eeprom_t),
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 282341a..b71d251 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -377,8 +377,7 @@ static const VMStateDescription vmstate_fw_cfg = {
     .name = "fw_cfg",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(cur_entry, FWCfgState),
         VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1),
         VMSTATE_UINT32_V(cur_offset, FWCfgState, 2),
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 2eb0081..170b10b 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -96,8 +96,7 @@ static const VMStateDescription vmstate_macio_nvram = {
     .name = "macio_nvram",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(data, MacIONVRAMState, 0, NULL, 0, size),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index 0f7f209..f4e17ac 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -184,7 +184,6 @@ static const VMStateDescription vmstate_ioh3420 = {
     .name = "ioh-3240-express-root-port",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = pcie_cap_slot_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCIE_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
index 94f9781..8f22f93 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -151,7 +151,6 @@ static const VMStateDescription vmstate_xio3130_downstream = {
     .name = "xio3130-express-downstream-port",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = pcie_cap_slot_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCIE_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index 59f97f6..eada582 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -131,7 +131,6 @@ static const VMStateDescription vmstate_xio3130_upstream = {
     .name = "xio3130-express-upstream-port",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCIE_DEVICE(parent_obj.parent_obj, PCIEPort),
         VMSTATE_STRUCT(parent_obj.parent_obj.exp.aer_log, PCIEPort, 0,
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 902441f..56292ad 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -687,8 +687,7 @@ static const VMStateDescription vmstate_bonito = {
     .name = "Bonito",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCIBonitoState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index ffdc853..e0e0946 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -203,7 +203,7 @@ static const VMStateDescription vmstate_i440fx = {
     .minimum_version_id_old = 1,
     .load_state_old = i440fx_load_old,
     .post_load = i440fx_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCII440FXState),
         VMSTATE_UINT8(smm_enabled, PCII440FXState),
         VMSTATE_END_OF_LIST()
@@ -553,7 +553,7 @@ static const VMStateDescription vmstate_piix3_rcr = {
     .name = "PIIX3/rcr",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(rcr, PIIX3State),
         VMSTATE_END_OF_LIST()
     }
@@ -563,10 +563,9 @@ static const VMStateDescription vmstate_piix3 = {
     .name = "PIIX3",
     .version_id = 3,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = piix3_post_load,
     .pre_save = piix3_pre_save,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PIIX3State),
         VMSTATE_INT32_ARRAY_V(pci_irq_levels_vmstate, PIIX3State,
                               PIIX_NUM_PIRQS, 3),
diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
index c80b7cb..e12d731 100644
--- a/hw/pci-host/ppce500.c
+++ b/hw/pci-host/ppce500.c
@@ -278,8 +278,7 @@ static const VMStateDescription vmstate_pci_outbound = {
     .name = "pci_outbound",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(potar, struct pci_outbound),
         VMSTATE_UINT32(potear, struct pci_outbound),
         VMSTATE_UINT32(powbar, struct pci_outbound),
@@ -292,8 +291,7 @@ static const VMStateDescription vmstate_pci_inbound = {
     .name = "pci_inbound",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(pitar, struct pci_inbound),
         VMSTATE_UINT32(piwbar, struct pci_inbound),
         VMSTATE_UINT32(piwbear, struct pci_inbound),
@@ -306,8 +304,7 @@ static const VMStateDescription vmstate_ppce500_pci = {
     .name = "ppce500_pci",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(pob, PPCE500PCIState, PPCE500_PCI_NR_POBS, 1,
                              vmstate_pci_outbound, struct pci_outbound),
         VMSTATE_STRUCT_ARRAY(pib, PPCE500PCIState, PPCE500_PCI_NR_PIBS, 1,
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 8b8cc4e..571e523 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -330,9 +330,8 @@ static const VMStateDescription vmstate_mch = {
     .name = "mch",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = mch_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, MCHPCIState),
         VMSTATE_UINT8(smm_enabled, MCHPCIState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2a9f08e..d4375b6 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -64,8 +64,7 @@ static const VMStateDescription vmstate_pcibus = {
     .name = "PCIBUS",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(nirq, PCIBus),
         VMSTATE_VARRAY_INT32(irq_count, PCIBus,
                              nirq, 0, vmstate_info_int32,
@@ -473,8 +472,7 @@ const VMStateDescription vmstate_pci_device = {
     .name = "PCIDevice",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_LE(version_id, PCIDevice),
         VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
                                    vmstate_info_pci_config,
@@ -490,8 +488,7 @@ const VMStateDescription vmstate_pcie_device = {
     .name = "PCIEDevice",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_LE(version_id, PCIDevice),
         VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
                                    vmstate_info_pci_config,
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index 991502e..090f307 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -784,8 +784,7 @@ static const VMStateDescription vmstate_pcie_aer_err = {
     .name = "PCIE_AER_ERROR",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields     = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(status, PCIEAERErr),
         VMSTATE_UINT16(source_id, PCIEAERErr),
         VMSTATE_UINT16(flags, PCIEAERErr),
@@ -799,8 +798,7 @@ const VMStateDescription vmstate_pcie_aer_log = {
     .name = "PCIE_AER_ERROR_LOG",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields     = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(log_num, PCIEAERLog),
         VMSTATE_UINT16(log_max, PCIEAERLog),
         VMSTATE_STRUCT_VARRAY_POINTER_UINT16(log, PCIEAERLog, log_num,
diff --git a/hw/ppc/ppc4xx_pci.c b/hw/ppc/ppc4xx_pci.c
index 4cb7851..55a3cab 100644
--- a/hw/ppc/ppc4xx_pci.c
+++ b/hw/ppc/ppc4xx_pci.c
@@ -294,8 +294,7 @@ static const VMStateDescription vmstate_pci_master_map = {
     .name = "pci_master_map",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(la, struct PCIMasterMap),
         VMSTATE_UINT32(ma, struct PCIMasterMap),
         VMSTATE_UINT32(pcila, struct PCIMasterMap),
@@ -308,8 +307,7 @@ static const VMStateDescription vmstate_pci_target_map = {
     .name = "pci_target_map",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(ms, struct PCITargetMap),
         VMSTATE_UINT32(la, struct PCITargetMap),
         VMSTATE_END_OF_LIST()
@@ -320,8 +318,7 @@ static const VMStateDescription vmstate_ppc4xx_pci = {
     .name = "ppc4xx_pci",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(pmm, PPC4xxPCIState, PPC4xx_PCI_NR_PMMS, 1,
                              vmstate_pci_master_map,
                              struct PCIMasterMap),
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index a11e121..ceae989 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -819,8 +819,7 @@ static const VMStateDescription vmstate_spapr = {
     .name = "spapr",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(next_irq, sPAPREnvironment),

         /* RTC offset */
diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
index d9fe946..ce15751 100644
--- a/hw/ppc/spapr_iommu.c
+++ b/hw/ppc/spapr_iommu.c
@@ -97,9 +97,8 @@ static const VMStateDescription vmstate_spapr_tce_table = {
     .name = "spapr_iommu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_load = spapr_tce_table_pre_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         /* Sanity check */
         VMSTATE_UINT32_EQUAL(liobn, sPAPRTCETable),
         VMSTATE_UINT32_EQUAL(window_size, sPAPRTCETable),
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index cbef095..a4a51d4 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -659,8 +659,7 @@ static const VMStateDescription vmstate_spapr_pci_lsi = {
     .name = "spapr_pci/lsi",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi),

         VMSTATE_END_OF_LIST()
@@ -671,8 +670,7 @@ static const VMStateDescription vmstate_spapr_pci_msi = {
     .name = "spapr_pci/lsi",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(config_addr, struct spapr_pci_msi),
         VMSTATE_UINT32(irq, struct spapr_pci_msi),
         VMSTATE_UINT32(nvec, struct spapr_pci_msi),
@@ -685,8 +683,7 @@ static const VMStateDescription vmstate_spapr_pci = {
     .name = "spapr_pci",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64_EQUAL(buid, sPAPRPHBState),
         VMSTATE_UINT32_EQUAL(dma_liobn, sPAPRPHBState),
         VMSTATE_UINT64_EQUAL(mem_win_addr, sPAPRPHBState),
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 2ae06a3..bce8d7f 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -547,8 +547,7 @@ const VMStateDescription vmstate_spapr_vio = {
     .name = "spapr_vio",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         /* Sanity check */
         VMSTATE_UINT32_EQUAL(reg, VIOsPAPRDevice),
         VMSTATE_UINT32_EQUAL(irq, VIOsPAPRDevice),
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 0777a93..057cb57 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -319,8 +319,7 @@ static const VMStateDescription vmstate_event_facility = {
     .name = "vmstate-event-facility",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(receive_mask, SCLPEventFacility),
         VMSTATE_END_OF_LIST()
      }
diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c
index a3c4bd6..1a399bd 100644
--- a/hw/s390x/sclpquiesce.c
+++ b/hw/s390x/sclpquiesce.c
@@ -69,8 +69,7 @@ static const VMStateDescription vmstate_sclpquiesce = {
     .name = "sclpquiesce",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_BOOL(event_pending, SCLPEvent),
         VMSTATE_END_OF_LIST()
      }
diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 48c8b82..9971bbf 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -310,7 +310,6 @@ static const VMStateDescription vmstate_esp_pci_scsi = {
     .name = "pciespscsi",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIESPState),
         VMSTATE_BUFFER_UNSAFE(dma_regs, PCIESPState, 0, 8 * sizeof(uint32_t)),
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 2d150bf..5ab44d8 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -560,8 +560,7 @@ const VMStateDescription vmstate_esp = {
     .name ="esp",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_BUFFER(rregs, ESPState),
         VMSTATE_BUFFER(wregs, ESPState),
         VMSTATE_INT32(ti_size, ESPState),
@@ -706,7 +705,6 @@ static const VMStateDescription vmstate_sysbus_esp_scsi = {
     .name = "sysbusespscsi",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(esp, SysBusESPState, 0, vmstate_esp, ESPState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index cb30414..786d848 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -1994,9 +1994,8 @@ static const VMStateDescription vmstate_lsi_scsi = {
     .name = "lsiscsi",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .pre_save = lsi_pre_save,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, LSIState),

         VMSTATE_INT32(carry, LSIState),
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index e6e1ffd..c735c08 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2065,8 +2065,7 @@ static const VMStateDescription vmstate_megasas = {
     .name = "megasas",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, MegasasState),

         VMSTATE_INT32(fw_state, MegasasState),
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index ae921a6..a137c98 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1915,8 +1915,7 @@ static const VMStateDescription vmstate_scsi_sense_state = {
     .name = "SCSIDevice/sense",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice,
                                 SCSI_SENSE_BUF_SIZE_OLD,
                                 SCSI_SENSE_BUF_SIZE - SCSI_SENSE_BUF_SIZE_OLD),
@@ -1928,7 +1927,6 @@ const VMStateDescription vmstate_scsi_device = {
     .name = "SCSIDevice",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(unit_attention.key, SCSIDevice),
         VMSTATE_UINT8(unit_attention.asc, SCSIDevice),
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 48a28ae..f05c772 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2571,7 +2571,6 @@ static const VMStateDescription vmstate_scsi_disk_state = {
     .name = "scsi-disk",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_SCSI_DEVICE(qdev, SCSIDiskState),
         VMSTATE_BOOL(media_changed, SCSIDiskState),
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index d4ada4f..f96b7af 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -598,8 +598,7 @@ static const VMStateDescription vmstate_spapr_vscsi_req = {
     .name = "spapr_vscsi_req",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_BUFFER(crq.raw, vscsi_req),
         VMSTATE_BUFFER(iu.srp.reserved, vscsi_req),
         VMSTATE_UINT32(qtag, vscsi_req),
@@ -1260,8 +1259,7 @@ static const VMStateDescription vmstate_spapr_vscsi = {
     .name = "spapr_vscsi",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_SPAPR_VIO(vdev, VSCSIState),
         /* VSCSI state */
         /* ???? */
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index e35bff7..f9ed926 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -1143,10 +1143,9 @@ static const VMStateDescription vmstate_pvscsi = {
     .name = "pvscsi",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .pre_save = pvscsi_pre_save,
     .post_load = pvscsi_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PVSCSIState),
         VMSTATE_UINT8(msi_used, PVSCSIState),
         VMSTATE_UINT32(resetting, PVSCSIState),
diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
index d1168c9..2a40f92 100644
--- a/hw/sd/milkymist-memcard.c
+++ b/hw/sd/milkymist-memcard.c
@@ -272,8 +272,7 @@ static const VMStateDescription vmstate_milkymist_memcard = {
     .name = "milkymist-memcard",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(command_write_ptr, MilkymistMemcardState),
         VMSTATE_INT32(response_read_ptr, MilkymistMemcardState),
         VMSTATE_INT32(response_len, MilkymistMemcardState),
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 843e697..e2951e6 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1197,7 +1197,7 @@ const VMStateDescription sdhci_vmstate = {
     .name = "sdhci",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(sdmasysad, SDHCIState),
         VMSTATE_UINT16(blksize, SDHCIState),
         VMSTATE_UINT16(blkcnt, SDHCIState),
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
index fd479ef..c1e2c97 100644
--- a/hw/ssi/pl022.c
+++ b/hw/ssi/pl022.c
@@ -244,8 +244,7 @@ static const VMStateDescription vmstate_pl022 = {
     .name = "pl022_ssp",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(cr0, PL022State),
         VMSTATE_UINT32(cr1, PL022State),
         VMSTATE_UINT32(bitmask, PL022State),
diff --git a/hw/ssi/ssi.c b/hw/ssi/ssi.c
index 017f022..1c82a93 100644
--- a/hw/ssi/ssi.c
+++ b/hw/ssi/ssi.c
@@ -126,8 +126,7 @@ const VMStateDescription vmstate_ssi_slave = {
     .name = "SSISlave",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_BOOL(cs, SSISlave),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c
index d44caae..207f47a 100644
--- a/hw/ssi/xilinx_spi.c
+++ b/hw/ssi/xilinx_spi.c
@@ -351,7 +351,6 @@ static const VMStateDescription vmstate_xilinx_spi = {
     .name = "xilinx_spi",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_FIFO8(tx_fifo, XilinxSPI),
         VMSTATE_FIFO8(rx_fifo, XilinxSPI),
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
index 8977243..0910f54 100644
--- a/hw/ssi/xilinx_spips.c
+++ b/hw/ssi/xilinx_spips.c
@@ -704,7 +704,6 @@ static const VMStateDescription vmstate_xilinx_spips = {
     .name = "xilinx_spips",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .post_load = xilinx_spips_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_FIFO8(tx_fifo, XilinxSPIPS),
diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c
index b27fce8..5e78e12 100644
--- a/hw/timer/allwinner-a10-pit.c
+++ b/hw/timer/allwinner-a10-pit.c
@@ -154,7 +154,6 @@ static const VMStateDescription vmstate_a10_pit = {
     .name = "a10.pit",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(irq_enable, AwA10PITState),
         VMSTATE_UINT32(irq_status, AwA10PITState),
diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
index fb0a45c..1452910 100644
--- a/hw/timer/arm_timer.c
+++ b/hw/timer/arm_timer.c
@@ -150,8 +150,7 @@ static const VMStateDescription vmstate_arm_timer = {
     .name = "arm_timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(control, arm_timer_state),
         VMSTATE_UINT32(limit, arm_timer_state),
         VMSTATE_INT32(int_level, arm_timer_state),
@@ -271,8 +270,7 @@ static const VMStateDescription vmstate_sp804 = {
     .name = "sp804",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_ARRAY(level, SP804State, 2),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c
index a279bce..19f89fc 100644
--- a/hw/timer/cadence_ttc.c
+++ b/hw/timer/cadence_ttc.c
@@ -441,7 +441,6 @@ static const VMStateDescription vmstate_cadence_timer = {
     .name = "cadence_timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = cadence_timer_pre_save,
     .post_load = cadence_timer_post_load,
     .fields = (VMStateField[]) {
@@ -462,7 +461,6 @@ static const VMStateDescription vmstate_cadence_ttc = {
     .name = "cadence_TTC",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(timer, CadenceTTCState, 3, 0,
                             vmstate_cadence_timer,
diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c
index 1fde22c..7e28e7e 100644
--- a/hw/timer/digic-timer.c
+++ b/hw/timer/digic-timer.c
@@ -36,7 +36,6 @@ static const VMStateDescription vmstate_digic_timer = {
     .name = "digic.timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PTIMER(ptimer, DigicTimerState),
         VMSTATE_UINT32(control, DigicTimerState),
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index bb2f8ee..ec6dbee 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -40,7 +40,6 @@ static const VMStateDescription vmstate_ds1338 = {
     .name = "ds1338",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_I2C_SLAVE(parent_obj, DS1338State),
         VMSTATE_INT64(offset, DS1338State),
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index 86f4fcd..01e750e 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -264,7 +264,6 @@ static const VMStateDescription vmstate_tick_timer = {
     .name = "exynos4210.mct.tick_timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(cnt_run, struct tick_timer),
         VMSTATE_UINT32(int_run, struct tick_timer),
@@ -284,7 +283,6 @@ static const VMStateDescription vmstate_lregs = {
     .name = "exynos4210.mct.lregs",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(cnt, struct lregs, L_REG_CNT_AMOUNT),
         VMSTATE_UINT32(tcon, struct lregs),
@@ -299,7 +297,6 @@ static const VMStateDescription vmstate_exynos4210_mct_lt = {
     .name = "exynos4210.mct.lt",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(id, Exynos4210MCTLT),
         VMSTATE_STRUCT(tick_timer, Exynos4210MCTLT, 0,
@@ -317,7 +314,6 @@ static const VMStateDescription vmstate_gregs = {
     .name = "exynos4210.mct.lregs",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT64(cnt, struct gregs),
         VMSTATE_UINT32(cnt_wstat, struct gregs),
@@ -336,7 +332,6 @@ static const VMStateDescription vmstate_exynos4210_mct_gt = {
     .name = "exynos4210.mct.lt",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(reg, Exynos4210MCTGT, 0, vmstate_gregs,
                 struct gregs),
@@ -351,7 +346,6 @@ static const VMStateDescription vmstate_exynos4210_mct_state = {
     .name = "exynos4210.mct",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(reg_mct_cfg, Exynos4210MCTState),
         VMSTATE_STRUCT_ARRAY(l_timer, Exynos4210MCTState, 2, 0,
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
index 1aa8f4d..1c1a2b8 100644
--- a/hw/timer/exynos4210_pwm.c
+++ b/hw/timer/exynos4210_pwm.c
@@ -120,7 +120,6 @@ static const VMStateDescription vmstate_exynos4210_pwm = {
     .name = "exynos4210.pwm.pwm",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(id, Exynos4210PWM),
         VMSTATE_UINT32(freq, Exynos4210PWM),
@@ -135,7 +134,6 @@ static const VMStateDescription vmstate_exynos4210_pwm_state = {
     .name = "exynos4210.pwm",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(reg_tcfg, Exynos4210PWMState, 2),
         VMSTATE_UINT32(reg_tcon, Exynos4210PWMState),
diff --git a/hw/timer/exynos4210_rtc.c b/hw/timer/exynos4210_rtc.c
index 026f81a..bf2ee9f 100644
--- a/hw/timer/exynos4210_rtc.c
+++ b/hw/timer/exynos4210_rtc.c
@@ -118,7 +118,6 @@ static const VMStateDescription vmstate_exynos4210_rtc_state = {
     .name = "exynos4210.rtc",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(reg_intp, Exynos4210RTCState),
         VMSTATE_UINT32(reg_rtccon, Exynos4210RTCState),
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index e15d6bc..fa590e3 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -270,8 +270,7 @@ static const VMStateDescription vmstate_hpet_rtc_irq_level = {
     .name = "hpet/rtc_irq_level",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(rtc_irq_level, HPETState),
         VMSTATE_END_OF_LIST()
     }
@@ -281,8 +280,7 @@ static const VMStateDescription vmstate_hpet_timer = {
     .name = "hpet_timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(tn, HPETTimer),
         VMSTATE_UINT64(config, HPETTimer),
         VMSTATE_UINT64(cmp, HPETTimer),
@@ -298,11 +296,10 @@ static const VMStateDescription vmstate_hpet = {
     .name = "hpet",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_save = hpet_pre_save,
     .pre_load = hpet_pre_load,
     .post_load = hpet_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(config, HPETState),
         VMSTATE_UINT64(isr, HPETState),
         VMSTATE_UINT64(hpet_counter, HPETState),
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index 9db5c9d..07345f6 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -180,7 +180,6 @@ static const VMStateDescription vmstate_pit_channel = {
     .name = "pit channel",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(count, PITChannelState),
         VMSTATE_UINT16(latched_count, PITChannelState),
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
index 0dbe15c..c855eba 100644
--- a/hw/timer/imx_epit.c
+++ b/hw/timer/imx_epit.c
@@ -353,8 +353,7 @@ static const VMStateDescription vmstate_imx_timer_epit = {
     .name = "imx.epit",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(cr, IMXEPITState),
         VMSTATE_UINT32(sr, IMXEPITState),
         VMSTATE_UINT32(lr, IMXEPITState),
diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c
index f2d1975..56ee4db 100644
--- a/hw/timer/imx_gpt.c
+++ b/hw/timer/imx_gpt.c
@@ -146,8 +146,7 @@ static const VMStateDescription vmstate_imx_timer_gpt = {
     .name = "imx.gpt",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(cr, IMXGPTState),
         VMSTATE_UINT32(pr, IMXGPTState),
         VMSTATE_UINT32(sr, IMXGPTState),
diff --git a/hw/timer/lm32_timer.c b/hw/timer/lm32_timer.c
index 8ed138c..d2ab1e7 100644
--- a/hw/timer/lm32_timer.c
+++ b/hw/timer/lm32_timer.c
@@ -196,8 +196,7 @@ static const VMStateDescription vmstate_lm32_timer = {
     .name = "lm32-timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PTIMER(ptimer, LM32TimerState),
         VMSTATE_UINT32(freq_hz, LM32TimerState),
         VMSTATE_UINT32_ARRAY(regs, LM32TimerState, R_MAX),
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index 7cf8684..31509d5 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -595,8 +595,7 @@ static const VMStateDescription vmstate_m48t59 = {
     .name = "m48t59",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(lock, M48t59State),
         VMSTATE_UINT16(addr, M48t59State),
         VMSTATE_VBUFFER_UINT32(buffer, M48t59State, 0, NULL, 0, size),
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 8509309..1822af2 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -720,9 +720,8 @@ static const VMStateDescription vmstate_rtc = {
     .name = "mc146818rtc",
     .version_id = 3,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = rtc_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_BUFFER(cmos_data, RTCState),
         VMSTATE_UINT8(cmos_index, RTCState),
         VMSTATE_UNUSED(7*4),
diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c
index 94246e5..30535a4 100644
--- a/hw/timer/milkymist-sysctl.c
+++ b/hw/timer/milkymist-sysctl.c
@@ -295,8 +295,7 @@ static const VMStateDescription vmstate_milkymist_sysctl = {
     .name = "milkymist-sysctl",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistSysctlState, R_MAX),
         VMSTATE_PTIMER(ptimer0, MilkymistSysctlState),
         VMSTATE_PTIMER(ptimer1, MilkymistSysctlState),
diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c
index 0f546c4..130e9dc 100644
--- a/hw/timer/pxa2xx_timer.c
+++ b/hw/timer/pxa2xx_timer.c
@@ -476,7 +476,6 @@ static const VMStateDescription vmstate_pxa2xx_timer0_regs = {
     .name = "pxa2xx_timer0",
     .version_id = 2,
     .minimum_version_id = 2,
-    .minimum_version_id_old = 2,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(value, PXA2xxTimer0),
         VMSTATE_END_OF_LIST(),
@@ -487,7 +486,6 @@ static const VMStateDescription vmstate_pxa2xx_timer4_regs = {
     .name = "pxa2xx_timer4",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(tm, PXA2xxTimer4, 1,
                         vmstate_pxa2xx_timer0_regs, PXA2xxTimer0),
@@ -509,7 +507,6 @@ static const VMStateDescription vmstate_pxa2xx_timer_regs = {
     .name = "pxa2xx_timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = pxa25x_timer_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(clock, PXA2xxTimerInfo),
diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c
index e4dccea..45d97e6 100644
--- a/hw/timer/slavio_timer.c
+++ b/hw/timer/slavio_timer.c
@@ -329,8 +329,7 @@ static const VMStateDescription vmstate_timer = {
     .name ="timer",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(limit, CPUTimerState),
         VMSTATE_UINT32(count, CPUTimerState),
         VMSTATE_UINT32(counthigh, CPUTimerState),
@@ -345,8 +344,7 @@ static const VMStateDescription vmstate_slavio_timer = {
     .name ="slavio_timer",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT_ARRAY(cputimer, SLAVIO_TIMERState, MAX_CPUS + 1, 3,
                              vmstate_timer, CPUTimerState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index 85d5990..7ded4ba 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -772,8 +772,7 @@ static const VMStateDescription vmstate_menelaus_tm = {
     .name = "menelaus_tm",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16_HACK(tm_sec, struct tm),
         VMSTATE_UINT16_HACK(tm_min, struct tm),
         VMSTATE_UINT16_HACK(tm_hour, struct tm),
@@ -811,10 +810,9 @@ static const VMStateDescription vmstate_menelaus = {
     .name = "menelaus",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
     .pre_save = menelaus_pre_save,
     .post_load = menelaus_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32(firstbyte, MenelausState),
         VMSTATE_UINT8(reg, MenelausState),
         VMSTATE_UINT8_ARRAY(vcore, MenelausState, 5),
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index fe70429..5f201cb 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -61,7 +61,7 @@ const VMStateDescription vmstate_usb_device = {
     .version_id = 1,
     .minimum_version_id = 1,
     .post_load = usb_device_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT8(addr, USBDevice),
         VMSTATE_INT32(state, USBDevice),
         VMSTATE_INT32(remote_wakeup, USBDevice),
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index f36e617..d097d93 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -622,7 +622,7 @@ static const VMStateDescription vmstate_usb_ptr = {
     .version_id = 1,
     .minimum_version_id = 1,
     .post_load = usb_ptr_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_USB_DEVICE(dev, USBHIDState),
         VMSTATE_HID_POINTER_DEVICE(hid, USBHIDState),
         VMSTATE_END_OF_LIST()
@@ -633,7 +633,7 @@ static const VMStateDescription vmstate_usb_kbd = {
     .name = "usb-kbd",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_USB_DEVICE(dev, USBHIDState),
         VMSTATE_HID_KEYBOARD_DEVICE(hid, USBHIDState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index bc03531..7492174 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -540,7 +540,7 @@ static const VMStateDescription vmstate_usb_hub_port = {
     .name = "usb-hub-port",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(wPortStatus, USBHubPort),
         VMSTATE_UINT16(wPortChange, USBHubPort),
         VMSTATE_END_OF_LIST()
@@ -551,7 +551,7 @@ static const VMStateDescription vmstate_usb_hub = {
     .name = "usb-hub",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_USB_DEVICE(dev, USBHubState),
         VMSTATE_STRUCT_ARRAY(ports, USBHubState, NUM_PORTS, 0,
                              vmstate_usb_hub_port, USBHubPort),
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 2852669..e919100 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -716,7 +716,7 @@ static const VMStateDescription vmstate_usb_msd = {
     .name = "usb-storage",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_USB_DEVICE(dev, MSDState),
         VMSTATE_UINT32(mode, MSDState),
         VMSTATE_UINT32(scsi_len, MSDState),
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 484a9bd..505741a 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -108,7 +108,7 @@ static const VMStateDescription vmstate_ehci_pci = {
     .name        = "ehci",
     .version_id  = 2,
     .minimum_version_id  = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(pcidev, EHCIPCIState),
         VMSTATE_STRUCT(ehci, EHCIPCIState, 2, vmstate_ehci, EHCIState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index fe6eea5..19ed2c2 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -21,7 +21,7 @@ static const VMStateDescription vmstate_ehci_sysbus = {
     .name        = "ehci-sysbus",
     .version_id  = 2,
     .minimum_version_id  = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(ehci, EHCISysBusState, 2, vmstate_ehci, EHCIState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 355bbd6..a3ae9f2 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2492,7 +2492,7 @@ const VMStateDescription vmstate_ehci = {
     .minimum_version_id  = 1,
     .pre_save    = usb_ehci_pre_save,
     .post_load   = usb_ehci_post_load,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         /* mmio registers */
         VMSTATE_UINT32(usbcmd, EHCIState),
         VMSTATE_UINT32(usbsts, EHCIState),
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 0820244..9b1166b 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -422,8 +422,7 @@ static const VMStateDescription vmstate_uhci_port = {
     .name = "uhci port",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(ctrl, UHCIPort),
         VMSTATE_END_OF_LIST()
     }
@@ -444,9 +443,8 @@ static const VMStateDescription vmstate_uhci = {
     .name = "uhci",
     .version_id = 3,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .post_load = uhci_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, UHCIState),
         VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState),
         VMSTATE_STRUCT_ARRAY(ports, UHCIState, NB_PORTS, 1,
diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index 36d3887..b3d6f39 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -379,18 +379,18 @@ static const VMStateDescription vmstate_i6300esb = {
      * version_id to be set for every build. This eventually broke
      * migration.
      *
-     * To correct this without breaking old->new migration for older versions
-     * of QEMU, we've set version_id to a value high enough to exceed all past
-     * values of sizeof(I6300State) across various build environments, and have
-     * reset minimum_version_id_old/minimum_version_id to 1, since this VMSD
-     * has never changed and thus can accept all past versions.
+     * To correct this without breaking old->new migration for older
+     * versions of QEMU, we've set version_id to a value high enough
+     * to exceed all past values of sizeof(I6300State) across various
+     * build environments, and have reset minimum_version_id to 1,
+     * since this VMSD has never changed and thus can accept all past
+     * versions.
      *
      * For future changes we can treat these values as we normally would.
      */
     .version_id = 10000,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, I6300State),
         VMSTATE_INT32(reboot_enabled, I6300State),
         VMSTATE_INT32(clock_scale, I6300State),
diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
index bc994a4..99bd7ea 100644
--- a/hw/watchdog/wdt_ib700.c
+++ b/hw/watchdog/wdt_ib700.c
@@ -90,8 +90,7 @@ static const VMStateDescription vmstate_ib700 = {
     .name = "ib700_wdt",
     .version_id = 0,
     .minimum_version_id = 0,
-    .minimum_version_id_old = 0,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_TIMER(timer, IB700State),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/xen/xen_platform.c b/hw/xen/xen_platform.c
index 1d9d0e9..8bb18b4 100644
--- a/hw/xen/xen_platform.c
+++ b/hw/xen/xen_platform.c
@@ -375,9 +375,8 @@ static const VMStateDescription vmstate_xen_platform = {
     .name = "platform",
     .version_id = 4,
     .minimum_version_id = 4,
-    .minimum_version_id_old = 4,
     .post_load = xen_platform_post_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIXenPlatformState),
         VMSTATE_UINT8(flags, PCIXenPlatformState),
         VMSTATE_END_OF_LIST()
diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index 889f2fc..e796bbe 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -72,7 +72,6 @@ static const VMStateDescription vmstate_env = {
     .name = "env",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = vmstate_env_fields,
 };

@@ -86,6 +85,5 @@ const VMStateDescription vmstate_alpha_cpu = {
     .name = "cpu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = vmstate_cpu_fields,
 };
diff --git a/target-arm/machine.c b/target-arm/machine.c
index 7ced87a..ee67b67 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -39,7 +39,6 @@ static const VMStateDescription vmstate_vfp = {
     .name = "cpu/vfp",
     .version_id = 3,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
     .fields = (VMStateField[]) {
         VMSTATE_FLOAT64_ARRAY(env.vfp.regs, ARMCPU, 64),
         /* The xregs array is a little awkward because element 1 (FPSCR)
@@ -72,7 +71,6 @@ static const VMStateDescription vmstate_iwmmxt = {
     .name = "cpu/iwmmxt",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT64_ARRAY(env.iwmmxt.regs, ARMCPU, 16),
         VMSTATE_UINT32_ARRAY(env.iwmmxt.cregs, ARMCPU, 16),
@@ -92,7 +90,6 @@ static const VMStateDescription vmstate_m = {
     .name = "cpu/m",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.v7m.other_sp, ARMCPU),
         VMSTATE_UINT32(env.v7m.vecbase, ARMCPU),
@@ -116,7 +113,6 @@ static const VMStateDescription vmstate_thumb2ee = {
     .name = "cpu/thumb2ee",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.teecr, ARMCPU),
         VMSTATE_UINT32(env.teehbr, ARMCPU),
@@ -224,7 +220,6 @@ const VMStateDescription vmstate_arm_cpu = {
     .name = "cpu",
     .version_id = 14,
     .minimum_version_id = 14,
-    .minimum_version_id_old = 14,
     .pre_save = cpu_pre_save,
     .post_load = cpu_post_load,
     .fields = (VMStateField[]) {
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 168cab6..fe3f024 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -10,8 +10,7 @@ static const VMStateDescription vmstate_segment = {
     .name = "segment",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(selector, SegmentCache),
         VMSTATE_UINTTL(base, SegmentCache),
         VMSTATE_UINT32(limit, SegmentCache),
@@ -36,8 +35,7 @@ static const VMStateDescription vmstate_xmm_reg = {
     .name = "xmm_reg",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(XMM_Q(0), XMMReg),
         VMSTATE_UINT64(XMM_Q(1), XMMReg),
         VMSTATE_END_OF_LIST()
@@ -52,8 +50,7 @@ static const VMStateDescription vmstate_ymmh_reg = {
     .name = "ymmh_reg",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(XMM_Q(0), XMMReg),
         VMSTATE_UINT64(XMM_Q(1), XMMReg),
         VMSTATE_END_OF_LIST()
@@ -67,8 +64,7 @@ static const VMStateDescription vmstate_bnd_regs = {
     .name = "bnd_regs",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(lb, BNDReg),
         VMSTATE_UINT64(ub, BNDReg),
         VMSTATE_END_OF_LIST()
@@ -82,8 +78,7 @@ static const VMStateDescription vmstate_mtrr_var = {
     .name = "mtrr_var",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(base, MTRRVar),
         VMSTATE_UINT64(mask, MTRRVar),
         VMSTATE_END_OF_LIST()
@@ -355,8 +350,7 @@ static const VMStateDescription vmstate_steal_time_msr = {
     .name = "cpu/steal_time_msr",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.steal_time_msr, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -366,8 +360,7 @@ static const VMStateDescription vmstate_async_pf_msr = {
     .name = "cpu/async_pf_msr",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.async_pf_en_msr, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -377,8 +370,7 @@ static const VMStateDescription vmstate_pv_eoi_msr = {
     .name = "cpu/async_pv_eoi_msr",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.pv_eoi_en_msr, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -396,8 +388,7 @@ static const VMStateDescription vmstate_fpop_ip_dp = {
     .name = "cpu/fpop_ip_dp",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(env.fpop, X86CPU),
         VMSTATE_UINT64(env.fpip, X86CPU),
         VMSTATE_UINT64(env.fpdp, X86CPU),
@@ -417,8 +408,7 @@ static const VMStateDescription vmstate_msr_tsc_adjust = {
     .name = "cpu/msr_tsc_adjust",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.tsc_adjust, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -436,8 +426,7 @@ static const VMStateDescription vmstate_msr_tscdeadline = {
     .name = "cpu/msr_tscdeadline",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.tsc_deadline, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -463,8 +452,7 @@ static const VMStateDescription vmstate_msr_ia32_misc_enable = {
     .name = "cpu/msr_ia32_misc_enable",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.msr_ia32_misc_enable, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -474,8 +462,7 @@ static const VMStateDescription vmstate_msr_ia32_feature_control = {
     .name = "cpu/msr_ia32_feature_control",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.msr_ia32_feature_control, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -509,8 +496,7 @@ static const VMStateDescription vmstate_msr_architectural_pmu = {
     .name = "cpu/msr_architectural_pmu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.msr_fixed_ctr_ctrl, X86CPU),
         VMSTATE_UINT64(env.msr_global_ctrl, X86CPU),
         VMSTATE_UINT64(env.msr_global_status, X86CPU),
@@ -545,8 +531,7 @@ static const VMStateDescription vmstate_mpx = {
     .name = "cpu/mpx",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_BND_REGS(env.bnd_regs, X86CPU, 4),
         VMSTATE_UINT64(env.bndcs_regs.cfgu, X86CPU),
         VMSTATE_UINT64(env.bndcs_regs.sts, X86CPU),
@@ -567,8 +552,7 @@ static const VMStateDescription vmstate_msr_hypercall_hypercall = {
     .name = "cpu/msr_hyperv_hypercall",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.msr_hv_guest_os_id, X86CPU),
         VMSTATE_UINT64(env.msr_hv_hypercall, X86CPU),
         VMSTATE_END_OF_LIST()
@@ -587,8 +571,7 @@ static const VMStateDescription vmstate_msr_hyperv_vapic = {
     .name = "cpu/msr_hyperv_vapic",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.msr_hv_vapic, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -606,8 +589,7 @@ static const VMStateDescription vmstate_msr_hyperv_time = {
     .name = "cpu/msr_hyperv_time",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(env.msr_hv_tsc, X86CPU),
         VMSTATE_END_OF_LIST()
     }
@@ -617,10 +599,9 @@ const VMStateDescription vmstate_x86_cpu = {
     .name = "cpu",
     .version_id = 12,
     .minimum_version_id = 3,
-    .minimum_version_id_old = 3,
     .pre_save = cpu_pre_save,
     .post_load = cpu_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINTTL_ARRAY(env.regs, X86CPU, CPU_NB_REGS),
         VMSTATE_UINTTL(env.eip, X86CPU),
         VMSTATE_UINTTL(env.eflags, X86CPU),
diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index 9e0919c..8327c6d 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -5,8 +5,7 @@ static const VMStateDescription vmstate_env = {
     .name = "env",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, CPULM32State, 32),
         VMSTATE_UINT32(pc, CPULM32State),
         VMSTATE_UINT32(ie, CPULM32State),
@@ -26,8 +25,7 @@ const VMStateDescription vmstate_lm32_cpu = {
     .name = "cpu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_STRUCT(env, LM32CPU, 1, vmstate_env, CPULM32State),
         VMSTATE_END_OF_LIST()
     }
diff --git a/target-moxie/machine.c b/target-moxie/machine.c
index 0f5992b..da1a857 100644
--- a/target-moxie/machine.c
+++ b/target-moxie/machine.c
@@ -5,8 +5,7 @@ const VMStateDescription vmstate_moxie_cpu = {
     .name = "cpu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(flags, CPUMoxieState),
         VMSTATE_UINT32_ARRAY(gregs, CPUMoxieState, 16),
         VMSTATE_UINT32_ARRAY(sregs, CPUMoxieState, 256),
diff --git a/target-openrisc/machine.c b/target-openrisc/machine.c
index 6f864fe..9f66a9c 100644
--- a/target-openrisc/machine.c
+++ b/target-openrisc/machine.c
@@ -24,7 +24,6 @@ static const VMStateDescription vmstate_env = {
     .name = "env",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(gpr, CPUOpenRISCState, 32),
         VMSTATE_UINT32(sr, CPUOpenRISCState),
@@ -43,7 +42,6 @@ const VMStateDescription vmstate_openrisc_cpu = {
     .name = "cpu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_CPU(),
         VMSTATE_STRUCT(env, OpenRISCCPU, 1, vmstate_env, CPUOpenRISCState),
diff --git a/target-ppc/machine.c b/target-ppc/machine.c
index 063b379..d7807f8 100644
--- a/target-ppc/machine.c
+++ b/target-ppc/machine.c
@@ -202,8 +202,7 @@ static const VMStateDescription vmstate_fpu = {
     .name = "cpu/fpu",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_FLOAT64_ARRAY(env.fpr, PowerPCCPU, 32),
         VMSTATE_UINTTL(env.fpscr, PowerPCCPU),
         VMSTATE_END_OF_LIST()
@@ -221,8 +220,7 @@ static const VMStateDescription vmstate_altivec = {
     .name = "cpu/altivec",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_AVR_ARRAY(env.avr, PowerPCCPU, 32),
         VMSTATE_UINT32(env.vscr, PowerPCCPU),
         VMSTATE_END_OF_LIST()
@@ -240,8 +238,7 @@ static const VMStateDescription vmstate_vsx = {
     .name = "cpu/vsx",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64_ARRAY(env.vsr, PowerPCCPU, 32),
         VMSTATE_END_OF_LIST()
     },
@@ -262,8 +259,7 @@ static const VMStateDescription vmstate_sr = {
     .name = "cpu/sr",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINTTL_ARRAY(env.sr, PowerPCCPU, 32),
         VMSTATE_END_OF_LIST()
     },
@@ -312,8 +308,7 @@ static const VMStateDescription vmstate_slb = {
     .name = "cpu/slb",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(env.slb_nr, PowerPCCPU),
         VMSTATE_SLB_ARRAY(env.slb, PowerPCCPU, MAX_SLB_ENTRIES),
         VMSTATE_END_OF_LIST()
@@ -325,8 +320,7 @@ static const VMStateDescription vmstate_tlb6xx_entry = {
     .name = "cpu/tlb6xx_entry",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINTTL(pte0, ppc6xx_tlb_t),
         VMSTATE_UINTTL(pte1, ppc6xx_tlb_t),
         VMSTATE_UINTTL(EPN, ppc6xx_tlb_t),
@@ -346,8 +340,7 @@ static const VMStateDescription vmstate_tlb6xx = {
     .name = "cpu/tlb6xx",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU),
         VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlb6, PowerPCCPU,
                                             env.nb_tlb,
@@ -362,8 +355,7 @@ static const VMStateDescription vmstate_tlbemb_entry = {
     .name = "cpu/tlbemb_entry",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(RPN, ppcemb_tlb_t),
         VMSTATE_UINTTL(EPN, ppcemb_tlb_t),
         VMSTATE_UINTTL(PID, ppcemb_tlb_t),
@@ -394,8 +386,7 @@ static const VMStateDescription vmstate_pbr403 = {
     .name = "cpu/pbr403",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINTTL_ARRAY(env.pb, PowerPCCPU, 4),
         VMSTATE_END_OF_LIST()
     },
@@ -405,8 +396,7 @@ static const VMStateDescription vmstate_tlbemb = {
     .name = "cpu/tlb6xx",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU),
         VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbe, PowerPCCPU,
                                             env.nb_tlb,
@@ -429,8 +419,7 @@ static const VMStateDescription vmstate_tlbmas_entry = {
     .name = "cpu/tlbmas_entry",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(mas8, ppcmas_tlb_t),
         VMSTATE_UINT32(mas1, ppcmas_tlb_t),
         VMSTATE_UINT64(mas2, ppcmas_tlb_t),
@@ -451,8 +440,7 @@ static const VMStateDescription vmstate_tlbmas = {
     .name = "cpu/tlbmas",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU),
         VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbm, PowerPCCPU,
                                             env.nb_tlb,
@@ -470,7 +458,7 @@ const VMStateDescription vmstate_ppc_cpu = {
     .load_state_old = cpu_load_old,
     .pre_save = cpu_pre_save,
     .post_load = cpu_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         /* Verify we haven't changed the pvr */
         VMSTATE_UINTTL_EQUAL(env.spr[SPR_PVR], PowerPCCPU),

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 75cd1a1..30cc721 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -65,8 +65,7 @@ static const VMStateDescription vmstate_simple = {
     .name = "test",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(a, TestStruct),
         VMSTATE_UINT32(b, TestStruct),
         VMSTATE_UINT32(c, TestStruct),
@@ -131,8 +130,7 @@ static const VMStateDescription vmstate_versioned = {
     .name = "test",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(a, TestStruct),
         VMSTATE_UINT32_V(b, TestStruct, 2), /* Versioned field in the middle, so
                                              * we catch bugs more easily.
@@ -207,8 +205,7 @@ static const VMStateDescription vmstate_skipping = {
     .name = "test",
     .version_id = 2,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(a, TestStruct),
         VMSTATE_UINT32(b, TestStruct),
         VMSTATE_UINT32_TEST(c, TestStruct, test_skip),
diff --git a/util/fifo8.c b/util/fifo8.c
index 6a43482..0ea5ad9 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -116,8 +116,7 @@ const VMStateDescription vmstate_fifo8 = {
     .name = "Fifo8",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(data, Fifo8, 1, NULL, 0, capacity),
         VMSTATE_UINT32(head, Fifo8),
         VMSTATE_UINT32(num, Fifo8),
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 03/97] vmstate: return error in case of error
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 01/97] savevm: Ignore minimum_version_id_old if there is no load_state_old Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive) Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  8:19   ` Dr. David Alan Gilbert
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 04/97] vmstate: reduce code duplication Juan Quintela
                   ` (95 subsequent siblings)
  98 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

If there is an error while loading a field, we should stop reading and
not continue with the rest of fields.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 vmstate.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/vmstate.c b/vmstate.c
index bfa34cc..d82cccf 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -74,6 +74,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                     ret = field->info->get(f, addr, size);

                 }
+                if (ret >= 0) {
+                    ret = qemu_file_get_error(f);
+                }
                 if (ret < 0) {
                     trace_vmstate_load_field_error(field->name, ret);
                     return ret;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 04/97] vmstate: reduce code duplication
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (2 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 03/97] vmstate: return error in case of error Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 05/97] vmstate: refactor opening of files Juan Quintela
                   ` (94 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dr. David Alan Gilbert, Michael S. Tsirkin

From: "Michael S. Tsirkin" <mst@redhat.com>

move size offset and number of elements math out
to functions, to reduce code duplication.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 vmstate.c | 100 ++++++++++++++++++++++++++++++++------------------------------
 1 file changed, 52 insertions(+), 48 deletions(-)

diff --git a/vmstate.c b/vmstate.c
index d82cccf..cb0af5e 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -10,6 +10,50 @@ static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
                                    void *opaque);

+static int vmstate_n_elems(void *opaque, VMStateField *field)
+{
+    int n_elems = 1;
+
+    if (field->flags & VMS_ARRAY) {
+        n_elems = field->num;
+    } else if (field->flags & VMS_VARRAY_INT32) {
+        n_elems = *(int32_t *)(opaque+field->num_offset);
+    } else if (field->flags & VMS_VARRAY_UINT32) {
+        n_elems = *(uint32_t *)(opaque+field->num_offset);
+    } else if (field->flags & VMS_VARRAY_UINT16) {
+        n_elems = *(uint16_t *)(opaque+field->num_offset);
+    } else if (field->flags & VMS_VARRAY_UINT8) {
+        n_elems = *(uint8_t *)(opaque+field->num_offset);
+    }
+
+    return n_elems;
+}
+
+static int vmstate_size(void *opaque, VMStateField *field)
+{
+    int size = field->size;
+
+    if (field->flags & VMS_VBUFFER) {
+        size = *(int32_t *)(opaque+field->size_offset);
+        if (field->flags & VMS_MULTIPLY) {
+            size *= field->size;
+        }
+    }
+
+    return size;
+}
+
+static void *vmstate_base_addr(void *opaque, VMStateField *field)
+{
+    void *base_addr = opaque + field->offset;
+
+    if (field->flags & VMS_POINTER) {
+        base_addr = *(void **)base_addr + field->start;
+    }
+
+    return base_addr;
+}
+
 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                        void *opaque, int version_id)
 {
@@ -37,30 +81,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
              field->field_exists(opaque, version_id)) ||
             (!field->field_exists &&
              field->version_id <= 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_MULTIPLY) {
-                    size *= field->size;
-                }
-            }
-            if (field->flags & VMS_ARRAY) {
-                n_elems = field->num;
-            } else if (field->flags & VMS_VARRAY_INT32) {
-                n_elems = *(int32_t *)(opaque+field->num_offset);
-            } else if (field->flags & VMS_VARRAY_UINT32) {
-                n_elems = *(uint32_t *)(opaque+field->num_offset);
-            } else if (field->flags & VMS_VARRAY_UINT16) {
-                n_elems = *(uint16_t *)(opaque+field->num_offset);
-            } else if (field->flags & VMS_VARRAY_UINT8) {
-                n_elems = *(uint8_t *)(opaque+field->num_offset);
-            }
-            if (field->flags & VMS_POINTER) {
-                base_addr = *(void **)base_addr + field->start;
-            }
+            void *base_addr = vmstate_base_addr(opaque, field);
+            int i, n_elems = vmstate_n_elems(opaque, field);
+            int size = vmstate_size(opaque, field);
+
             for (i = 0; i < n_elems; i++) {
                 void *addr = base_addr + size * i;

@@ -106,30 +130,10 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
     while (field->name) {
         if (!field->field_exists ||
             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_MULTIPLY) {
-                    size *= field->size;
-                }
-            }
-            if (field->flags & VMS_ARRAY) {
-                n_elems = field->num;
-            } else if (field->flags & VMS_VARRAY_INT32) {
-                n_elems = *(int32_t *)(opaque+field->num_offset);
-            } else if (field->flags & VMS_VARRAY_UINT32) {
-                n_elems = *(uint32_t *)(opaque+field->num_offset);
-            } else if (field->flags & VMS_VARRAY_UINT16) {
-                n_elems = *(uint16_t *)(opaque+field->num_offset);
-            } else if (field->flags & VMS_VARRAY_UINT8) {
-                n_elems = *(uint8_t *)(opaque+field->num_offset);
-            }
-            if (field->flags & VMS_POINTER) {
-                base_addr = *(void **)base_addr + field->start;
-            }
+            void *base_addr = vmstate_base_addr(opaque, field);
+            int i, n_elems = vmstate_n_elems(opaque, field);
+            int size = vmstate_size(opaque, field);
+
             for (i = 0; i < n_elems; i++) {
                 void *addr = base_addr + size * i;

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 05/97] vmstate: refactor opening of files
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (3 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 04/97] vmstate: reduce code duplication Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07 17:34   ` Eduardo Habkost
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 06/97] vmstate: Refactor & increase tests for primitive types Juan Quintela
                   ` (93 subsequent siblings)
  98 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 30cc721..8b242c4 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -44,14 +44,14 @@ void yield_until_fd_readable(int fd)
 }

 /* Duplicate temp_fd and seek to the beginning of the file */
-static int dup_temp_fd(bool truncate)
+static QEMUFile *open_test_file(bool write)
 {
     int fd = dup(temp_fd);
     lseek(fd, 0, SEEK_SET);
-    if (truncate) {
+    if (write) {
         g_assert_cmpint(ftruncate(fd, 0), ==, 0);
     }
-    return fd;
+    return qemu_fdopen(fd, write ? "wb" : "rb");
 }

 typedef struct TestSruct {
@@ -76,13 +76,13 @@ static const VMStateDescription vmstate_simple = {

 static void test_simple_save(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4 };
     vmstate_save_state(fsave, &vmstate_simple, &obj);
     g_assert(!qemu_file_get_error(fsave));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     uint8_t expected[] = {
         0, 0, 0, 1, /* a */
         0, 0, 0, 2, /* b */
@@ -104,7 +104,7 @@ static void test_simple_save(void)

 static void test_simple_load(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     uint8_t buf[] = {
         0, 0, 0, 10,             /* a */
         0, 0, 0, 20,             /* b */
@@ -115,7 +115,7 @@ static void test_simple_load(void)
     qemu_put_buffer(fsave, buf, sizeof(buf));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     TestStruct obj;
     vmstate_load_state(loading, &vmstate_simple, &obj, 1);
     g_assert(!qemu_file_get_error(loading));
@@ -145,7 +145,7 @@ static const VMStateDescription vmstate_versioned = {

 static void test_load_v1(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     uint8_t buf[] = {
         0, 0, 0, 10,             /* a */
         0, 0, 0, 30,             /* c */
@@ -155,7 +155,7 @@ static void test_load_v1(void)
     qemu_put_buffer(fsave, buf, sizeof(buf));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     TestStruct obj = { .b = 200, .e = 500, .f = 600 };
     vmstate_load_state(loading, &vmstate_versioned, &obj, 1);
     g_assert(!qemu_file_get_error(loading));
@@ -170,7 +170,7 @@ static void test_load_v1(void)

 static void test_load_v2(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     uint8_t buf[] = {
         0, 0, 0, 10,             /* a */
         0, 0, 0, 20,             /* b */
@@ -183,7 +183,7 @@ static void test_load_v2(void)
     qemu_put_buffer(fsave, buf, sizeof(buf));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     TestStruct obj;
     vmstate_load_state(loading, &vmstate_versioned, &obj, 2);
     g_assert_cmpint(obj.a, ==, 10);
@@ -219,14 +219,14 @@ static const VMStateDescription vmstate_skipping = {

 static void test_save_noskip(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4, .e = 5, .f = 6,
                        .skip_c_e = false };
     vmstate_save_state(fsave, &vmstate_skipping, &obj);
     g_assert(!qemu_file_get_error(fsave));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     uint8_t expected[] = {
         0, 0, 0, 1,             /* a */
         0, 0, 0, 2,             /* b */
@@ -250,14 +250,14 @@ static void test_save_noskip(void)

 static void test_save_skip(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4, .e = 5, .f = 6,
                        .skip_c_e = true };
     vmstate_save_state(fsave, &vmstate_skipping, &obj);
     g_assert(!qemu_file_get_error(fsave));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     uint8_t expected[] = {
         0, 0, 0, 1,             /* a */
         0, 0, 0, 2,             /* b */
@@ -280,7 +280,7 @@ static void test_save_skip(void)

 static void test_load_noskip(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     uint8_t buf[] = {
         0, 0, 0, 10,             /* a */
         0, 0, 0, 20,             /* b */
@@ -293,7 +293,7 @@ static void test_load_noskip(void)
     qemu_put_buffer(fsave, buf, sizeof(buf));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     TestStruct obj = { .skip_c_e = false };
     vmstate_load_state(loading, &vmstate_skipping, &obj, 2);
     g_assert(!qemu_file_get_error(loading));
@@ -308,7 +308,7 @@ static void test_load_noskip(void)

 static void test_load_skip(void)
 {
-    QEMUFile *fsave = qemu_fdopen(dup_temp_fd(true), "wb");
+    QEMUFile *fsave = open_test_file(true);
     uint8_t buf[] = {
         0, 0, 0, 10,             /* a */
         0, 0, 0, 20,             /* b */
@@ -319,7 +319,7 @@ static void test_load_skip(void)
     qemu_put_buffer(fsave, buf, sizeof(buf));
     qemu_fclose(fsave);

-    QEMUFile *loading = qemu_fdopen(dup_temp_fd(false), "rb");
+    QEMUFile *loading = open_test_file(false);
     TestStruct obj = { .skip_c_e = true, .c = 300, .e = 500 };
     vmstate_load_state(loading, &vmstate_skipping, &obj, 2);
     g_assert(!qemu_file_get_error(loading));
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 06/97] vmstate: Refactor & increase tests for primitive types
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (4 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 05/97] vmstate: refactor opening of files Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07 17:57   ` Eduardo Habkost
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 07/97] vmstate: create test functions for versions until 15 Juan Quintela
                   ` (92 subsequent siblings)
  98 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

This commit refactor the simple tests to test all integer types. We
move to hex because it is easier to read values of different types.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 195 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 150 insertions(+), 45 deletions(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 8b242c4..39a769e 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -54,80 +54,186 @@ static QEMUFile *open_test_file(bool write)
     return qemu_fdopen(fd, write ? "wb" : "rb");
 }

-typedef struct TestSruct {
-    uint32_t a, b, c, e;
-    uint64_t d, f;
-    bool skip_c_e;
-} TestStruct;
+/* Test struct that we are going to use for our tests */
+
+typedef struct TestSimple {
+    bool     b_1,   b_2;
+    uint8_t  u8_1,  u8_2;
+    uint16_t u16_1, u16_2;
+    uint32_t u32_1, u32_2;
+    uint64_t u64_1, u64_2;
+    int8_t   i8_1,  i8_2;
+    int16_t  i16_1, i16_2;
+    int32_t  i32_1, i32_2;
+    int64_t  i64_1, i64_2;
+} TestSimple;
+
+/* Object instantiation, we are going to use it in more than one test */
+
+TestSimple obj_simple = {
+    .b_1 = true,
+    .b_2 = false,
+    .u8_1 = 129,
+    .u8_1 = 130,
+    .u16_1 = 512,
+    .u16_2 = 45000,
+    .u32_1 = 70000,
+    .u32_2 = 100000,
+    .u64_1 = 12121212,
+    .u64_2 = 23232323,
+    .i8_1 = 65,
+    .i8_2 = -65,
+    .i16_1 = 512,
+    .i16_2 = -512,
+    .i32_1 = 70000,
+    .i32_2 = -70000,
+    .i64_1 = 12121212,
+    .i64_2 = -12121212,
+};

+/* Description of the values.  If you add a primitive type
+   you are expected to add a test here */

-static const VMStateDescription vmstate_simple = {
-    .name = "test",
+static const VMStateDescription vmstate_simple_primitive = {
+    .name = "simple/primitive",
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT32(a, TestStruct),
-        VMSTATE_UINT32(b, TestStruct),
-        VMSTATE_UINT32(c, TestStruct),
-        VMSTATE_UINT64(d, TestStruct),
+        VMSTATE_BOOL(b_1, TestSimple),
+        VMSTATE_BOOL(b_2, TestSimple),
+        VMSTATE_UINT8(u8_1, TestSimple),
+        VMSTATE_UINT16(u16_1, TestSimple),
+        VMSTATE_UINT32(u32_1, TestSimple),
+        VMSTATE_UINT64(u64_1, TestSimple),
+        VMSTATE_INT8(i8_1, TestSimple),
+        VMSTATE_INT8(i8_2, TestSimple),
+        VMSTATE_INT16(i16_1, TestSimple),
+        VMSTATE_INT16(i16_2, TestSimple),
+        VMSTATE_INT32(i32_1, TestSimple),
+        VMSTATE_INT32(i32_2, TestSimple),
+        VMSTATE_INT64(i64_1, TestSimple),
+        VMSTATE_INT64(i64_2, TestSimple),
         VMSTATE_END_OF_LIST()
     }
 };

-static void test_simple_save(void)
+/* It describes what goes through the wire.  Our tests are basically:
+
+   * save test
+     - save a struct a vmstate to a file
+     - read that file back (binary read, no vmstate)
+     - compare it with what we expect to be on the wire
+   * load test
+     - save to the file what we expect to be on the wire
+     - read struct back with vmstate in a different
+     - compare back with the original struct
+*/
+
+uint8_t wire_simple_primitive[] = {
+    /* b_1 */   0x01,
+    /* b_2 */   0x00,
+    /* u8_1 */  0x82,
+    /* u16_1 */ 0x02, 0x00,
+    /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* i8_1 */  0x41,
+    /* i8_2 */  0xbf,
+    /* i16_1 */ 0x02, 0x00,
+    /* i16_2 */ 0xfe, 0x0,
+    /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
+    /* i32_2 */ 0xff, 0xfe, 0xee, 0x90,
+    /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* i64_2 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x0b, 0x84,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+#define SUCCESS(val) \
+    g_assert_cmpint((val), ==, 0)
+
+#define FAILURE(val) \
+    g_assert_cmpint((val), !=, 0)
+
+static void test_simple_primitive(void)
 {
     QEMUFile *fsave = open_test_file(true);
-    TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4 };
-    vmstate_save_state(fsave, &vmstate_simple, &obj);
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_simple_primitive, &obj_simple);
     g_assert(!qemu_file_get_error(fsave));
     qemu_fclose(fsave);

     QEMUFile *loading = open_test_file(false);
-    uint8_t expected[] = {
-        0, 0, 0, 1, /* a */
-        0, 0, 0, 2, /* b */
-        0, 0, 0, 3, /* c */
-        0, 0, 0, 0, 0, 0, 0, 4, /* d */
-    };
-    uint8_t result[sizeof(expected)];
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_simple_primitive)-1];
+
+    /* read back as binary */
+
     g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
                     sizeof(result));
     g_assert(!qemu_file_get_error(loading));
-    g_assert_cmpint(memcmp(result, expected, sizeof(result)), ==, 0);
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_simple_primitive, sizeof(result)));

     /* Must reach EOF */
     qemu_get_byte(loading);
     g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);

     qemu_fclose(loading);
-}

-static void test_simple_load(void)
-{
-    QEMUFile *fsave = open_test_file(true);
-    uint8_t buf[] = {
-        0, 0, 0, 10,             /* a */
-        0, 0, 0, 20,             /* b */
-        0, 0, 0, 30,             /* c */
-        0, 0, 0, 0, 0, 0, 0, 40, /* d */
-        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
-    };
-    qemu_put_buffer(fsave, buf, sizeof(buf));
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_simple_primitive,
+                    sizeof(wire_simple_primitive));
     qemu_fclose(fsave);

-    QEMUFile *loading = open_test_file(false);
-    TestStruct obj;
-    vmstate_load_state(loading, &vmstate_simple, &obj, 1);
+    loading = open_test_file(false);
+    TestSimple obj;
+    SUCCESS(vmstate_load_state(loading, &vmstate_simple_primitive, &obj, 1));
     g_assert(!qemu_file_get_error(loading));
-    g_assert_cmpint(obj.a, ==, 10);
-    g_assert_cmpint(obj.b, ==, 20);
-    g_assert_cmpint(obj.c, ==, 30);
-    g_assert_cmpint(obj.d, ==, 40);
+
+#define FIELD_ASSERT(name)   g_assert_cmpint(obj.name, ==, obj_simple.name)
+    FIELD_ASSERT(b_1);
+    FIELD_ASSERT(b_2);
+    FIELD_ASSERT(u8_1);
+    FIELD_ASSERT(u16_1);
+    FIELD_ASSERT(u32_1);
+    FIELD_ASSERT(u64_1);
+    FIELD_ASSERT(i8_1);
+    FIELD_ASSERT(i8_2);
+    FIELD_ASSERT(i16_1);
+    FIELD_ASSERT(i16_2);
+    FIELD_ASSERT(i32_1);
+    FIELD_ASSERT(i32_2);
+    FIELD_ASSERT(i64_1);
+    FIELD_ASSERT(i64_2);
+#undef FIELD_ASSERT
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    /* this time we don't write the whole file */
+    qemu_put_buffer(fsave, wire_simple_primitive, 10);
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    FAILURE(vmstate_load_state(loading, &vmstate_simple_primitive, &obj, 1));
+
+    /* Now it has to have an error */
+    g_assert(qemu_file_get_error(loading));
     qemu_fclose(loading);
 }

+typedef struct TestStruct {
+    uint32_t a, b, c, e;
+    uint64_t d, f;
+    bool skip_c_e;
+} TestStruct;
+
 static const VMStateDescription vmstate_versioned = {
-    .name = "test",
+    .name = "test/versioned",
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
@@ -202,7 +308,7 @@ static bool test_skip(void *opaque, int version_id)
 }

 static const VMStateDescription vmstate_skipping = {
-    .name = "test",
+    .name = "test/skip",
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
@@ -337,8 +443,7 @@ int main(int argc, char **argv)
     temp_fd = mkstemp(temp_file);

     g_test_init(&argc, &argv, NULL);
-    g_test_add_func("/vmstate/simple/save", test_simple_save);
-    g_test_add_func("/vmstate/simple/load", test_simple_load);
+    g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 07/97] vmstate: create test functions for versions until 15
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (5 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 06/97] vmstate: Refactor & increase tests for primitive types Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 08/97] vmstate: Remove VMSTATE_UINTL_EQUAL_V Juan Quintela
                   ` (91 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Using macros, just to avoid repeating code.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index e7e1705..001ff76 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -769,4 +769,26 @@ void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev);
 void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev);
 void vmstate_register_ram_global(struct MemoryRegion *memory);

+/* version is X or bigger */
+#define VMSTATE_X_PLUS(X)\
+static inline bool vmstate_##X##_plus(void *opaque, int version_id)\
+{\
+    return version_id >= X;\
+}
+
+VMSTATE_X_PLUS(2)
+VMSTATE_X_PLUS(3)
+VMSTATE_X_PLUS(4)
+VMSTATE_X_PLUS(5)
+VMSTATE_X_PLUS(6)
+VMSTATE_X_PLUS(7)
+VMSTATE_X_PLUS(8)
+VMSTATE_X_PLUS(9)
+VMSTATE_X_PLUS(10)
+VMSTATE_X_PLUS(11)
+VMSTATE_X_PLUS(12)
+VMSTATE_X_PLUS(13)
+VMSTATE_X_PLUS(14)
+VMSTATE_X_PLUS(15)
+
 #endif
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 08/97] vmstate: Remove VMSTATE_UINTL_EQUAL_V
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (6 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 07/97] vmstate: create test functions for versions until 15 Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 09/97] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST Juan Quintela
                   ` (90 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

It was not used anywhere.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/hw/hw.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/include/hw/hw.h b/include/hw/hw.h
index 33bdb92..2b68ac3 100644
--- a/include/hw/hw.h
+++ b/include/hw/hw.h
@@ -51,22 +51,20 @@ int qemu_boot_set(const char *boot_order);
 #if TARGET_LONG_BITS == 64
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     VMSTATE_UINT64_V(_f, _s, _v)
-#define VMSTATE_UINTTL_EQUAL_V(_f, _s, _v)                            \
-    VMSTATE_UINT64_EQUAL_V(_f, _s, _v)
+#define VMSTATE_UINTTL_EQUAL(_f, _s)                                  \
+    VMSTATE_UINT64_EQUAL(_f, _s)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
     VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
 #else
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     VMSTATE_UINT32_V(_f, _s, _v)
-#define VMSTATE_UINTTL_EQUAL_V(_f, _s, _v)                            \
-    VMSTATE_UINT32_EQUAL_V(_f, _s, _v)
+#define VMSTATE_UINTTL_EQUAL(_f, _s)                                  \
+    VMSTATE_UINT32_EQUAL(_f, _s)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
     VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
 #endif
 #define VMSTATE_UINTTL(_f, _s)                                        \
     VMSTATE_UINTTL_V(_f, _s, 0)
-#define VMSTATE_UINTTL_EQUAL(_f, _s)                                  \
-    VMSTATE_UINTTL_EQUAL_V(_f, _s, 0)
 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 09/97] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (7 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 08/97] vmstate: Remove VMSTATE_UINTL_EQUAL_V Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 10/97] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V Juan Quintela
                   ` (89 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

And fix all users.
VMSTATE_UINT64_TEST don't exist.  Create it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/hw/hw.h             | 10 +++++-----
 include/migration/vmstate.h |  3 +++
 target-i386/machine.c       |  4 ++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/hw/hw.h b/include/hw/hw.h
index 2b68ac3..211eb8b 100644
--- a/include/hw/hw.h
+++ b/include/hw/hw.h
@@ -49,22 +49,22 @@ int qemu_boot_set(const char *boot_order);

 #ifdef NEED_CPU_H
 #if TARGET_LONG_BITS == 64
-#define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
-    VMSTATE_UINT64_V(_f, _s, _v)
+#define VMSTATE_UINTTL_TEST(_f, _s, _t)                               \
+    VMSTATE_UINT64_TEST(_f, _s, _t)
 #define VMSTATE_UINTTL_EQUAL(_f, _s)                                  \
     VMSTATE_UINT64_EQUAL(_f, _s)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
     VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
 #else
-#define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
-    VMSTATE_UINT32_V(_f, _s, _v)
+#define VMSTATE_UINTTL_TEST(_f, _s, _t)                               \
+    VMSTATE_UINT32_TEST(_f, _s, _t)
 #define VMSTATE_UINTTL_EQUAL(_f, _s)                                  \
     VMSTATE_UINT32_EQUAL(_f, _s)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
     VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
 #endif
 #define VMSTATE_UINTTL(_f, _s)                                        \
-    VMSTATE_UINTTL_V(_f, _s, 0)
+    VMSTATE_UINTTL_TEST(_f, _s, NULL)
 #define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 001ff76..e97ac2f 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -604,6 +604,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_TEST(_f, _s, _t)                                  \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)

+#define VMSTATE_UINT64_TEST(_f, _s, _t)                                  \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t)
+

 #define VMSTATE_FLOAT64_V(_f, _s, _v)                                 \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64)
diff --git a/target-i386/machine.c b/target-i386/machine.c
index fe3f024..838a5b0 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -624,8 +624,8 @@ const VMStateDescription vmstate_x86_cpu = {
         /* Hack: In v7 size changed from 32 to 64 bits on x86_64 */
         VMSTATE_HACK_UINT32(env.sysenter_esp, X86CPU, less_than_7),
         VMSTATE_HACK_UINT32(env.sysenter_eip, X86CPU, less_than_7),
-        VMSTATE_UINTTL_V(env.sysenter_esp, X86CPU, 7),
-        VMSTATE_UINTTL_V(env.sysenter_eip, X86CPU, 7),
+        VMSTATE_UINTTL_TEST(env.sysenter_esp, X86CPU, vmstate_7_plus),
+        VMSTATE_UINTTL_TEST(env.sysenter_eip, X86CPU, vmstate_7_plus),
 #else
         VMSTATE_UINTTL(env.sysenter_esp, X86CPU),
         VMSTATE_UINTTL(env.sysenter_eip, X86CPU),
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 10/97] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (8 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 09/97] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 11/97] vmstate: Test for VMSTATE_BOOL_TEST Juan Quintela
                   ` (88 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/hw/hw.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/hw/hw.h b/include/hw/hw.h
index 211eb8b..2c19297 100644
--- a/include/hw/hw.h
+++ b/include/hw/hw.h
@@ -53,21 +53,18 @@ int qemu_boot_set(const char *boot_order);
     VMSTATE_UINT64_TEST(_f, _s, _t)
 #define VMSTATE_UINTTL_EQUAL(_f, _s)                                  \
     VMSTATE_UINT64_EQUAL(_f, _s)
-#define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
-    VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
+#define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
+    VMSTATE_UINT64_ARRAY(_f, _s, _n)
 #else
 #define VMSTATE_UINTTL_TEST(_f, _s, _t)                               \
     VMSTATE_UINT32_TEST(_f, _s, _t)
 #define VMSTATE_UINTTL_EQUAL(_f, _s)                                  \
     VMSTATE_UINT32_EQUAL(_f, _s)
-#define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
-    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
+#define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
+    VMSTATE_UINT32_ARRAY(_f, _s, _n)
 #endif
 #define VMSTATE_UINTTL(_f, _s)                                        \
     VMSTATE_UINTTL_TEST(_f, _s, NULL)
-#define VMSTATE_UINTTL_ARRAY(_f, _s, _n)                              \
-    VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0)
-
 #endif

 #endif
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 11/97] vmstate: Test for VMSTATE_BOOL_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (9 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 10/97] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 12/97] vmstate: Test for VMSTATE_INT8_TEST Juan Quintela
                   ` (87 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_BOOL_V, we are removing versioning, would use only tests.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  6 ++--
 tests/test-vmstate.c        | 75 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index e97ac2f..184d564 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -526,8 +526,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version,   \
             _vmsd, _type)

-#define VMSTATE_BOOL_V(_f, _s, _v)                                    \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool)
+#define VMSTATE_BOOL_TEST(_f, _s, _t)                                 \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_bool, bool)

 #define VMSTATE_INT8_V(_f, _s, _v)                                    \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
@@ -548,7 +548,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)

 #define VMSTATE_BOOL(_f, _s)                                          \
-    VMSTATE_BOOL_V(_f, _s, 0)
+    VMSTATE_BOOL_TEST(_f, _s, NULL)

 #define VMSTATE_INT8(_f, _s)                                          \
     VMSTATE_INT8_V(_f, _s, 0)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 39a769e..7ca32af 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -209,7 +209,6 @@ static void test_simple_primitive(void)
     FIELD_ASSERT(i32_2);
     FIELD_ASSERT(i64_1);
     FIELD_ASSERT(i64_2);
-#undef FIELD_ASSERT

     /* We save the file again.  We want the EOF this time */

@@ -226,6 +225,79 @@ static void test_simple_primitive(void)
     qemu_fclose(loading);
 }

+static bool test_true(void *opaque, int version_id)
+{
+    return true;
+}
+
+static bool test_false(void *opaque, int version_id)
+{
+    return false;
+}
+
+static const VMStateDescription vmstate_simple_test = {
+    .name = "simple/test",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_BOOL_TEST(b_1, TestSimple, test_true),
+        VMSTATE_BOOL_TEST(b_2, TestSimple, test_false),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_simple_test[] = {
+    /* b_1 */   0x01,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_simple_test(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_simple_test, &obj_simple);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_simple_test)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_simple_test, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_simple_test, sizeof(wire_simple_test));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestSimple obj;
+    SUCCESS(vmstate_load_state(loading, &vmstate_simple_test, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+
+    FIELD_ASSERT(b_1);
+
+    qemu_fclose(loading);
+}
+#undef FIELD_ASSERT
+
 typedef struct TestStruct {
     uint32_t a, b, c, e;
     uint64_t d, f;
@@ -444,6 +516,7 @@ int main(int argc, char **argv)

     g_test_init(&argc, &argv, NULL);
     g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
+    g_test_add_func("/vmstate/simple/test", test_simple_test);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 12/97] vmstate: Test for VMSTATE_INT8_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (10 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 11/97] vmstate: Test for VMSTATE_BOOL_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 13/97] vmstate: Test for VMSTATE_INT16_TEST Juan Quintela
                   ` (86 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_INT8_V, we are removing versioning, would use only tests.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 6 +++---
 tests/test-vmstate.c        | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 184d564..70c89b3 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -529,8 +529,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_BOOL_TEST(_f, _s, _t)                                 \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_bool, bool)

-#define VMSTATE_INT8_V(_f, _s, _v)                                    \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t)
+#define VMSTATE_INT8_TEST(_f, _s, _t)                                 \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int8, int8_t)
 #define VMSTATE_INT16_V(_f, _s, _v)                                   \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
 #define VMSTATE_INT32_V(_f, _s, _v)                                   \
@@ -551,7 +551,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_BOOL_TEST(_f, _s, NULL)

 #define VMSTATE_INT8(_f, _s)                                          \
-    VMSTATE_INT8_V(_f, _s, 0)
+    VMSTATE_INT8_TEST(_f, _s, NULL)
 #define VMSTATE_INT16(_f, _s)                                         \
     VMSTATE_INT16_V(_f, _s, 0)
 #define VMSTATE_INT32(_f, _s)                                         \
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 7ca32af..476cef8 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -243,12 +243,15 @@ static const VMStateDescription vmstate_simple_test = {
     .fields = (VMStateField[]) {
         VMSTATE_BOOL_TEST(b_1, TestSimple, test_true),
         VMSTATE_BOOL_TEST(b_2, TestSimple, test_false),
+        VMSTATE_INT8_TEST(i8_1, TestSimple, test_true),
+        VMSTATE_INT8_TEST(i8_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };

 uint8_t wire_simple_test[] = {
     /* b_1 */   0x01,
+    /* i8_1 */  0x41,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -293,6 +296,7 @@ static void test_simple_test(void)
     g_assert(!qemu_file_get_error(loading));

     FIELD_ASSERT(b_1);
+    FIELD_ASSERT(i8_1);

     qemu_fclose(loading);
 }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 13/97] vmstate: Test for VMSTATE_INT16_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (11 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 12/97] vmstate: Test for VMSTATE_INT8_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 14/97] vmstate: Test for VMSTATE_INT32_TEST Juan Quintela
                   ` (85 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATES_INT16_V, we are removing versioning, would use only tests.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 6 +++---
 tests/test-vmstate.c        | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 70c89b3..645316a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -531,8 +531,8 @@ extern const VMStateInfo vmstate_info_bitmap;

 #define VMSTATE_INT8_TEST(_f, _s, _t)                                 \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int8, int8_t)
-#define VMSTATE_INT16_V(_f, _s, _v)                                   \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t)
+#define VMSTATE_INT16_TEST(_f, _s, _t)                                \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int16, int16_t)
 #define VMSTATE_INT32_V(_f, _s, _v)                                   \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
 #define VMSTATE_INT64_V(_f, _s, _v)                                   \
@@ -553,7 +553,7 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT8(_f, _s)                                          \
     VMSTATE_INT8_TEST(_f, _s, NULL)
 #define VMSTATE_INT16(_f, _s)                                         \
-    VMSTATE_INT16_V(_f, _s, 0)
+    VMSTATE_INT16_TEST(_f, _s, NULL)
 #define VMSTATE_INT32(_f, _s)                                         \
     VMSTATE_INT32_V(_f, _s, 0)
 #define VMSTATE_INT64(_f, _s)                                         \
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 476cef8..278df0e 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -245,6 +245,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_BOOL_TEST(b_2, TestSimple, test_false),
         VMSTATE_INT8_TEST(i8_1, TestSimple, test_true),
         VMSTATE_INT8_TEST(i8_2, TestSimple, test_false),
+        VMSTATE_INT16_TEST(i16_1, TestSimple, test_true),
+        VMSTATE_INT16_TEST(i16_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -252,6 +254,7 @@ static const VMStateDescription vmstate_simple_test = {
 uint8_t wire_simple_test[] = {
     /* b_1 */   0x01,
     /* i8_1 */  0x41,
+    /* i16_1 */ 0x02, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -297,6 +300,7 @@ static void test_simple_test(void)

     FIELD_ASSERT(b_1);
     FIELD_ASSERT(i8_1);
+    FIELD_ASSERT(i16_1);

     qemu_fclose(loading);
 }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 14/97] vmstate: Test for VMSTATE_INT32_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (12 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 13/97] vmstate: Test for VMSTATE_INT16_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 15/97] vmstate: test for VMSTATE_INT64_TEST Juan Quintela
                   ` (84 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_INT32_V, we are removing versioning.
Move all users to use tests.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/input/ps2.c              | 2 +-
 include/migration/vmstate.h | 6 +++---
 target-i386/machine.c       | 4 ++--
 tests/test-vmstate.c        | 4 ++++
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 0a0bd80..e05ff0d 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -613,7 +613,7 @@ static const VMStateDescription vmstate_ps2_keyboard = {
         VMSTATE_STRUCT(common, PS2KbdState, 0, vmstate_ps2_common, PS2State),
         VMSTATE_INT32(scan_enabled, PS2KbdState),
         VMSTATE_INT32(translate, PS2KbdState),
-        VMSTATE_INT32_V(scancode_set, PS2KbdState,3),
+        VMSTATE_INT32_TEST(scancode_set, PS2KbdState, vmstate_3_plus),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (VMStateSubsection []) {
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 645316a..85356be 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -533,8 +533,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int8, int8_t)
 #define VMSTATE_INT16_TEST(_f, _s, _t)                                \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int16, int16_t)
-#define VMSTATE_INT32_V(_f, _s, _v)                                   \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t)
+#define VMSTATE_INT32_TEST(_f, _s, _t)                                \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int32, int32_t)
 #define VMSTATE_INT64_V(_f, _s, _v)                                   \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)

@@ -555,7 +555,7 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT16(_f, _s)                                         \
     VMSTATE_INT16_TEST(_f, _s, NULL)
 #define VMSTATE_INT32(_f, _s)                                         \
-    VMSTATE_INT32_V(_f, _s, 0)
+    VMSTATE_INT32_TEST(_f, _s, NULL)
 #define VMSTATE_INT64(_f, _s)                                         \
     VMSTATE_INT64_V(_f, _s, 0)

diff --git a/target-i386/machine.c b/target-i386/machine.c
index 838a5b0..2aecf5f 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -671,10 +671,10 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT64_V(env.mtrr_deftype, X86CPU, 8),
         VMSTATE_MTRR_VARS(env.mtrr_var, X86CPU, 8, 8),
         /* KVM-related states */
-        VMSTATE_INT32_V(env.interrupt_injected, X86CPU, 9),
+        VMSTATE_INT32_TEST(env.interrupt_injected, X86CPU, vmstate_9_plus),
         VMSTATE_UINT32_V(env.mp_state, X86CPU, 9),
         VMSTATE_UINT64_V(env.tsc, X86CPU, 9),
-        VMSTATE_INT32_V(env.exception_injected, X86CPU, 11),
+        VMSTATE_INT32_TEST(env.exception_injected, X86CPU, vmstate_11_plus),
         VMSTATE_UINT8_V(env.soft_interrupt, X86CPU, 11),
         VMSTATE_UINT8_V(env.nmi_injected, X86CPU, 11),
         VMSTATE_UINT8_V(env.nmi_pending, X86CPU, 11),
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 278df0e..75e5600 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -247,6 +247,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_INT8_TEST(i8_2, TestSimple, test_false),
         VMSTATE_INT16_TEST(i16_1, TestSimple, test_true),
         VMSTATE_INT16_TEST(i16_2, TestSimple, test_false),
+        VMSTATE_INT32_TEST(i32_1, TestSimple, test_true),
+        VMSTATE_INT32_TEST(i32_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -255,6 +257,7 @@ uint8_t wire_simple_test[] = {
     /* b_1 */   0x01,
     /* i8_1 */  0x41,
     /* i16_1 */ 0x02, 0x00,
+    /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -301,6 +304,7 @@ static void test_simple_test(void)
     FIELD_ASSERT(b_1);
     FIELD_ASSERT(i8_1);
     FIELD_ASSERT(i16_1);
+    FIELD_ASSERT(i32_1);

     qemu_fclose(loading);
 }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 15/97] vmstate: test for VMSTATE_INT64_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (13 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 14/97] vmstate: Test for VMSTATE_INT32_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 16/97] vmstate: Test for VMSTATE_UINT8_TEST Juan Quintela
                   ` (83 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_INT64_V, we are removing versioning.
Move all users to VMSTATE_INT64_TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 cpus.c                      | 2 +-
 hw/timer/mc146818rtc.c      | 2 +-
 hw/usb/hcd-uhci.c           | 2 +-
 include/migration/vmstate.h | 6 +++---
 tests/test-vmstate.c        | 4 ++++
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/cpus.c b/cpus.c
index c510052..83aa302 100644
--- a/cpus.c
+++ b/cpus.c
@@ -433,7 +433,7 @@ static const VMStateDescription vmstate_timers = {
     .fields = (VMStateField[]) {
         VMSTATE_INT64(cpu_ticks_offset, TimersState),
         VMSTATE_INT64(dummy, TimersState),
-        VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
+        VMSTATE_INT64_TEST(cpu_clock_offset, TimersState, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 1822af2..8342749 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -732,7 +732,7 @@ static const VMStateDescription vmstate_rtc = {
         VMSTATE_UINT32_V(period, RTCState, 2),
         VMSTATE_UINT64_V(base_rtc, RTCState, 3),
         VMSTATE_UINT64_V(last_update, RTCState, 3),
-        VMSTATE_INT64_V(offset, RTCState, 3),
+        VMSTATE_INT64_TEST(offset, RTCState, vmstate_3_plus),
         VMSTATE_TIMER_V(update_timer, RTCState, 3),
         VMSTATE_UINT64_V(next_alarm_time, RTCState, 3),
         VMSTATE_END_OF_LIST()
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 9b1166b..5590e18 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -457,7 +457,7 @@ static const VMStateDescription vmstate_uhci = {
         VMSTATE_UINT8(sof_timing, UHCIState),
         VMSTATE_UINT8(status2, UHCIState),
         VMSTATE_TIMER(frame_timer, UHCIState),
-        VMSTATE_INT64_V(expire_time, UHCIState, 2),
+        VMSTATE_INT64_TEST(expire_time, UHCIState, vmstate_3_plus),
         VMSTATE_UINT32_V(pending_int_mask, UHCIState, 3),
         VMSTATE_END_OF_LIST()
     }
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 85356be..ba8b44d 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -535,8 +535,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int16, int16_t)
 #define VMSTATE_INT32_TEST(_f, _s, _t)                                \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int32, int32_t)
-#define VMSTATE_INT64_V(_f, _s, _v)                                   \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t)
+#define VMSTATE_INT64_TEST(_f, _s, _t)                                \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int64, int64_t)

 #define VMSTATE_UINT8_V(_f, _s, _v)                                   \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
@@ -557,7 +557,7 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32(_f, _s)                                         \
     VMSTATE_INT32_TEST(_f, _s, NULL)
 #define VMSTATE_INT64(_f, _s)                                         \
-    VMSTATE_INT64_V(_f, _s, 0)
+    VMSTATE_INT64_TEST(_f, _s, NULL)

 #define VMSTATE_UINT8(_f, _s)                                         \
     VMSTATE_UINT8_V(_f, _s, 0)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 75e5600..b8d1309 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -249,6 +249,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_INT16_TEST(i16_2, TestSimple, test_false),
         VMSTATE_INT32_TEST(i32_1, TestSimple, test_true),
         VMSTATE_INT32_TEST(i32_2, TestSimple, test_false),
+        VMSTATE_INT64_TEST(i64_1, TestSimple, test_true),
+        VMSTATE_INT64_TEST(i64_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -258,6 +260,7 @@ uint8_t wire_simple_test[] = {
     /* i8_1 */  0x41,
     /* i16_1 */ 0x02, 0x00,
     /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
+    /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -305,6 +308,7 @@ static void test_simple_test(void)
     FIELD_ASSERT(i8_1);
     FIELD_ASSERT(i16_1);
     FIELD_ASSERT(i32_1);
+    FIELD_ASSERT(i64_1);

     qemu_fclose(loading);
 }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 16/97] vmstate: Test for VMSTATE_UINT8_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (14 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 15/97] vmstate: test for VMSTATE_INT64_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 17/97] vmstate: Test for VMSTATE_UINT16_TEST Juan Quintela
                   ` (82 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_UINT8_V, we are removing versioning.
Move all users to VMSTATE_UINT8_TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/char/serial.c            |  2 +-
 hw/ide/core.c               |  2 +-
 hw/net/ne2000.c             |  2 +-
 hw/timer/ds1338.c           |  2 +-
 hw/timer/hpet.c             |  2 +-
 include/migration/vmstate.h |  9 +++------
 target-i386/machine.c       | 10 +++++-----
 tests/test-vmstate.c        |  4 ++++
 8 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 16646d0..6243555 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -610,7 +610,7 @@ const VMStateDescription vmstate_serial = {
         VMSTATE_UINT8(lsr, SerialState),
         VMSTATE_UINT8(msr, SerialState),
         VMSTATE_UINT8(scr, SerialState),
-        VMSTATE_UINT8_V(fcr_vmstate, SerialState, 3),
+        VMSTATE_UINT8_TEST(fcr_vmstate, SerialState, vmstate_3_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/ide/core.c b/hw/ide/core.c
index ade1b89..b79cc9e 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2404,7 +2404,7 @@ const VMStateDescription vmstate_ide_drive = {
         VMSTATE_UINT8(lba48, IDEState),
         VMSTATE_UINT8(sense_key, IDEState),
         VMSTATE_UINT8(asc, IDEState),
-        VMSTATE_UINT8_V(cdrom_changed, IDEState, 3),
+        VMSTATE_UINT8_TEST(cdrom_changed, IDEState, vmstate_3_plus),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (VMStateSubsection []) {
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index d558b8c..84745d64 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -617,7 +617,7 @@ const VMStateDescription vmstate_ne2000 = {
     .minimum_version_id = 0,
     .post_load = ne2000_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT8_V(rxcr, NE2000State, 2),
+        VMSTATE_UINT8_TEST(rxcr, NE2000State, vmstate_2_plus),
         VMSTATE_UINT8(cmd, NE2000State),
         VMSTATE_UINT32(start, NE2000State),
         VMSTATE_UINT32(stop, NE2000State),
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index ec6dbee..78b8e7b 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -43,7 +43,7 @@ static const VMStateDescription vmstate_ds1338 = {
     .fields = (VMStateField[]) {
         VMSTATE_I2C_SLAVE(parent_obj, DS1338State),
         VMSTATE_INT64(offset, DS1338State),
-        VMSTATE_UINT8_V(wday_offset, DS1338State, 2),
+        VMSTATE_UINT8_TEST(wday_offset, DS1338State, vmstate_2_plus),
         VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE),
         VMSTATE_INT32(ptr, DS1338State),
         VMSTATE_BOOL(addr_byte, DS1338State),
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index fa590e3..2148568 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -303,7 +303,7 @@ static const VMStateDescription vmstate_hpet = {
         VMSTATE_UINT64(config, HPETState),
         VMSTATE_UINT64(isr, HPETState),
         VMSTATE_UINT64(hpet_counter, HPETState),
-        VMSTATE_UINT8_V(num_timers, HPETState, 2),
+        VMSTATE_UINT8_TEST(num_timers, HPETState, vmstate_2_plus),
         VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0,
                                     vmstate_hpet_timer, HPETTimer),
         VMSTATE_END_OF_LIST()
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index ba8b44d..5d2b68d 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -538,8 +538,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT64_TEST(_f, _s, _t)                                \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int64, int64_t)

-#define VMSTATE_UINT8_V(_f, _s, _v)                                   \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t)
+#define VMSTATE_UINT8_TEST(_f, _s, _t)                                \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
 #define VMSTATE_UINT16_V(_f, _s, _v)                                  \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
 #define VMSTATE_UINT32_V(_f, _s, _v)                                  \
@@ -560,7 +560,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_INT64_TEST(_f, _s, NULL)

 #define VMSTATE_UINT8(_f, _s)                                         \
-    VMSTATE_UINT8_V(_f, _s, 0)
+    VMSTATE_UINT8_TEST(_f, _s, NULL)
 #define VMSTATE_UINT16(_f, _s)                                        \
     VMSTATE_UINT16_V(_f, _s, 0)
 #define VMSTATE_UINT32(_f, _s)                                        \
@@ -595,9 +595,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_LE(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)

-#define VMSTATE_UINT8_TEST(_f, _s, _t)                               \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
-
 #define VMSTATE_UINT16_TEST(_f, _s, _t)                               \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)

diff --git a/target-i386/machine.c b/target-i386/machine.c
index 2aecf5f..e4fd27c 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -665,7 +665,7 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT16_V(env.intercept_dr_read, X86CPU, 5),
         VMSTATE_UINT16_V(env.intercept_dr_write, X86CPU, 5),
         VMSTATE_UINT32_V(env.intercept_exceptions, X86CPU, 5),
-        VMSTATE_UINT8_V(env.v_tpr, X86CPU, 5),
+        VMSTATE_UINT8_TEST(env.v_tpr, X86CPU, vmstate_5_plus),
         /* MTRRs */
         VMSTATE_UINT64_ARRAY_V(env.mtrr_fixed, X86CPU, 11, 8),
         VMSTATE_UINT64_V(env.mtrr_deftype, X86CPU, 8),
@@ -675,10 +675,10 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT32_V(env.mp_state, X86CPU, 9),
         VMSTATE_UINT64_V(env.tsc, X86CPU, 9),
         VMSTATE_INT32_TEST(env.exception_injected, X86CPU, vmstate_11_plus),
-        VMSTATE_UINT8_V(env.soft_interrupt, X86CPU, 11),
-        VMSTATE_UINT8_V(env.nmi_injected, X86CPU, 11),
-        VMSTATE_UINT8_V(env.nmi_pending, X86CPU, 11),
-        VMSTATE_UINT8_V(env.has_error_code, X86CPU, 11),
+        VMSTATE_UINT8_TEST(env.soft_interrupt, X86CPU, vmstate_11_plus),
+        VMSTATE_UINT8_TEST(env.nmi_injected, X86CPU, vmstate_11_plus),
+        VMSTATE_UINT8_TEST(env.nmi_pending, X86CPU, vmstate_11_plus),
+        VMSTATE_UINT8_TEST(env.has_error_code, X86CPU, vmstate_11_plus),
         VMSTATE_UINT32_V(env.sipi_vector, X86CPU, 11),
         /* MCE */
         VMSTATE_UINT64_V(env.mcg_cap, X86CPU, 10),
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index b8d1309..9af83a6 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -251,6 +251,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_INT32_TEST(i32_2, TestSimple, test_false),
         VMSTATE_INT64_TEST(i64_1, TestSimple, test_true),
         VMSTATE_INT64_TEST(i64_2, TestSimple, test_false),
+        VMSTATE_UINT8_TEST(u8_1, TestSimple, test_true),
+        VMSTATE_UINT8_TEST(u8_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -261,6 +263,7 @@ uint8_t wire_simple_test[] = {
     /* i16_1 */ 0x02, 0x00,
     /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
     /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* u8_1 */  0x82,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -309,6 +312,7 @@ static void test_simple_test(void)
     FIELD_ASSERT(i16_1);
     FIELD_ASSERT(i32_1);
     FIELD_ASSERT(i64_1);
+    FIELD_ASSERT(u8_1);

     qemu_fclose(loading);
 }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 17/97] vmstate: Test for VMSTATE_UINT16_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (15 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 16/97] vmstate: Test for VMSTATE_UINT8_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 18/97] vmstate: Test for VMSTATE_UINT32_TEST Juan Quintela
                   ` (81 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_UINT16_V, we are removing versioning.
Move all users to VMSTATE_UINT16_TEST.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/char/serial.c            | 2 +-
 hw/net/lan9118.c            | 4 ++--
 include/migration/vmstate.h | 9 +++------
 target-i386/machine.c       | 8 ++++----
 tests/test-vmstate.c        | 4 ++++
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 6243555..57f2f0a 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -601,7 +601,7 @@ const VMStateDescription vmstate_serial = {
     .pre_save = serial_pre_save,
     .post_load = serial_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT16_V(divider, SerialState, 2),
+        VMSTATE_UINT16_TEST(divider, SerialState, vmstate_2_plus),
         VMSTATE_UINT8(rbr, SerialState),
         VMSTATE_UINT8(ier, SerialState),
         VMSTATE_UINT8(iir, SerialState),
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index e528290..fecbf8d 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -310,8 +310,8 @@ static const VMStateDescription vmstate_lan9118 = {
         VMSTATE_INT32(rxp_pad, lan9118_state),
         VMSTATE_UINT32_V(write_word_prev_offset, lan9118_state, 2),
         VMSTATE_UINT32_V(write_word_n, lan9118_state, 2),
-        VMSTATE_UINT16_V(write_word_l, lan9118_state, 2),
-        VMSTATE_UINT16_V(write_word_h, lan9118_state, 2),
+        VMSTATE_UINT16_TEST(write_word_l, lan9118_state, vmstate_2_plus),
+        VMSTATE_UINT16_TEST(write_word_h, lan9118_state, vmstate_2_plus),
         VMSTATE_UINT32_V(read_word_prev_offset, lan9118_state, 2),
         VMSTATE_UINT32_V(read_word_n, lan9118_state, 2),
         VMSTATE_UINT32_V(read_long, lan9118_state, 2),
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 5d2b68d..7f822c5 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -540,8 +540,8 @@ extern const VMStateInfo vmstate_info_bitmap;

 #define VMSTATE_UINT8_TEST(_f, _s, _t)                                \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
-#define VMSTATE_UINT16_V(_f, _s, _v)                                  \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t)
+#define VMSTATE_UINT16_TEST(_f, _s, _t)                               \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
 #define VMSTATE_UINT32_V(_f, _s, _v)                                  \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
 #define VMSTATE_UINT64_V(_f, _s, _v)                                  \
@@ -562,7 +562,7 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT8(_f, _s)                                         \
     VMSTATE_UINT8_TEST(_f, _s, NULL)
 #define VMSTATE_UINT16(_f, _s)                                        \
-    VMSTATE_UINT16_V(_f, _s, 0)
+    VMSTATE_UINT16_TEST(_f, _s, NULL)
 #define VMSTATE_UINT32(_f, _s)                                        \
     VMSTATE_UINT32_V(_f, _s, 0)
 #define VMSTATE_UINT64(_f, _s)                                        \
@@ -595,9 +595,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #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)

diff --git a/target-i386/machine.c b/target-i386/machine.c
index e4fd27c..c05dc5a 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -660,10 +660,10 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT64_V(env.vm_vmcb, X86CPU, 5),
         VMSTATE_UINT64_V(env.tsc_offset, X86CPU, 5),
         VMSTATE_UINT64_V(env.intercept, X86CPU, 5),
-        VMSTATE_UINT16_V(env.intercept_cr_read, X86CPU, 5),
-        VMSTATE_UINT16_V(env.intercept_cr_write, X86CPU, 5),
-        VMSTATE_UINT16_V(env.intercept_dr_read, X86CPU, 5),
-        VMSTATE_UINT16_V(env.intercept_dr_write, X86CPU, 5),
+        VMSTATE_UINT16_TEST(env.intercept_cr_read, X86CPU, vmstate_5_plus),
+        VMSTATE_UINT16_TEST(env.intercept_cr_write, X86CPU, vmstate_5_plus),
+        VMSTATE_UINT16_TEST(env.intercept_dr_read, X86CPU, vmstate_5_plus),
+        VMSTATE_UINT16_TEST(env.intercept_dr_write, X86CPU, vmstate_5_plus),
         VMSTATE_UINT32_V(env.intercept_exceptions, X86CPU, 5),
         VMSTATE_UINT8_TEST(env.v_tpr, X86CPU, vmstate_5_plus),
         /* MTRRs */
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 9af83a6..018d8a2 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -253,6 +253,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_INT64_TEST(i64_2, TestSimple, test_false),
         VMSTATE_UINT8_TEST(u8_1, TestSimple, test_true),
         VMSTATE_UINT8_TEST(u8_2, TestSimple, test_false),
+        VMSTATE_UINT16_TEST(u16_1, TestSimple, test_true),
+        VMSTATE_UINT16_TEST(u16_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -264,6 +266,7 @@ uint8_t wire_simple_test[] = {
     /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
     /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
     /* u8_1 */  0x82,
+    /* u16_1 */ 0x02, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -313,6 +316,7 @@ static void test_simple_test(void)
     FIELD_ASSERT(i32_1);
     FIELD_ASSERT(i64_1);
     FIELD_ASSERT(u8_1);
+    FIELD_ASSERT(u16_1);

     qemu_fclose(loading);
 }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 18/97] vmstate: Test for VMSTATE_UINT32_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (16 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 17/97] vmstate: Test for VMSTATE_UINT16_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 19/97] vmstate: Test for VMSTATE_UINT64_TEST Juan Quintela
                   ` (80 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_UINT32_V, we are removing versioning.
Move all users to VMSTATE_UINT32_TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/arm/stellaris.c          |  2 +-
 hw/display/pl110.c          |  2 +-
 hw/gpio/pl061.c             |  2 +-
 hw/intc/ioapic_common.c     |  2 +-
 hw/misc/arm_sysctl.c        | 10 +++++-----
 hw/net/lan9118.c            | 14 ++++++++------
 hw/net/rtl8139.c            |  2 +-
 hw/nvram/fw_cfg.c           |  2 +-
 hw/timer/i8254_common.c     |  3 ++-
 hw/timer/mc146818rtc.c      |  4 ++--
 hw/usb/hcd-ehci.c           |  4 ++--
 hw/usb/hcd-uhci.c           |  2 +-
 include/migration/vmstate.h |  9 +++------
 target-i386/machine.c       | 10 +++++-----
 tests/test-vmstate.c        | 12 ++++++++----
 15 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index c7de9cf..a732ee9 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -650,7 +650,7 @@ static const VMStateDescription vmstate_stellaris_sys = {
         VMSTATE_UINT32(int_status, ssys_state),
         VMSTATE_UINT32(resc, ssys_state),
         VMSTATE_UINT32(rcc, ssys_state),
-        VMSTATE_UINT32_V(rcc2, ssys_state, 2),
+        VMSTATE_UINT32_TEST(rcc2, ssys_state, vmstate_2_plus),
         VMSTATE_UINT32_ARRAY(rcgc, ssys_state, 3),
         VMSTATE_UINT32_ARRAY(scgc, ssys_state, 3),
         VMSTATE_UINT32_ARRAY(dcgc, ssys_state, 3),
diff --git a/hw/display/pl110.c b/hw/display/pl110.c
index c574cf1..3405d02 100644
--- a/hw/display/pl110.c
+++ b/hw/display/pl110.c
@@ -86,7 +86,7 @@ static const VMStateDescription vmstate_pl110 = {
         VMSTATE_INT32(invalidate, PL110State),
         VMSTATE_UINT32_ARRAY(palette, PL110State, 256),
         VMSTATE_UINT32_ARRAY(raw_palette, PL110State, 128),
-        VMSTATE_UINT32_V(mux_ctrl, PL110State, 2),
+        VMSTATE_UINT32_TEST(mux_ctrl, PL110State, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
index dd4ea29..1f54b8f 100644
--- a/hw/gpio/pl061.c
+++ b/hw/gpio/pl061.c
@@ -86,7 +86,7 @@ static const VMStateDescription vmstate_pl061 = {
         VMSTATE_UINT32(den, PL061State),
         VMSTATE_UINT32(cr, PL061State),
         VMSTATE_UINT32(float_high, PL061State),
-        VMSTATE_UINT32_V(amsel, PL061State, 2),
+        VMSTATE_UINT32_TEST(amsel, PL061State, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c
index 8b7d118..d4c0c8e 100644
--- a/hw/intc/ioapic_common.c
+++ b/hw/intc/ioapic_common.c
@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_ioapic_common = {
         VMSTATE_UINT8(id, IOAPICCommonState),
         VMSTATE_UINT8(ioregsel, IOAPICCommonState),
         VMSTATE_UNUSED_V(2, 8), /* to account for qemu-kvm's v2 format */
-        VMSTATE_UINT32_V(irr, IOAPICCommonState, 2),
+        VMSTATE_UINT32_TEST(irr, IOAPICCommonState, vmstate_2_plus),
         VMSTATE_UINT64_ARRAY(ioredtbl, IOAPICCommonState, IOAPIC_NUM_PINS),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c
index 3fad6f8..807d48e 100644
--- a/hw/misc/arm_sysctl.c
+++ b/hw/misc/arm_sysctl.c
@@ -60,11 +60,11 @@ static const VMStateDescription vmstate_arm_sysctl = {
         VMSTATE_UINT32(flags, arm_sysctl_state),
         VMSTATE_UINT32(nvflags, arm_sysctl_state),
         VMSTATE_UINT32(resetlevel, arm_sysctl_state),
-        VMSTATE_UINT32_V(sys_mci, arm_sysctl_state, 2),
-        VMSTATE_UINT32_V(sys_cfgdata, arm_sysctl_state, 2),
-        VMSTATE_UINT32_V(sys_cfgctrl, arm_sysctl_state, 2),
-        VMSTATE_UINT32_V(sys_cfgstat, arm_sysctl_state, 2),
-        VMSTATE_UINT32_V(sys_clcd, arm_sysctl_state, 3),
+        VMSTATE_UINT32_TEST(sys_mci, arm_sysctl_state, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(sys_cfgdata, arm_sysctl_state, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(sys_cfgctrl, arm_sysctl_state, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(sys_cfgstat, arm_sysctl_state, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(sys_clcd, arm_sysctl_state, vmstate_3_plus),
         VMSTATE_UINT32_ARRAY_V(mb_clock, arm_sysctl_state, 6, 4),
         VMSTATE_VARRAY_UINT32(db_clock, arm_sysctl_state, db_num_clocks,
                               4, vmstate_info_uint32, uint32_t),
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index fecbf8d..fbba410 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -308,14 +308,16 @@ static const VMStateDescription vmstate_lan9118 = {
         VMSTATE_INT32(rxp_offset, lan9118_state),
         VMSTATE_INT32(rxp_size, lan9118_state),
         VMSTATE_INT32(rxp_pad, lan9118_state),
-        VMSTATE_UINT32_V(write_word_prev_offset, lan9118_state, 2),
-        VMSTATE_UINT32_V(write_word_n, lan9118_state, 2),
+        VMSTATE_UINT32_TEST(write_word_prev_offset, lan9118_state,
+                            vmstate_2_plus),
+        VMSTATE_UINT32_TEST(write_word_n, lan9118_state, vmstate_2_plus),
         VMSTATE_UINT16_TEST(write_word_l, lan9118_state, vmstate_2_plus),
         VMSTATE_UINT16_TEST(write_word_h, lan9118_state, vmstate_2_plus),
-        VMSTATE_UINT32_V(read_word_prev_offset, lan9118_state, 2),
-        VMSTATE_UINT32_V(read_word_n, lan9118_state, 2),
-        VMSTATE_UINT32_V(read_long, lan9118_state, 2),
-        VMSTATE_UINT32_V(mode_16bit, lan9118_state, 2),
+        VMSTATE_UINT32_TEST(read_word_prev_offset, lan9118_state,
+                            vmstate_2_plus),
+        VMSTATE_UINT32_TEST(read_word_n, lan9118_state, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(read_long, lan9118_state, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(mode_16bit, lan9118_state, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 90bc5ec..936adb0 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3363,7 +3363,7 @@ static const VMStateDescription vmstate_rtl8139 = {
         VMSTATE_STRUCT(tally_counters, RTL8139State, 0,
                        vmstate_tally_counters, RTL8139TallyCounters),

-        VMSTATE_UINT32_V(cplus_enabled, RTL8139State, 4),
+        VMSTATE_UINT32_TEST(cplus_enabled, RTL8139State, vmstate_4_plus),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (VMStateSubsection []) {
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index b71d251..8ea3ac8 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -380,7 +380,7 @@ static const VMStateDescription vmstate_fw_cfg = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT16(cur_entry, FWCfgState),
         VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1),
-        VMSTATE_UINT32_V(cur_offset, FWCfgState, 2),
+        VMSTATE_UINT32_TEST(cur_offset, FWCfgState, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index 07345f6..f519864 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -266,7 +266,8 @@ static const VMStateDescription vmstate_pit_common = {
     .pre_save = pit_dispatch_pre_save,
     .post_load = pit_dispatch_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
+        VMSTATE_UINT32_TEST(channels[0].irq_disabled, PITCommonState,
+            vmstate_3_plus),
         VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
                              vmstate_pit_channel, PITChannelState),
         VMSTATE_INT64(channels[0].next_transition_time,
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 8342749..079ae93 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -728,8 +728,8 @@ static const VMStateDescription vmstate_rtc = {
         VMSTATE_TIMER(periodic_timer, RTCState),
         VMSTATE_INT64(next_periodic_time, RTCState),
         VMSTATE_UNUSED(3*8),
-        VMSTATE_UINT32_V(irq_coalesced, RTCState, 2),
-        VMSTATE_UINT32_V(period, RTCState, 2),
+        VMSTATE_UINT32_TEST(irq_coalesced, RTCState, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(period, RTCState, vmstate_2_plus),
         VMSTATE_UINT64_V(base_rtc, RTCState, 3),
         VMSTATE_UINT64_V(last_update, RTCState, 3),
         VMSTATE_INT64_TEST(offset, RTCState, vmstate_3_plus),
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index a3ae9f2..da78296 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2496,8 +2496,8 @@ const VMStateDescription vmstate_ehci = {
         /* mmio registers */
         VMSTATE_UINT32(usbcmd, EHCIState),
         VMSTATE_UINT32(usbsts, EHCIState),
-        VMSTATE_UINT32_V(usbsts_pending, EHCIState, 2),
-        VMSTATE_UINT32_V(usbsts_frindex, EHCIState, 2),
+        VMSTATE_UINT32_TEST(usbsts_pending, EHCIState, vmstate_2_plus),
+        VMSTATE_UINT32_TEST(usbsts_frindex, EHCIState, vmstate_2_plus),
         VMSTATE_UINT32(usbintr, EHCIState),
         VMSTATE_UINT32(frindex, EHCIState),
         VMSTATE_UINT32(ctrldssegment, EHCIState),
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 5590e18..eb6a448 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -458,7 +458,7 @@ static const VMStateDescription vmstate_uhci = {
         VMSTATE_UINT8(status2, UHCIState),
         VMSTATE_TIMER(frame_timer, UHCIState),
         VMSTATE_INT64_TEST(expire_time, UHCIState, vmstate_3_plus),
-        VMSTATE_UINT32_V(pending_int_mask, UHCIState, 3),
+        VMSTATE_UINT32_TEST(pending_int_mask, UHCIState, vmstate_3_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 7f822c5..aa99102 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -542,8 +542,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
 #define VMSTATE_UINT16_TEST(_f, _s, _t)                               \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
-#define VMSTATE_UINT32_V(_f, _s, _v)                                  \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t)
+#define VMSTATE_UINT32_TEST(_f, _s, _t)                               \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
 #define VMSTATE_UINT64_V(_f, _s, _v)                                  \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)

@@ -564,7 +564,7 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT16(_f, _s)                                        \
     VMSTATE_UINT16_TEST(_f, _s, NULL)
 #define VMSTATE_UINT32(_f, _s)                                        \
-    VMSTATE_UINT32_V(_f, _s, 0)
+    VMSTATE_UINT32_TEST(_f, _s, NULL)
 #define VMSTATE_UINT64(_f, _s)                                        \
     VMSTATE_UINT64_V(_f, _s, 0)

@@ -595,9 +595,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_LE(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)

-#define VMSTATE_UINT32_TEST(_f, _s, _t)                                  \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
-
 #define VMSTATE_UINT64_TEST(_f, _s, _t)                                  \
     VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t)

diff --git a/target-i386/machine.c b/target-i386/machine.c
index c05dc5a..42c9de0 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -650,10 +650,10 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT64(env.fmask, X86CPU),
         VMSTATE_UINT64(env.kernelgsbase, X86CPU),
 #endif
-        VMSTATE_UINT32_V(env.smbase, X86CPU, 4),
+        VMSTATE_UINT32_TEST(env.smbase, X86CPU, vmstate_4_plus),

         VMSTATE_UINT64_V(env.pat, X86CPU, 5),
-        VMSTATE_UINT32_V(env.hflags2, X86CPU, 5),
+        VMSTATE_UINT32_TEST(env.hflags2, X86CPU, vmstate_5_plus),

         VMSTATE_UINT32_TEST(parent_obj.halted, X86CPU, version_is_5),
         VMSTATE_UINT64_V(env.vm_hsave, X86CPU, 5),
@@ -664,7 +664,7 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT16_TEST(env.intercept_cr_write, X86CPU, vmstate_5_plus),
         VMSTATE_UINT16_TEST(env.intercept_dr_read, X86CPU, vmstate_5_plus),
         VMSTATE_UINT16_TEST(env.intercept_dr_write, X86CPU, vmstate_5_plus),
-        VMSTATE_UINT32_V(env.intercept_exceptions, X86CPU, 5),
+        VMSTATE_UINT32_TEST(env.intercept_exceptions, X86CPU, vmstate_5_plus),
         VMSTATE_UINT8_TEST(env.v_tpr, X86CPU, vmstate_5_plus),
         /* MTRRs */
         VMSTATE_UINT64_ARRAY_V(env.mtrr_fixed, X86CPU, 11, 8),
@@ -672,14 +672,14 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_MTRR_VARS(env.mtrr_var, X86CPU, 8, 8),
         /* KVM-related states */
         VMSTATE_INT32_TEST(env.interrupt_injected, X86CPU, vmstate_9_plus),
-        VMSTATE_UINT32_V(env.mp_state, X86CPU, 9),
+        VMSTATE_UINT32_TEST(env.mp_state, X86CPU, vmstate_9_plus),
         VMSTATE_UINT64_V(env.tsc, X86CPU, 9),
         VMSTATE_INT32_TEST(env.exception_injected, X86CPU, vmstate_11_plus),
         VMSTATE_UINT8_TEST(env.soft_interrupt, X86CPU, vmstate_11_plus),
         VMSTATE_UINT8_TEST(env.nmi_injected, X86CPU, vmstate_11_plus),
         VMSTATE_UINT8_TEST(env.nmi_pending, X86CPU, vmstate_11_plus),
         VMSTATE_UINT8_TEST(env.has_error_code, X86CPU, vmstate_11_plus),
-        VMSTATE_UINT32_V(env.sipi_vector, X86CPU, 11),
+        VMSTATE_UINT32_TEST(env.sipi_vector, X86CPU, vmstate_11_plus),
         /* MCE */
         VMSTATE_UINT64_V(env.mcg_cap, X86CPU, 10),
         VMSTATE_UINT64_V(env.mcg_status, X86CPU, 10),
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 018d8a2..d1f45f8 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -255,6 +255,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_UINT8_TEST(u8_2, TestSimple, test_false),
         VMSTATE_UINT16_TEST(u16_1, TestSimple, test_true),
         VMSTATE_UINT16_TEST(u16_2, TestSimple, test_false),
+        VMSTATE_UINT32_TEST(u32_1, TestSimple, test_true),
+        VMSTATE_UINT32_TEST(u32_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -267,6 +269,7 @@ uint8_t wire_simple_test[] = {
     /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
     /* u8_1 */  0x82,
     /* u16_1 */ 0x02, 0x00,
+    /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -317,6 +320,7 @@ static void test_simple_test(void)
     FIELD_ASSERT(i64_1);
     FIELD_ASSERT(u8_1);
     FIELD_ASSERT(u16_1);
+    FIELD_ASSERT(u32_1);

     qemu_fclose(loading);
 }
@@ -334,12 +338,12 @@ static const VMStateDescription vmstate_versioned = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(a, TestStruct),
-        VMSTATE_UINT32_V(b, TestStruct, 2), /* Versioned field in the middle, so
-                                             * we catch bugs more easily.
-                                             */
+        /* Versioned field in the middle, so we catch bugs more easily. */
+        VMSTATE_UINT32_TEST(b, TestStruct, vmstate_2_plus),
+
         VMSTATE_UINT32(c, TestStruct),
         VMSTATE_UINT64(d, TestStruct),
-        VMSTATE_UINT32_V(e, TestStruct, 2),
+        VMSTATE_UINT32_TEST(e, TestStruct, vmstate_2_plus),
         VMSTATE_UINT64_V(f, TestStruct, 2),
         VMSTATE_END_OF_LIST()
     }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 19/97] vmstate: Test for VMSTATE_UINT64_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (17 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 18/97] vmstate: Test for VMSTATE_UINT32_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 20/97] vmstate: Test for VMSTATE_FLOAT64 Juan Quintela
                   ` (79 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_UINT64_V, we are removing versioning.
Move all users to VMSTATE_UINT64_TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/timer/mc146818rtc.c      |  6 +++---
 include/migration/vmstate.h |  9 +++------
 target-i386/machine.c       | 30 +++++++++++++++---------------
 tests/test-vmstate.c        |  8 ++++++--
 4 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 079ae93..8446d48 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -730,11 +730,11 @@ static const VMStateDescription vmstate_rtc = {
         VMSTATE_UNUSED(3*8),
         VMSTATE_UINT32_TEST(irq_coalesced, RTCState, vmstate_2_plus),
         VMSTATE_UINT32_TEST(period, RTCState, vmstate_2_plus),
-        VMSTATE_UINT64_V(base_rtc, RTCState, 3),
-        VMSTATE_UINT64_V(last_update, RTCState, 3),
+        VMSTATE_UINT64_TEST(base_rtc, RTCState, vmstate_3_plus),
+        VMSTATE_UINT64_TEST(last_update, RTCState, vmstate_3_plus),
         VMSTATE_INT64_TEST(offset, RTCState, vmstate_3_plus),
         VMSTATE_TIMER_V(update_timer, RTCState, 3),
-        VMSTATE_UINT64_V(next_alarm_time, RTCState, 3),
+        VMSTATE_UINT64_TEST(next_alarm_time, RTCState, vmstate_3_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index aa99102..25032ef 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -544,8 +544,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     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)
-#define VMSTATE_UINT64_V(_f, _s, _v)                                  \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t)
+#define VMSTATE_UINT64_TEST(_f, _s, _t)                               \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t)

 #define VMSTATE_BOOL(_f, _s)                                          \
     VMSTATE_BOOL_TEST(_f, _s, NULL)
@@ -566,7 +566,7 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32(_f, _s)                                        \
     VMSTATE_UINT32_TEST(_f, _s, NULL)
 #define VMSTATE_UINT64(_f, _s)                                        \
-    VMSTATE_UINT64_V(_f, _s, 0)
+    VMSTATE_UINT64_TEST(_f, _s, NULL)

 #define VMSTATE_UINT8_EQUAL(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
@@ -595,9 +595,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_LE(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)

-#define VMSTATE_UINT64_TEST(_f, _s, _t)                                  \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t)
-

 #define VMSTATE_FLOAT64_V(_f, _s, _v)                                 \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64)
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 42c9de0..d4ffe8e 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -652,14 +652,14 @@ const VMStateDescription vmstate_x86_cpu = {
 #endif
         VMSTATE_UINT32_TEST(env.smbase, X86CPU, vmstate_4_plus),

-        VMSTATE_UINT64_V(env.pat, X86CPU, 5),
+        VMSTATE_UINT64_TEST(env.pat, X86CPU, vmstate_5_plus),
         VMSTATE_UINT32_TEST(env.hflags2, X86CPU, vmstate_5_plus),

         VMSTATE_UINT32_TEST(parent_obj.halted, X86CPU, version_is_5),
-        VMSTATE_UINT64_V(env.vm_hsave, X86CPU, 5),
-        VMSTATE_UINT64_V(env.vm_vmcb, X86CPU, 5),
-        VMSTATE_UINT64_V(env.tsc_offset, X86CPU, 5),
-        VMSTATE_UINT64_V(env.intercept, X86CPU, 5),
+        VMSTATE_UINT64_TEST(env.vm_hsave, X86CPU, vmstate_5_plus),
+        VMSTATE_UINT64_TEST(env.vm_vmcb, X86CPU, vmstate_5_plus),
+        VMSTATE_UINT64_TEST(env.tsc_offset, X86CPU, vmstate_5_plus),
+        VMSTATE_UINT64_TEST(env.intercept, X86CPU, vmstate_5_plus),
         VMSTATE_UINT16_TEST(env.intercept_cr_read, X86CPU, vmstate_5_plus),
         VMSTATE_UINT16_TEST(env.intercept_cr_write, X86CPU, vmstate_5_plus),
         VMSTATE_UINT16_TEST(env.intercept_dr_read, X86CPU, vmstate_5_plus),
@@ -668,12 +668,12 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT8_TEST(env.v_tpr, X86CPU, vmstate_5_plus),
         /* MTRRs */
         VMSTATE_UINT64_ARRAY_V(env.mtrr_fixed, X86CPU, 11, 8),
-        VMSTATE_UINT64_V(env.mtrr_deftype, X86CPU, 8),
+        VMSTATE_UINT64_TEST(env.mtrr_deftype, X86CPU, vmstate_8_plus),
         VMSTATE_MTRR_VARS(env.mtrr_var, X86CPU, 8, 8),
         /* KVM-related states */
         VMSTATE_INT32_TEST(env.interrupt_injected, X86CPU, vmstate_9_plus),
         VMSTATE_UINT32_TEST(env.mp_state, X86CPU, vmstate_9_plus),
-        VMSTATE_UINT64_V(env.tsc, X86CPU, 9),
+        VMSTATE_UINT64_TEST(env.tsc, X86CPU, vmstate_9_plus),
         VMSTATE_INT32_TEST(env.exception_injected, X86CPU, vmstate_11_plus),
         VMSTATE_UINT8_TEST(env.soft_interrupt, X86CPU, vmstate_11_plus),
         VMSTATE_UINT8_TEST(env.nmi_injected, X86CPU, vmstate_11_plus),
@@ -681,18 +681,18 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT8_TEST(env.has_error_code, X86CPU, vmstate_11_plus),
         VMSTATE_UINT32_TEST(env.sipi_vector, X86CPU, vmstate_11_plus),
         /* MCE */
-        VMSTATE_UINT64_V(env.mcg_cap, X86CPU, 10),
-        VMSTATE_UINT64_V(env.mcg_status, X86CPU, 10),
-        VMSTATE_UINT64_V(env.mcg_ctl, X86CPU, 10),
+        VMSTATE_UINT64_TEST(env.mcg_cap, X86CPU, vmstate_10_plus),
+        VMSTATE_UINT64_TEST(env.mcg_status, X86CPU, vmstate_10_plus),
+        VMSTATE_UINT64_TEST(env.mcg_ctl, X86CPU, vmstate_10_plus),
         VMSTATE_UINT64_ARRAY_V(env.mce_banks, X86CPU, MCE_BANKS_DEF * 4, 10),
         /* rdtscp */
-        VMSTATE_UINT64_V(env.tsc_aux, X86CPU, 11),
+        VMSTATE_UINT64_TEST(env.tsc_aux, X86CPU, vmstate_11_plus),
         /* KVM pvclock msr */
-        VMSTATE_UINT64_V(env.system_time_msr, X86CPU, 11),
-        VMSTATE_UINT64_V(env.wall_clock_msr, X86CPU, 11),
+        VMSTATE_UINT64_TEST(env.system_time_msr, X86CPU, vmstate_11_plus),
+        VMSTATE_UINT64_TEST(env.wall_clock_msr, X86CPU, vmstate_11_plus),
         /* XSAVE related fields */
-        VMSTATE_UINT64_V(env.xcr0, X86CPU, 12),
-        VMSTATE_UINT64_V(env.xstate_bv, X86CPU, 12),
+        VMSTATE_UINT64_TEST(env.xcr0, X86CPU, vmstate_12_plus),
+        VMSTATE_UINT64_TEST(env.xstate_bv, X86CPU, vmstate_12_plus),
         VMSTATE_YMMH_REGS_VARS(env.ymmh_regs, X86CPU, CPU_NB_REGS, 12),
         VMSTATE_END_OF_LIST()
         /* The above list is not sorted /wrt version numbers, watch out! */
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index d1f45f8..632c7a7 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -257,6 +257,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_UINT16_TEST(u16_2, TestSimple, test_false),
         VMSTATE_UINT32_TEST(u32_1, TestSimple, test_true),
         VMSTATE_UINT32_TEST(u32_2, TestSimple, test_false),
+        VMSTATE_UINT64_TEST(u64_1, TestSimple, test_true),
+        VMSTATE_UINT64_TEST(u64_2, TestSimple, test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -270,6 +272,7 @@ uint8_t wire_simple_test[] = {
     /* u8_1 */  0x82,
     /* u16_1 */ 0x02, 0x00,
     /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -321,6 +324,7 @@ static void test_simple_test(void)
     FIELD_ASSERT(u8_1);
     FIELD_ASSERT(u16_1);
     FIELD_ASSERT(u32_1);
+    FIELD_ASSERT(u64_1);

     qemu_fclose(loading);
 }
@@ -344,7 +348,7 @@ static const VMStateDescription vmstate_versioned = {
         VMSTATE_UINT32(c, TestStruct),
         VMSTATE_UINT64(d, TestStruct),
         VMSTATE_UINT32_TEST(e, TestStruct, vmstate_2_plus),
-        VMSTATE_UINT64_V(f, TestStruct, 2),
+        VMSTATE_UINT64_TEST(f, TestStruct, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -417,7 +421,7 @@ static const VMStateDescription vmstate_skipping = {
         VMSTATE_UINT32_TEST(c, TestStruct, test_skip),
         VMSTATE_UINT64(d, TestStruct),
         VMSTATE_UINT32_TEST(e, TestStruct, test_skip),
-        VMSTATE_UINT64_V(f, TestStruct, 2),
+        VMSTATE_UINT64_TEST(f, TestStruct, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 20/97] vmstate: Test for VMSTATE_FLOAT64
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (18 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 19/97] vmstate: Test for VMSTATE_UINT64_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 21/97] vmstate: Test for VMSTATE_UNUSED Juan Quintela
                   ` (78 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_FLOAT64_V.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 5 +----
 tests/test-vmstate.c        | 5 +++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 25032ef..eec4b13 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -596,11 +596,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)


-#define VMSTATE_FLOAT64_V(_f, _s, _v)                                 \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_float64, float64)
-
 #define VMSTATE_FLOAT64(_f, _s)                                       \
-    VMSTATE_FLOAT64_V(_f, _s, 0)
+    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_float64, float64)

 #define VMSTATE_TIMER_TEST(_f, _s, _test)                             \
     VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 632c7a7..21f02ad 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -66,6 +66,7 @@ typedef struct TestSimple {
     int16_t  i16_1, i16_2;
     int32_t  i32_1, i32_2;
     int64_t  i64_1, i64_2;
+    float64 f64;
 } TestSimple;

 /* Object instantiation, we are going to use it in more than one test */
@@ -89,6 +90,7 @@ TestSimple obj_simple = {
     .i32_2 = -70000,
     .i64_1 = 12121212,
     .i64_2 = -12121212,
+    .f64 = float64_pi,
 };

 /* Description of the values.  If you add a primitive type
@@ -113,6 +115,7 @@ static const VMStateDescription vmstate_simple_primitive = {
         VMSTATE_INT32(i32_2, TestSimple),
         VMSTATE_INT64(i64_1, TestSimple),
         VMSTATE_INT64(i64_2, TestSimple),
+        VMSTATE_FLOAT64(f64, TestSimple),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -144,6 +147,7 @@ uint8_t wire_simple_primitive[] = {
     /* i32_2 */ 0xff, 0xfe, 0xee, 0x90,
     /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
     /* i64_2 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x0b, 0x84,
+    /* f64 */   0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -209,6 +213,7 @@ static void test_simple_primitive(void)
     FIELD_ASSERT(i32_2);
     FIELD_ASSERT(i64_1);
     FIELD_ASSERT(i64_2);
+    FIELD_ASSERT(f64);

     /* We save the file again.  We want the EOF this time */

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 21/97] vmstate: Test for VMSTATE_UNUSED
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (19 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 20/97] vmstate: Test for VMSTATE_FLOAT64 Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 22/97] vmstate: Test for VMSTATE_BITMAP Juan Quintela
                   ` (77 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_UNUSED_V and fix only user.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/intc/ioapic_common.c     |  3 ++-
 include/migration/vmstate.h | 11 ++---------
 tests/test-vmstate.c        |  5 +++++
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c
index d4c0c8e..ae81d3f 100644
--- a/hw/intc/ioapic_common.c
+++ b/hw/intc/ioapic_common.c
@@ -91,7 +91,8 @@ static const VMStateDescription vmstate_ioapic_common = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(id, IOAPICCommonState),
         VMSTATE_UINT8(ioregsel, IOAPICCommonState),
-        VMSTATE_UNUSED_V(2, 8), /* to account for qemu-kvm's v2 format */
+        /* to account for qemu-kvm's v2 format */
+        VMSTATE_UNUSED_TEST(vmstate_2_plus, 8),
         VMSTATE_UINT32_TEST(irr, IOAPICCommonState, vmstate_2_plus),
         VMSTATE_UINT64_ARRAY(ioredtbl, IOAPICCommonState, IOAPIC_NUM_PINS),
         VMSTATE_END_OF_LIST()
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index eec4b13..b350eac 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -482,10 +482,9 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }

-#define VMSTATE_UNUSED_BUFFER(_test, _version, _size) {              \
+#define VMSTATE_UNUSED_TEST(_test, _size) {                          \
     .name         = "unused",                                        \
     .field_exists = (_test),                                         \
-    .version_id   = (_version),                                      \
     .size         = (_size),                                         \
     .info         = &vmstate_info_unused_buffer,                     \
     .flags        = VMS_BUFFER,                                      \
@@ -719,14 +718,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size)        \
     VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)

-#define VMSTATE_UNUSED_V(_v, _size)                                   \
-    VMSTATE_UNUSED_BUFFER(NULL, _v, _size)
-
 #define VMSTATE_UNUSED(_size)                                         \
-    VMSTATE_UNUSED_V(0, _size)
-
-#define VMSTATE_UNUSED_TEST(_test, _size)                             \
-    VMSTATE_UNUSED_BUFFER(_test, 0, _size)
+    VMSTATE_UNUSED_TEST(NULL, _size)

 #define VMSTATE_END_OF_LIST()                                         \
     {}
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 21f02ad..e4096f7 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -116,6 +116,7 @@ static const VMStateDescription vmstate_simple_primitive = {
         VMSTATE_INT64(i64_1, TestSimple),
         VMSTATE_INT64(i64_2, TestSimple),
         VMSTATE_FLOAT64(f64, TestSimple),
+        VMSTATE_UNUSED(5),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -148,6 +149,7 @@ uint8_t wire_simple_primitive[] = {
     /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
     /* i64_2 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x0b, 0x84,
     /* f64 */   0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,
+    /* unused */0x00, 0x00, 0x00, 0x00, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -264,6 +266,8 @@ static const VMStateDescription vmstate_simple_test = {
         VMSTATE_UINT32_TEST(u32_2, TestSimple, test_false),
         VMSTATE_UINT64_TEST(u64_1, TestSimple, test_true),
         VMSTATE_UINT64_TEST(u64_2, TestSimple, test_false),
+        VMSTATE_UNUSED_TEST(test_true, 5),
+        VMSTATE_UNUSED_TEST(test_false, 5),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -278,6 +282,7 @@ uint8_t wire_simple_test[] = {
     /* u16_1 */ 0x02, 0x00,
     /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
     /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* unused */0x00, 0x00, 0x00, 0x00, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 22/97] vmstate: Test for VMSTATE_BITMAP
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (20 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 21/97] vmstate: Test for VMSTATE_UNUSED Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 23/97] vmstate: Test for VMSTATE_UINT8_EQUAL Juan Quintela
                   ` (76 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove the unused version field (was unused).

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/sd/sd.c                  |  2 +-
 include/migration/vmstate.h |  4 +-
 tests/test-vmstate.c        | 90 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+), 3 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 4502ad1..7ee8c24 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -467,7 +467,7 @@ static const VMStateDescription sd_vmstate = {
         VMSTATE_UINT32(card_status, SDState),
         VMSTATE_PARTIAL_BUFFER(sd_status, SDState, 1),
         VMSTATE_UINT32(vhs, SDState),
-        VMSTATE_BITMAP(wp_groups, SDState, 0, wpgrps_size),
+        VMSTATE_BITMAP(wp_groups, SDState, wpgrps_size),
         VMSTATE_UINT32(blk_len, SDState),
         VMSTATE_UINT32(erase_start, SDState),
         VMSTATE_UINT32(erase_end, SDState),
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index b350eac..9cfc356 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -493,9 +493,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 /* _field_size should be a int32_t field in the _state struct giving the
  * size of the bitmap _field in bits.
  */
-#define VMSTATE_BITMAP(_field, _state, _version, _field_size) {      \
+#define VMSTATE_BITMAP(_field, _state, _field_size) {                \
     .name         = (stringify(_field)),                             \
-    .version_id   = (_version),                                      \
+    .version_id   = 0,                                               \
     .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
     .info         = &vmstate_info_bitmap,                            \
     .flags        = VMS_VBUFFER|VMS_POINTER,                         \
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index e4096f7..d5cecbf 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -28,6 +28,7 @@
 #include "migration/migration.h"
 #include "migration/vmstate.h"
 #include "block/coroutine.h"
+#include "qemu/bitmap.h"

 char temp_file[] = "/tmp/vmst.test.XXXXXX";
 int temp_fd;
@@ -340,6 +341,94 @@ static void test_simple_test(void)
 }
 #undef FIELD_ASSERT

+typedef struct TestBitmap {
+    int32_t bitmap_size;
+    unsigned long *bitmap;
+} TestBitmap;
+
+static const VMStateDescription vmstate_simple_bitmap = {
+    .name = "simple/bitmap",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(bitmap_size, TestBitmap),
+        VMSTATE_BITMAP(bitmap, TestBitmap, bitmap_size),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+/* This is the binary representation on the wire of that struct */
+uint8_t wire_simple_bitmap[] = {
+    0x00,  0x00,  0x00,  0x40,  /* size */
+    0x40,  0x00,  0x00,  0x00,  /* bitmap */
+    0x40,  0x40,  0x00,  0x01,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+#define VMSTATE_BITMAP_SIZE 64
+
+static void test_simple_bitmap(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+
+    TestBitmap obj_simple;
+
+    obj_simple.bitmap_size = VMSTATE_BITMAP_SIZE;
+    obj_simple.bitmap = bitmap_new(VMSTATE_BITMAP_SIZE);
+    set_bit(0, obj_simple.bitmap);
+    set_bit(22, obj_simple.bitmap);
+    set_bit(30, obj_simple.bitmap);
+    set_bit(62, obj_simple.bitmap);
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_simple_bitmap, &obj_simple);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_simple_bitmap)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_simple_bitmap, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_simple_bitmap, sizeof(wire_simple_bitmap));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestBitmap obj;
+
+    obj.bitmap = bitmap_new(VMSTATE_BITMAP_SIZE);
+
+    SUCCESS(vmstate_load_state(loading, &vmstate_simple_bitmap, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+
+#define FIELD_ASSERT(name)   g_assert_cmpint(obj.name, ==, obj_simple.name)
+    FIELD_ASSERT(bitmap_size);
+    g_assert_cmpint(bitmap_equal(obj.bitmap, obj_simple.bitmap,
+                                 obj_simple.bitmap_size), ==, 1);
+
+    qemu_fclose(loading);
+}
+#undef FIELD_ASSERT
+
 typedef struct TestStruct {
     uint32_t a, b, c, e;
     uint64_t d, f;
@@ -559,6 +648,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
     g_test_add_func("/vmstate/simple/test", test_simple_test);
+    g_test_add_func("/vmstate/simple/bitmap", test_simple_bitmap);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 23/97] vmstate: Test for VMSTATE_UINT8_EQUAL
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (21 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 22/97] vmstate: Test for VMSTATE_BITMAP Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 24/97] vmstate: Test for VMSTATE_UINT16_EQUAL Juan Quintela
                   ` (75 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

We intruduce another full test.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  2 +-
 tests/test-vmstate.c        | 71 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 9cfc356..2c7f150 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -568,7 +568,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_UINT64_TEST(_f, _s, NULL)

 #define VMSTATE_UINT8_EQUAL(_f, _s)                                   \
-    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
+    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint8_equal, uint8_t)

 #define VMSTATE_UINT16_EQUAL(_f, _s)                                  \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index d5cecbf..c6e4b67 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -339,6 +339,75 @@ static void test_simple_test(void)

     qemu_fclose(loading);
 }
+
+static const VMStateDescription vmstate_simple_compare = {
+    .name = "simple/compare",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8_EQUAL(u8_1, TestSimple),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_simple_compare[] = {
+    /* u8_1 */  0x82,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_simple_compare(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_simple_compare, &obj_simple);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_simple_compare)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_simple_compare, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_simple_compare, sizeof(wire_simple_compare));
+    qemu_fclose(fsave);
+
+    TestSimple obj;
+    loading = open_test_file(false);
+    memcpy(&obj, &obj_simple, sizeof(obj));
+
+    SUCCESS(vmstate_load_state(loading, &vmstate_simple_compare, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+    qemu_fclose(loading);
+
+    loading = open_test_file(false);
+    memcpy(&obj, &obj_simple, sizeof(obj));
+    /* we change the value, so it is not equal anymore */
+    obj.u8_1 = 27;
+
+    FAILURE(vmstate_load_state(loading, &vmstate_simple_compare, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+    qemu_fclose(loading);
+}
 #undef FIELD_ASSERT

 typedef struct TestBitmap {
@@ -427,6 +496,7 @@ static void test_simple_bitmap(void)

     qemu_fclose(loading);
 }
+
 #undef FIELD_ASSERT

 typedef struct TestStruct {
@@ -648,6 +718,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
     g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
     g_test_add_func("/vmstate/simple/test", test_simple_test);
+    g_test_add_func("/vmstate/simple/compare", test_simple_compare);
     g_test_add_func("/vmstate/simple/bitmap", test_simple_bitmap);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 24/97] vmstate: Test for VMSTATE_UINT16_EQUAL
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (22 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 23/97] vmstate: Test for VMSTATE_UINT8_EQUAL Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 25/97] vmstate: Test for VMSTATE_UINT32_EQUAL Juan Quintela
                   ` (74 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

We change only user of VMSTATE_UINT16_EQUAL_V to VMSTATE_UINT16_EQUAL_TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/nvram/eeprom93xx.c       | 7 ++++++-
 include/migration/vmstate.h | 8 ++++----
 tests/test-vmstate.c        | 8 +++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
index 0af4d67..d07bafb 100644
--- a/hw/nvram/eeprom93xx.c
+++ b/hw/nvram/eeprom93xx.c
@@ -121,6 +121,11 @@ static bool is_old_eeprom_version(void *opaque, int version_id)
     return version_id == OLD_EEPROM_VERSION;
 }

+static bool is_eeprom_version(void *opaque, int version_id)
+{
+    return version_id == EEPROM_VERSION;
+}
+
 static const VMStateDescription vmstate_eeprom = {
     .name = "eeprom",
     .version_id = EEPROM_VERSION,
@@ -138,7 +143,7 @@ static const VMStateDescription vmstate_eeprom = {
         VMSTATE_UINT8(addrbits, eeprom_t),
         VMSTATE_UINT16_HACK_TEST(size, eeprom_t, is_old_eeprom_version),
         VMSTATE_UNUSED_TEST(is_old_eeprom_version, 1),
-        VMSTATE_UINT16_EQUAL_V(size, eeprom_t, EEPROM_VERSION),
+        VMSTATE_UINT16_EQUAL_TEST(size, eeprom_t, is_eeprom_version),
         VMSTATE_UINT16(data, eeprom_t),
         VMSTATE_VARRAY_UINT16_UNSAFE(contents, eeprom_t, size, 0,
                                      vmstate_info_uint16, uint16_t),
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 2c7f150..e6f6a46 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -570,11 +570,11 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT8_EQUAL(_f, _s)                                   \
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint8_equal, uint8_t)

-#define VMSTATE_UINT16_EQUAL(_f, _s)                                  \
-    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
+#define VMSTATE_UINT16_EQUAL_TEST(_f, _s, _t)                         \
+    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16_equal, uint16_t)

-#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v)                            \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
+#define VMSTATE_UINT16_EQUAL(_f, _s)                                  \
+    VMSTATE_UINT16_EQUAL_TEST(_f, _s, NULL)

 #define VMSTATE_INT32_EQUAL(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index c6e4b67..bd13723 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -60,7 +60,7 @@ static QEMUFile *open_test_file(bool write)
 typedef struct TestSimple {
     bool     b_1,   b_2;
     uint8_t  u8_1,  u8_2;
-    uint16_t u16_1, u16_2;
+    uint16_t u16_1, u16_2, u16_3;
     uint32_t u32_1, u32_2;
     uint64_t u64_1, u64_2;
     int8_t   i8_1,  i8_2;
@@ -79,6 +79,7 @@ TestSimple obj_simple = {
     .u8_1 = 130,
     .u16_1 = 512,
     .u16_2 = 45000,
+    .u16_3 = 512,
     .u32_1 = 70000,
     .u32_2 = 100000,
     .u64_1 = 12121212,
@@ -347,12 +348,17 @@ static const VMStateDescription vmstate_simple_compare = {
     .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8_EQUAL(u8_1, TestSimple),
+        VMSTATE_UINT16_EQUAL(u16_1, TestSimple),
+        VMSTATE_UINT16_EQUAL_TEST(u16_2, TestSimple, test_false),
+        VMSTATE_UINT16_EQUAL_TEST(u16_3, TestSimple, test_true),
         VMSTATE_END_OF_LIST()
     }
 };

 uint8_t wire_simple_compare[] = {
     /* u8_1 */  0x82,
+    /* u16_1 */ 0x02, 0x00,
+    /* u16_3 */ 0x02, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 25/97] vmstate: Test for VMSTATE_UINT32_EQUAL
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (23 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 24/97] vmstate: Test for VMSTATE_UINT16_EQUAL Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 26/97] vmstate: Test for VMSTATE_UINT64_EQUAL Juan Quintela
                   ` (73 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_UINT32_EQUAL_V.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 9 +++------
 tests/test-vmstate.c        | 2 ++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index e6f6a46..267ce4e 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -576,15 +576,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT16_EQUAL(_f, _s)                                  \
     VMSTATE_UINT16_EQUAL_TEST(_f, _s, NULL)

+#define VMSTATE_UINT32_EQUAL(_f, _s)                                  \
+    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint32_equal, uint32_t)
+
 #define VMSTATE_INT32_EQUAL(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)

-#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v)                            \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32_equal, uint32_t)
-
-#define VMSTATE_UINT32_EQUAL(_f, _s)                                  \
-    VMSTATE_UINT32_EQUAL_V(_f, _s, 0)
-
 #define VMSTATE_UINT64_EQUAL_V(_f, _s, _v)                            \
     VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index bd13723..f913b57 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -351,6 +351,7 @@ static const VMStateDescription vmstate_simple_compare = {
         VMSTATE_UINT16_EQUAL(u16_1, TestSimple),
         VMSTATE_UINT16_EQUAL_TEST(u16_2, TestSimple, test_false),
         VMSTATE_UINT16_EQUAL_TEST(u16_3, TestSimple, test_true),
+        VMSTATE_UINT32_EQUAL(u32_1, TestSimple),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -359,6 +360,7 @@ uint8_t wire_simple_compare[] = {
     /* u8_1 */  0x82,
     /* u16_1 */ 0x02, 0x00,
     /* u16_3 */ 0x02, 0x00,
+    /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 26/97] vmstate: Test for VMSTATE_UINT64_EQUAL
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (24 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 25/97] vmstate: Test for VMSTATE_UINT32_EQUAL Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 27/97] vmstate: Test for VMSTATE_INT32_EQUAL Juan Quintela
                   ` (72 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_UINT64_EQUAL_V.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 9 +++------
 tests/test-vmstate.c        | 2 ++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 267ce4e..55750f4 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -579,15 +579,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_EQUAL(_f, _s)                                  \
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint32_equal, uint32_t)

+#define VMSTATE_UINT64_EQUAL(_f, _s)                                  \
+    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint64_equal, uint64_t)
+
 #define VMSTATE_INT32_EQUAL(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)

-#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v)                            \
-    VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t)
-
-#define VMSTATE_UINT64_EQUAL(_f, _s)                                  \
-    VMSTATE_UINT64_EQUAL_V(_f, _s, 0)
-
 #define VMSTATE_INT32_LE(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f913b57..0ac816d 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -352,6 +352,7 @@ static const VMStateDescription vmstate_simple_compare = {
         VMSTATE_UINT16_EQUAL_TEST(u16_2, TestSimple, test_false),
         VMSTATE_UINT16_EQUAL_TEST(u16_3, TestSimple, test_true),
         VMSTATE_UINT32_EQUAL(u32_1, TestSimple),
+        VMSTATE_UINT64_EQUAL(u64_1, TestSimple),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -361,6 +362,7 @@ uint8_t wire_simple_compare[] = {
     /* u16_1 */ 0x02, 0x00,
     /* u16_3 */ 0x02, 0x00,
     /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 27/97] vmstate: Test for VMSTATE_INT32_EQUAL
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (25 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 26/97] vmstate: Test for VMSTATE_UINT64_EQUAL Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 28/97] vmstate: Test for VMSTATE_INT32_LE Juan Quintela
                   ` (71 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 2 +-
 tests/test-vmstate.c        | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 55750f4..9eec546 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -583,7 +583,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint64_equal, uint64_t)

 #define VMSTATE_INT32_EQUAL(_f, _s)                                   \
-    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
+    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_equal, int32_t)

 #define VMSTATE_INT32_LE(_f, _s)                                   \
     VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 0ac816d..70f27f8 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -353,6 +353,7 @@ static const VMStateDescription vmstate_simple_compare = {
         VMSTATE_UINT16_EQUAL_TEST(u16_3, TestSimple, test_true),
         VMSTATE_UINT32_EQUAL(u32_1, TestSimple),
         VMSTATE_UINT64_EQUAL(u64_1, TestSimple),
+        VMSTATE_INT32_EQUAL(i32_1, TestSimple),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -363,6 +364,7 @@ uint8_t wire_simple_compare[] = {
     /* u16_3 */ 0x02, 0x00,
     /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
     /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 28/97] vmstate: Test for VMSTATE_INT32_LE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (26 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 27/97] vmstate: Test for VMSTATE_INT32_EQUAL Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 29/97] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ Juan Quintela
                   ` (70 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Add tests for less/more than the value on destination.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  4 ++--
 tests/test-vmstate.c        | 25 ++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 9eec546..8707c4f 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -585,8 +585,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_EQUAL(_f, _s)                                   \
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_equal, int32_t)

-#define VMSTATE_INT32_LE(_f, _s)                                   \
-    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
+#define VMSTATE_INT32_LE(_f, _s)                                      \
+    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_le, int32_t)


 #define VMSTATE_FLOAT64(_f, _s)                                       \
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 70f27f8..d52f722 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -353,7 +353,8 @@ static const VMStateDescription vmstate_simple_compare = {
         VMSTATE_UINT16_EQUAL_TEST(u16_3, TestSimple, test_true),
         VMSTATE_UINT32_EQUAL(u32_1, TestSimple),
         VMSTATE_UINT64_EQUAL(u64_1, TestSimple),
-        VMSTATE_INT32_EQUAL(i32_1, TestSimple),
+        VMSTATE_INT32_EQUAL(i32_2, TestSimple),
+        VMSTATE_INT32_LE(i32_1, TestSimple),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -364,6 +365,7 @@ uint8_t wire_simple_compare[] = {
     /* u16_3 */ 0x02, 0x00,
     /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
     /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* i32_2 */ 0xff, 0xfe, 0xee, 0x90,
     /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };
@@ -419,6 +421,27 @@ static void test_simple_compare(void)
     FAILURE(vmstate_load_state(loading, &vmstate_simple_compare, &obj, 1));
     g_assert(!qemu_file_get_error(loading));
     qemu_fclose(loading);
+
+    /* testing less equal */
+
+    loading = open_test_file(false);
+    memcpy(&obj, &obj_simple, sizeof(obj));
+    /* value on the wire is bigger, so fail */
+    obj.i32_1 = 8000;
+
+    FAILURE(vmstate_load_state(loading, &vmstate_simple_compare, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+    qemu_fclose(loading);
+
+    loading = open_test_file(false);
+    memcpy(&obj, &obj_simple, sizeof(obj));
+    /* value on the wire is lower, so success */
+    obj.i32_1 = 80000;
+
+    SUCCESS(vmstate_load_state(loading, &vmstate_simple_compare, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+    qemu_fclose(loading);
+
 }
 #undef FIELD_ASSERT

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 29/97] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (27 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 28/97] vmstate: Test for VMSTATE_INT32_LE Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 30/97] vmstate: Move VMSTATE_TIMER_V to VMSTATE_TIMER_TEST Juan Quintela
                   ` (69 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin

From: "Michael S. Tsirkin" <mst@redhat.com>

As the macro verifies the value is positive, rename it
to make the function clearer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/pci/pci.c                | 4 ++--
 include/migration/vmstate.h | 3 +--
 target-arm/machine.c        | 2 +-
 tests/test-vmstate.c        | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index d4375b6..2ba6b30 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -473,7 +473,7 @@ const VMStateDescription vmstate_pci_device = {
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_INT32_LE(version_id, PCIDevice),
+        VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice),
         VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
                                    vmstate_info_pci_config,
                                    PCI_CONFIG_SPACE_SIZE),
@@ -489,7 +489,7 @@ const VMStateDescription vmstate_pcie_device = {
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_INT32_LE(version_id, PCIDevice),
+        VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice),
         VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
                                    vmstate_info_pci_config,
                                    PCIE_CONFIG_SPACE_SIZE),
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 8707c4f..f6bec36 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -585,10 +585,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_EQUAL(_f, _s)                                   \
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_equal, int32_t)

-#define VMSTATE_INT32_LE(_f, _s)                                      \
+#define VMSTATE_INT32_POSITIVE_LE(_f, _s)                             \
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_le, int32_t)

-
 #define VMSTATE_FLOAT64(_f, _s)                                       \
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_float64, float64)

diff --git a/target-arm/machine.c b/target-arm/machine.c
index ee67b67..3f4fd42 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -241,7 +241,7 @@ const VMStateDescription vmstate_arm_cpu = {
         /* The length-check must come before the arrays to avoid
          * incoming data possibly overflowing the array.
          */
-        VMSTATE_INT32_LE(cpreg_vmstate_array_len, ARMCPU),
+        VMSTATE_INT32_POSITIVE_LE(cpreg_vmstate_array_len, ARMCPU),
         VMSTATE_VARRAY_INT32(cpreg_vmstate_indexes, ARMCPU,
                              cpreg_vmstate_array_len,
                              0, vmstate_info_uint64, uint64_t),
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index d52f722..846ed39 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -354,7 +354,7 @@ static const VMStateDescription vmstate_simple_compare = {
         VMSTATE_UINT32_EQUAL(u32_1, TestSimple),
         VMSTATE_UINT64_EQUAL(u64_1, TestSimple),
         VMSTATE_INT32_EQUAL(i32_2, TestSimple),
-        VMSTATE_INT32_LE(i32_1, TestSimple),
+        VMSTATE_INT32_POSITIVE_LE(i32_1, TestSimple),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 30/97] vmstate: Move VMSTATE_TIMER_V to VMSTATE_TIMER_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (28 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 29/97] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 31/97] vmstate: Test for VMSTATE_ARRAY_BOOL_TEST Juan Quintela
                   ` (68 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

No test created, because it is basically imposible to create a timer by hand :-(

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/timer/mc146818rtc.c      | 2 +-
 include/migration/vmstate.h | 7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 8446d48..f3dc2fe 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -733,7 +733,7 @@ static const VMStateDescription vmstate_rtc = {
         VMSTATE_UINT64_TEST(base_rtc, RTCState, vmstate_3_plus),
         VMSTATE_UINT64_TEST(last_update, RTCState, vmstate_3_plus),
         VMSTATE_INT64_TEST(offset, RTCState, vmstate_3_plus),
-        VMSTATE_TIMER_V(update_timer, RTCState, 3),
+        VMSTATE_TIMER_TEST(update_timer, RTCState, vmstate_3_plus),
         VMSTATE_UINT64_TEST(next_alarm_time, RTCState, vmstate_3_plus),
         VMSTATE_END_OF_LIST()
     }
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f6bec36..956a358 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -594,13 +594,10 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_TIMER_TEST(_f, _s, _test)                             \
     VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)

-#define VMSTATE_TIMER_V(_f, _s, _v)                                   \
-    VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *)
-
 #define VMSTATE_TIMER(_f, _s)                                         \
-    VMSTATE_TIMER_V(_f, _s, 0)
+    VMSTATE_TIMER_TEST(_f, _s, NULL)

-#define VMSTATE_TIMER_ARRAY(_f, _s, _n)                              \
+#define VMSTATE_TIMER_ARRAY(_f, _s, _n)                               \
     VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)

 #define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v)                         \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 31/97] vmstate: Test for VMSTATE_ARRAY_BOOL_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (29 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 30/97] vmstate: Move VMSTATE_TIMER_V to VMSTATE_TIMER_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 32/97] vmstate: Test for VMSTATE_UINT8_ARRAY Juan Quintela
                   ` (67 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

We add all the boilerplate code for testing arrays.
We change only user of VMSTATE_ARRAY_BOOL_V to VMSTATE_ARRAY_BOOL_TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/audio/hda-codec.c        |   3 +-
 include/migration/vmstate.h |   8 +--
 tests/test-vmstate.c        | 171 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 177 insertions(+), 5 deletions(-)

diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 09559ef..1c1a138 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -603,7 +603,8 @@ static const VMStateDescription vmstate_hda_audio = {
                              vmstate_hda_audio_stream,
                              HDAAudioStream),
         VMSTATE_BOOL_ARRAY(running_compat, HDAAudioState, 16),
-        VMSTATE_BOOL_ARRAY_V(running_real, HDAAudioState, 2 * 16, 2),
+        VMSTATE_BOOL_ARRAY_TEST(running_real, HDAAudioState, 2 * 16,
+                                vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 956a358..ac5a939 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -600,11 +600,11 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_TIMER_ARRAY(_f, _s, _n)                               \
     VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)

-#define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v)                         \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool)
+#define VMSTATE_BOOL_ARRAY_TEST(_f, _s, _n, _t)                       \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_bool, bool)

-#define VMSTATE_BOOL_ARRAY(_f, _s, _n)                               \
-    VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
+#define VMSTATE_BOOL_ARRAY(_f, _s, _n)                                \
+    VMSTATE_BOOL_ARRAY_TEST(_f, _s, _n, NULL)

 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v)                         \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 846ed39..656e563 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -534,6 +534,175 @@ static void test_simple_bitmap(void)

 #undef FIELD_ASSERT

+#define VMSTATE_ARRAY_SIZE 5
+
+typedef struct TestArray {
+    int32_t  size;
+    bool     b_1[VMSTATE_ARRAY_SIZE];
+    bool     b_2[VMSTATE_ARRAY_SIZE];
+} TestArray;
+
+TestArray obj_array = {
+    .size = VMSTATE_ARRAY_SIZE,
+    .b_1 = { false, true, false, true, false},
+    .b_2 = { true, false, true, false, true},
+};
+
+static const VMStateDescription vmstate_array_primitive = {
+    .name = "array/primitive",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(size, TestArray),
+        VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_array_primitive[] = {
+    /* size */  0x00, 0x00, 0x00, 0x05,
+    /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_array_primitive(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+    int i;
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_array_primitive, &obj_array);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_array_primitive)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_array_primitive, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_array_primitive, sizeof(wire_array_primitive));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestArray obj;
+    SUCCESS(vmstate_load_state(loading, &vmstate_array_primitive, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+    qemu_fclose(loading);
+
+#define FIELD_ASSERT(name)   g_assert_cmpint(obj.name, ==, obj_array.name)
+#define ELEM_ASSERT(name, i) \
+    g_assert_cmpint(obj.name[i], ==, obj_array.name[i])
+
+    FIELD_ASSERT(size);
+    for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
+        ELEM_ASSERT(b_1, i);
+    }
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    /* this time we don't write the whole file */
+    qemu_put_buffer(fsave, wire_array_primitive, 4);
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    FAILURE(vmstate_load_state(loading, &vmstate_array_primitive, &obj, 1));
+
+    /* Now it has to have an error */
+    g_assert(qemu_file_get_error(loading));
+    qemu_fclose(loading);
+}
+
+static const VMStateDescription vmstate_array_test = {
+    .name = "array/test",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(size, TestArray),
+        VMSTATE_BOOL_ARRAY_TEST(b_1, TestArray, VMSTATE_ARRAY_SIZE, test_true),
+        VMSTATE_BOOL_ARRAY_TEST(b_2, TestArray, VMSTATE_ARRAY_SIZE, test_false),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_array_test[] = {
+    /* size */  0x00, 0x00, 0x00, 0x05,
+    /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_array_test(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+    int i;
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_array_test, &obj_array);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_array_test)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_array_test, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_array_test, sizeof(wire_array_test));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestArray obj;
+    SUCCESS(vmstate_load_state(loading, &vmstate_array_test, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+
+    qemu_fclose(loading);
+
+    FIELD_ASSERT(size);
+    for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
+        ELEM_ASSERT(b_1, i);
+    }
+}
+#undef FIELD_ASSERT
+#undef ELEM_ASSERT
+
+
 typedef struct TestStruct {
     uint32_t a, b, c, e;
     uint64_t d, f;
@@ -755,6 +924,8 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/simple/test", test_simple_test);
     g_test_add_func("/vmstate/simple/compare", test_simple_compare);
     g_test_add_func("/vmstate/simple/bitmap", test_simple_bitmap);
+    g_test_add_func("/vmstate/array/primitive", test_array_primitive);
+    g_test_add_func("/vmstate/array/test", test_array_test);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 32/97] vmstate: Test for VMSTATE_UINT8_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (30 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 31/97] vmstate: Test for VMSTATE_ARRAY_BOOL_TEST Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 33/97] vmstate: Test for VMSTATE_UINT16_ARRAY Juan Quintela
                   ` (66 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove VMSTATE_UINT8_ARRAY_V that was unused.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  9 +++------
 tests/test-vmstate.c        | 11 +++++++++++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index ac5a939..c74cdf3 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -606,6 +606,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_BOOL_ARRAY(_f, _s, _n)                                \
     VMSTATE_BOOL_ARRAY_TEST(_f, _s, _n, NULL)

+#define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint8, uint8_t)
+
 #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v)                         \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)

@@ -621,12 +624,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, _v)                 \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint8, uint8_t)

-#define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v)                         \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t)
-
-#define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
-    VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 656e563..8a73d4c 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -540,12 +540,16 @@ typedef struct TestArray {
     int32_t  size;
     bool     b_1[VMSTATE_ARRAY_SIZE];
     bool     b_2[VMSTATE_ARRAY_SIZE];
+    uint8_t  u8_1[VMSTATE_ARRAY_SIZE];
+    uint8_t  u8_2[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
     .size = VMSTATE_ARRAY_SIZE,
     .b_1 = { false, true, false, true, false},
     .b_2 = { true, false, true, false, true},
+    .u8_1 = { 1, 2, 3, 4, 5},
+    .u8_2 = { 5, 4, 3, 2, 1},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -556,6 +560,7 @@ static const VMStateDescription vmstate_array_primitive = {
     .fields = (VMStateField[]) {
         VMSTATE_INT32(size, TestArray),
         VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -563,6 +568,7 @@ static const VMStateDescription vmstate_array_primitive = {
 uint8_t wire_array_primitive[] = {
     /* size */  0x00, 0x00, 0x00, 0x05,
     /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
+    /* u8_1 */  0x01, 0x02, 0x03, 0x04, 0x05,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -611,10 +617,14 @@ static void test_array_primitive(void)
 #define FIELD_ASSERT(name)   g_assert_cmpint(obj.name, ==, obj_array.name)
 #define ELEM_ASSERT(name, i) \
     g_assert_cmpint(obj.name[i], ==, obj_array.name[i])
+#define ELEM_NOT_ASSERT(name, i) \
+    g_assert_cmpint(obj.name[i], !=, obj_array.name[i])

     FIELD_ASSERT(size);
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_ASSERT(b_1, i);
+        ELEM_ASSERT(u8_1, i);
+        ELEM_NOT_ASSERT(u8_2, i);
     }

     /* We save the file again.  We want the EOF this time */
@@ -701,6 +711,7 @@ static void test_array_test(void)
 }
 #undef FIELD_ASSERT
 #undef ELEM_ASSERT
+#undef ELEM_NOT_ASSERT


 typedef struct TestStruct {
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 33/97] vmstate: Test for VMSTATE_UINT16_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (31 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 32/97] vmstate: Test for VMSTATE_UINT8_ARRAY Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 34/97] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST} Juan Quintela
                   ` (65 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_UINT16_ARRAY_V.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 7 ++-----
 tests/test-vmstate.c        | 5 +++++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index c74cdf3..2579c4f 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -609,15 +609,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint8, uint8_t)

-#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v)                         \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
+#define VMSTATE_UINT16_ARRAY(_f, _s, _n)                              \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint16, uint16_t)

 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

-#define VMSTATE_UINT16_ARRAY(_f, _s, _n)                               \
-    VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 8a73d4c..ae0421e 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -542,6 +542,7 @@ typedef struct TestArray {
     bool     b_2[VMSTATE_ARRAY_SIZE];
     uint8_t  u8_1[VMSTATE_ARRAY_SIZE];
     uint8_t  u8_2[VMSTATE_ARRAY_SIZE];
+    uint16_t u16_1[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -550,6 +551,7 @@ TestArray obj_array = {
     .b_2 = { true, false, true, false, true},
     .u8_1 = { 1, 2, 3, 4, 5},
     .u8_2 = { 5, 4, 3, 2, 1},
+    .u16_1 = {11, 12, 13, 14, 15},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -561,6 +563,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_INT32(size, TestArray),
         VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT16_ARRAY(u16_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -569,6 +572,7 @@ uint8_t wire_array_primitive[] = {
     /* size */  0x00, 0x00, 0x00, 0x05,
     /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
     /* u8_1 */  0x01, 0x02, 0x03, 0x04, 0x05,
+    /* u16_1 */ 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0e, 0x00, 0x0f,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -625,6 +629,7 @@ static void test_array_primitive(void)
         ELEM_ASSERT(b_1, i);
         ELEM_ASSERT(u8_1, i);
         ELEM_NOT_ASSERT(u8_2, i);
+        ELEM_ASSERT(u16_1, i);
     }

     /* We save the file again.  We want the EOF this time */
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 34/97] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST}
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (32 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 33/97] vmstate: Test for VMSTATE_UINT16_ARRAY Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 35/97] vmstate: Test for VMSTATE_UINT64_ARRAY{_TEST} Juan Quintela
                   ` (64 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Once there, change only user of VMSTATE_UInT32_ARRAY_V.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/misc/arm_sysctl.c        |  3 ++-
 include/migration/vmstate.h | 15 ++++++---------
 tests/test-vmstate.c        | 18 ++++++++++++++++++
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c
index 807d48e..0f61241 100644
--- a/hw/misc/arm_sysctl.c
+++ b/hw/misc/arm_sysctl.c
@@ -65,7 +65,8 @@ static const VMStateDescription vmstate_arm_sysctl = {
         VMSTATE_UINT32_TEST(sys_cfgctrl, arm_sysctl_state, vmstate_2_plus),
         VMSTATE_UINT32_TEST(sys_cfgstat, arm_sysctl_state, vmstate_2_plus),
         VMSTATE_UINT32_TEST(sys_clcd, arm_sysctl_state, vmstate_3_plus),
-        VMSTATE_UINT32_ARRAY_V(mb_clock, arm_sysctl_state, 6, 4),
+        VMSTATE_UINT32_ARRAY_TEST(mb_clock, arm_sysctl_state, 6,
+                                  vmstate_4_plus),
         VMSTATE_VARRAY_UINT32(db_clock, arm_sysctl_state, db_num_clocks,
                               4, vmstate_info_uint32, uint32_t),
         VMSTATE_END_OF_LIST()
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 2579c4f..703f07b 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -612,6 +612,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT16_ARRAY(_f, _s, _n)                              \
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint16, uint16_t)

+#define VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, _t)                     \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_uint32, uint32_t)
+
+#define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
+    VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, NULL)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

@@ -627,15 +633,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
     VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)

-#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)                        \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t)
-
 #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)

-#define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
-    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)

@@ -660,9 +660,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)

-#define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
-    VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v)                         \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index ae0421e..76ad401 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -543,6 +543,8 @@ typedef struct TestArray {
     uint8_t  u8_1[VMSTATE_ARRAY_SIZE];
     uint8_t  u8_2[VMSTATE_ARRAY_SIZE];
     uint16_t u16_1[VMSTATE_ARRAY_SIZE];
+    uint32_t u32_1[VMSTATE_ARRAY_SIZE];
+    uint32_t u32_2[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -552,6 +554,8 @@ TestArray obj_array = {
     .u8_1 = { 1, 2, 3, 4, 5},
     .u8_2 = { 5, 4, 3, 2, 1},
     .u16_1 = {11, 12, 13, 14, 15},
+    .u32_1 = {21, 22, 23, 24, 25},
+    .u32_2 = {25, 24, 23, 22, 21},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -564,6 +568,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_BOOL_ARRAY(b_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT16_ARRAY(u16_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT32_ARRAY(u32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -573,6 +578,9 @@ uint8_t wire_array_primitive[] = {
     /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
     /* u8_1 */  0x01, 0x02, 0x03, 0x04, 0x05,
     /* u16_1 */ 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0e, 0x00, 0x0f,
+    /* u32_1 */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
+                0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
+                0x00, 0x00, 0x00, 0x19,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -630,6 +638,7 @@ static void test_array_primitive(void)
         ELEM_ASSERT(u8_1, i);
         ELEM_NOT_ASSERT(u8_2, i);
         ELEM_ASSERT(u16_1, i);
+        ELEM_ASSERT(u32_1, i);
     }

     /* We save the file again.  We want the EOF this time */
@@ -656,6 +665,10 @@ static const VMStateDescription vmstate_array_test = {
         VMSTATE_INT32(size, TestArray),
         VMSTATE_BOOL_ARRAY_TEST(b_1, TestArray, VMSTATE_ARRAY_SIZE, test_true),
         VMSTATE_BOOL_ARRAY_TEST(b_2, TestArray, VMSTATE_ARRAY_SIZE, test_false),
+        VMSTATE_UINT32_ARRAY_TEST(u32_1, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_true),
+        VMSTATE_UINT32_ARRAY_TEST(u32_2, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -663,6 +676,9 @@ static const VMStateDescription vmstate_array_test = {
 uint8_t wire_array_test[] = {
     /* size */  0x00, 0x00, 0x00, 0x05,
     /* b_1 */   0x00, 0x01, 0x00, 0x01, 0x00,
+    /* u32_1 */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
+                0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
+                0x00, 0x00, 0x00, 0x19,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -712,6 +728,8 @@ static void test_array_test(void)
     FIELD_ASSERT(size);
     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_ASSERT(b_1, i);
+        ELEM_ASSERT(u32_1, i);
+        ELEM_NOT_ASSERT(u32_2, i);
     }
 }
 #undef FIELD_ASSERT
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 35/97] vmstate: Test for VMSTATE_UINT64_ARRAY{_TEST}
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (33 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 34/97] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST} Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 36/97] vmstate: Test for VMSTATE_INT16_ARRAY Juan Quintela
                   ` (63 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

CHange users of _V to _TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 12 ++++++------
 target-i386/machine.c       |  5 +++--
 tests/test-vmstate.c        | 22 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 703f07b..3271114 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -618,6 +618,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, NULL)

+#define VMSTATE_UINT64_ARRAY_TEST(_f, _s, _n, _t)                     \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_uint64, uint64_t)
+
+#define VMSTATE_UINT64_ARRAY(_f, _s, _n)                              \
+    VMSTATE_UINT64_ARRAY_TEST(_f, _s, _n, NULL)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

@@ -639,12 +645,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)

-#define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)                        \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t)
-
-#define VMSTATE_UINT64_ARRAY(_f, _s, _n)                              \
-    VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v)                         \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)

diff --git a/target-i386/machine.c b/target-i386/machine.c
index d4ffe8e..1b8e3c4 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -667,7 +667,7 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT32_TEST(env.intercept_exceptions, X86CPU, vmstate_5_plus),
         VMSTATE_UINT8_TEST(env.v_tpr, X86CPU, vmstate_5_plus),
         /* MTRRs */
-        VMSTATE_UINT64_ARRAY_V(env.mtrr_fixed, X86CPU, 11, 8),
+        VMSTATE_UINT64_ARRAY_TEST(env.mtrr_fixed, X86CPU, 11, vmstate_8_plus),
         VMSTATE_UINT64_TEST(env.mtrr_deftype, X86CPU, vmstate_8_plus),
         VMSTATE_MTRR_VARS(env.mtrr_var, X86CPU, 8, 8),
         /* KVM-related states */
@@ -684,7 +684,8 @@ const VMStateDescription vmstate_x86_cpu = {
         VMSTATE_UINT64_TEST(env.mcg_cap, X86CPU, vmstate_10_plus),
         VMSTATE_UINT64_TEST(env.mcg_status, X86CPU, vmstate_10_plus),
         VMSTATE_UINT64_TEST(env.mcg_ctl, X86CPU, vmstate_10_plus),
-        VMSTATE_UINT64_ARRAY_V(env.mce_banks, X86CPU, MCE_BANKS_DEF * 4, 10),
+        VMSTATE_UINT64_ARRAY_TEST(env.mce_banks, X86CPU, MCE_BANKS_DEF * 4,
+                                  vmstate_10_plus),
         /* rdtscp */
         VMSTATE_UINT64_TEST(env.tsc_aux, X86CPU, vmstate_11_plus),
         /* KVM pvclock msr */
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 76ad401..1f50948 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -545,6 +545,8 @@ typedef struct TestArray {
     uint16_t u16_1[VMSTATE_ARRAY_SIZE];
     uint32_t u32_1[VMSTATE_ARRAY_SIZE];
     uint32_t u32_2[VMSTATE_ARRAY_SIZE];
+    uint64_t u64_1[VMSTATE_ARRAY_SIZE];
+    uint64_t u64_2[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -556,6 +558,8 @@ TestArray obj_array = {
     .u16_1 = {11, 12, 13, 14, 15},
     .u32_1 = {21, 22, 23, 24, 25},
     .u32_2 = {25, 24, 23, 22, 21},
+    .u64_1 = {31, 32, 33, 34, 35},
+    .u64_2 = {35, 34, 33, 32, 31},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -569,6 +573,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_UINT8_ARRAY(u8_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT16_ARRAY(u16_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT32_ARRAY(u32_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT64_ARRAY(u64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -581,6 +586,11 @@ uint8_t wire_array_primitive[] = {
     /* u32_1 */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
                 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
                 0x00, 0x00, 0x00, 0x19,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -639,6 +649,7 @@ static void test_array_primitive(void)
         ELEM_NOT_ASSERT(u8_2, i);
         ELEM_ASSERT(u16_1, i);
         ELEM_ASSERT(u32_1, i);
+        ELEM_ASSERT(u64_1, i);
     }

     /* We save the file again.  We want the EOF this time */
@@ -669,6 +680,10 @@ static const VMStateDescription vmstate_array_test = {
                                   test_true),
         VMSTATE_UINT32_ARRAY_TEST(u32_2, TestArray, VMSTATE_ARRAY_SIZE,
                                   test_false),
+        VMSTATE_UINT64_ARRAY_TEST(u64_1, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_true),
+        VMSTATE_UINT64_ARRAY_TEST(u64_2, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -679,6 +694,11 @@ uint8_t wire_array_test[] = {
     /* u32_1 */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
                 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
                 0x00, 0x00, 0x00, 0x19,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -730,6 +750,8 @@ static void test_array_test(void)
         ELEM_ASSERT(b_1, i);
         ELEM_ASSERT(u32_1, i);
         ELEM_NOT_ASSERT(u32_2, i);
+        ELEM_ASSERT(u64_1, i);
+        ELEM_NOT_ASSERT(u64_2, i);
     }
 }
 #undef FIELD_ASSERT
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 36/97] vmstate: Test for VMSTATE_INT16_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (34 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 35/97] vmstate: Test for VMSTATE_UINT64_ARRAY{_TEST} Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 37/97] vmstate: Test for VMSTATE_INT32_ARRAY{_TEST} Juan Quintela
                   ` (62 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_INT16_ARRAY_V

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 9 +++------
 tests/test-vmstate.c        | 5 +++++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 3271114..5e62206 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -624,6 +624,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT64_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINT64_ARRAY_TEST(_f, _s, _n, NULL)

+#define VMSTATE_INT16_ARRAY(_f, _s, _n)                               \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_int16, int16_t)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

@@ -645,12 +648,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)

-#define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v)                         \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t)
-
-#define VMSTATE_INT16_ARRAY(_f, _s, _n)                               \
-    VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v)                         \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 1f50948..e800be0 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -547,6 +547,7 @@ typedef struct TestArray {
     uint32_t u32_2[VMSTATE_ARRAY_SIZE];
     uint64_t u64_1[VMSTATE_ARRAY_SIZE];
     uint64_t u64_2[VMSTATE_ARRAY_SIZE];
+    int16_t i16_1[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -560,6 +561,7 @@ TestArray obj_array = {
     .u32_2 = {25, 24, 23, 22, 21},
     .u64_1 = {31, 32, 33, 34, 35},
     .u64_2 = {35, 34, 33, 32, 31},
+    .i16_1 = {41, 42, 43, 44, 45},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -574,6 +576,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_UINT16_ARRAY(u16_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT32_ARRAY(u32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT64_ARRAY(u64_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_INT16_ARRAY(i16_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -591,6 +594,7 @@ uint8_t wire_array_primitive[] = {
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
+    /* i16_1 */ 0x00, 0x29, 0x00, 0x2a, 0x00, 0x2b, 0x00, 0x2c, 0x00, 0x2d,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -650,6 +654,7 @@ static void test_array_primitive(void)
         ELEM_ASSERT(u16_1, i);
         ELEM_ASSERT(u32_1, i);
         ELEM_ASSERT(u64_1, i);
+        ELEM_ASSERT(i16_1, i);
     }

     /* We save the file again.  We want the EOF this time */
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 37/97] vmstate: Test for VMSTATE_INT32_ARRAY{_TEST}
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (35 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 36/97] vmstate: Test for VMSTATE_INT16_ARRAY Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 38/97] vmstate: Test for VMSTATE_INT64_ARRAY Juan Quintela
                   ` (61 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Change only user of _V to _TEST.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/pci-host/piix.c          |  4 ++--
 include/migration/vmstate.h | 12 ++++++------
 tests/test-vmstate.c        | 18 ++++++++++++++++++
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index e0e0946..a6c6834 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -567,8 +567,8 @@ static const VMStateDescription vmstate_piix3 = {
     .pre_save = piix3_pre_save,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PIIX3State),
-        VMSTATE_INT32_ARRAY_V(pci_irq_levels_vmstate, PIIX3State,
-                              PIIX_NUM_PIRQS, 3),
+        VMSTATE_INT32_ARRAY_TEST(pci_irq_levels_vmstate, PIIX3State,
+                                 PIIX_NUM_PIRQS, vmstate_3_plus),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (VMStateSubsection[]) {
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 5e62206..20062ff 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -627,6 +627,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT16_ARRAY(_f, _s, _n)                               \
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_int16, int16_t)

+#define VMSTATE_INT32_ARRAY_TEST(_f, _s, _n, _t)                      \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_int32, int32_t)
+
+#define VMSTATE_INT32_ARRAY(_f, _s, _n)                               \
+    VMSTATE_INT32_ARRAY_TEST(_f, _s, _n, NULL)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

@@ -648,12 +654,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)

-#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v)                         \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t)
-
-#define VMSTATE_INT32_ARRAY(_f, _s, _n)                               \
-    VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index e800be0..348851d 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -548,6 +548,8 @@ typedef struct TestArray {
     uint64_t u64_1[VMSTATE_ARRAY_SIZE];
     uint64_t u64_2[VMSTATE_ARRAY_SIZE];
     int16_t i16_1[VMSTATE_ARRAY_SIZE];
+    int32_t i32_1[VMSTATE_ARRAY_SIZE];
+    int32_t i32_2[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -562,6 +564,8 @@ TestArray obj_array = {
     .u64_1 = {31, 32, 33, 34, 35},
     .u64_2 = {35, 34, 33, 32, 31},
     .i16_1 = {41, 42, 43, 44, 45},
+    .i32_1 = {51, 52, 53, 54, 55},
+    .i32_2 = {55, 54, 53, 52, 51},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -577,6 +581,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_UINT32_ARRAY(u32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT64_ARRAY(u64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_INT16_ARRAY(i16_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_INT32_ARRAY(i32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -595,6 +600,9 @@ uint8_t wire_array_primitive[] = {
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
     /* i16_1 */ 0x00, 0x29, 0x00, 0x2a, 0x00, 0x2b, 0x00, 0x2c, 0x00, 0x2d,
+    /* i32_1 */ 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34,
+                0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36,
+                0x00, 0x00, 0x00, 0x37,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -655,6 +663,7 @@ static void test_array_primitive(void)
         ELEM_ASSERT(u32_1, i);
         ELEM_ASSERT(u64_1, i);
         ELEM_ASSERT(i16_1, i);
+        ELEM_ASSERT(i32_1, i);
     }

     /* We save the file again.  We want the EOF this time */
@@ -689,6 +698,10 @@ static const VMStateDescription vmstate_array_test = {
                                   test_true),
         VMSTATE_UINT64_ARRAY_TEST(u64_2, TestArray, VMSTATE_ARRAY_SIZE,
                                   test_false),
+        VMSTATE_INT32_ARRAY_TEST(i32_1, TestArray, VMSTATE_ARRAY_SIZE,
+                                 test_true),
+        VMSTATE_INT32_ARRAY_TEST(i32_2, TestArray, VMSTATE_ARRAY_SIZE,
+                                 test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -704,6 +717,9 @@ uint8_t wire_array_test[] = {
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
+    /* i32_1 */ 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34,
+                0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36,
+                0x00, 0x00, 0x00, 0x37,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -757,6 +773,8 @@ static void test_array_test(void)
         ELEM_NOT_ASSERT(u32_2, i);
         ELEM_ASSERT(u64_1, i);
         ELEM_NOT_ASSERT(u64_2, i);
+        ELEM_ASSERT(i32_1, i);
+        ELEM_NOT_ASSERT(i32_2, i);
     }
 }
 #undef FIELD_ASSERT
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 38/97] vmstate: Test for VMSTATE_INT64_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (36 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 37/97] vmstate: Test for VMSTATE_INT32_ARRAY{_TEST} Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 39/97] vmstate: Test for VMSTATE_FLOAT64_ARRAY Juan Quintela
                   ` (60 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_INT64_ARRAY_V.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 9 +++------
 tests/test-vmstate.c        | 9 +++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 20062ff..35c7bef 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -633,6 +633,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_ARRAY(_f, _s, _n)                               \
     VMSTATE_INT32_ARRAY_TEST(_f, _s, _n, NULL)

+#define VMSTATE_INT64_ARRAY(_f, _s, _n)                               \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_int64, int64_t)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

@@ -657,12 +660,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)

-#define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v)                         \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t)
-
-#define VMSTATE_INT64_ARRAY(_f, _s, _n)                               \
-    VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, _v)                       \
     VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_float64, float64)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 348851d..d33fa77 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -550,6 +550,7 @@ typedef struct TestArray {
     int16_t i16_1[VMSTATE_ARRAY_SIZE];
     int32_t i32_1[VMSTATE_ARRAY_SIZE];
     int32_t i32_2[VMSTATE_ARRAY_SIZE];
+    int64_t i64_1[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -566,6 +567,7 @@ TestArray obj_array = {
     .i16_1 = {41, 42, 43, 44, 45},
     .i32_1 = {51, 52, 53, 54, 55},
     .i32_2 = {55, 54, 53, 52, 51},
+    .i64_1 = {61, 62, 63, 64, 65},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -582,6 +584,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_UINT64_ARRAY(u64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_INT16_ARRAY(i16_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_INT32_ARRAY(i32_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_INT64_ARRAY(i64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -603,6 +606,11 @@ uint8_t wire_array_primitive[] = {
     /* i32_1 */ 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34,
                 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36,
                 0x00, 0x00, 0x00, 0x37,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -664,6 +672,7 @@ static void test_array_primitive(void)
         ELEM_ASSERT(u64_1, i);
         ELEM_ASSERT(i16_1, i);
         ELEM_ASSERT(i32_1, i);
+        ELEM_ASSERT(i64_1, i);
     }

     /* We save the file again.  We want the EOF this time */
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 39/97] vmstate: Test for VMSTATE_FLOAT64_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (37 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 38/97] vmstate: Test for VMSTATE_INT64_ARRAY Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 40/97] vmstate: Test for VMSTATE_UINT8_2DARRAY Juan Quintela
                   ` (59 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_FLOAT64_ARRAY_V.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  9 +++------
 tests/test-vmstate.c        | 10 ++++++++++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 35c7bef..f925cc6 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -636,6 +636,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT64_ARRAY(_f, _s, _n)                               \
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_int64, int64_t)

+#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_float64, float64)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

@@ -660,12 +663,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)

-#define VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, _v)                       \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_float64, float64)
-
-#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
-    VMSTATE_FLOAT64_ARRAY_V(_f, _s, _n, 0)
-
 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
     VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index d33fa77..e64706f 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -551,6 +551,7 @@ typedef struct TestArray {
     int32_t i32_1[VMSTATE_ARRAY_SIZE];
     int32_t i32_2[VMSTATE_ARRAY_SIZE];
     int64_t i64_1[VMSTATE_ARRAY_SIZE];
+    float64 f64_1[VMSTATE_ARRAY_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -568,6 +569,8 @@ TestArray obj_array = {
     .i32_1 = {51, 52, 53, 54, 55},
     .i32_2 = {55, 54, 53, 52, 51},
     .i64_1 = {61, 62, 63, 64, 65},
+    .f64_1 = {float64_zero, float64_one, float64_ln2, float64_pi,
+              float64_infinity},
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -585,6 +588,7 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_INT16_ARRAY(i16_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_INT32_ARRAY(i32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_INT64_ARRAY(i64_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_FLOAT64_ARRAY(f64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -611,6 +615,11 @@ uint8_t wire_array_primitive[] = {
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41,
+    /* f64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x3f, 0xe6, 0x2e, 0x42, 0xfe, 0xfa, 0x39, 0xef,
+                0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,
+                0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -673,6 +682,7 @@ static void test_array_primitive(void)
         ELEM_ASSERT(i16_1, i);
         ELEM_ASSERT(i32_1, i);
         ELEM_ASSERT(i64_1, i);
+        ELEM_ASSERT(f64_1, i);
     }

     /* We save the file again.  We want the EOF this time */
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 40/97] vmstate: Test for VMSTATE_UINT8_2DARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (38 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 39/97] vmstate: Test for VMSTATE_FLOAT64_ARRAY Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 41/97] vmstate: Test for VMSTATE_UINT16_2DARRAY Juan Quintela
                   ` (58 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused _V version.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  9 +++------
 tests/test-vmstate.c        | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f925cc6..24f2bcf 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -639,21 +639,18 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_float64, float64)

+#define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
+    VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint8, uint8_t)
+
 #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)

 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0)

-#define VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, _v)                 \
-    VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint8, uint8_t)
-
 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)

-#define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
-    VMSTATE_UINT8_2DARRAY_V(_f, _s, _n1, _n2, 0)
-
 #define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index e64706f..e029960 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -535,6 +535,7 @@ static void test_simple_bitmap(void)
 #undef FIELD_ASSERT

 #define VMSTATE_ARRAY_SIZE 5
+#define VMSTATE_2D_SIZE 3

 typedef struct TestArray {
     int32_t  size;
@@ -552,6 +553,7 @@ typedef struct TestArray {
     int32_t i32_2[VMSTATE_ARRAY_SIZE];
     int64_t i64_1[VMSTATE_ARRAY_SIZE];
     float64 f64_1[VMSTATE_ARRAY_SIZE];
+    uint8_t u8_1d[VMSTATE_2D_SIZE][VMSTATE_2D_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -571,6 +573,9 @@ TestArray obj_array = {
     .i64_1 = {61, 62, 63, 64, 65},
     .f64_1 = {float64_zero, float64_one, float64_ln2, float64_pi,
               float64_infinity},
+    .u8_1d = { {71, 72, 73},
+               {74, 75, 76},
+               {77, 78, 79} },
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -589,6 +594,8 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_INT32_ARRAY(i32_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_INT64_ARRAY(i64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_FLOAT64_ARRAY(f64_1, TestArray, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT8_2DARRAY(u8_1d, TestArray, VMSTATE_2D_SIZE,
+                              VMSTATE_2D_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -620,13 +627,16 @@ uint8_t wire_array_primitive[] = {
                 0x3f, 0xe6, 0x2e, 0x42, 0xfe, 0xfa, 0x39, 0xef,
                 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,
                 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    /* u8_1d */ 0x47, 0x48, 0x49,
+                0x4a, 0x4b, 0x4c,
+                0x4d, 0x4e, 0x4f,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

 static void test_array_primitive(void)
 {
     QEMUFile *fsave = open_test_file(true);
-    int i;
+    int i, j;

     /* Save file with vmstate */
     vmstate_save_state(fsave, &vmstate_array_primitive, &obj_array);
@@ -668,6 +678,8 @@ static void test_array_primitive(void)
 #define FIELD_ASSERT(name)   g_assert_cmpint(obj.name, ==, obj_array.name)
 #define ELEM_ASSERT(name, i) \
     g_assert_cmpint(obj.name[i], ==, obj_array.name[i])
+#define ELEM_ASSERT_2D(name, i, j)                        \
+    g_assert_cmpint(obj.name[i][j], ==, obj_array.name[i][j])
 #define ELEM_NOT_ASSERT(name, i) \
     g_assert_cmpint(obj.name[i], !=, obj_array.name[i])

@@ -684,6 +696,11 @@ static void test_array_primitive(void)
         ELEM_ASSERT(i64_1, i);
         ELEM_ASSERT(f64_1, i);
     }
+    for (i = 0; i < VMSTATE_2D_SIZE; i++) {
+        for (j = 0; j < VMSTATE_2D_SIZE; j++) {
+            ELEM_ASSERT_2D(u8_1d, i, j);
+        }
+    }

     /* We save the file again.  We want the EOF this time */

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 41/97] vmstate: Test for VMSTATE_UINT16_2DARRAY.
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (39 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 40/97] vmstate: Test for VMSTATE_UINT8_2DARRAY Juan Quintela
@ 2014-04-07  3:20 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 42/97] vmstate: Test for VMSTATE_UINT32_2DARRAY Juan Quintela
                   ` (57 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:20 UTC (permalink / raw)
  To: qemu-devel

Remove unused _V version.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  5 +----
 tests/test-vmstate.c        | 10 ++++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 24f2bcf..14c905a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -642,11 +642,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint8, uint8_t)

-#define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
-    VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t)
-
 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2)                      \
-    VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0)
+    VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint16, uint16_t)

 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index e029960..d0f6d4b 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -554,6 +554,7 @@ typedef struct TestArray {
     int64_t i64_1[VMSTATE_ARRAY_SIZE];
     float64 f64_1[VMSTATE_ARRAY_SIZE];
     uint8_t u8_1d[VMSTATE_2D_SIZE][VMSTATE_2D_SIZE];
+    uint16_t u16_1d[VMSTATE_2D_SIZE][VMSTATE_2D_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -576,6 +577,9 @@ TestArray obj_array = {
     .u8_1d = { {71, 72, 73},
                {74, 75, 76},
                {77, 78, 79} },
+    .u16_1d = { {81, 82, 83},
+                {84, 85, 86},
+                {87, 88, 89} },
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -596,6 +600,8 @@ static const VMStateDescription vmstate_array_primitive = {
         VMSTATE_FLOAT64_ARRAY(f64_1, TestArray, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT8_2DARRAY(u8_1d, TestArray, VMSTATE_2D_SIZE,
                               VMSTATE_2D_SIZE),
+        VMSTATE_UINT16_2DARRAY(u16_1d, TestArray, VMSTATE_2D_SIZE,
+                               VMSTATE_2D_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -630,6 +636,9 @@ uint8_t wire_array_primitive[] = {
     /* u8_1d */ 0x47, 0x48, 0x49,
                 0x4a, 0x4b, 0x4c,
                 0x4d, 0x4e, 0x4f,
+    /* u16_1d */0x00, 0x51, 0x00, 0x52, 0x00, 0x53,
+                0x00, 0x54, 0x00, 0x55, 0x00, 0x56,
+                0x00, 0x57, 0x00, 0x58, 0x00, 0x59,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -699,6 +708,7 @@ static void test_array_primitive(void)
     for (i = 0; i < VMSTATE_2D_SIZE; i++) {
         for (j = 0; j < VMSTATE_2D_SIZE; j++) {
             ELEM_ASSERT_2D(u8_1d, i, j);
+            ELEM_ASSERT_2D(u16_1d, i, j);
         }
     }

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 42/97] vmstate: Test for VMSTATE_UINT32_2DARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (40 preceding siblings ...)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 41/97] vmstate: Test for VMSTATE_UINT16_2DARRAY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 43/97] vmstate: Remove unused VMSTATE_BUFFER_V Juan Quintela
                   ` (56 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Remove unused _V version.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |  9 +++------
 tests/test-vmstate.c        | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 14c905a..e7ceb59 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -645,15 +645,12 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2)                      \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint16, uint16_t)

+#define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
+    VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint32, uint32_t)
+
 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)

-#define VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v)                \
-    VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint32, uint32_t)
-
-#define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
-    VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0)
-
 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index d0f6d4b..f51c887 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -555,6 +555,7 @@ typedef struct TestArray {
     float64 f64_1[VMSTATE_ARRAY_SIZE];
     uint8_t u8_1d[VMSTATE_2D_SIZE][VMSTATE_2D_SIZE];
     uint16_t u16_1d[VMSTATE_2D_SIZE][VMSTATE_2D_SIZE];
+    uint32_t u32_1d[VMSTATE_2D_SIZE][VMSTATE_2D_SIZE];
 } TestArray;

 TestArray obj_array = {
@@ -580,6 +581,9 @@ TestArray obj_array = {
     .u16_1d = { {81, 82, 83},
                 {84, 85, 86},
                 {87, 88, 89} },
+    .u32_1d = { {91, 92, 93},
+                {94, 95, 96},
+                {97, 98, 99} },
 };

 static const VMStateDescription vmstate_array_primitive = {
@@ -602,6 +606,8 @@ static const VMStateDescription vmstate_array_primitive = {
                               VMSTATE_2D_SIZE),
         VMSTATE_UINT16_2DARRAY(u16_1d, TestArray, VMSTATE_2D_SIZE,
                                VMSTATE_2D_SIZE),
+        VMSTATE_UINT32_2DARRAY(u32_1d, TestArray, VMSTATE_2D_SIZE,
+                               VMSTATE_2D_SIZE),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -639,6 +645,15 @@ uint8_t wire_array_primitive[] = {
     /* u16_1d */0x00, 0x51, 0x00, 0x52, 0x00, 0x53,
                 0x00, 0x54, 0x00, 0x55, 0x00, 0x56,
                 0x00, 0x57, 0x00, 0x58, 0x00, 0x59,
+    /* u16_1d */0x00, 0x00, 0x00, 0x5b,
+                0x00, 0x00, 0x00, 0x5c,
+                0x00, 0x00, 0x00, 0x5d,
+                0x00, 0x00, 0x00, 0x5e,
+                0x00, 0x00, 0x00, 0x5f,
+                0x00, 0x00, 0x00, 0x60,
+                0x00, 0x00, 0x00, 0x61,
+                0x00, 0x00, 0x00, 0x62,
+                0x00, 0x00, 0x00, 0x63,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -709,6 +724,7 @@ static void test_array_primitive(void)
         for (j = 0; j < VMSTATE_2D_SIZE; j++) {
             ELEM_ASSERT_2D(u8_1d, i, j);
             ELEM_ASSERT_2D(u16_1d, i, j);
+            ELEM_ASSERT_2D(u32_1d, i, j);
         }
     }

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 43/97] vmstate: Remove unused VMSTATE_BUFFER_V
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (41 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 42/97] vmstate: Test for VMSTATE_UINT32_2DARRAY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 44/97] vmstate: Remove version from VMSTATE_BUFFER_UNSAFE Juan Quintela
                   ` (55 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index e7ceb59..fbf7dbe 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -654,11 +654,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)

-#define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
-    VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
-
 #define VMSTATE_BUFFER(_f, _s)                                        \
-    VMSTATE_BUFFER_V(_f, _s, 0)
+    VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, sizeof(typeof_field(_s, _f)))

 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size)                         \
     VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 44/97] vmstate: Remove version from VMSTATE_BUFFER_UNSAFE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (42 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 43/97] vmstate: Remove unused VMSTATE_BUFFER_V Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 45/97] vmstate: Remove unused version fields from ARM Juan Quintela
                   ` (54 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

All users used 0 anyways.  Rename VMSTATE_BUFFER_UNSAFE_INFO to
VMSTATE_BUFFER_UNSAFE_TEST to be consistent with rest of fields.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/display/g364fb.c         |  4 ++--
 hw/net/smc91c111.c          |  2 +-
 hw/pci/pci.c                | 10 ++++++----
 hw/scsi/esp-pci.c           |  2 +-
 hw/scsi/lsi53c895a.c        |  4 ++--
 include/hw/pci/shpc.h       |  2 +-
 include/migration/vmstate.h | 18 +++++++++---------
 7 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 46f7b41..9f6717e 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -462,8 +462,8 @@ static const VMStateDescription vmstate_g364fb = {
     .post_load = g364fb_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(vram, G364State, 1, NULL, 0, vram_size),
-        VMSTATE_BUFFER_UNSAFE(color_palette, G364State, 0, 256 * 3),
-        VMSTATE_BUFFER_UNSAFE(cursor_palette, G364State, 0, 9),
+        VMSTATE_BUFFER_UNSAFE(color_palette, G364State, 256 * 3),
+        VMSTATE_BUFFER_UNSAFE(cursor_palette, G364State, 9),
         VMSTATE_UINT16_ARRAY(cursor, G364State, 512),
         VMSTATE_UINT32(cursor_position, G364State),
         VMSTATE_UINT32(ctla, G364State),
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index d1dca8f..e74142e 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -72,7 +72,7 @@ static const VMStateDescription vmstate_smc91c111 = {
         VMSTATE_INT32_ARRAY(rx_fifo, smc91c111_state, NUM_PACKETS),
         VMSTATE_INT32(tx_fifo_done_len, smc91c111_state),
         VMSTATE_INT32_ARRAY(tx_fifo_done, smc91c111_state, NUM_PACKETS),
-        VMSTATE_BUFFER_UNSAFE(data, smc91c111_state, 0, NUM_PACKETS * 2048),
+        VMSTATE_BUFFER_UNSAFE(data, smc91c111_state, NUM_PACKETS * 2048),
         VMSTATE_UINT8(int_level, smc91c111_state),
         VMSTATE_UINT8(int_mask, smc91c111_state),
         VMSTATE_END_OF_LIST()
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 2ba6b30..828df53 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -474,10 +474,11 @@ const VMStateDescription vmstate_pci_device = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
+        VMSTATE_BUFFER_UNSAFE_TEST(config, PCIDevice, NULL,
                                    vmstate_info_pci_config,
                                    PCI_CONFIG_SPACE_SIZE),
-        VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
+        VMSTATE_BUFFER_UNSAFE_TEST(irq_state, PCIDevice,
+                                   vmstate_2_plus,
 				   vmstate_info_pci_irq_state,
 				   PCI_NUM_PINS * sizeof(int32_t)),
         VMSTATE_END_OF_LIST()
@@ -490,10 +491,11 @@ const VMStateDescription vmstate_pcie_device = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
+        VMSTATE_BUFFER_UNSAFE_TEST(config, PCIDevice, NULL,
                                    vmstate_info_pci_config,
                                    PCIE_CONFIG_SPACE_SIZE),
-        VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
+        VMSTATE_BUFFER_UNSAFE_TEST(irq_state, PCIDevice,
+                                   vmstate_2_plus,
 				   vmstate_info_pci_irq_state,
 				   PCI_NUM_PINS * sizeof(int32_t)),
         VMSTATE_END_OF_LIST()
diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 9971bbf..e592d81 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -312,7 +312,7 @@ static const VMStateDescription vmstate_esp_pci_scsi = {
     .minimum_version_id = 0,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIESPState),
-        VMSTATE_BUFFER_UNSAFE(dma_regs, PCIESPState, 0, 8 * sizeof(uint32_t)),
+        VMSTATE_BUFFER_UNSAFE(dma_regs, PCIESPState, 8 * sizeof(uint32_t)),
         VMSTATE_STRUCT(esp, PCIESPState, 0, vmstate_esp, ESPState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 786d848..4f9bf29 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -2064,10 +2064,10 @@ static const VMStateDescription vmstate_lsi_scsi = {
         VMSTATE_UINT32(ia, LSIState),
         VMSTATE_UINT32(sbc, LSIState),
         VMSTATE_UINT32(csbc, LSIState),
-        VMSTATE_BUFFER_UNSAFE(scratch, LSIState, 0, 18 * sizeof(uint32_t)),
+        VMSTATE_BUFFER_UNSAFE(scratch, LSIState, 18 * sizeof(uint32_t)),
         VMSTATE_UINT8(sbr, LSIState),

-        VMSTATE_BUFFER_UNSAFE(script_ram, LSIState, 0, 2048 * sizeof(uint32_t)),
+        VMSTATE_BUFFER_UNSAFE(script_ram, LSIState, 2048 * sizeof(uint32_t)),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h
index eef1a1a..5925100 100644
--- a/include/hw/pci/shpc.h
+++ b/include/hw/pci/shpc.h
@@ -51,6 +51,6 @@ void shpc_device_hot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,

 extern VMStateInfo shpc_vmstate_info;
 #define SHPC_VMSTATE(_field, _type) \
-    VMSTATE_BUFFER_UNSAFE_INFO(_field, _type, 0, shpc_vmstate_info, 0)
+    VMSTATE_BUFFER_UNSAFE_TEST(_field, _type, 0, shpc_vmstate_info, 0)

 #endif
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index fbf7dbe..3f2084b 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -464,13 +464,13 @@ extern const VMStateInfo vmstate_info_bitmap;
     .start        = (_start),                                        \
 }

-#define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
-    .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
-    .size       = (_size),                                           \
-    .info       = &(_info),                                          \
-    .flags      = VMS_BUFFER,                                        \
-    .offset     = offsetof(_state, _field),                          \
+#define VMSTATE_BUFFER_UNSAFE_TEST(_field, _state, _test, _info, _size) { \
+    .name         = (stringify(_field)),                             \
+    .field_exists = (_test),                                         \
+    .size         = (_size),                                         \
+    .info         = &(_info),                                        \
+    .flags        = VMS_BUFFER,                                      \
+    .offset       = offsetof(_state, _field),                        \
 }

 #define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \
@@ -675,8 +675,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_BUFFER_TEST(_f, _s, _test)                            \
     VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))

-#define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size)        \
-    VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
+#define VMSTATE_BUFFER_UNSAFE(_field, _state,  _size)                 \
+    VMSTATE_BUFFER_UNSAFE_TEST(_field, _state, NULL, vmstate_info_buffer, _size)

 #define VMSTATE_UNUSED(_size)                                         \
     VMSTATE_UNUSED_TEST(NULL, _size)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 45/97] vmstate: Remove unused version fields from ARM
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (43 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 44/97] vmstate: Remove version from VMSTATE_BUFFER_UNSAFE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 46/97] vmstate: All ptimers users were at least at version 1 or more Juan Quintela
                   ` (53 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 target-ppc/machine.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/target-ppc/machine.c b/target-ppc/machine.c
index d7807f8..4540fe2 100644
--- a/target-ppc/machine.c
+++ b/target-ppc/machine.c
@@ -120,11 +120,8 @@ static const VMStateInfo vmstate_info_avr = {
     .put  = put_avr,
 };

-#define VMSTATE_AVR_ARRAY_V(_f, _s, _n, _v)                       \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_avr, ppc_avr_t)
-
-#define VMSTATE_AVR_ARRAY(_f, _s, _n)                             \
-    VMSTATE_AVR_ARRAY_V(_f, _s, _n, 0)
+#define VMSTATE_AVR_ARRAY(_f, _s, _n)                                 \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_avr, ppc_avr_t)

 static void cpu_pre_save(void *opaque)
 {
@@ -290,11 +287,8 @@ static const VMStateInfo vmstate_info_slbe = {
     .put  = put_slbe,
 };

-#define VMSTATE_SLB_ARRAY_V(_f, _s, _n, _v)                       \
-    VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_slbe, ppc_slb_t)
-
-#define VMSTATE_SLB_ARRAY(_f, _s, _n)                             \
-    VMSTATE_SLB_ARRAY_V(_f, _s, _n, 0)
+#define VMSTATE_SLB_ARRAY(_f, _s, _n)                                 \
+    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_slbe, ppc_slb_t)

 static bool slb_needed(void *opaque)
 {
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 46/97] vmstate: All ptimers users were at least at version 1 or more
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (44 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 45/97] vmstate: Remove unused version fields from ARM Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 47/97] vmstate: remove version from all variants of VMSTATE_STRUCT_POINTER* Juan Quintela
                   ` (52 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

So we can remove the version field.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/hw/ptimer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h
index 8ebacbb..ef852bf 100644
--- a/include/hw/ptimer.h
+++ b/include/hw/ptimer.h
@@ -28,7 +28,7 @@ void ptimer_stop(ptimer_state *s);
 extern const VMStateDescription vmstate_ptimer;

 #define VMSTATE_PTIMER(_field, _state) \
-    VMSTATE_STRUCT_POINTER_V(_field, _state, 1, vmstate_ptimer, ptimer_state)
+    VMSTATE_STRUCT_POINTER(_field, _state, vmstate_ptimer, ptimer_state)

 #define VMSTATE_PTIMER_ARRAY(_f, _s, _n)                                \
     VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, 0,                   \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 47/97] vmstate: remove version from all variants of VMSTATE_STRUCT_POINTER*
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (45 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 46/97] vmstate: All ptimers users were at least at version 1 or more Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 48/97] vmstate: Port last 3 users of VMSTATE_ARRAY to VMSTATE_ARRAY_TEST Juan Quintela
                   ` (51 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

There were no more users of them.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 3f2084b..61d677e 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -310,18 +310,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_value(_state, _field, _type),     \
 }

-#define VMSTATE_STRUCT_POINTER_V(_field, _state, _version, _vmsd, _type) { \
+#define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \
     .name         = (stringify(_field)),                             \
-    .version_id   = (_version),                                        \
-    .vmsd         = &(_vmsd),                                        \
-    .size         = sizeof(_type *),                                 \
-    .flags        = VMS_STRUCT|VMS_POINTER,                          \
-    .offset       = vmstate_offset_pointer(_state, _field, _type),   \
-}
-
-#define VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, _version, _vmsd, _type) { \
-    .name         = (stringify(_field)),                             \
-    .version_id   = (_version),                                        \
     .field_exists = (_test),                                         \
     .vmsd         = &(_vmsd),                                        \
     .size         = sizeof(_type *),                                 \
@@ -516,10 +506,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)

 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type)          \
-    VMSTATE_STRUCT_POINTER_V(_field, _state, 0, _vmsd, _type)
-
-#define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type)     \
-    VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, 0, _vmsd, _type)
+    VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)

 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
     VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version,   \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 48/97] vmstate: Port last 3 users of VMSTATE_ARRAY to VMSTATE_ARRAY_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (46 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 47/97] vmstate: remove version from all variants of VMSTATE_STRUCT_POINTER* Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 49/97] vmstate: Port last user of VMSTATE_SINGLE to VMSTATE_SINGLE_TEST Juan Quintela
                   ` (50 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

And then remove VMSTATE_ARRAY.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/net/vmxnet3.c            | 13 +++++++------
 include/migration/vmstate.h | 10 ----------
 2 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 781b06a..0c4d055 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2405,14 +2405,15 @@ static const VMStateDescription vmstate_vmxnet3 = {
             VMSTATE_UINT64(drv_shmem, VMXNET3State),
             VMSTATE_UINT64(temp_shared_guest_driver_memory, VMXNET3State),

-            VMSTATE_ARRAY(txq_descr, VMXNET3State,
-                VMXNET3_DEVICE_MAX_TX_QUEUES, 0, txq_descr_info,
+            VMSTATE_ARRAY_TEST(txq_descr, VMXNET3State,
+                VMXNET3_DEVICE_MAX_TX_QUEUES, NULL, txq_descr_info,
                 Vmxnet3TxqDescr),
-            VMSTATE_ARRAY(rxq_descr, VMXNET3State,
-                VMXNET3_DEVICE_MAX_RX_QUEUES, 0, rxq_descr_info,
+            VMSTATE_ARRAY_TEST(rxq_descr, VMXNET3State,
+                VMXNET3_DEVICE_MAX_RX_QUEUES, NULL, rxq_descr_info,
                 Vmxnet3RxqDescr),
-            VMSTATE_ARRAY(interrupt_states, VMXNET3State, VMXNET3_MAX_INTRS,
-                0, int_state_info, Vmxnet3IntState),
+            VMSTATE_ARRAY_TEST(interrupt_states, VMXNET3State,
+                VMXNET3_MAX_INTRS, NULL, int_state_info,
+                Vmxnet3IntState),

             VMSTATE_END_OF_LIST()
     },
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 61d677e..b98527c 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -221,16 +221,6 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_value(_state, _field, _type),       \
 }

-#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\
-    .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
-    .num        = (_num),                                            \
-    .info       = &(_info),                                          \
-    .size       = sizeof(_type),                                     \
-    .flags      = VMS_ARRAY,                                         \
-    .offset     = vmstate_offset_array(_state, _field, _type, _num), \
-}
-
 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _version, _info, _type) { \
     .name       = (stringify(_field)),                                      \
     .version_id = (_version),                                               \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 49/97] vmstate: Port last user of VMSTATE_SINGLE to VMSTATE_SINGLE_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (47 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 48/97] vmstate: Port last 3 users of VMSTATE_ARRAY to VMSTATE_ARRAY_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 50/97] vmstate: Remove unused VMSTATE_POINTER Juan Quintela
                   ` (49 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/timer/twl92230.c         | 2 +-
 include/migration/vmstate.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index 7ded4ba..3aacaeb 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -765,7 +765,7 @@ static const VMStateInfo vmstate_hack_int32_as_uint16 = {
 };

 #define VMSTATE_UINT16_HACK(_f, _s)                                  \
-    VMSTATE_SINGLE(_f, _s, 0, vmstate_hack_int32_as_uint16, int32_t)
+    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_hack_int32_as_uint16, int32_t)


 static const VMStateDescription vmstate_menelaus_tm = {
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index b98527c..c9e72bb 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -489,9 +489,6 @@ extern const VMStateInfo vmstate_info_bitmap;
    _v : version
 */

-#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)

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 50/97] vmstate: Remove unused VMSTATE_POINTER
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (48 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 49/97] vmstate: Port last user of VMSTATE_SINGLE to VMSTATE_SINGLE_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 51/97] vmstate: Rename VMSTATE_SINGLE_TEST to VMSTATE_SINGLE Juan Quintela
                   ` (48 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index c9e72bb..141187c 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -203,15 +203,6 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_value(_state, _field, _type),     \
 }

-#define VMSTATE_POINTER(_field, _state, _version, _info, _type) {    \
-    .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
-    .info       = &(_info),                                          \
-    .size       = sizeof(_type),                                     \
-    .flags      = VMS_SINGLE|VMS_POINTER,                            \
-    .offset     = vmstate_offset_value(_state, _field, _type),       \
-}
-
 #define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) {  \
     .name       = (stringify(_field)),                               \
     .info       = &(_info),                                          \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 51/97] vmstate: Rename VMSTATE_SINGLE_TEST to VMSTATE_SINGLE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (49 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 50/97] vmstate: Remove unused VMSTATE_POINTER Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 52/97] vmstate: Move VMSTATE_2DARRAY to use _test Juan Quintela
                   ` (47 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

And as no user used the version_id, just remove the parameter.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/nvram/eeprom93xx.c       |  2 +-
 hw/nvram/fw_cfg.c           |  2 +-
 hw/timer/twl92230.c         |  2 +-
 include/migration/vmstate.h | 36 +++++++++++++++++-------------------
 target-i386/machine.c       |  2 +-
 5 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
index d07bafb..7e09037 100644
--- a/hw/nvram/eeprom93xx.c
+++ b/hw/nvram/eeprom93xx.c
@@ -114,7 +114,7 @@ static const VMStateInfo vmstate_hack_uint16_from_uint8 = {
 };

 #define VMSTATE_UINT16_HACK_TEST(_f, _s, _t)                           \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint16_from_uint8, uint16_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_hack_uint16_from_uint8, uint16_t)

 static bool is_old_eeprom_version(void *opaque, int version_id)
 {
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 8ea3ac8..97218c7 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -365,7 +365,7 @@ static const VMStateInfo vmstate_hack_uint32_as_uint16 = {
 };

 #define VMSTATE_UINT16_HACK(_f, _s, _t)                                    \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint32_as_uint16, uint32_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_hack_uint32_as_uint16, uint32_t)


 static bool is_version_1(void *opaque, int version_id)
diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index 3aacaeb..26c6001 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -765,7 +765,7 @@ static const VMStateInfo vmstate_hack_int32_as_uint16 = {
 };

 #define VMSTATE_UINT16_HACK(_f, _s)                                  \
-    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_hack_int32_as_uint16, int32_t)
+    VMSTATE_SINGLE(_f, _s, NULL, vmstate_hack_int32_as_uint16, int32_t)


 static const VMStateDescription vmstate_menelaus_tm = {
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 141187c..6d5073a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -193,9 +193,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     vmstate_offset_array(_state, _field, uint8_t,                    \
                          sizeof(typeof_field(_state, _field)))

-#define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \
+#define VMSTATE_SINGLE(_field, _state, _test, _info, _type) {        \
     .name         = (stringify(_field)),                             \
-    .version_id   = (_version),                                      \
     .field_exists = (_test),                                         \
     .size         = sizeof(_type),                                   \
     .info         = &(_info),                                        \
@@ -491,25 +490,24 @@ extern const VMStateInfo vmstate_info_bitmap;
             _vmsd, _type)

 #define VMSTATE_BOOL_TEST(_f, _s, _t)                                 \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_bool, bool)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_bool, bool)

 #define VMSTATE_INT8_TEST(_f, _s, _t)                                 \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int8, int8_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_int8, int8_t)
 #define VMSTATE_INT16_TEST(_f, _s, _t)                                \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int16, int16_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_int16, int16_t)
 #define VMSTATE_INT32_TEST(_f, _s, _t)                                \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int32, int32_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_int32, int32_t)
 #define VMSTATE_INT64_TEST(_f, _s, _t)                                \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int64, int64_t)
-
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_int64, int64_t)
 #define VMSTATE_UINT8_TEST(_f, _s, _t)                                \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_uint8, uint8_t)
 #define VMSTATE_UINT16_TEST(_f, _s, _t)                               \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_uint16, uint16_t)
 #define VMSTATE_UINT32_TEST(_f, _s, _t)                               \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_uint32, uint32_t)
 #define VMSTATE_UINT64_TEST(_f, _s, _t)                               \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_uint64, uint64_t)

 #define VMSTATE_BOOL(_f, _s)                                          \
     VMSTATE_BOOL_TEST(_f, _s, NULL)
@@ -533,28 +531,28 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_UINT64_TEST(_f, _s, NULL)

 #define VMSTATE_UINT8_EQUAL(_f, _s)                                   \
-    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint8_equal, uint8_t)
+    VMSTATE_SINGLE(_f, _s, NULL, vmstate_info_uint8_equal, uint8_t)

 #define VMSTATE_UINT16_EQUAL_TEST(_f, _s, _t)                         \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16_equal, uint16_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_info_uint16_equal, uint16_t)

 #define VMSTATE_UINT16_EQUAL(_f, _s)                                  \
     VMSTATE_UINT16_EQUAL_TEST(_f, _s, NULL)

 #define VMSTATE_UINT32_EQUAL(_f, _s)                                  \
-    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint32_equal, uint32_t)
+    VMSTATE_SINGLE(_f, _s, NULL, vmstate_info_uint32_equal, uint32_t)

 #define VMSTATE_UINT64_EQUAL(_f, _s)                                  \
-    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_uint64_equal, uint64_t)
+    VMSTATE_SINGLE(_f, _s, NULL, vmstate_info_uint64_equal, uint64_t)

 #define VMSTATE_INT32_EQUAL(_f, _s)                                   \
-    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_equal, int32_t)
+    VMSTATE_SINGLE(_f, _s, NULL, vmstate_info_int32_equal, int32_t)

 #define VMSTATE_INT32_POSITIVE_LE(_f, _s)                             \
-    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_le, int32_t)
+    VMSTATE_SINGLE(_f, _s, NULL, vmstate_info_int32_le, int32_t)

 #define VMSTATE_FLOAT64(_f, _s)                                       \
-    VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_float64, float64)
+    VMSTATE_SINGLE(_f, _s, NULL, vmstate_info_float64, float64)

 #define VMSTATE_TIMER_TEST(_f, _s, _test)                             \
     VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 1b8e3c4..8e4a518 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -245,7 +245,7 @@ static const VMStateInfo vmstate_hack_uint64_as_uint32 = {
 };

 #define VMSTATE_HACK_UINT32(_f, _s, _t)                                  \
-    VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint64_as_uint32, uint64_t)
+    VMSTATE_SINGLE(_f, _s, _t, vmstate_hack_uint64_as_uint32, uint64_t)
 #endif

 static void cpu_pre_save(void *opaque)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 52/97] vmstate: Move VMSTATE_2DARRAY to use _test
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (50 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 51/97] vmstate: Rename VMSTATE_SINGLE_TEST to VMSTATE_SINGLE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 53/97] vmstate: Rename VMSTATE_POINTER_TEST without _TEST Juan Quintela
                   ` (46 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

No user used versions, so easy to change.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 6d5073a..db70163 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -211,14 +211,14 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_value(_state, _field, _type),       \
 }

-#define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _version, _info, _type) { \
-    .name       = (stringify(_field)),                                      \
-    .version_id = (_version),                                               \
-    .num        = (_n1) * (_n2),                                            \
-    .info       = &(_info),                                                 \
-    .size       = sizeof(_type),                                            \
-    .flags      = VMS_ARRAY,                                                \
-    .offset     = vmstate_offset_2darray(_state, _field, _type, _n1, _n2),  \
+#define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _test, _info, _type) { \
+    .name         = (stringify(_field)),                                      \
+    .field_exists = (_test),                                                  \
+    .num          = (_n1) * (_n2),                                            \
+    .info         = &(_info),                                                 \
+    .size         = sizeof(_type),                                            \
+    .flags        = VMS_ARRAY,                                                \
+    .offset       = vmstate_offset_2darray(_state, _field, _type, _n1, _n2),  \
 }

 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
@@ -603,13 +603,13 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_float64, float64)

 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
-    VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint8, uint8_t)
+    VMSTATE_2DARRAY(_f, _s, _n1, _n2, NULL, vmstate_info_uint8, uint8_t)

 #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2)                      \
-    VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint16, uint16_t)
+    VMSTATE_2DARRAY(_f, _s, _n1, _n2, NULL, vmstate_info_uint16, uint16_t)

 #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2)                      \
-    VMSTATE_2DARRAY(_f, _s, _n1, _n2, 0, vmstate_info_uint32, uint32_t)
+    VMSTATE_2DARRAY(_f, _s, _n1, _n2, NULL, vmstate_info_uint32, uint32_t)

 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 53/97] vmstate: Rename VMSTATE_POINTER_TEST without _TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (51 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 52/97] vmstate: Move VMSTATE_2DARRAY to use _test Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 54/97] vmstate: Rename VMSTATE_ARRAY_TEST to VMSTATE_ARRAY Juan Quintela
                   ` (45 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

The other didn't exist anymore.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index db70163..8dac300 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -202,13 +202,13 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_value(_state, _field, _type),     \
 }

-#define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) {  \
-    .name       = (stringify(_field)),                               \
-    .info       = &(_info),                                          \
+#define VMSTATE_POINTER(_field, _state, _test, _info, _type) {  \
+    .name         = (stringify(_field)),                             \
+    .info         = &(_info),                                        \
     .field_exists = (_test),                                         \
-    .size       = sizeof(_type),                                     \
-    .flags      = VMS_SINGLE|VMS_POINTER,                            \
-    .offset     = vmstate_offset_value(_state, _field, _type),       \
+    .size         = sizeof(_type),                                   \
+    .flags        = VMS_SINGLE|VMS_POINTER,                          \
+    .offset       = vmstate_offset_value(_state, _field, _type),     \
 }

 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _test, _info, _type) { \
@@ -555,7 +555,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE(_f, _s, NULL, vmstate_info_float64, float64)

 #define VMSTATE_TIMER_TEST(_f, _s, _test)                             \
-    VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *)
+    VMSTATE_POINTER(_f, _s, _test, vmstate_info_timer, QEMUTimer*)

 #define VMSTATE_TIMER(_f, _s)                                         \
     VMSTATE_TIMER_TEST(_f, _s, NULL)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 54/97] vmstate: Rename VMSTATE_ARRAY_TEST to VMSTATE_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (52 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 53/97] vmstate: Rename VMSTATE_POINTER_TEST without _TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 55/97] vmstate: Remove version_id from VMSTATE_VBUFFER Juan Quintela
                   ` (44 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

VMSTATE_ARRAY is not being used anymore.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/net/vmxnet3.c            |  9 ++++-----
 include/migration/vmstate.h | 20 ++++++++++----------
 target-i386/machine.c       |  6 +++---
 target-ppc/machine.c        |  4 ++--
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 0c4d055..4140f9f 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2405,15 +2405,14 @@ static const VMStateDescription vmstate_vmxnet3 = {
             VMSTATE_UINT64(drv_shmem, VMXNET3State),
             VMSTATE_UINT64(temp_shared_guest_driver_memory, VMXNET3State),

-            VMSTATE_ARRAY_TEST(txq_descr, VMXNET3State,
+            VMSTATE_ARRAY(txq_descr, VMXNET3State,
                 VMXNET3_DEVICE_MAX_TX_QUEUES, NULL, txq_descr_info,
                 Vmxnet3TxqDescr),
-            VMSTATE_ARRAY_TEST(rxq_descr, VMXNET3State,
+            VMSTATE_ARRAY(rxq_descr, VMXNET3State,
                 VMXNET3_DEVICE_MAX_RX_QUEUES, NULL, rxq_descr_info,
                 Vmxnet3RxqDescr),
-            VMSTATE_ARRAY_TEST(interrupt_states, VMXNET3State,
-                VMXNET3_MAX_INTRS, NULL, int_state_info,
-                Vmxnet3IntState),
+            VMSTATE_ARRAY(interrupt_states, VMXNET3State, VMXNET3_MAX_INTRS,
+                NULL, int_state_info, Vmxnet3IntState),

             VMSTATE_END_OF_LIST()
     },
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 8dac300..2a38743 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -221,7 +221,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_2darray(_state, _field, _type, _n1, _n2),  \
 }

-#define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
+#define VMSTATE_ARRAY(_field, _state, _num, _test, _info, _type) {\
     .name         = (stringify(_field)),                              \
     .field_exists = (_test),                                          \
     .num          = (_num),                                           \
@@ -564,43 +564,43 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)

 #define VMSTATE_BOOL_ARRAY_TEST(_f, _s, _n, _t)                       \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_bool, bool)
+    VMSTATE_ARRAY(_f, _s, _n, _t, vmstate_info_bool, bool)

 #define VMSTATE_BOOL_ARRAY(_f, _s, _n)                                \
     VMSTATE_BOOL_ARRAY_TEST(_f, _s, _n, NULL)

 #define VMSTATE_UINT8_ARRAY(_f, _s, _n)                               \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint8, uint8_t)
+    VMSTATE_ARRAY(_f, _s, _n, NULL, vmstate_info_uint8, uint8_t)

 #define VMSTATE_UINT16_ARRAY(_f, _s, _n)                              \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_uint16, uint16_t)
+    VMSTATE_ARRAY(_f, _s, _n, NULL, vmstate_info_uint16, uint16_t)

 #define VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, _t)                     \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_uint32, uint32_t)
+    VMSTATE_ARRAY(_f, _s, _n, _t, vmstate_info_uint32, uint32_t)

 #define VMSTATE_UINT32_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINT32_ARRAY_TEST(_f, _s, _n, NULL)

 #define VMSTATE_UINT64_ARRAY_TEST(_f, _s, _n, _t)                     \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_uint64, uint64_t)
+    VMSTATE_ARRAY(_f, _s, _n, _t, vmstate_info_uint64, uint64_t)

 #define VMSTATE_UINT64_ARRAY(_f, _s, _n)                              \
     VMSTATE_UINT64_ARRAY_TEST(_f, _s, _n, NULL)

 #define VMSTATE_INT16_ARRAY(_f, _s, _n)                               \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_int16, int16_t)
+    VMSTATE_ARRAY(_f, _s, _n, NULL, vmstate_info_int16, int16_t)

 #define VMSTATE_INT32_ARRAY_TEST(_f, _s, _n, _t)                      \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_int32, int32_t)
+    VMSTATE_ARRAY(_f, _s, _n, _t, vmstate_info_int32, int32_t)

 #define VMSTATE_INT32_ARRAY(_f, _s, _n)                               \
     VMSTATE_INT32_ARRAY_TEST(_f, _s, _n, NULL)

 #define VMSTATE_INT64_ARRAY(_f, _s, _n)                               \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_int64, int64_t)
+    VMSTATE_ARRAY(_f, _s, _n, NULL, vmstate_info_int64, int64_t)

 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_float64, float64)
+    VMSTATE_ARRAY(_f, _s, _n, NULL, vmstate_info_float64, float64)

 #define VMSTATE_UINT8_2DARRAY(_f, _s, _n1, _n2)                       \
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, NULL, vmstate_info_uint8, uint8_t)
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 8e4a518..09c1f50 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -210,9 +210,9 @@ static bool fpregs_is_1_no_mmx(void *opaque, int version_id)
 }

 #define VMSTATE_FP_REGS(_field, _state, _n)                               \
-    VMSTATE_ARRAY_TEST(_field, _state, _n, fpregs_is_0, vmstate_fpreg, FPReg), \
-    VMSTATE_ARRAY_TEST(_field, _state, _n, fpregs_is_1_mmx, vmstate_fpreg_1_mmx, FPReg), \
-    VMSTATE_ARRAY_TEST(_field, _state, _n, fpregs_is_1_no_mmx, vmstate_fpreg_1_no_mmx, FPReg)
+    VMSTATE_ARRAY(_field, _state, _n, fpregs_is_0, vmstate_fpreg, FPReg), \
+    VMSTATE_ARRAY(_field, _state, _n, fpregs_is_1_mmx, vmstate_fpreg_1_mmx, FPReg), \
+    VMSTATE_ARRAY(_field, _state, _n, fpregs_is_1_no_mmx, vmstate_fpreg_1_no_mmx, FPReg)

 static bool version_is_5(void *opaque, int version_id)
 {
diff --git a/target-ppc/machine.c b/target-ppc/machine.c
index 4540fe2..8ec6580 100644
--- a/target-ppc/machine.c
+++ b/target-ppc/machine.c
@@ -121,7 +121,7 @@ static const VMStateInfo vmstate_info_avr = {
 };

 #define VMSTATE_AVR_ARRAY(_f, _s, _n)                                 \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_avr, ppc_avr_t)
+    VMSTATE_ARRAY(_f, _s, _n, NULL, vmstate_info_avr, ppc_avr_t)

 static void cpu_pre_save(void *opaque)
 {
@@ -288,7 +288,7 @@ static const VMStateInfo vmstate_info_slbe = {
 };

 #define VMSTATE_SLB_ARRAY(_f, _s, _n)                                 \
-    VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_slbe, ppc_slb_t)
+    VMSTATE_ARRAY(_f, _s, _n, NULL, vmstate_info_slbe, ppc_slb_t)

 static bool slb_needed(void *opaque)
 {
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 55/97] vmstate: Remove version_id from VMSTATE_VBUFFER
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (53 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 54/97] vmstate: Rename VMSTATE_ARRAY_TEST to VMSTATE_ARRAY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 56/97] vmstate: Remove version_id fields that were not used Juan Quintela
                   ` (43 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

None of its two users use it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 2a38743..553c909 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -412,9 +412,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .start        = (_start),                                        \
 }

-#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \
+#define VMSTATE_VBUFFER(_field, _state, _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,                            \
@@ -627,13 +626,13 @@ extern const VMStateInfo vmstate_info_bitmap;
     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)
+    VMSTATE_VBUFFER(_f, _s, NULL, 0, _size)

 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size)                        \
     VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size)

 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size)                    \
-    VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size)
+    VMSTATE_VBUFFER(_f, _s, NULL, _start, _size)

 #define VMSTATE_BUFFER_TEST(_f, _s, _test)                            \
     VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 56/97] vmstate: Remove version_id fields that were not used
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (54 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 55/97] vmstate: Remove version_id from VMSTATE_VBUFFER Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 57/97] vmstate: Remove version_id from VMSTATE_SUB_ARRAY Juan Quintela
                   ` (42 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 553c909..95d0a9a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -342,7 +342,6 @@ extern const VMStateInfo vmstate_info_bitmap;

 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
     .name       = (stringify(_field)),                               \
-    .version_id = 0,                                                 \
     .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
     .size       = sizeof(_type),                                     \
     .vmsd       = &(_vmsd),                                          \
@@ -352,7 +351,6 @@ extern const VMStateInfo vmstate_info_bitmap;

 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _vmsd, _type) { \
     .name       = (stringify(_field)),                               \
-    .version_id = 0,                                                 \
     .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
     .size       = sizeof(_type),                                     \
     .vmsd       = &(_vmsd),                                          \
@@ -362,7 +360,6 @@ extern const VMStateInfo vmstate_info_bitmap;

 #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \
     .name       = (stringify(_field)),                               \
-    .version_id = 0,                                                 \
     .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
     .size       = sizeof(_type),                                     \
     .vmsd       = &(_vmsd),                                          \
@@ -464,7 +461,6 @@ extern const VMStateInfo vmstate_info_bitmap;
  */
 #define VMSTATE_BITMAP(_field, _state, _field_size) {                \
     .name         = (stringify(_field)),                             \
-    .version_id   = 0,                                               \
     .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
     .info         = &vmstate_info_bitmap,                            \
     .flags        = VMS_VBUFFER|VMS_POINTER,                         \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 57/97] vmstate: Remove version_id from VMSTATE_SUB_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (55 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 56/97] vmstate: Remove version_id fields that were not used Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 58/97] vmstate: Remove version parameter from VMSTATE_VARRAY_INT32 Juan Quintela
                   ` (41 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

None of its two users used it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 95d0a9a..59afc3e 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -231,9 +231,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_array(_state, _field, _type, _num),\
 }

-#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \
+#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _info, _type) { \
     .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
     .num        = (_num),                                            \
     .info       = &(_info),                                          \
     .size       = sizeof(_type),                                     \
@@ -607,10 +606,10 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_2DARRAY(_f, _s, _n1, _n2, NULL, vmstate_info_uint32, uint32_t)

 #define VMSTATE_UINT8_SUB_ARRAY(_f, _s, _start, _num)                \
-    VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint8, uint8_t)
+    VMSTATE_SUB_ARRAY(_f, _s, _start, _num, vmstate_info_uint8, uint8_t)

 #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num)                \
-    VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t)
+    VMSTATE_SUB_ARRAY(_f, _s, _start, _num, vmstate_info_uint32, uint32_t)

 #define VMSTATE_BUFFER(_f, _s)                                        \
     VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, sizeof(typeof_field(_s, _f)))
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 58/97] vmstate: Remove version parameter from VMSTATE_VARRAY_INT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (56 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 57/97] vmstate: Remove version_id from VMSTATE_SUB_ARRAY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 59/97] vmstate: Remove version_id from VMSTATE_VARRAY_UINT16_UNSAFE Juan Quintela
                   ` (40 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 docs/migration.txt          | 2 +-
 hw/block/fdc.c              | 2 +-
 hw/display/qxl.c            | 2 +-
 hw/display/vmware_vga.c     | 2 +-
 hw/ide/core.c               | 2 +-
 hw/pci/pci.c                | 3 +--
 include/migration/vmstate.h | 3 +--
 target-arm/machine.c        | 4 ++--
 8 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/docs/migration.txt b/docs/migration.txt
index 0492a45..794fa70 100644
--- a/docs/migration.txt
+++ b/docs/migration.txt
@@ -259,7 +259,7 @@ const VMStateDescription vmstate_ide_drive_pio_state = {
     .post_load = ide_drive_pio_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(req_nb_sectors, IDEState),
-        VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 1,
+        VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len,
                              vmstate_info_uint8, uint8_t),
         VMSTATE_INT32(cur_io_buffer_offset, IDEState),
         VMSTATE_INT32(cur_io_buffer_len, IDEState),
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 490d127..ca973f4 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -752,7 +752,7 @@ static const VMStateDescription vmstate_fdc = {
         VMSTATE_UINT8(status1, FDCtrl),
         VMSTATE_UINT8(status2, FDCtrl),
         /* Command FIFO */
-        VMSTATE_VARRAY_INT32(fifo, FDCtrl, fifo_size, 0, vmstate_info_uint8,
+        VMSTATE_VARRAY_INT32(fifo, FDCtrl, fifo_size, vmstate_info_uint8,
                              uint8_t),
         VMSTATE_UINT32(data_pos, FDCtrl),
         VMSTATE_UINT32(data_len, FDCtrl),
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 47bbf1f..9dd4e22 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2271,7 +2271,7 @@ static VMStateDescription qxl_vmstate = {
                        qxl_surface, QXLSurfaceCreate),
         VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice),
         VMSTATE_VARRAY_INT32(guest_surfaces.cmds, PCIQXLDevice,
-                             ssd.num_surfaces, 0,
+                             ssd.num_surfaces,
                              vmstate_info_uint64, uint64_t),
         VMSTATE_UINT64(guest_cursor, PCIQXLDevice),
         VMSTATE_END_OF_LIST()
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 00bb385..90dfbf3 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1163,7 +1163,7 @@ static const VMStateDescription vmstate_vmware_vga_internal = {
         VMSTATE_INT32(cursor.on, struct vmsvga_state_s),
         VMSTATE_INT32(index, struct vmsvga_state_s),
         VMSTATE_VARRAY_INT32(scratch, struct vmsvga_state_s,
-                             scratch_size, 0, vmstate_info_uint32, uint32_t),
+                             scratch_size, vmstate_info_uint32, uint32_t),
         VMSTATE_INT32(new_width, struct vmsvga_state_s),
         VMSTATE_INT32(new_height, struct vmsvga_state_s),
         VMSTATE_UINT32(guest, struct vmsvga_state_s),
diff --git a/hw/ide/core.c b/hw/ide/core.c
index b79cc9e..d33f3f3 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2368,7 +2368,7 @@ static const VMStateDescription vmstate_ide_drive_pio_state = {
     .post_load = ide_drive_pio_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(req_nb_sectors, IDEState),
-        VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 1,
+        VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len,
 			     vmstate_info_uint8, uint8_t),
         VMSTATE_INT32(cur_io_buffer_offset, IDEState),
         VMSTATE_INT32(cur_io_buffer_len, IDEState),
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 828df53..a8d671c 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -66,8 +66,7 @@ static const VMStateDescription vmstate_pcibus = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32_EQUAL(nirq, PCIBus),
-        VMSTATE_VARRAY_INT32(irq_count, PCIBus,
-                             nirq, 0, vmstate_info_int32,
+        VMSTATE_VARRAY_INT32(irq_count, PCIBus, nirq, vmstate_info_int32,
                              int32_t),
         VMSTATE_END_OF_LIST()
     }
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 59afc3e..905c19a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -249,9 +249,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }

-#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\
+#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _info, _type) {\
     .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
     .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
     .info       = &(_info),                                          \
     .size       = sizeof(_type),                                     \
diff --git a/target-arm/machine.c b/target-arm/machine.c
index 3f4fd42..3f2c485 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -244,10 +244,10 @@ const VMStateDescription vmstate_arm_cpu = {
         VMSTATE_INT32_POSITIVE_LE(cpreg_vmstate_array_len, ARMCPU),
         VMSTATE_VARRAY_INT32(cpreg_vmstate_indexes, ARMCPU,
                              cpreg_vmstate_array_len,
-                             0, vmstate_info_uint64, uint64_t),
+                             vmstate_info_uint64, uint64_t),
         VMSTATE_VARRAY_INT32(cpreg_vmstate_values, ARMCPU,
                              cpreg_vmstate_array_len,
-                             0, vmstate_info_uint64, uint64_t),
+                             vmstate_info_uint64, uint64_t),
         VMSTATE_UINT64(env.exclusive_addr, ARMCPU),
         VMSTATE_UINT64(env.exclusive_val, ARMCPU),
         VMSTATE_UINT64(env.exclusive_high, ARMCPU),
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 59/97] vmstate: Remove version_id from VMSTATE_VARRAY_UINT16_UNSAFE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (57 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 58/97] vmstate: Remove version parameter from VMSTATE_VARRAY_INT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 60/97] vmstate: VMSTATE_ARRAY_OF_POINTER didn't used the version_id field Juan Quintela
                   ` (39 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/nvram/eeprom93xx.c       | 2 +-
 include/migration/vmstate.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
index 7e09037..8f59509 100644
--- a/hw/nvram/eeprom93xx.c
+++ b/hw/nvram/eeprom93xx.c
@@ -145,7 +145,7 @@ static const VMStateDescription vmstate_eeprom = {
         VMSTATE_UNUSED_TEST(is_old_eeprom_version, 1),
         VMSTATE_UINT16_EQUAL_TEST(size, eeprom_t, is_eeprom_version),
         VMSTATE_UINT16(data, eeprom_t),
-        VMSTATE_VARRAY_UINT16_UNSAFE(contents, eeprom_t, size, 0,
+        VMSTATE_VARRAY_UINT16_UNSAFE(contents, eeprom_t, size,
                                      vmstate_info_uint16, uint16_t),
         VMSTATE_END_OF_LIST()
     }
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 905c19a..5a26b6a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -268,9 +268,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_pointer(_state, _field, _type),     \
 }

-#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\
+#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _info, _type) {\
     .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
     .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\
     .info       = &(_info),                                          \
     .size       = sizeof(_type),                                     \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 60/97] vmstate: VMSTATE_ARRAY_OF_POINTER didn't used the version_id field
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (58 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 59/97] vmstate: Remove version_id from VMSTATE_VARRAY_UINT16_UNSAFE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 61/97] vmstate: remove version parameter from VMSTATE_BUFFER_POINTER_UNSAFE Juan Quintela
                   ` (38 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 5a26b6a..6d064de 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -296,9 +296,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_pointer(_state, _field, _type),   \
 }

-#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\
+#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _info, _type) {\
     .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
     .num        = (_num),                                            \
     .info       = &(_info),                                          \
     .size       = sizeof(_type),                                     \
@@ -553,7 +552,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_TIMER_TEST(_f, _s, NULL)

 #define VMSTATE_TIMER_ARRAY(_f, _s, _n)                               \
-    VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *)
+    VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, vmstate_info_timer, QEMUTimer*)

 #define VMSTATE_BOOL_ARRAY_TEST(_f, _s, _n, _t)                       \
     VMSTATE_ARRAY(_f, _s, _n, _t, vmstate_info_bool, bool)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 61/97] vmstate: remove version parameter from VMSTATE_BUFFER_POINTER_UNSAFE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (59 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 60/97] vmstate: VMSTATE_ARRAY_OF_POINTER didn't used the version_id field Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 62/97] vmstate: Remove version, test and start parameter from VMSTATE_VBUFFER_UINT32 Juan Quintela
                   ` (37 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/block/onenand.c          | 2 +-
 hw/sd/sd.c                  | 2 +-
 include/migration/vmstate.h | 3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index 60d5311..87fbf00 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -189,7 +189,7 @@ static const VMStateDescription vmstate_onenand = {
         VMSTATE_UINT8(ecc.cp, OneNANDState),
         VMSTATE_UINT16_ARRAY(ecc.lp, OneNANDState, 2),
         VMSTATE_UINT16(ecc.count, OneNANDState),
-        VMSTATE_BUFFER_POINTER_UNSAFE(otp, OneNANDState, 0,
+        VMSTATE_BUFFER_POINTER_UNSAFE(otp, OneNANDState,
             ((64 + 2) << PAGE_SHIFT)),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 7ee8c24..ac909f3 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -480,7 +480,7 @@ static const VMStateDescription sd_vmstate = {
         VMSTATE_UINT64(data_start, SDState),
         VMSTATE_UINT32(data_offset, SDState),
         VMSTATE_UINT8_ARRAY(data, SDState, 512),
-        VMSTATE_BUFFER_POINTER_UNSAFE(buf, SDState, 1, 512),
+        VMSTATE_BUFFER_POINTER_UNSAFE(buf, SDState, 512),
         VMSTATE_BOOL(enable, SDState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 6d064de..a114d30 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -435,9 +435,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = offsetof(_state, _field),                        \
 }

-#define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \
+#define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _size) { \
     .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
     .size       = (_size),                                           \
     .info       = &vmstate_info_buffer,                              \
     .flags      = VMS_BUFFER|VMS_POINTER,                            \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 62/97] vmstate: Remove version, test and start parameter from VMSTATE_VBUFFER_UINT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (60 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 61/97] vmstate: remove version parameter from VMSTATE_BUFFER_POINTER_UNSAFE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 63/97] vmstate: Remove version paramenter from VMSTATE_ARRAY_OF_POINTER_TO_STRUCT Juan Quintela
                   ` (36 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

None of its users use them.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/char/exynos4210_uart.c   | 2 +-
 hw/display/g364fb.c         | 2 +-
 hw/dma/pl330.c              | 8 ++++----
 hw/intc/exynos4210_gic.c    | 2 +-
 hw/net/vmxnet3.c            | 3 +--
 hw/nvram/mac_nvram.c        | 2 +-
 hw/sd/sdhci.c               | 2 +-
 hw/timer/m48t59.c           | 2 +-
 include/migration/vmstate.h | 7 ++-----
 util/fifo8.c                | 2 +-
 10 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 7614e58..872bc99 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -563,7 +563,7 @@ static const VMStateDescription vmstate_exynos4210_uart_fifo = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(sp, Exynos4210UartFIFO),
         VMSTATE_UINT32(rp, Exynos4210UartFIFO),
-        VMSTATE_VBUFFER_UINT32(data, Exynos4210UartFIFO, 1, NULL, 0, size),
+        VMSTATE_VBUFFER_UINT32(data, Exynos4210UartFIFO, size),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 9f6717e..b1a7985 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -461,7 +461,7 @@ static const VMStateDescription vmstate_g364fb = {
     .minimum_version_id = 1,
     .post_load = g364fb_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_VBUFFER_UINT32(vram, G364State, 1, NULL, 0, vram_size),
+        VMSTATE_VBUFFER_UINT32(vram, G364State, vram_size),
         VMSTATE_BUFFER_UNSAFE(color_palette, G364State, 256 * 3),
         VMSTATE_BUFFER_UNSAFE(cursor_palette, G364State, 9),
         VMSTATE_UINT16_ARRAY(cursor, G364State, 512),
diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index 6b6eaae..e4f8993 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -170,8 +170,8 @@ static const VMStateDescription vmstate_pl330_fifo = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_VBUFFER_UINT32(buf, PL330Fifo, 1, NULL, 0, buf_size),
-        VMSTATE_VBUFFER_UINT32(tag, PL330Fifo, 1, NULL, 0, buf_size),
+        VMSTATE_VBUFFER_UINT32(buf, PL330Fifo, buf_size),
+        VMSTATE_VBUFFER_UINT32(tag, PL330Fifo, buf_size),
         VMSTATE_UINT32(head, PL330Fifo),
         VMSTATE_UINT32(num, PL330Fifo),
         VMSTATE_UINT32(buf_size, PL330Fifo),
@@ -279,8 +279,8 @@ static const VMStateDescription vmstate_pl330 = {
         VMSTATE_STRUCT(manager, PL330State, 0, vmstate_pl330_chan, PL330Chan),
         VMSTATE_STRUCT_VARRAY_UINT32(chan, PL330State, num_chnls, 0,
                                      vmstate_pl330_chan, PL330Chan),
-        VMSTATE_VBUFFER_UINT32(lo_seqn, PL330State, 1, NULL, 0, num_chnls),
-        VMSTATE_VBUFFER_UINT32(hi_seqn, PL330State, 1, NULL, 0, num_chnls),
+        VMSTATE_VBUFFER_UINT32(lo_seqn, PL330State, num_chnls),
+        VMSTATE_VBUFFER_UINT32(hi_seqn, PL330State, num_chnls),
         VMSTATE_STRUCT(fifo, PL330State, 0, vmstate_pl330_fifo, PL330Fifo),
         VMSTATE_STRUCT(read_queue, PL330State, 0, vmstate_pl330_queue,
                        PL330Queue),
diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
index 0590d5d..4c1f095 100644
--- a/hw/intc/exynos4210_gic.c
+++ b/hw/intc/exynos4210_gic.c
@@ -395,7 +395,7 @@ static const VMStateDescription vmstate_exynos4210_irq_gate = {
     .version_id = 2,
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
-        VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, 1, NULL, 0, n_in),
+        VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, n_in),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 4140f9f..1e90af4 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -2176,8 +2176,7 @@ static const VMStateDescription vmxstate_vmxnet3_mcast_list = {
     .minimum_version_id = 1,
     .pre_load = vmxnet3_mcast_list_pre_load,
     .fields = (VMStateField[]) {
-        VMSTATE_VBUFFER_UINT32(mcast_list, VMXNET3State, 0, NULL, 0,
-            mcast_list_buff_size),
+        VMSTATE_VBUFFER_UINT32(mcast_list, VMXNET3State, mcast_list_buff_size),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 170b10b..c4b4a4e 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -97,7 +97,7 @@ static const VMStateDescription vmstate_macio_nvram = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_VBUFFER_UINT32(data, MacIONVRAMState, 0, NULL, 0, size),
+        VMSTATE_VBUFFER_UINT32(data, MacIONVRAMState, size),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index e2951e6..d9c67a6 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1223,7 +1223,7 @@ const VMStateDescription sdhci_vmstate = {
         VMSTATE_UINT16(data_count, SDHCIState),
         VMSTATE_UINT64(admasysaddr, SDHCIState),
         VMSTATE_UINT8(stopped_state, SDHCIState),
-        VMSTATE_VBUFFER_UINT32(fifo_buffer, SDHCIState, 1, NULL, 0, buf_maxsz),
+        VMSTATE_VBUFFER_UINT32(fifo_buffer, SDHCIState, buf_maxsz),
         VMSTATE_TIMER(insert_timer, SDHCIState),
         VMSTATE_TIMER(transfer_timer, SDHCIState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index 31509d5..3015a02 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -598,7 +598,7 @@ static const VMStateDescription vmstate_m48t59 = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(lock, M48t59State),
         VMSTATE_UINT16(addr, M48t59State),
-        VMSTATE_VBUFFER_UINT32(buffer, M48t59State, 0, NULL, 0, size),
+        VMSTATE_VBUFFER_UINT32(buffer, M48t59State, size),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index a114d30..0498339 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -415,15 +415,12 @@ extern const VMStateInfo vmstate_info_bitmap;
     .start        = (_start),                                        \
 }

-#define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \
+#define VMSTATE_VBUFFER_UINT32(_field, _state, _field_size) { \
     .name         = (stringify(_field)),                             \
-    .version_id   = (_version),                                      \
-    .field_exists = (_test),                                         \
     .size_offset  = vmstate_offset_value(_state, _field_size, uint32_t),\
     .info         = &vmstate_info_buffer,                            \
     .flags        = VMS_VBUFFER|VMS_POINTER,                         \
     .offset       = offsetof(_state, _field),                        \
-    .start        = (_start),                                        \
 }

 #define VMSTATE_BUFFER_UNSAFE_TEST(_field, _state, _test, _info, _size) { \
@@ -620,7 +617,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_VBUFFER(_f, _s, NULL, 0, _size)

 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size)                        \
-    VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size)
+    VMSTATE_VBUFFER_UINT32(_f, _s, _size)

 #define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size)                    \
     VMSTATE_VBUFFER(_f, _s, NULL, _start, _size)
diff --git a/util/fifo8.c b/util/fifo8.c
index 0ea5ad9..2f0facd 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -117,7 +117,7 @@ const VMStateDescription vmstate_fifo8 = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_VBUFFER_UINT32(data, Fifo8, 1, NULL, 0, capacity),
+        VMSTATE_VBUFFER_UINT32(data, Fifo8, capacity),
         VMSTATE_UINT32(head, Fifo8),
         VMSTATE_UINT32(num, Fifo8),
         VMSTATE_END_OF_LIST()
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 63/97] vmstate: Remove version paramenter from VMSTATE_ARRAY_OF_POINTER_TO_STRUCT
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (61 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 62/97] vmstate: Remove version, test and start parameter from VMSTATE_VBUFFER_UINT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 64/97] vmstate: Remove VMSTATE_BUFFER_MULTIPLY Juan Quintela
                   ` (35 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/hw/ptimer.h         | 2 +-
 include/migration/vmstate.h | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h
index ef852bf..57a65e6 100644
--- a/include/hw/ptimer.h
+++ b/include/hw/ptimer.h
@@ -31,7 +31,7 @@ extern const VMStateDescription vmstate_ptimer;
     VMSTATE_STRUCT_POINTER(_field, _state, vmstate_ptimer, ptimer_state)

 #define VMSTATE_PTIMER_ARRAY(_f, _s, _n)                                \
-    VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, 0,                   \
+    VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n,                      \
                                        vmstate_ptimer, ptimer_state)

 #endif
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 0498339..ed70734 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -305,12 +305,11 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_array(_state, _field, _type, _num), \
 }

-#define VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, _v, _vmsd, _type) { \
+#define VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(_f, _s, _n, _vmsd, _type) { \
     .name       = (stringify(_f)),                                   \
-    .version_id = (_v),                                              \
     .num        = (_n),                                              \
     .vmsd       = &(_vmsd),                                          \
-    .size       = sizeof(_type *),                                    \
+    .size       = sizeof(_type *),                                   \
     .flags      = VMS_ARRAY|VMS_STRUCT|VMS_ARRAY_OF_POINTER,         \
     .offset     = vmstate_offset_array(_s, _f, _type*, _n),          \
 }
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 64/97] vmstate: Remove VMSTATE_BUFFER_MULTIPLY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (62 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 63/97] vmstate: Remove version paramenter from VMSTATE_ARRAY_OF_POINTER_TO_STRUCT Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 65/97] vmstate: Remove version parameter from VMSTATE_STATIC_BUFFER Juan Quintela
                   ` (34 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

It was unused.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 13 -------------
 vmstate.c                   |  3 ---
 2 files changed, 16 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index ed70734..b9d5a28 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -97,7 +97,6 @@ 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 */
     VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
     VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
 };
@@ -392,18 +391,6 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_buffer(_state, _field) + _start,  \
 }

-#define VMSTATE_VBUFFER_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_POINTER|VMS_MULTIPLY,            \
-    .offset       = offsetof(_state, _field),                        \
-    .start        = (_start),                                        \
-}
-
 #define VMSTATE_VBUFFER(_field, _state, _test, _start, _field_size) { \
     .name         = (stringify(_field)),                             \
     .field_exists = (_test),                                         \
diff --git a/vmstate.c b/vmstate.c
index cb0af5e..ce197d2 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -35,9 +35,6 @@ static int vmstate_size(void *opaque, VMStateField *field)

     if (field->flags & VMS_VBUFFER) {
         size = *(int32_t *)(opaque+field->size_offset);
-        if (field->flags & VMS_MULTIPLY) {
-            size *= field->size;
-        }
     }

     return size;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 65/97] vmstate: Remove version parameter from VMSTATE_STATIC_BUFFER
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (63 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 64/97] vmstate: Remove VMSTATE_BUFFER_MULTIPLY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 66/97] vmstate: Remove version field from VMSTATE_STRUCT_VARRAY_UINT32 Juan Quintela
                   ` (33 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

No user for it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index b9d5a28..95e4e17 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -381,9 +381,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }

-#define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \
+#define VMSTATE_STATIC_BUFFER(_field, _state, _test, _start, _size) { \
     .name         = (stringify(_field)),                             \
-    .version_id   = (_version),                                      \
     .field_exists = (_test),                                         \
     .size         = (_size - _start),                                \
     .info         = &vmstate_info_buffer,                            \
@@ -591,13 +590,13 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SUB_ARRAY(_f, _s, _start, _num, vmstate_info_uint32, uint32_t)

 #define VMSTATE_BUFFER(_f, _s)                                        \
-    VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, sizeof(typeof_field(_s, _f)))
+    VMSTATE_STATIC_BUFFER(_f, _s, NULL, 0, sizeof(typeof_field(_s, _f)))

 #define VMSTATE_PARTIAL_BUFFER(_f, _s, _size)                         \
-    VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size)
+    VMSTATE_STATIC_BUFFER(_f, _s, NULL, 0, _size)

 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
-    VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f)))
+    VMSTATE_STATIC_BUFFER(_f, _s, NULL, _start, sizeof(typeof_field(_s, _f)))

 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size)                        \
     VMSTATE_VBUFFER(_f, _s, NULL, 0, _size)
@@ -609,7 +608,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_VBUFFER(_f, _s, NULL, _start, _size)

 #define VMSTATE_BUFFER_TEST(_f, _s, _test)                            \
-    VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)))
+    VMSTATE_STATIC_BUFFER(_f, _s, _test, 0, sizeof(typeof_field(_s, _f)))

 #define VMSTATE_BUFFER_UNSAFE(_field, _state,  _size)                 \
     VMSTATE_BUFFER_UNSAFE_TEST(_field, _state, NULL, vmstate_info_buffer, _size)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 66/97] vmstate: Remove version field from VMSTATE_STRUCT_VARRAY_UINT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (64 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 65/97] vmstate: Remove version parameter from VMSTATE_STATIC_BUFFER Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 67/97] vmstate: Move all users of versioning of VMSTATE_STRUCT_ARRAY to _TEST Juan Quintela
                   ` (32 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

No user of it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/dma/pl330.c              | 4 ++--
 hw/timer/a9gtimer.c         | 2 +-
 hw/timer/arm_mptimer.c      | 2 +-
 hw/usb/hcd-xhci.c           | 6 +++---
 include/migration/vmstate.h | 3 +--
 5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index e4f8993..9ba3108 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -216,7 +216,7 @@ static const VMStateDescription vmstate_pl330_queue = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_VARRAY_UINT32(queue, PL330Queue, queue_size, 1,
+        VMSTATE_STRUCT_VARRAY_UINT32(queue, PL330Queue, queue_size,
                                  vmstate_pl330_queue_entry, PL330QueueEntry),
         VMSTATE_END_OF_LIST()
     }
@@ -277,7 +277,7 @@ static const VMStateDescription vmstate_pl330 = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT(manager, PL330State, 0, vmstate_pl330_chan, PL330Chan),
-        VMSTATE_STRUCT_VARRAY_UINT32(chan, PL330State, num_chnls, 0,
+        VMSTATE_STRUCT_VARRAY_UINT32(chan, PL330State, num_chnls,
                                      vmstate_pl330_chan, PL330Chan),
         VMSTATE_VBUFFER_UINT32(lo_seqn, PL330State, num_chnls),
         VMSTATE_VBUFFER_UINT32(hi_seqn, PL330State, num_chnls),
diff --git a/hw/timer/a9gtimer.c b/hw/timer/a9gtimer.c
index a0656d5..e4ac695 100644
--- a/hw/timer/a9gtimer.c
+++ b/hw/timer/a9gtimer.c
@@ -333,7 +333,7 @@ static const VMStateDescription vmstate_a9_gtimer = {
         VMSTATE_UINT64(ref_counter, A9GTimerState),
         VMSTATE_UINT64(cpu_ref_time, A9GTimerState),
         VMSTATE_STRUCT_VARRAY_UINT32(per_cpu, A9GTimerState, num_cpu,
-                                     1, vmstate_a9_gtimer_per_cpu,
+                                     vmstate_a9_gtimer_per_cpu,
                                      A9GTimerPerCPU),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
index 35a0a23..b98a81e 100644
--- a/hw/timer/arm_mptimer.c
+++ b/hw/timer/arm_mptimer.c
@@ -257,7 +257,7 @@ static const VMStateDescription vmstate_arm_mptimer = {
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_STRUCT_VARRAY_UINT32(timerblock, ARMMPTimerState, num_cpu,
-                                     2, vmstate_timerblock, TimerBlock),
+                                     vmstate_timerblock, TimerBlock),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index ef3177a..a95bd30 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3752,11 +3752,11 @@ static const VMStateDescription vmstate_xhci = {
         VMSTATE_PCIE_DEVICE(parent_obj, XHCIState),
         VMSTATE_MSIX(parent_obj, XHCIState),

-        VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1,
+        VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports,
                                      vmstate_xhci_port, XHCIPort),
-        VMSTATE_STRUCT_VARRAY_UINT32(slots, XHCIState, numslots, 1,
+        VMSTATE_STRUCT_VARRAY_UINT32(slots, XHCIState, numslots,
                                      vmstate_xhci_slot, XHCISlot),
-        VMSTATE_STRUCT_VARRAY_UINT32(intr, XHCIState, numintrs, 1,
+        VMSTATE_STRUCT_VARRAY_UINT32(intr, XHCIState, numintrs,
                                      vmstate_xhci_intr, XHCIInterrupter),

         /* Operational Registers */
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 95e4e17..6076a35 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -371,10 +371,9 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }

-#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \
+#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _vmsd, _type) { \
     .name       = (stringify(_field)),                               \
     .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \
-    .version_id = (_version),                                        \
     .vmsd       = &(_vmsd),                                          \
     .size       = sizeof(_type),                                     \
     .flags      = VMS_STRUCT|VMS_VARRAY_UINT32,                      \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 67/97] vmstate: Move all users of versioning of VMSTATE_STRUCT_ARRAY to _TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (65 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 66/97] vmstate: Remove version field from VMSTATE_STRUCT_VARRAY_UINT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 68/97] vmstate: Remove version paramenter from VMSTATE_STRUCT_ARRAY Juan Quintela
                   ` (31 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/char/escc.c          |  4 ++--
 hw/ide/internal.h       |  3 ++-
 hw/timer/i8254_common.c |  5 +++--
 target-i386/machine.c   | 15 +++++++++------
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 4875a2b..dc5768f 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -678,8 +678,8 @@ static const VMStateDescription vmstate_escc = {
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(chn, ESCCState, 2, 2, vmstate_escc_chn,
-                             ChannelState),
+        VMSTATE_STRUCT_ARRAY_TEST(chn, ESCCState, 2, vmstate_2_plus, 0,
+                                  vmstate_escc_chn, ChannelState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 0567a52..d771308 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -526,7 +526,8 @@ extern const VMStateDescription vmstate_ide_bus;
 extern const VMStateDescription vmstate_ide_drive;

 #define VMSTATE_IDE_DRIVES(_field, _state) \
-    VMSTATE_STRUCT_ARRAY(_field, _state, 2, 3, vmstate_ide_drive, IDEState)
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, 2, vmstate_3_plus, 0,\
+                              vmstate_ide_drive, IDEState)

 void ide_bus_reset(IDEBus *bus);
 int64_t ide_get_sector(IDEState *s);
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index f519864..b7bd908 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -268,8 +268,9 @@ static const VMStateDescription vmstate_pit_common = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_TEST(channels[0].irq_disabled, PITCommonState,
             vmstate_3_plus),
-        VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
-                             vmstate_pit_channel, PITChannelState),
+        VMSTATE_STRUCT_ARRAY_TEST(channels, PITCommonState, 3,
+                                  vmstate_2_plus, 0, vmstate_pit_channel,
+                                  PITChannelState),
         VMSTATE_INT64(channels[0].next_transition_time,
                       PITCommonState), /* formerly irq_timer */
         VMSTATE_END_OF_LIST()
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 09c1f50..ac9dde1 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -57,8 +57,9 @@ static const VMStateDescription vmstate_ymmh_reg = {
     }
 };

-#define VMSTATE_YMMH_REGS_VARS(_field, _state, _n, _v)                         \
-    VMSTATE_STRUCT_ARRAY(_field, _state, _n, _v, vmstate_ymmh_reg, XMMReg)
+#define VMSTATE_YMMH_REGS_VARS(_field, _state, _n, _t)                         \
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _n, _t, 0,\
+                              vmstate_ymmh_reg, XMMReg)

 static const VMStateDescription vmstate_bnd_regs = {
     .name = "bnd_regs",
@@ -85,8 +86,9 @@ static const VMStateDescription vmstate_mtrr_var = {
     }
 };

-#define VMSTATE_MTRR_VARS(_field, _state, _n, _v)                    \
-    VMSTATE_STRUCT_ARRAY(_field, _state, _n, _v, vmstate_mtrr_var, MTRRVar)
+#define VMSTATE_MTRR_VARS(_field, _state, _n, _t)                    \
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _n, _t, 0,\
+                              vmstate_mtrr_var, MTRRVar)

 static void put_fpreg_error(QEMUFile *f, void *opaque, size_t size)
 {
@@ -669,7 +671,7 @@ const VMStateDescription vmstate_x86_cpu = {
         /* MTRRs */
         VMSTATE_UINT64_ARRAY_TEST(env.mtrr_fixed, X86CPU, 11, vmstate_8_plus),
         VMSTATE_UINT64_TEST(env.mtrr_deftype, X86CPU, vmstate_8_plus),
-        VMSTATE_MTRR_VARS(env.mtrr_var, X86CPU, 8, 8),
+        VMSTATE_MTRR_VARS(env.mtrr_var, X86CPU, 8, vmstate_8_plus),
         /* KVM-related states */
         VMSTATE_INT32_TEST(env.interrupt_injected, X86CPU, vmstate_9_plus),
         VMSTATE_UINT32_TEST(env.mp_state, X86CPU, vmstate_9_plus),
@@ -694,7 +696,8 @@ const VMStateDescription vmstate_x86_cpu = {
         /* XSAVE related fields */
         VMSTATE_UINT64_TEST(env.xcr0, X86CPU, vmstate_12_plus),
         VMSTATE_UINT64_TEST(env.xstate_bv, X86CPU, vmstate_12_plus),
-        VMSTATE_YMMH_REGS_VARS(env.ymmh_regs, X86CPU, CPU_NB_REGS, 12),
+        VMSTATE_YMMH_REGS_VARS(env.ymmh_regs, X86CPU, CPU_NB_REGS,
+                               vmstate_12_plus),
         VMSTATE_END_OF_LIST()
         /* The above list is not sorted /wrt version numbers, watch out! */
     },
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 68/97] vmstate: Remove version paramenter from VMSTATE_STRUCT_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (66 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 67/97] vmstate: Move all users of versioning of VMSTATE_STRUCT_ARRAY to _TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 69/97] vmstate: Remove version parameter from VMSTATE_STRUCT_ARRAY_TEST Juan Quintela
                   ` (30 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

No users of that field left.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/arm/musicpal.c             |  2 +-
 hw/audio/ac97.c               |  2 +-
 hw/audio/es1370.c             |  2 +-
 hw/audio/hda-codec.c          |  3 +--
 hw/audio/intel-hda.c          |  3 +--
 hw/block/fdc.c                |  2 +-
 hw/char/ipoctal232.c          |  4 ++--
 hw/char/serial-pci.c          |  2 +-
 hw/display/exynos4210_fimd.c  |  2 +-
 hw/display/pxa2xx_lcd.c       |  2 +-
 hw/display/qxl.c              |  2 +-
 hw/dma/i8257.c                |  2 +-
 hw/dma/pl080.c                |  2 +-
 hw/ide/internal.h             |  2 +-
 hw/ide/pci.c                  |  3 +--
 hw/input/hid.c                |  2 +-
 hw/intc/arm_gic_common.c      |  2 +-
 hw/intc/exynos4210_combiner.c |  2 +-
 hw/intc/heathrow_pic.c        |  2 +-
 hw/intc/slavio_intctl.c       |  2 +-
 hw/misc/macio/cuda.c          |  2 +-
 hw/misc/macio/mac_dbdma.c     |  2 +-
 hw/net/allwinner_emac.c       |  2 +-
 hw/pci-host/ppce500.c         |  4 ++--
 hw/ppc/ppc4xx_pci.c           | 10 ++++------
 hw/ppc/spapr_pci.c            |  4 ++--
 hw/timer/cadence_ttc.c        |  3 +--
 hw/timer/exynos4210_mct.c     |  2 +-
 hw/timer/exynos4210_pwm.c     |  4 ++--
 hw/timer/pxa2xx_timer.c       |  4 ++--
 hw/timer/slavio_timer.c       |  2 +-
 hw/usb/dev-hub.c              |  2 +-
 hw/usb/dev-smartcard-reader.c |  4 ++--
 hw/usb/hcd-uhci.c             |  2 +-
 hw/usb/redirect.c             |  2 +-
 include/migration/vmstate.h   |  5 ++---
 target-i386/machine.c         |  6 +++---
 37 files changed, 49 insertions(+), 56 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 2a27a19..9ac05d8 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -949,7 +949,7 @@ static const VMStateDescription mv88w8618_pit_vmsd = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(timer, mv88w8618_pit_state, 4, 1,
+        VMSTATE_STRUCT_ARRAY(timer, mv88w8618_pit_state, 4,
                              mv88w8618_timer_vmsd, mv88w8618_timer_state),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index 45cb118..af00545 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -1216,7 +1216,7 @@ static const VMStateDescription vmstate_ac97 = {
         VMSTATE_UINT32 (glob_cnt, AC97LinkState),
         VMSTATE_UINT32 (glob_sta, AC97LinkState),
         VMSTATE_UINT32 (cas, AC97LinkState),
-        VMSTATE_STRUCT_ARRAY (bm_regs, AC97LinkState, 3, 1,
+        VMSTATE_STRUCT_ARRAY (bm_regs, AC97LinkState, 3,
                               vmstate_ac97_bm_regs, AC97BusMasterRegs),
         VMSTATE_BUFFER (mixer_data, AC97LinkState),
         VMSTATE_UNUSED_TEST (is_version_2, 3),
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 5dbf803..b4cfe5d 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -999,7 +999,7 @@ static const VMStateDescription vmstate_es1370 = {
     .post_load = es1370_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE (dev, ES1370State),
-        VMSTATE_STRUCT_ARRAY (chan, ES1370State, NB_CHANNELS, 2,
+        VMSTATE_STRUCT_ARRAY (chan, ES1370State, NB_CHANNELS,
                               vmstate_es1370_channel, struct chan),
         VMSTATE_UINT32 (ctl, ES1370State),
         VMSTATE_UINT32 (status, ES1370State),
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 1c1a138..76f4d3c 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -599,8 +599,7 @@ static const VMStateDescription vmstate_hda_audio = {
     .version_id = 2,
     .post_load = hda_audio_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(st, HDAAudioState, 4, 0,
-                             vmstate_hda_audio_stream,
+        VMSTATE_STRUCT_ARRAY(st, HDAAudioState, 4, vmstate_hda_audio_stream,
                              HDAAudioStream),
         VMSTATE_BOOL_ARRAY(running_compat, HDAAudioState, 16),
         VMSTATE_BOOL_ARRAY_TEST(running_real, HDAAudioState, 2 * 16,
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 1c660a4..426d178 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -1220,8 +1220,7 @@ static const VMStateDescription vmstate_intel_hda = {
         VMSTATE_UINT32(icw, IntelHDAState),
         VMSTATE_UINT32(irr, IntelHDAState),
         VMSTATE_UINT32(ics, IntelHDAState),
-        VMSTATE_STRUCT_ARRAY(st, IntelHDAState, 8, 0,
-                             vmstate_intel_hda_stream,
+        VMSTATE_STRUCT_ARRAY(st, IntelHDAState, 8, vmstate_intel_hda_stream,
                              IntelHDAStream),

         /* additional state info */
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index ca973f4..9d8d5d5 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -767,7 +767,7 @@ static const VMStateDescription vmstate_fdc = {
         VMSTATE_UINT8(lock, FDCtrl),
         VMSTATE_UINT8(pwrd, FDCtrl),
         VMSTATE_UINT8_EQUAL(num_floppies, FDCtrl),
-        VMSTATE_STRUCT_ARRAY(drives, FDCtrl, MAX_FD, 1,
+        VMSTATE_STRUCT_ARRAY(drives, FDCtrl, MAX_FD,
                              vmstate_fdrive, FDrive),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/char/ipoctal232.c b/hw/char/ipoctal232.c
index c8d5cdb..9e53ee7 100644
--- a/hw/char/ipoctal232.c
+++ b/hw/char/ipoctal232.c
@@ -153,9 +153,9 @@ static const VMStateDescription vmstate_ipoctal = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_IPACK_DEVICE(parent_obj, IPOctalState),
-        VMSTATE_STRUCT_ARRAY(ch, IPOctalState, N_CHANNELS, 1,
+        VMSTATE_STRUCT_ARRAY(ch, IPOctalState, N_CHANNELS,
                              vmstate_scc2698_channel, SCC2698Channel),
-        VMSTATE_STRUCT_ARRAY(blk, IPOctalState, N_BLOCKS, 1,
+        VMSTATE_STRUCT_ARRAY(blk, IPOctalState, N_BLOCKS,
                              vmstate_scc2698_block, SCC2698Block),
         VMSTATE_UINT8(irq_vector, IPOctalState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 44f50c3..25c930b 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -169,7 +169,7 @@ static const VMStateDescription vmstate_pci_multi_serial = {
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCIMultiSerialState),
         VMSTATE_STRUCT_ARRAY(state, PCIMultiSerialState, PCI_SERIAL_MAX_PORTS,
-                             0, vmstate_serial, SerialState),
+                             vmstate_serial, SerialState),
         VMSTATE_UINT32_ARRAY(level, PCIMultiSerialState, PCI_SERIAL_MAX_PORTS),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index 45c62af..d4afae9 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -1893,7 +1893,7 @@ static const VMStateDescription exynos4210_fimd_vmstate = {
         VMSTATE_UINT32(hueoffset, Exynos4210fimdState),
         VMSTATE_UINT32_ARRAY(i80ifcmd, Exynos4210fimdState, 12),
         VMSTATE_UINT32(blendcon, Exynos4210fimdState),
-        VMSTATE_STRUCT_ARRAY(window, Exynos4210fimdState, 5, 1,
+        VMSTATE_STRUCT_ARRAY(window, Exynos4210fimdState, 5,
                 exynos4210_fimd_window_vmstate, Exynos4210fimdWindow),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
index 80edb70..f9428d5 100644
--- a/hw/display/pxa2xx_lcd.c
+++ b/hw/display/pxa2xx_lcd.c
@@ -972,7 +972,7 @@ static const VMStateDescription vmstate_pxa2xx_lcdc = {
         VMSTATE_UINT32(tcr, PXA2xxLCDState),
         VMSTATE_UINT32(liidr, PXA2xxLCDState),
         VMSTATE_UINT8(bscntr, PXA2xxLCDState),
-        VMSTATE_STRUCT_ARRAY(dma_ch, PXA2xxLCDState, 7, 0,
+        VMSTATE_STRUCT_ARRAY(dma_ch, PXA2xxLCDState, 7,
                              vmstate_dma_channel, struct DMAChannel),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 9dd4e22..4114427 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2265,7 +2265,7 @@ static VMStateDescription qxl_vmstate = {
         VMSTATE_UINT32(mode, PCIQXLDevice),
         VMSTATE_UINT32(ssd.unique, PCIQXLDevice),
         VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice),
-        VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS, 0,
+        VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS,
                              qxl_memslot, struct guest_slots),
         VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, 0,
                        qxl_surface, QXLSurfaceCreate),
diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index dd370ed..775571b 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -580,7 +580,7 @@ static const VMStateDescription vmstate_dma = {
         VMSTATE_UINT8(mask, struct dma_cont),
         VMSTATE_UINT8(flip_flop, struct dma_cont),
         VMSTATE_INT32(dshift, struct dma_cont),
-        VMSTATE_STRUCT_ARRAY(regs, struct dma_cont, 4, 1, vmstate_dma_regs, struct dma_regs),
+        VMSTATE_STRUCT_ARRAY(regs, struct dma_cont, 4, vmstate_dma_regs, struct dma_regs),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/dma/pl080.c b/hw/dma/pl080.c
index 741dd20..a71ab21 100644
--- a/hw/dma/pl080.c
+++ b/hw/dma/pl080.c
@@ -89,7 +89,7 @@ static const VMStateDescription vmstate_pl080 = {
         VMSTATE_UINT8(tc_int, PL080State),
         VMSTATE_UINT8(tc_int, PL080State),
         VMSTATE_STRUCT_ARRAY(chan, PL080State, PL080_MAX_CHANNELS,
-                             1, vmstate_pl080_channel, pl080_channel),
+                             vmstate_pl080_channel, pl080_channel),
         VMSTATE_INT32(running, PL080State),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index d771308..23330be 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -521,7 +521,7 @@ extern const VMStateDescription vmstate_ide_bus;
     VMSTATE_STRUCT(_field, _state, 1, vmstate_ide_bus, IDEBus)

 #define VMSTATE_IDE_BUS_ARRAY(_field, _state, _num)              \
-    VMSTATE_STRUCT_ARRAY(_field, _state, _num, 1, vmstate_ide_bus, IDEBus)
+    VMSTATE_STRUCT_ARRAY(_field, _state, _num, vmstate_ide_bus, IDEBus)

 extern const VMStateDescription vmstate_ide_drive;

diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 6257a21..9136ec9 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -479,8 +479,7 @@ const VMStateDescription vmstate_ide_pci = {
     .post_load = ide_pci_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIIDEState),
-        VMSTATE_STRUCT_ARRAY(bmdma, PCIIDEState, 2, 0,
-                             vmstate_bmdma, BMDMAState),
+        VMSTATE_STRUCT_ARRAY(bmdma, PCIIDEState, 2, vmstate_bmdma, BMDMAState),
         VMSTATE_IDE_BUS_ARRAY(bus, PCIIDEState, 2),
         VMSTATE_IDE_DRIVES(bus[0].ifs, PCIIDEState),
         VMSTATE_IDE_DRIVES(bus[1].ifs, PCIIDEState),
diff --git a/hw/input/hid.c b/hw/input/hid.c
index bb0fa6a..35ec26d 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -468,7 +468,7 @@ const VMStateDescription vmstate_hid_ptr_device = {
     .minimum_version_id = 1,
     .post_load = hid_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(ptr.queue, HIDState, QUEUE_LENGTH, 0,
+        VMSTATE_STRUCT_ARRAY(ptr.queue, HIDState, QUEUE_LENGTH,
                              vmstate_hid_ptr_queue, HIDPointerEvent),
         VMSTATE_UINT32(head, HIDState),
         VMSTATE_UINT32(n, HIDState),
diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c
index 6d884ec..95ae9bc 100644
--- a/hw/intc/arm_gic_common.c
+++ b/hw/intc/arm_gic_common.c
@@ -65,7 +65,7 @@ static const VMStateDescription vmstate_gic = {
     .fields = (VMStateField[]) {
         VMSTATE_BOOL(enabled, GICState),
         VMSTATE_BOOL_ARRAY(cpu_enabled, GICState, GIC_NCPU),
-        VMSTATE_STRUCT_ARRAY(irq_state, GICState, GIC_MAXIRQ, 1,
+        VMSTATE_STRUCT_ARRAY(irq_state, GICState, GIC_MAXIRQ,
                              vmstate_gic_irq_state, gic_irq_state),
         VMSTATE_UINT8_ARRAY(irq_target, GICState, GIC_MAXIRQ),
         VMSTATE_UINT8_2DARRAY(priority1, GICState, GIC_INTERNAL, GIC_NCPU),
diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c
index a6b7028..b4efb45 100644
--- a/hw/intc/exynos4210_combiner.c
+++ b/hw/intc/exynos4210_combiner.c
@@ -89,7 +89,7 @@ static const VMStateDescription vmstate_exynos4210_combiner = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(group, Exynos4210CombinerState, IIC_NGRP, 0,
+        VMSTATE_STRUCT_ARRAY(group, Exynos4210CombinerState, IIC_NGRP,
                 vmstate_exynos4210_combiner_group_state, CombinerGroupState),
         VMSTATE_UINT32_ARRAY(reg_set, Exynos4210CombinerState,
                 IIC_REGSET_SIZE),
diff --git a/hw/intc/heathrow_pic.c b/hw/intc/heathrow_pic.c
index 9ff3119..8844231 100644
--- a/hw/intc/heathrow_pic.c
+++ b/hw/intc/heathrow_pic.c
@@ -173,7 +173,7 @@ static const VMStateDescription vmstate_heathrow_pic = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(pics, HeathrowPICS, 2, 1,
+        VMSTATE_STRUCT_ARRAY(pics, HeathrowPICS, 2,
                              vmstate_heathrow_pic_one, HeathrowPIC),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/intc/slavio_intctl.c b/hw/intc/slavio_intctl.c
index f22aba0..47debaf 100644
--- a/hw/intc/slavio_intctl.c
+++ b/hw/intc/slavio_intctl.c
@@ -393,7 +393,7 @@ static const VMStateDescription vmstate_intctl = {
     .minimum_version_id = 1,
     .post_load = vmstate_intctl_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(slaves, SLAVIO_INTCTLState, MAX_CPUS, 1,
+        VMSTATE_STRUCT_ARRAY(slaves, SLAVIO_INTCTLState, MAX_CPUS,
                              vmstate_intctl_cpu, SLAVIO_CPUINTCTLState),
         VMSTATE_UINT32(intregm_pending, SLAVIO_INTCTLState),
         VMSTATE_UINT32(intregm_disabled, SLAVIO_INTCTLState),
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index ff6051d..3c65d2b 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -649,7 +649,7 @@ static const VMStateDescription vmstate_cuda = {
         VMSTATE_BUFFER(data_in, CUDAState),
         VMSTATE_BUFFER(data_out, CUDAState),
         VMSTATE_UINT32(tick_offset, CUDAState),
-        VMSTATE_STRUCT_ARRAY(timers, CUDAState, 2, 1,
+        VMSTATE_STRUCT_ARRAY(timers, CUDAState, 2,
                              vmstate_cuda_timer, CUDATimer),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
index 3335476..fa02282 100644
--- a/hw/misc/macio/mac_dbdma.c
+++ b/hw/misc/macio/mac_dbdma.c
@@ -730,7 +730,7 @@ static const VMStateDescription vmstate_dbdma = {
     .version_id = 2,
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(channels, DBDMAState, DBDMA_CHANNELS, 1,
+        VMSTATE_STRUCT_ARRAY(channels, DBDMAState, DBDMA_CHANNELS,
                              vmstate_dbdma_channel, DBDMA_channel),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
index 469f2f0..0b3cf9a 100644
--- a/hw/net/allwinner_emac.c
+++ b/hw/net/allwinner_emac.c
@@ -505,7 +505,7 @@ static const VMStateDescription vmstate_aw_emac = {
         VMSTATE_UINT32(rx_num_packets, AwEmacState),
         VMSTATE_UINT32(rx_packet_size, AwEmacState),
         VMSTATE_UINT32(rx_packet_pos, AwEmacState),
-        VMSTATE_STRUCT_ARRAY(tx_fifo, AwEmacState, NUM_TX_FIFOS, 1,
+        VMSTATE_STRUCT_ARRAY(tx_fifo, AwEmacState, NUM_TX_FIFOS,
                              vmstate_fifo8, Fifo8),
         VMSTATE_UINT32_ARRAY(tx_length, AwEmacState, NUM_TX_FIFOS),
         VMSTATE_UINT32(tx_channel, AwEmacState),
diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c
index e12d731..5c0e73c 100644
--- a/hw/pci-host/ppce500.c
+++ b/hw/pci-host/ppce500.c
@@ -305,9 +305,9 @@ static const VMStateDescription vmstate_ppce500_pci = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(pob, PPCE500PCIState, PPCE500_PCI_NR_POBS, 1,
+        VMSTATE_STRUCT_ARRAY(pob, PPCE500PCIState, PPCE500_PCI_NR_POBS,
                              vmstate_pci_outbound, struct pci_outbound),
-        VMSTATE_STRUCT_ARRAY(pib, PPCE500PCIState, PPCE500_PCI_NR_PIBS, 1,
+        VMSTATE_STRUCT_ARRAY(pib, PPCE500PCIState, PPCE500_PCI_NR_PIBS,
                              vmstate_pci_outbound, struct pci_inbound),
         VMSTATE_UINT32(gasket_time, PPCE500PCIState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/ppc/ppc4xx_pci.c b/hw/ppc/ppc4xx_pci.c
index 55a3cab..4672787 100644
--- a/hw/ppc/ppc4xx_pci.c
+++ b/hw/ppc/ppc4xx_pci.c
@@ -319,12 +319,10 @@ static const VMStateDescription vmstate_ppc4xx_pci = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(pmm, PPC4xxPCIState, PPC4xx_PCI_NR_PMMS, 1,
-                             vmstate_pci_master_map,
-                             struct PCIMasterMap),
-        VMSTATE_STRUCT_ARRAY(ptm, PPC4xxPCIState, PPC4xx_PCI_NR_PTMS, 1,
-                             vmstate_pci_target_map,
-                             struct PCITargetMap),
+        VMSTATE_STRUCT_ARRAY(pmm, PPC4xxPCIState, PPC4xx_PCI_NR_PMMS,
+                             vmstate_pci_master_map, struct PCIMasterMap),
+        VMSTATE_STRUCT_ARRAY(ptm, PPC4xxPCIState, PPC4xx_PCI_NR_PTMS,
+                             vmstate_pci_target_map, struct PCITargetMap),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index a4a51d4..ac93f82 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -690,9 +690,9 @@ static const VMStateDescription vmstate_spapr_pci = {
         VMSTATE_UINT64_EQUAL(mem_win_size, sPAPRPHBState),
         VMSTATE_UINT64_EQUAL(io_win_addr, sPAPRPHBState),
         VMSTATE_UINT64_EQUAL(io_win_size, sPAPRPHBState),
-        VMSTATE_STRUCT_ARRAY(lsi_table, sPAPRPHBState, PCI_NUM_PINS, 0,
+        VMSTATE_STRUCT_ARRAY(lsi_table, sPAPRPHBState, PCI_NUM_PINS,
                              vmstate_spapr_pci_lsi, struct spapr_pci_lsi),
-        VMSTATE_STRUCT_ARRAY(msi_table, sPAPRPHBState, SPAPR_MSIX_MAX_DEVS, 0,
+        VMSTATE_STRUCT_ARRAY(msi_table, sPAPRPHBState, SPAPR_MSIX_MAX_DEVS,
                              vmstate_spapr_pci_msi, struct spapr_pci_msi),

         VMSTATE_END_OF_LIST()
diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c
index 19f89fc..2f7c168 100644
--- a/hw/timer/cadence_ttc.c
+++ b/hw/timer/cadence_ttc.c
@@ -462,8 +462,7 @@ static const VMStateDescription vmstate_cadence_ttc = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(timer, CadenceTTCState, 3, 0,
-                            vmstate_cadence_timer,
+        VMSTATE_STRUCT_ARRAY(timer, CadenceTTCState, 3, vmstate_cadence_timer,
                             CadenceTimerState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index 01e750e..0fd8d24 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -348,7 +348,7 @@ static const VMStateDescription vmstate_exynos4210_mct_state = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(reg_mct_cfg, Exynos4210MCTState),
-        VMSTATE_STRUCT_ARRAY(l_timer, Exynos4210MCTState, 2, 0,
+        VMSTATE_STRUCT_ARRAY(l_timer, Exynos4210MCTState, 2,
             vmstate_exynos4210_mct_lt, Exynos4210MCTLT),
         VMSTATE_STRUCT(g_timer, Exynos4210MCTState, 0,
             vmstate_exynos4210_mct_gt, Exynos4210MCTGT),
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
index 1c1a2b8..34fd2b3 100644
--- a/hw/timer/exynos4210_pwm.c
+++ b/hw/timer/exynos4210_pwm.c
@@ -139,8 +139,8 @@ static const VMStateDescription vmstate_exynos4210_pwm_state = {
         VMSTATE_UINT32(reg_tcon, Exynos4210PWMState),
         VMSTATE_UINT32(reg_tint_cstat, Exynos4210PWMState),
         VMSTATE_STRUCT_ARRAY(timer, Exynos4210PWMState,
-            EXYNOS4210_PWM_TIMERS_NUM, 0,
-        vmstate_exynos4210_pwm, Exynos4210PWM),
+                             EXYNOS4210_PWM_TIMERS_NUM,
+                             vmstate_exynos4210_pwm, Exynos4210PWM),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c
index 130e9dc..393a792 100644
--- a/hw/timer/pxa2xx_timer.c
+++ b/hw/timer/pxa2xx_timer.c
@@ -512,8 +512,8 @@ static const VMStateDescription vmstate_pxa2xx_timer_regs = {
         VMSTATE_INT32(clock, PXA2xxTimerInfo),
         VMSTATE_INT32(oldclock, PXA2xxTimerInfo),
         VMSTATE_UINT64(lastload, PXA2xxTimerInfo),
-        VMSTATE_STRUCT_ARRAY(timer, PXA2xxTimerInfo, 4, 1,
-                        vmstate_pxa2xx_timer0_regs, PXA2xxTimer0),
+        VMSTATE_STRUCT_ARRAY(timer, PXA2xxTimerInfo, 4,
+                             vmstate_pxa2xx_timer0_regs, PXA2xxTimer0),
         VMSTATE_UINT32(events, PXA2xxTimerInfo),
         VMSTATE_UINT32(irq_enabled, PXA2xxTimerInfo),
         VMSTATE_UINT32(reset3, PXA2xxTimerInfo),
diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c
index 45d97e6..1616bcb 100644
--- a/hw/timer/slavio_timer.c
+++ b/hw/timer/slavio_timer.c
@@ -345,7 +345,7 @@ static const VMStateDescription vmstate_slavio_timer = {
     .version_id = 3,
     .minimum_version_id = 3,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(cputimer, SLAVIO_TIMERState, MAX_CPUS + 1, 3,
+        VMSTATE_STRUCT_ARRAY(cputimer, SLAVIO_TIMERState, MAX_CPUS + 1,
                              vmstate_timer, CPUTimerState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index 7492174..5756856 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -553,7 +553,7 @@ static const VMStateDescription vmstate_usb_hub = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_USB_DEVICE(dev, USBHubState),
-        VMSTATE_STRUCT_ARRAY(ports, USBHubState, NUM_PORTS, 0,
+        VMSTATE_STRUCT_ARRAY(ports, USBHubState, NUM_PORTS,
                              vmstate_usb_hub_port, USBHubPort),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 470e69f..b72a578 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1419,11 +1419,11 @@ static VMStateDescription ccid_vmstate = {
         VMSTATE_BUFFER(abProtocolDataStructure.data, USBCCIDState),
         VMSTATE_UINT32(ulProtocolDataStructureSize, USBCCIDState),
         VMSTATE_STRUCT_ARRAY(bulk_in_pending, USBCCIDState,
-                       BULK_IN_PENDING_NUM, 1, bulk_in_vmstate, BulkIn),
+                       BULK_IN_PENDING_NUM, bulk_in_vmstate, BulkIn),
         VMSTATE_UINT32(bulk_in_pending_start, USBCCIDState),
         VMSTATE_UINT32(bulk_in_pending_end, USBCCIDState),
         VMSTATE_STRUCT_ARRAY(pending_answers, USBCCIDState,
-                        PENDING_ANSWERS_NUM, 1, answer_vmstate, Answer),
+                        PENDING_ANSWERS_NUM, answer_vmstate, Answer),
         VMSTATE_UINT32(pending_answers_num, USBCCIDState),
         VMSTATE_UINT8(migration_state, USBCCIDState),
         VMSTATE_UINT32(state_vmstate, USBCCIDState),
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index eb6a448..9133ff1 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -447,7 +447,7 @@ static const VMStateDescription vmstate_uhci = {
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, UHCIState),
         VMSTATE_UINT8_EQUAL(num_ports_vmstate, UHCIState),
-        VMSTATE_STRUCT_ARRAY(ports, UHCIState, NB_PORTS, 1,
+        VMSTATE_STRUCT_ARRAY(ports, UHCIState, NB_PORTS,
                              vmstate_uhci_port, UHCIPort),
         VMSTATE_UINT16(cmd, UHCIState),
         VMSTATE_UINT16(status, UHCIState),
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 287a505..9eff1ac 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -2321,7 +2321,7 @@ static const VMStateDescription usbredir_vmstate = {
             .flags        = VMS_SINGLE,
             .offset       = 0,
         },
-        VMSTATE_STRUCT_ARRAY(endpoint, USBRedirDevice, MAX_ENDPOINTS, 1,
+        VMSTATE_STRUCT_ARRAY(endpoint, USBRedirDevice, MAX_ENDPOINTS,
                              usbredir_ep_vmstate, struct endp_data),
         VMSTATE_STRUCT(cancelled, USBRedirDevice, 1,
                        usbredir_ep_packet_id_queue_vmstate,
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 6076a35..b0e49f1 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -456,9 +456,8 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type)          \
     VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)

-#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
-    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version,   \
-            _vmsd, _type)
+#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _vmsd, _type) \
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, 0, _vmsd, _type)

 #define VMSTATE_BOOL_TEST(_f, _s, _t)                                 \
     VMSTATE_SINGLE(_f, _s, _t, vmstate_info_bool, bool)
diff --git a/target-i386/machine.c b/target-i386/machine.c
index ac9dde1..0e91901 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -29,7 +29,7 @@ static const VMStateDescription vmstate_segment = {
 }

 #define VMSTATE_SEGMENT_ARRAY(_field, _state, _n)                    \
-    VMSTATE_STRUCT_ARRAY(_field, _state, _n, 0, vmstate_segment, SegmentCache)
+    VMSTATE_STRUCT_ARRAY(_field, _state, _n, vmstate_segment, SegmentCache)

 static const VMStateDescription vmstate_xmm_reg = {
     .name = "xmm_reg",
@@ -43,7 +43,7 @@ static const VMStateDescription vmstate_xmm_reg = {
 };

 #define VMSTATE_XMM_REGS(_field, _state, _n)                         \
-    VMSTATE_STRUCT_ARRAY(_field, _state, _n, 0, vmstate_xmm_reg, XMMReg)
+    VMSTATE_STRUCT_ARRAY(_field, _state, _n, vmstate_xmm_reg, XMMReg)

 /* YMMH format is the same as XMM */
 static const VMStateDescription vmstate_ymmh_reg = {
@@ -73,7 +73,7 @@ static const VMStateDescription vmstate_bnd_regs = {
 };

 #define VMSTATE_BND_REGS(_field, _state, _n)          \
-    VMSTATE_STRUCT_ARRAY(_field, _state, _n, 0, vmstate_bnd_regs, BNDReg)
+    VMSTATE_STRUCT_ARRAY(_field, _state, _n, vmstate_bnd_regs, BNDReg)

 static const VMStateDescription vmstate_mtrr_var = {
     .name = "mtrr_var",
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 69/97] vmstate: Remove version parameter from VMSTATE_STRUCT_ARRAY_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (67 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 68/97] vmstate: Remove version paramenter from VMSTATE_STRUCT_ARRAY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 70/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_INT32 Juan Quintela
                   ` (29 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

No users left.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/char/escc.c              | 2 +-
 hw/ide/internal.h           | 2 +-
 hw/timer/i8254_common.c     | 2 +-
 hw/timer/pxa2xx_timer.c     | 2 +-
 hw/usb/hcd-xhci.c           | 2 +-
 include/hw/acpi/pcihp.h     | 2 +-
 include/migration/vmstate.h | 5 ++---
 target-i386/machine.c       | 6 ++----
 8 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index dc5768f..99dcb04 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -678,7 +678,7 @@ static const VMStateDescription vmstate_escc = {
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY_TEST(chn, ESCCState, 2, vmstate_2_plus, 0,
+        VMSTATE_STRUCT_ARRAY_TEST(chn, ESCCState, 2, vmstate_2_plus,
                                   vmstate_escc_chn, ChannelState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 23330be..a75e524 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -526,7 +526,7 @@ extern const VMStateDescription vmstate_ide_bus;
 extern const VMStateDescription vmstate_ide_drive;

 #define VMSTATE_IDE_DRIVES(_field, _state) \
-    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, 2, vmstate_3_plus, 0,\
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, 2, vmstate_3_plus,\
                               vmstate_ide_drive, IDEState)

 void ide_bus_reset(IDEBus *bus);
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
index b7bd908..9e36a93 100644
--- a/hw/timer/i8254_common.c
+++ b/hw/timer/i8254_common.c
@@ -269,7 +269,7 @@ static const VMStateDescription vmstate_pit_common = {
         VMSTATE_UINT32_TEST(channels[0].irq_disabled, PITCommonState,
             vmstate_3_plus),
         VMSTATE_STRUCT_ARRAY_TEST(channels, PITCommonState, 3,
-                                  vmstate_2_plus, 0, vmstate_pit_channel,
+                                  vmstate_2_plus, vmstate_pit_channel,
                                   PITChannelState),
         VMSTATE_INT64(channels[0].next_transition_time,
                       PITCommonState), /* formerly irq_timer */
diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c
index 393a792..a8af5a0 100644
--- a/hw/timer/pxa2xx_timer.c
+++ b/hw/timer/pxa2xx_timer.c
@@ -519,7 +519,7 @@ static const VMStateDescription vmstate_pxa2xx_timer_regs = {
         VMSTATE_UINT32(reset3, PXA2xxTimerInfo),
         VMSTATE_UINT32(snapshot, PXA2xxTimerInfo),
         VMSTATE_STRUCT_ARRAY_TEST(tm4, PXA2xxTimerInfo, 8,
-                        pxa2xx_timer_has_tm4_test, 0,
+                        pxa2xx_timer_has_tm4_test,
                         vmstate_pxa2xx_timer4_regs, PXA2xxTimer4),
         VMSTATE_END_OF_LIST(),
     }
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index a95bd30..d1e4bd0 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3737,7 +3737,7 @@ static const VMStateDescription vmstate_xhci_intr = {
         VMSTATE_UINT32_TEST(ev_buffer_put, XHCIInterrupter, xhci_er_full),
         VMSTATE_UINT32_TEST(ev_buffer_get, XHCIInterrupter, xhci_er_full),
         VMSTATE_STRUCT_ARRAY_TEST(ev_buffer, XHCIInterrupter, EV_QUEUE,
-                                  xhci_er_full, 1,
+                                  xhci_er_full,
                                   vmstate_xhci_event, XHCIEvent),

         VMSTATE_END_OF_LIST()
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 9323838..ac80832 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -68,7 +68,7 @@ extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
                             test_pcihp), \
         VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
                                   ACPI_PCIHP_MAX_HOTPLUG_BUS, \
-                                  test_pcihp, 1, \
+                                  test_pcihp, \
                                   vmstate_acpi_pcihp_pci_status, \
                                   AcpiPciHpPciStatus)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index b0e49f1..02b20b1 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -313,11 +313,10 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_array(_s, _f, _type*, _n),          \
 }

-#define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \
+#define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _vmsd, _type) { \
     .name         = (stringify(_field)),                             \
     .num          = (_num),                                          \
     .field_exists = (_test),                                         \
-    .version_id   = (_version),                                      \
     .vmsd         = &(_vmsd),                                        \
     .size         = sizeof(_type),                                   \
     .flags        = VMS_STRUCT|VMS_ARRAY,                            \
@@ -457,7 +456,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)

 #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _vmsd, _type) \
-    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, 0, _vmsd, _type)
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _vmsd, _type)

 #define VMSTATE_BOOL_TEST(_f, _s, _t)                                 \
     VMSTATE_SINGLE(_f, _s, _t, vmstate_info_bool, bool)
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 0e91901..15be22b 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -58,8 +58,7 @@ static const VMStateDescription vmstate_ymmh_reg = {
 };

 #define VMSTATE_YMMH_REGS_VARS(_field, _state, _n, _t)                         \
-    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _n, _t, 0,\
-                              vmstate_ymmh_reg, XMMReg)
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _n, _t, vmstate_ymmh_reg, XMMReg)

 static const VMStateDescription vmstate_bnd_regs = {
     .name = "bnd_regs",
@@ -87,8 +86,7 @@ static const VMStateDescription vmstate_mtrr_var = {
 };

 #define VMSTATE_MTRR_VARS(_field, _state, _n, _t)                    \
-    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _n, _t, 0,\
-                              vmstate_mtrr_var, MTRRVar)
+    VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _n, _t, vmstate_mtrr_var, MTRRVar)

 static void put_fpreg_error(QEMUFile *f, void *opaque, size_t size)
 {
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 70/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_INT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (68 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 69/97] vmstate: Remove version parameter from VMSTATE_STRUCT_ARRAY_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 71/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_UINT8 Juan Quintela
                   ` (28 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/input/stellaris_input.c  | 2 +-
 include/migration/vmstate.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
index 0609e80..07e7856 100644
--- a/hw/input/stellaris_input.c
+++ b/hw/input/stellaris_input.c
@@ -63,7 +63,7 @@ static const VMStateDescription vmstate_stellaris_gamepad = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(extension, gamepad_state),
-        VMSTATE_STRUCT_VARRAY_INT32(buttons, gamepad_state, num_buttons, 0,
+        VMSTATE_STRUCT_VARRAY_INT32(buttons, gamepad_state, num_buttons,
                               vmstate_stellaris_button, gamepad_button),
         VMSTATE_END_OF_LIST()
     }
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 02b20b1..1322220 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -360,10 +360,9 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_pointer(_state, _field, _type),     \
 }

-#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \
+#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _vmsd, _type) { \
     .name       = (stringify(_field)),                               \
     .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
-    .version_id = (_version),                                        \
     .vmsd       = &(_vmsd),                                          \
     .size       = sizeof(_type),                                     \
     .flags      = VMS_STRUCT|VMS_VARRAY_INT32,                       \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 71/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_UINT8
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (69 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 70/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_INT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 72/97] vmstate: Introduce VMSTATE_VARRAY_UINT32_TEST Juan Quintela
                   ` (27 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/timer/hpet.c             | 2 +-
 include/migration/vmstate.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 2148568..0fd2eb0 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -304,7 +304,7 @@ static const VMStateDescription vmstate_hpet = {
         VMSTATE_UINT64(isr, HPETState),
         VMSTATE_UINT64(hpet_counter, HPETState),
         VMSTATE_UINT8_TEST(num_timers, HPETState, vmstate_2_plus),
-        VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0,
+        VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers,
                                     vmstate_hpet_timer, HPETTimer),
         VMSTATE_END_OF_LIST()
     },
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 1322220..47219ad 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -323,10 +323,9 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_array(_state, _field, _type, _num),\
 }

-#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \
+#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _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_VARRAY_UINT8,                       \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 72/97] vmstate: Introduce VMSTATE_VARRAY_UINT32_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (70 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 71/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_UINT8 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 73/97] vmstate: Remove version parameter from VMSTATE_VARRAY_UINT32 Juan Quintela
                   ` (26 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Use it on the only case were a version was used.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/misc/arm_sysctl.c        | 5 +++--
 include/migration/vmstate.h | 7 +++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c
index 0f61241..668681f 100644
--- a/hw/misc/arm_sysctl.c
+++ b/hw/misc/arm_sysctl.c
@@ -67,8 +67,9 @@ static const VMStateDescription vmstate_arm_sysctl = {
         VMSTATE_UINT32_TEST(sys_clcd, arm_sysctl_state, vmstate_3_plus),
         VMSTATE_UINT32_ARRAY_TEST(mb_clock, arm_sysctl_state, 6,
                                   vmstate_4_plus),
-        VMSTATE_VARRAY_UINT32(db_clock, arm_sysctl_state, db_num_clocks,
-                              4, vmstate_info_uint32, uint32_t),
+        VMSTATE_VARRAY_UINT32_TEST(db_clock, arm_sysctl_state, db_num_clocks,
+                                   vmstate_4_plus, vmstate_info_uint32,
+                                   uint32_t),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 47219ad..2a914ec 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -257,9 +257,9 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = vmstate_offset_pointer(_state, _field, _type),     \
 }

-#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\
+#define VMSTATE_VARRAY_UINT32_TEST(_field, _state, _field_num, _test, _info, _type) {\
     .name       = (stringify(_field)),                               \
-    .version_id = (_version),                                        \
+    .field_exists = (_test),                                         \
     .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
     .info       = &(_info),                                          \
     .size       = sizeof(_type),                                     \
@@ -611,6 +611,9 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UNUSED(_size)                                         \
     VMSTATE_UNUSED_TEST(NULL, _size)

+#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) \
+    VMSTATE_VARRAY_UINT32_TEST(_field, _state, _field_num, NULL, _info, _type)
+
 #define VMSTATE_END_OF_LIST()                                         \
     {}

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 73/97] vmstate: Remove version parameter from VMSTATE_VARRAY_UINT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (71 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 72/97] vmstate: Introduce VMSTATE_VARRAY_UINT32_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 74/97] vmstate: Remove version parameter from VMSTATE_STRUCT_TEST Juan Quintela
                   ` (25 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/nvram/ds1225y.c          | 2 +-
 hw/ppc/spapr_iommu.c        | 3 ++-
 include/migration/vmstate.h | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
index 332598b..cfedfa8 100644
--- a/hw/nvram/ds1225y.c
+++ b/hw/nvram/ds1225y.c
@@ -97,7 +97,7 @@ static const VMStateDescription vmstate_nvram = {
     .minimum_version_id = 0,
     .post_load = nvram_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_VARRAY_UINT32(contents, NvRamState, chip_size, 0,
+        VMSTATE_VARRAY_UINT32(contents, NvRamState, chip_size,
                               vmstate_info_uint8, uint8_t),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
index ce15751..9fda2b3 100644
--- a/hw/ppc/spapr_iommu.c
+++ b/hw/ppc/spapr_iommu.c
@@ -105,7 +105,8 @@ static const VMStateDescription vmstate_spapr_tce_table = {

         /* IOMMU state */
         VMSTATE_BOOL(bypass, sPAPRTCETable),
-        VMSTATE_VARRAY_UINT32(table, sPAPRTCETable, nb_table, 0, vmstate_info_uint64, uint64_t),
+        VMSTATE_VARRAY_UINT32(table, sPAPRTCETable, nb_table,
+                              vmstate_info_uint64, uint64_t),

         VMSTATE_END_OF_LIST()
     },
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 2a914ec..7bbac50 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -611,7 +611,7 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_UNUSED(_size)                                         \
     VMSTATE_UNUSED_TEST(NULL, _size)

-#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) \
+#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _info, _type) \
     VMSTATE_VARRAY_UINT32_TEST(_field, _state, _field_num, NULL, _info, _type)

 #define VMSTATE_END_OF_LIST()                                         \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 74/97] vmstate: Remove version parameter from VMSTATE_STRUCT_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (72 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 73/97] vmstate: Remove version parameter from VMSTATE_VARRAY_UINT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 75/97] vmstate: Move all users of versioning to VMSTATE_STRUCT_TEST Juan Quintela
                   ` (24 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

As we haven't yet moved everything that uses VMSTATE_STRUCT_TEST we create a
temporary VMSTATE_STRUCT_INFO.  This would allows us to not having to move
fields to VMSTATE_STRUCT_TEST and then remove the version parameter.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/acpi/piix4.c             | 2 +-
 include/migration/vmstate.h | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 252bbf2..091dca3 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -270,7 +270,7 @@ static const VMStateDescription vmstate_acpi = {
             acpi_pci_hotplug.acpi_pcihp_pci_status[ACPI_PCIHP_BSEL_DEFAULT],
             PIIX4PMState,
             vmstate_test_no_use_acpi_pci_hotplug,
-            2, vmstate_pci_status,
+            vmstate_pci_status,
             struct AcpiPciHpPciStatus),
         VMSTATE_PCI_HOTPLUG(acpi_pci_hotplug, PIIX4PMState,
                             vmstate_test_use_acpi_pci_hotplug),
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 7bbac50..c6590cb 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -276,7 +276,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }

-#define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \
+#define VMSTATE_STRUCT_INFO(_field, _state, _test, _version, _vmsd, _type) { \
     .name         = (stringify(_field)),                             \
     .version_id   = (_version),                                      \
     .field_exists = (_test),                                         \
@@ -447,8 +447,11 @@ extern const VMStateInfo vmstate_info_bitmap;
    _v : version
 */

+#define VMSTATE_STRUCT_TEST(_field, _state, _test, _vmsd, _type)        \
+    VMSTATE_STRUCT_INFO(_field, _state, _test, 0, _vmsd, _type)
+
 #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type)        \
-    VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
+    VMSTATE_STRUCT_INFO(_field, _state, NULL, _version, _vmsd, _type)

 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type)          \
     VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 75/97] vmstate: Move all users of versioning to VMSTATE_STRUCT_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (73 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 74/97] vmstate: Remove version parameter from VMSTATE_STRUCT_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 76/97] vmstate: Remove version from all VMSTATE_STRUCT calls Juan Quintela
                   ` (23 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/usb/hcd-ehci-pci.c    | 3 ++-
 hw/usb/hcd-ehci-sysbus.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 505741a..6ada623 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -110,7 +110,8 @@ static const VMStateDescription vmstate_ehci_pci = {
     .minimum_version_id  = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(pcidev, EHCIPCIState),
-        VMSTATE_STRUCT(ehci, EHCIPCIState, 2, vmstate_ehci, EHCIState),
+        VMSTATE_STRUCT_TEST(ehci, EHCIPCIState, vmstate_2_plus,
+                            vmstate_ehci, EHCIState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index 19ed2c2..2c28555 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -22,7 +22,8 @@ static const VMStateDescription vmstate_ehci_sysbus = {
     .version_id  = 2,
     .minimum_version_id  = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(ehci, EHCISysBusState, 2, vmstate_ehci, EHCIState),
+        VMSTATE_STRUCT_TEST(ehci, EHCISysBusState, vmstate_2_plus,
+                            vmstate_ehci, EHCIState),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 76/97] vmstate: Remove version from all VMSTATE_STRUCT calls
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (74 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 75/97] vmstate: Move all users of versioning to VMSTATE_STRUCT_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 77/97] vmstate: Create VMSTATE_VARRAY macro Juan Quintela
                   ` (22 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

It has no users at this point.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/acpi/piix4.c                    |  4 ++--
 hw/arm/spitz.c                     |  2 +-
 hw/audio/pl041.c                   | 16 ++++++----------
 hw/block/fdc.c                     |  4 ++--
 hw/char/exynos4210_uart.c          |  2 +-
 hw/char/serial-isa.c               |  2 +-
 hw/char/serial-pci.c               |  2 +-
 hw/display/cirrus_vga.c            |  2 +-
 hw/display/qxl.c                   |  4 ++--
 hw/display/vga-pci.c               |  2 +-
 hw/display/vmware_vga.c            |  2 +-
 hw/dma/i82374.c                    |  2 +-
 hw/dma/pl330.c                     |  8 ++++----
 hw/i386/kvmvapic.c                 |  6 +++---
 hw/ide/internal.h                  |  2 +-
 hw/input/pckbd.c                   |  2 +-
 hw/input/ps2.c                     |  4 ++--
 hw/isa/lpc_ich9.c                  |  4 ++--
 hw/isa/vt82c686.c                  |  2 +-
 hw/net/allwinner_emac.c            |  2 +-
 hw/net/lan9118.c                   |  2 +-
 hw/net/lance.c                     |  2 +-
 hw/net/milkymist-minimac2.c        |  2 +-
 hw/net/ne2000-isa.c                |  2 +-
 hw/net/ne2000.c                    |  2 +-
 hw/net/pcnet-pci.c                 |  2 +-
 hw/net/rtl8139.c                   |  2 +-
 hw/net/xgmac.c                     |  2 +-
 hw/pci-bridge/ioh3420.c            |  2 +-
 hw/pci-bridge/xio3130_downstream.c |  2 +-
 hw/pci-bridge/xio3130_upstream.c   |  2 +-
 hw/scsi/esp-pci.c                  |  2 +-
 hw/scsi/esp.c                      |  2 +-
 hw/timer/exynos4210_mct.c          | 11 ++++-------
 hw/timer/pxa2xx_timer.c            |  4 ++--
 hw/timer/twl92230.c                |  6 ++----
 hw/usb/dev-smartcard-reader.c      |  2 +-
 hw/usb/hcd-xhci.c                  |  2 +-
 hw/usb/redirect.c                  |  8 ++++----
 include/hw/ipack/ipack.h           |  2 +-
 include/hw/ppc/spapr_vio.h         |  2 +-
 include/migration/vmstate.h        | 10 +++-------
 target-alpha/machine.c             |  2 +-
 target-lm32/machine.c              |  2 +-
 target-openrisc/machine.c          |  2 +-
 45 files changed, 70 insertions(+), 83 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 091dca3..527a5c8 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -262,10 +262,10 @@ static const VMStateDescription vmstate_acpi = {
         VMSTATE_UINT16(ar.pm1.evt.sts, PIIX4PMState),
         VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState),
         VMSTATE_UINT16(ar.pm1.cnt.cnt, PIIX4PMState),
-        VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState),
+        VMSTATE_STRUCT(apm, PIIX4PMState, vmstate_apm, APMState),
         VMSTATE_TIMER(ar.tmr.timer, PIIX4PMState),
         VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState),
-        VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE),
+        VMSTATE_STRUCT(ar.gpe, PIIX4PMState, vmstate_gpe, ACPIGPE),
         VMSTATE_STRUCT_TEST(
             acpi_pci_hotplug.acpi_pcihp_pci_status[ACPI_PCIHP_BSEL_DEFAULT],
             PIIX4PMState,
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index a179c1d..cff3a9e 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -1008,7 +1008,7 @@ static VMStateDescription vmstate_sl_nand_info = {
     .minimum_version_id = 0,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(ctl, SLNANDState),
-        VMSTATE_STRUCT(ecc, SLNANDState, 0, vmstate_ecc_state, ECCState),
+        VMSTATE_STRUCT(ecc, SLNANDState, vmstate_ecc_state, ECCState),
         VMSTATE_END_OF_LIST(),
     },
 };
diff --git a/hw/audio/pl041.c b/hw/audio/pl041.c
index 19982f2..9b850c5 100644
--- a/hw/audio/pl041.c
+++ b/hw/audio/pl041.c
@@ -585,13 +585,11 @@ static const VMStateDescription vmstate_pl041_channel = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(tx_fifo, pl041_channel, 0,
-                       vmstate_pl041_fifo, pl041_fifo),
+        VMSTATE_STRUCT(tx_fifo, pl041_channel, vmstate_pl041_fifo, pl041_fifo),
         VMSTATE_UINT8(tx_enabled, pl041_channel),
         VMSTATE_UINT8(tx_compact_mode, pl041_channel),
         VMSTATE_UINT8(tx_sample_size, pl041_channel),
-        VMSTATE_STRUCT(rx_fifo, pl041_channel, 0,
-                       vmstate_pl041_fifo, pl041_fifo),
+        VMSTATE_STRUCT(rx_fifo, pl041_channel, vmstate_pl041_fifo, pl041_fifo),
         VMSTATE_UINT8(rx_enabled, pl041_channel),
         VMSTATE_UINT8(rx_compact_mode, pl041_channel),
         VMSTATE_UINT8(rx_sample_size, pl041_channel),
@@ -605,12 +603,10 @@ static const VMStateDescription vmstate_pl041 = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(fifo_depth, PL041State),
-        VMSTATE_STRUCT(regs, PL041State, 0,
-                       vmstate_pl041_regfile, pl041_regfile),
-        VMSTATE_STRUCT(fifo1, PL041State, 0,
-                       vmstate_pl041_channel, pl041_channel),
-        VMSTATE_STRUCT(codec, PL041State, 0,
-                       vmstate_lm4549_state, lm4549_state),
+        VMSTATE_STRUCT(regs, PL041State, vmstate_pl041_regfile, pl041_regfile),
+        VMSTATE_STRUCT(fifo1, PL041State, vmstate_pl041_channel,
+                       pl041_channel),
+        VMSTATE_STRUCT(codec, PL041State, vmstate_lm4549_state, lm4549_state),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 9d8d5d5..9d09369 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2206,7 +2206,7 @@ static const VMStateDescription vmstate_isa_fdc ={
     .version_id = 2,
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(state, FDCtrlISABus, 0, vmstate_fdc, FDCtrl),
+        VMSTATE_STRUCT(state, FDCtrlISABus, vmstate_fdc, FDCtrl),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -2248,7 +2248,7 @@ static const VMStateDescription vmstate_sysbus_fdc ={
     .version_id = 2,
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl),
+        VMSTATE_STRUCT(state, FDCtrlSysBus, vmstate_fdc, FDCtrl),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 872bc99..5722980 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -573,7 +573,7 @@ static const VMStateDescription vmstate_exynos4210_uart = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(rx, Exynos4210UartState, 1,
+        VMSTATE_STRUCT(rx, Exynos4210UartState,
                        vmstate_exynos4210_uart_fifo, Exynos4210UartFIFO),
         VMSTATE_UINT32_ARRAY(reg, Exynos4210UartState,
                              EXYNOS4210_UART_REGS_MEM_SIZE / sizeof(uint32_t)),
diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c
index c9fcb27..a36af51 100644
--- a/hw/char/serial-isa.c
+++ b/hw/char/serial-isa.c
@@ -81,7 +81,7 @@ static const VMStateDescription vmstate_isa_serial = {
     .version_id = 3,
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(state, ISASerialState, 0, vmstate_serial, SerialState),
+        VMSTATE_STRUCT(state, ISASerialState, vmstate_serial, SerialState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 25c930b..eea37eb 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -157,7 +157,7 @@ static const VMStateDescription vmstate_pci_serial = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCISerialState),
-        VMSTATE_STRUCT(state, PCISerialState, 0, vmstate_serial, SerialState),
+        VMSTATE_STRUCT(state, PCISerialState, vmstate_serial, SerialState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 55449a6..f3938f8 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2743,7 +2743,7 @@ static const VMStateDescription vmstate_pci_cirrus_vga = {
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCICirrusVGAState),
-        VMSTATE_STRUCT(cirrus_vga, PCICirrusVGAState, 0,
+        VMSTATE_STRUCT(cirrus_vga, PCICirrusVGAState,
                        vmstate_cirrus_vga, CirrusVGAState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 4114427..84399ec 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2258,7 +2258,7 @@ static VMStateDescription qxl_vmstate = {
     .post_load          = qxl_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(pci, PCIQXLDevice),
-        VMSTATE_STRUCT(vga, PCIQXLDevice, 0, vmstate_vga_common, VGACommonState),
+        VMSTATE_STRUCT(vga, PCIQXLDevice, vmstate_vga_common, VGACommonState),
         VMSTATE_UINT32(shadow_rom.mode, PCIQXLDevice),
         VMSTATE_UINT32(num_free_res, PCIQXLDevice),
         VMSTATE_UINT32(last_release_offset, PCIQXLDevice),
@@ -2267,7 +2267,7 @@ static VMStateDescription qxl_vmstate = {
         VMSTATE_INT32_EQUAL(num_memslots, PCIQXLDevice),
         VMSTATE_STRUCT_ARRAY(guest_slots, PCIQXLDevice, NUM_MEMSLOTS,
                              qxl_memslot, struct guest_slots),
-        VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, 0,
+        VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice,
                        qxl_surface, QXLSurfaceCreate),
         VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice),
         VMSTATE_VARRAY_INT32(guest_surfaces.cmds, PCIQXLDevice,
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index a2a9ca1..b3bc7e2 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -56,7 +56,7 @@ static const VMStateDescription vmstate_vga_pci = {
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCIVGAState),
-        VMSTATE_STRUCT(vga, PCIVGAState, 0, vmstate_vga_common, VGACommonState),
+        VMSTATE_STRUCT(vga, PCIVGAState, vmstate_vga_common, VGACommonState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 90dfbf3..3d1c965 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1180,7 +1180,7 @@ static const VMStateDescription vmstate_vmware_vga = {
     .minimum_version_id = 0,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, struct pci_vmsvga_state_s),
-        VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0,
+        VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s,
                        vmstate_vmware_vga_internal, struct vmsvga_state_s),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c
index dc7a767..b0377fa 100644
--- a/hw/dma/i82374.c
+++ b/hw/dma/i82374.c
@@ -119,7 +119,7 @@ static const VMStateDescription vmstate_isa_i82374 = {
     .version_id = 0,
     .minimum_version_id = 0,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(state, ISAi82374State, 0, vmstate_i82374, I82374State),
+        VMSTATE_STRUCT(state, ISAi82374State, vmstate_i82374, I82374State),
         VMSTATE_END_OF_LIST()
     },
 };
diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index 9ba3108..94d5cfd 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -276,15 +276,15 @@ static const VMStateDescription vmstate_pl330 = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(manager, PL330State, 0, vmstate_pl330_chan, PL330Chan),
+        VMSTATE_STRUCT(manager, PL330State, vmstate_pl330_chan, PL330Chan),
         VMSTATE_STRUCT_VARRAY_UINT32(chan, PL330State, num_chnls,
                                      vmstate_pl330_chan, PL330Chan),
         VMSTATE_VBUFFER_UINT32(lo_seqn, PL330State, num_chnls),
         VMSTATE_VBUFFER_UINT32(hi_seqn, PL330State, num_chnls),
-        VMSTATE_STRUCT(fifo, PL330State, 0, vmstate_pl330_fifo, PL330Fifo),
-        VMSTATE_STRUCT(read_queue, PL330State, 0, vmstate_pl330_queue,
+        VMSTATE_STRUCT(fifo, PL330State, vmstate_pl330_fifo, PL330Fifo),
+        VMSTATE_STRUCT(read_queue, PL330State, vmstate_pl330_queue,
                        PL330Queue),
-        VMSTATE_STRUCT(write_queue, PL330State, 0, vmstate_pl330_queue,
+        VMSTATE_STRUCT(write_queue, PL330State, vmstate_pl330_queue,
                        PL330Queue),
         VMSTATE_TIMER(timer, PL330State),
         VMSTATE_UINT32(inten, PL330State),
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index a730f4b..56001b4 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -795,8 +795,8 @@ static const VMStateDescription vmstate_guest_rom = {
         VMSTATE_UINT32(vapic_size, GuestROMState),
         VMSTATE_UINT32(vcpu_shift, GuestROMState),
         VMSTATE_UINT32(real_tpr_addr, GuestROMState),
-        VMSTATE_STRUCT(up, GuestROMState, 0, vmstate_handlers, VAPICHandlers),
-        VMSTATE_STRUCT(mp, GuestROMState, 0, vmstate_handlers, VAPICHandlers),
+        VMSTATE_STRUCT(up, GuestROMState, vmstate_handlers, VAPICHandlers),
+        VMSTATE_STRUCT(mp, GuestROMState, vmstate_handlers, VAPICHandlers),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -807,7 +807,7 @@ static const VMStateDescription vmstate_vapic = {
     .minimum_version_id = 1,
     .post_load = vapic_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(rom_state, VAPICROMState, 0, vmstate_guest_rom,
+        VMSTATE_STRUCT(rom_state, VAPICROMState, vmstate_guest_rom,
                        GuestROMState),
         VMSTATE_UINT32(state, VAPICROMState),
         VMSTATE_UINT32(real_tpr_addr, VAPICROMState),
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index a75e524..459fabc 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -518,7 +518,7 @@ static inline void ide_set_irq(IDEBus *bus)
 extern const VMStateDescription vmstate_ide_bus;

 #define VMSTATE_IDE_BUS(_field, _state)                          \
-    VMSTATE_STRUCT(_field, _state, 1, vmstate_ide_bus, IDEBus)
+    VMSTATE_STRUCT(_field, _state, vmstate_ide_bus, IDEBus)

 #define VMSTATE_IDE_BUS_ARRAY(_field, _state, _num)              \
     VMSTATE_STRUCT_ARRAY(_field, _state, _num, vmstate_ide_bus, IDEBus)
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index ca1cffc..0df9b11 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -462,7 +462,7 @@ static const VMStateDescription vmstate_kbd_isa = {
     .version_id = 3,
     .minimum_version_id = 3,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(kbd, ISAKBDState, 0, vmstate_kbd, KBDState),
+        VMSTATE_STRUCT(kbd, ISAKBDState, vmstate_kbd, KBDState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index e05ff0d..7bb98ee 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -610,7 +610,7 @@ static const VMStateDescription vmstate_ps2_keyboard = {
     .minimum_version_id = 2,
     .post_load = ps2_kbd_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(common, PS2KbdState, 0, vmstate_ps2_common, PS2State),
+        VMSTATE_STRUCT(common, PS2KbdState, vmstate_ps2_common, PS2State),
         VMSTATE_INT32(scan_enabled, PS2KbdState),
         VMSTATE_INT32(translate, PS2KbdState),
         VMSTATE_INT32_TEST(scancode_set, PS2KbdState, vmstate_3_plus),
@@ -631,7 +631,7 @@ static const VMStateDescription vmstate_ps2_mouse = {
     .version_id = 2,
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(common, PS2MouseState, 0, vmstate_ps2_common, PS2State),
+        VMSTATE_STRUCT(common, PS2MouseState, vmstate_ps2_common, PS2State),
         VMSTATE_UINT8(mouse_status, PS2MouseState),
         VMSTATE_UINT8(mouse_resolution, PS2MouseState),
         VMSTATE_UINT8(mouse_sample_rate, PS2MouseState),
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 97f69d6..b2dc66a 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -619,8 +619,8 @@ static const VMStateDescription vmstate_ich9_lpc = {
     .post_load = ich9_lpc_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(d, ICH9LPCState),
-        VMSTATE_STRUCT(apm, ICH9LPCState, 0, vmstate_apm, APMState),
-        VMSTATE_STRUCT(pm, ICH9LPCState, 0, vmstate_ich9_pm, ICH9LPCPMRegs),
+        VMSTATE_STRUCT(apm, ICH9LPCState, vmstate_apm, APMState),
+        VMSTATE_STRUCT(pm, ICH9LPCState, vmstate_ich9_pm, ICH9LPCPMRegs),
         VMSTATE_UINT8_ARRAY(chip_config, ICH9LPCState, ICH9_CC_SIZE),
         VMSTATE_UINT32(sci_level, ICH9LPCState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index e0c235c..948eb31 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -236,7 +236,7 @@ static const VMStateDescription vmstate_acpi = {
         VMSTATE_UINT16(ar.pm1.evt.sts, VT686PMState),
         VMSTATE_UINT16(ar.pm1.evt.en, VT686PMState),
         VMSTATE_UINT16(ar.pm1.cnt.cnt, VT686PMState),
-        VMSTATE_STRUCT(apm, VT686PMState, 0, vmstate_apm, APMState),
+        VMSTATE_STRUCT(apm, VT686PMState, vmstate_apm, APMState),
         VMSTATE_TIMER(ar.tmr.timer, VT686PMState),
         VMSTATE_INT64(ar.tmr.overflow_time, VT686PMState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
index 0b3cf9a..375fb98 100644
--- a/hw/net/allwinner_emac.c
+++ b/hw/net/allwinner_emac.c
@@ -494,7 +494,7 @@ static const VMStateDescription vmstate_aw_emac = {
     .minimum_version_id = 1,
     .post_load = aw_emac_post_load,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(mii, AwEmacState, 1, vmstate_mii, RTL8201CPState),
+        VMSTATE_STRUCT(mii, AwEmacState, vmstate_mii, RTL8201CPState),
         VMSTATE_UINT32(ctl, AwEmacState),
         VMSTATE_UINT32(tx_mode, AwEmacState),
         VMSTATE_UINT32(rx_ctl, AwEmacState),
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index fbba410..b5cac54 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -289,7 +289,7 @@ static const VMStateDescription vmstate_lan9118 = {
         VMSTATE_UINT8_ARRAY(eeprom, lan9118_state, 128),
         VMSTATE_INT32(tx_fifo_size, lan9118_state),
         /* txp always points at tx_packet so need not be saved */
-        VMSTATE_STRUCT(tx_packet, lan9118_state, 0,
+        VMSTATE_STRUCT(tx_packet, lan9118_state,
                        vmstate_lan9118_packet, LAN9118Packet),
         VMSTATE_INT32(tx_status_fifo_used, lan9118_state),
         VMSTATE_INT32(tx_status_fifo_head, lan9118_state),
diff --git a/hw/net/lance.c b/hw/net/lance.c
index 7811a9e..a8aa31f 100644
--- a/hw/net/lance.c
+++ b/hw/net/lance.c
@@ -111,7 +111,7 @@ static const VMStateDescription vmstate_lance = {
     .version_id = 3,
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(state, SysBusPCNetState, 0, vmstate_pcnet, PCNetState),
+        VMSTATE_STRUCT(state, SysBusPCNetState, vmstate_pcnet, PCNetState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/net/milkymist-minimac2.c b/hw/net/milkymist-minimac2.c
index c023351..88f2fff 100644
--- a/hw/net/milkymist-minimac2.c
+++ b/hw/net/milkymist-minimac2.c
@@ -511,7 +511,7 @@ static const VMStateDescription vmstate_milkymist_minimac2 = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, MilkymistMinimac2State, R_MAX),
         VMSTATE_UINT16_ARRAY(phy_regs, MilkymistMinimac2State, R_PHY_MAX),
-        VMSTATE_STRUCT(mdio, MilkymistMinimac2State, 0,
+        VMSTATE_STRUCT(mdio, MilkymistMinimac2State,
                 vmstate_milkymist_minimac2_mdio, MilkymistMinimac2MdioState),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/net/ne2000-isa.c b/hw/net/ne2000-isa.c
index 8740844..0ed0721 100644
--- a/hw/net/ne2000-isa.c
+++ b/hw/net/ne2000-isa.c
@@ -60,7 +60,7 @@ static const VMStateDescription vmstate_isa_ne2000 = {
     .version_id = 2,
     .minimum_version_id = 0,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(ne2000, ISANE2000State, 0, vmstate_ne2000, NE2000State),
+        VMSTATE_STRUCT(ne2000, ISANE2000State, vmstate_ne2000, NE2000State),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 84745d64..cda1934 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -646,7 +646,7 @@ static const VMStateDescription vmstate_pci_ne2000 = {
     .minimum_version_id = 3,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(dev, PCINE2000State),
-        VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
+        VMSTATE_STRUCT(ne2000, PCINE2000State, vmstate_ne2000, NE2000State),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index b25d789..49973a0 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -243,7 +243,7 @@ static const VMStateDescription vmstate_pci_pcnet = {
     .minimum_version_id = 2,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIPCNetState),
-        VMSTATE_STRUCT(state, PCIPCNetState, 0, vmstate_pcnet, PCNetState),
+        VMSTATE_STRUCT(state, PCIPCNetState, vmstate_pcnet, PCNetState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 936adb0..1da39fa 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3360,7 +3360,7 @@ static const VMStateDescription vmstate_rtl8139 = {
         VMSTATE_UINT32(TimerInt, RTL8139State),
         VMSTATE_INT64(TCTR_base, RTL8139State),

-        VMSTATE_STRUCT(tally_counters, RTL8139State, 0,
+        VMSTATE_STRUCT(tally_counters, RTL8139State,
                        vmstate_tally_counters, RTL8139TallyCounters),

         VMSTATE_UINT32_TEST(cplus_enabled, RTL8139State, vmstate_4_plus),
diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c
index 8619491..f860e0d 100644
--- a/hw/net/xgmac.c
+++ b/hw/net/xgmac.c
@@ -171,7 +171,7 @@ static const VMStateDescription vmstate_xgmac = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(stats, XgmacState, 0, vmstate_rxtx_stats, RxTxStats),
+        VMSTATE_STRUCT(stats, XgmacState, vmstate_rxtx_stats, RxTxStats),
         VMSTATE_UINT32_ARRAY(regs, XgmacState, R_MAX),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index f4e17ac..2805bc7 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -188,7 +188,7 @@ static const VMStateDescription vmstate_ioh3420 = {
     .fields = (VMStateField[]) {
         VMSTATE_PCIE_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
         VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
-                       PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
+                       PCIESlot, vmstate_pcie_aer_log, PCIEAERLog),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
index 8f22f93..3fbdacd 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -155,7 +155,7 @@ static const VMStateDescription vmstate_xio3130_downstream = {
     .fields = (VMStateField[]) {
         VMSTATE_PCIE_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
         VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
-                       PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
+                       PCIESlot, vmstate_pcie_aer_log, PCIEAERLog),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index eada582..9e1ef9d 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -133,7 +133,7 @@ static const VMStateDescription vmstate_xio3130_upstream = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCIE_DEVICE(parent_obj.parent_obj, PCIEPort),
-        VMSTATE_STRUCT(parent_obj.parent_obj.exp.aer_log, PCIEPort, 0,
+        VMSTATE_STRUCT(parent_obj.parent_obj.exp.aer_log, PCIEPort,
                        vmstate_pcie_aer_log, PCIEAERLog),
         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index e592d81..98e2926 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -313,7 +313,7 @@ static const VMStateDescription vmstate_esp_pci_scsi = {
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, PCIESPState),
         VMSTATE_BUFFER_UNSAFE(dma_regs, PCIESPState, 8 * sizeof(uint32_t)),
-        VMSTATE_STRUCT(esp, PCIESPState, 0, vmstate_esp, ESPState),
+        VMSTATE_STRUCT(esp, PCIESPState, vmstate_esp, ESPState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 5ab44d8..ab0b7fe 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -706,7 +706,7 @@ static const VMStateDescription vmstate_sysbus_esp_scsi = {
     .version_id = 0,
     .minimum_version_id = 0,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(esp, SysBusESPState, 0, vmstate_esp, ESPState),
+        VMSTATE_STRUCT(esp, SysBusESPState, vmstate_esp, ESPState),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index 0fd8d24..2705467 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -299,12 +299,10 @@ static const VMStateDescription vmstate_exynos4210_mct_lt = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(id, Exynos4210MCTLT),
-        VMSTATE_STRUCT(tick_timer, Exynos4210MCTLT, 0,
-                vmstate_tick_timer,
+        VMSTATE_STRUCT(tick_timer, Exynos4210MCTLT, vmstate_tick_timer,
                 struct tick_timer),
         VMSTATE_PTIMER(ptimer_frc, Exynos4210MCTLT),
-        VMSTATE_STRUCT(reg, Exynos4210MCTLT, 0,
-                vmstate_lregs,
+        VMSTATE_STRUCT(reg, Exynos4210MCTLT, vmstate_lregs,
                 struct lregs),
         VMSTATE_END_OF_LIST()
     }
@@ -333,8 +331,7 @@ static const VMStateDescription vmstate_exynos4210_mct_gt = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(reg, Exynos4210MCTGT, 0, vmstate_gregs,
-                struct gregs),
+        VMSTATE_STRUCT(reg, Exynos4210MCTGT, vmstate_gregs, struct gregs),
         VMSTATE_UINT64(count, Exynos4210MCTGT),
         VMSTATE_INT32(curr_comp, Exynos4210MCTGT),
         VMSTATE_PTIMER(ptimer_frc, Exynos4210MCTGT),
@@ -350,7 +347,7 @@ static const VMStateDescription vmstate_exynos4210_mct_state = {
         VMSTATE_UINT32(reg_mct_cfg, Exynos4210MCTState),
         VMSTATE_STRUCT_ARRAY(l_timer, Exynos4210MCTState, 2,
             vmstate_exynos4210_mct_lt, Exynos4210MCTLT),
-        VMSTATE_STRUCT(g_timer, Exynos4210MCTState, 0,
+        VMSTATE_STRUCT(g_timer, Exynos4210MCTState,
             vmstate_exynos4210_mct_gt, Exynos4210MCTGT),
         VMSTATE_UINT32(freq, Exynos4210MCTState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c
index a8af5a0..54c9ce3 100644
--- a/hw/timer/pxa2xx_timer.c
+++ b/hw/timer/pxa2xx_timer.c
@@ -487,8 +487,8 @@ static const VMStateDescription vmstate_pxa2xx_timer4_regs = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(tm, PXA2xxTimer4, 1,
-                        vmstate_pxa2xx_timer0_regs, PXA2xxTimer0),
+        VMSTATE_STRUCT(tm, PXA2xxTimer4, vmstate_pxa2xx_timer0_regs,
+                       PXA2xxTimer0),
         VMSTATE_INT32(oldclock, PXA2xxTimer4),
         VMSTATE_INT32(clock, PXA2xxTimer4),
         VMSTATE_UINT64(lastload, PXA2xxTimer4),
diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index 26c6001..842cd6a 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -833,10 +833,8 @@ static const VMStateDescription vmstate_menelaus = {
         VMSTATE_UINT8(rtc.ctrl, MenelausState),
         VMSTATE_UINT16(rtc.comp, MenelausState),
         VMSTATE_UINT16(rtc_next_vmstate, MenelausState),
-        VMSTATE_STRUCT(rtc.new, MenelausState, 0, vmstate_menelaus_tm,
-                       struct tm),
-        VMSTATE_STRUCT(rtc.alm, MenelausState, 0, vmstate_menelaus_tm,
-                       struct tm),
+        VMSTATE_STRUCT(rtc.new, MenelausState, vmstate_menelaus_tm, struct tm),
+        VMSTATE_STRUCT(rtc.alm, MenelausState, vmstate_menelaus_tm, struct tm),
         VMSTATE_UINT8(pwrbtn_state, MenelausState),
         VMSTATE_I2C_SLAVE(parent_obj, MenelausState),
         VMSTATE_END_OF_LIST()
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index b72a578..4814209 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1405,7 +1405,7 @@ static VMStateDescription ccid_vmstate = {
     .post_load = ccid_post_load,
     .pre_save = ccid_pre_save,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(dev, USBCCIDState, 1, usb_device_vmstate, USBDevice),
+        VMSTATE_STRUCT(dev, USBCCIDState, usb_device_vmstate, USBDevice),
         VMSTATE_UINT8(debug, USBCCIDState),
         VMSTATE_BUFFER(bulk_out_data, USBCCIDState),
         VMSTATE_UINT32(bulk_out_pos, USBCCIDState),
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index d1e4bd0..7318d8f 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3772,7 +3772,7 @@ static const VMStateDescription vmstate_xhci = {
         /* Runtime Registers & state */
         VMSTATE_INT64(mfindex_start,  XHCIState),
         VMSTATE_TIMER(mfwrap_timer,   XHCIState),
-        VMSTATE_STRUCT(cmd_ring, XHCIState, 1, vmstate_xhci_ring, XHCIRing),
+        VMSTATE_STRUCT(cmd_ring, XHCIState, vmstate_xhci_ring, XHCIRing),

         VMSTATE_END_OF_LIST()
     }
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 9eff1ac..24e7e99 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -2323,16 +2323,16 @@ static const VMStateDescription usbredir_vmstate = {
         },
         VMSTATE_STRUCT_ARRAY(endpoint, USBRedirDevice, MAX_ENDPOINTS,
                              usbredir_ep_vmstate, struct endp_data),
-        VMSTATE_STRUCT(cancelled, USBRedirDevice, 1,
+        VMSTATE_STRUCT(cancelled, USBRedirDevice,
                        usbredir_ep_packet_id_queue_vmstate,
                        struct PacketIdQueue),
-        VMSTATE_STRUCT(already_in_flight, USBRedirDevice, 1,
+        VMSTATE_STRUCT(already_in_flight, USBRedirDevice,
                        usbredir_ep_packet_id_queue_vmstate,
                        struct PacketIdQueue),
-        VMSTATE_STRUCT(device_info, USBRedirDevice, 1,
+        VMSTATE_STRUCT(device_info, USBRedirDevice,
                        usbredir_device_info_vmstate,
                        struct usb_redir_device_connect_header),
-        VMSTATE_STRUCT(interface_info, USBRedirDevice, 1,
+        VMSTATE_STRUCT(interface_info, USBRedirDevice,
                        usbredir_interface_info_vmstate,
                        struct usb_redir_interface_info_header),
         VMSTATE_END_OF_LIST()
diff --git a/include/hw/ipack/ipack.h b/include/hw/ipack/ipack.h
index e95ffe8..89332c6 100644
--- a/include/hw/ipack/ipack.h
+++ b/include/hw/ipack/ipack.h
@@ -76,7 +76,7 @@ struct IPackDevice {
 extern const VMStateDescription vmstate_ipack_device;

 #define VMSTATE_IPACK_DEVICE(_field, _state)                            \
-    VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
+    VMSTATE_STRUCT(_field, _state, vmstate_ipack_device, IPackDevice)

 IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
 void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h
index 46edc2a..8080b7f 100644
--- a/include/hw/ppc/spapr_vio.h
+++ b/include/hw/ppc/spapr_vio.h
@@ -137,6 +137,6 @@ void spapr_vio_quiesce(void);
 extern const VMStateDescription vmstate_spapr_vio;

 #define VMSTATE_SPAPR_VIO(_f, _s) \
-    VMSTATE_STRUCT(_f, _s, 0, vmstate_spapr_vio, VIOsPAPRDevice)
+    VMSTATE_STRUCT(_f, _s, vmstate_spapr_vio, VIOsPAPRDevice)

 #endif /* _HW_SPAPR_VIO_H */
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index c6590cb..8602536 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -276,9 +276,8 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset     = offsetof(_state, _field),                          \
 }

-#define VMSTATE_STRUCT_INFO(_field, _state, _test, _version, _vmsd, _type) { \
+#define VMSTATE_STRUCT_TEST(_field, _state, _test, _vmsd, _type) { \
     .name         = (stringify(_field)),                             \
-    .version_id   = (_version),                                      \
     .field_exists = (_test),                                         \
     .vmsd         = &(_vmsd),                                        \
     .size         = sizeof(_type),                                   \
@@ -447,11 +446,8 @@ extern const VMStateInfo vmstate_info_bitmap;
    _v : version
 */

-#define VMSTATE_STRUCT_TEST(_field, _state, _test, _vmsd, _type)        \
-    VMSTATE_STRUCT_INFO(_field, _state, _test, 0, _vmsd, _type)
-
-#define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type)        \
-    VMSTATE_STRUCT_INFO(_field, _state, NULL, _version, _vmsd, _type)
+#define VMSTATE_STRUCT(_field, _state, _vmsd, _type)        \
+    VMSTATE_STRUCT_TEST(_field, _state, NULL, _vmsd, _type)

 #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type)          \
     VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type)
diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index e796bbe..5e69b1e 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -77,7 +77,7 @@ static const VMStateDescription vmstate_env = {

 static VMStateField vmstate_cpu_fields[] = {
     VMSTATE_CPU(),
-    VMSTATE_STRUCT(env, AlphaCPU, 1, vmstate_env, CPUAlphaState),
+    VMSTATE_STRUCT(env, AlphaCPU, vmstate_env, CPUAlphaState),
     VMSTATE_END_OF_LIST()
 };

diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index 8327c6d..eac0659 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -26,7 +26,7 @@ const VMStateDescription vmstate_lm32_cpu = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(env, LM32CPU, 1, vmstate_env, CPULM32State),
+        VMSTATE_STRUCT(env, LM32CPU, vmstate_env, CPULM32State),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/target-openrisc/machine.c b/target-openrisc/machine.c
index 9f66a9c..d435e7d 100644
--- a/target-openrisc/machine.c
+++ b/target-openrisc/machine.c
@@ -44,7 +44,7 @@ const VMStateDescription vmstate_openrisc_cpu = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_CPU(),
-        VMSTATE_STRUCT(env, OpenRISCCPU, 1, vmstate_env, CPUOpenRISCState),
+        VMSTATE_STRUCT(env, OpenRISCCPU, vmstate_env, CPUOpenRISCState),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 77/97] vmstate: Create VMSTATE_VARRAY macro
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (75 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 76/97] vmstate: Remove version from all VMSTATE_STRUCT calls Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 78/97] vmstate: Create VMSTATE_POINTER_UNSAFE Juan Quintela
                   ` (21 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Use it instead of hard-ecoding it on ich9 for GPE.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/acpi/ich9.c              | 11 ++---------
 include/migration/vmstate.h | 10 ++++++++++
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 407ae89..f4801d1 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -129,15 +129,8 @@ static int ich9_pm_post_load(void *opaque, int version_id)
 }

 #define VMSTATE_GPE_ARRAY(_field, _state)                            \
- {                                                                   \
-     .name       = (stringify(_field)),                              \
-     .version_id = 0,                                                \
-     .num        = ICH9_PMIO_GPE0_LEN,                               \
-     .info       = &vmstate_info_uint8,                              \
-     .size       = sizeof(uint8_t),                                  \
-     .flags      = VMS_ARRAY | VMS_POINTER,                          \
-     .offset     = vmstate_offset_pointer(_state, _field, uint8_t),  \
- }
+    VMSTATE_VARRAY(_field, _state, ICH9_PMIO_GPE0_LEN, NULL,         \
+                   vmstate_info_uint8, uint8)

 const VMStateDescription vmstate_ich9_pm = {
     .name = "ich9_pm",
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 8602536..d0115e6 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -230,6 +230,16 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_array(_state, _field, _type, _num),\
 }

+#define VMSTATE_VARRAY(_field, _state, _num, _test, _info, _type) {   \
+    .name         = (stringify(_field)),                              \
+    .field_exists = (_test),                                          \
+    .num          = (_num),                                           \
+    .info         = &(_info),                                         \
+    .size         = sizeof(_type),                                    \
+    .flags        = VMS_ARRAY | VMS_POINTER,                          \
+    .offset       = vmstate_offset_pointer(_state, _field, _type),\
+}
+
 #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _info, _type) { \
     .name       = (stringify(_field)),                               \
     .num        = (_num),                                            \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 78/97] vmstate: Create VMSTATE_POINTER_UNSAFE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (76 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 77/97] vmstate: Create VMSTATE_VARRAY macro Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 79/97] vmstate: Create VMSTATE_OPENCODED_UNSAFE Juan Quintela
                   ` (20 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

And use it on piix4 acpi.
Comment asks for why this things happen!

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/acpi/piix4.c             | 15 +++++++--------
 include/migration/vmstate.h |  8 ++++++++
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 527a5c8..267b611 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -163,15 +163,14 @@ static int vmstate_acpi_post_load(void *opaque, int version_id)
     return 0;
 }

+/*
+ * Comment goes here why we are sending a uint16_t value through an
+ * uint8_t pointer.  And why we call it an array, when we only sent
+ * a single value.
+ */
+
 #define VMSTATE_GPE_ARRAY(_field, _state)                            \
- {                                                                   \
-     .name       = (stringify(_field)),                              \
-     .version_id = 0,                                                \
-     .info       = &vmstate_info_uint16,                             \
-     .size       = sizeof(uint16_t),                                 \
-     .flags      = VMS_SINGLE | VMS_POINTER,                         \
-     .offset     = vmstate_offset_pointer(_state, _field, uint8_t),  \
- }
+    VMSTATE_POINTER_UNSAFE(_field, _state, vmstate_info_uint16, uint16_t)

 static const VMStateDescription vmstate_gpe = {
     .name = "gpe",
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index d0115e6..7418c64 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -210,6 +210,14 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_value(_state, _field, _type),     \
 }

+#define VMSTATE_POINTER_UNSAFE(_field, _state, _info, _type) {       \
+    .name         = (stringify(_field)),                             \
+    .info         = &(_info),                                        \
+    .size         = sizeof(_type),                                   \
+    .flags        = VMS_SINGLE|VMS_POINTER,                          \
+    .offset       = offsetof(_state, _field),                        \
+}
+
 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _test, _info, _type) { \
     .name         = (stringify(_field)),                                      \
     .field_exists = (_test),                                                  \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 79/97] vmstate: Create VMSTATE_OPENCODED_UNSAFE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (77 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 78/97] vmstate: Create VMSTATE_POINTER_UNSAFE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC Juan Quintela
                   ` (19 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

This is trick, to use devices that haven't been converted inside
vmstate state.  It was already used on the "wild", so create a macro
and convert the users.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/pci/msix.c               | 10 +---------
 hw/scsi/scsi-bus.c          | 10 +---------
 hw/usb/redirect.c           | 30 +++---------------------------
 include/migration/vmstate.h | 15 +++++++++++++++
 4 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index 5c49bfc..93258f0 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -590,15 +590,7 @@ static VMStateInfo vmstate_info_msix = {
 const VMStateDescription vmstate_msix = {
     .name = "msix",
     .fields = (VMStateField[]) {
-        {
-            .name         = "msix",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,   /* ouch */
-            .info         = &vmstate_info_msix,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("msix", vmstate_info_msix),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index a137c98..e11b16d 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1934,15 +1934,7 @@ const VMStateDescription vmstate_scsi_device = {
         VMSTATE_BOOL(sense_is_ua, SCSIDevice),
         VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice, 0, SCSI_SENSE_BUF_SIZE_OLD),
         VMSTATE_UINT32(sense_len, SCSIDevice),
-        {
-            .name         = "requests",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,   /* ouch */
-            .info         = &vmstate_info_scsi_requests,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("requests", vmstate_info_scsi_requests),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (VMStateSubsection []) {
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 24e7e99..255a92b 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -2180,15 +2180,7 @@ static const VMStateDescription usbredir_ep_vmstate = {
         VMSTATE_UINT8(interrupt_error, struct endp_data),
         VMSTATE_UINT8(bufpq_prefilled, struct endp_data),
         VMSTATE_UINT8(bufpq_dropping_packets, struct endp_data),
-        {
-            .name         = "bufpq",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,
-            .info         = &usbredir_ep_bufpq_vmstate_info,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("bufpq", usbredir_ep_bufpq_vmstate_info),
         VMSTATE_INT32(bufpq_target_size, struct endp_data),
         VMSTATE_END_OF_LIST()
     },
@@ -2248,15 +2240,7 @@ static const VMStateDescription usbredir_ep_packet_id_queue_vmstate = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        {
-            .name         = "queue",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,
-            .info         = &usbredir_ep_packet_id_q_vmstate_info,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("queue", usbredir_ep_packet_id_q_vmstate_info),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -2312,15 +2296,7 @@ static const VMStateDescription usbredir_vmstate = {
     .fields = (VMStateField[]) {
         VMSTATE_USB_DEVICE(dev, USBRedirDevice),
         VMSTATE_TIMER(attach_timer, USBRedirDevice),
-        {
-            .name         = "parser",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,
-            .info         = &usbredir_parser_vmstate_info,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("parser", usbredir_parser_vmstate_info),
         VMSTATE_STRUCT_ARRAY(endpoint, USBRedirDevice, MAX_ENDPOINTS,
                              usbredir_ep_vmstate, struct endp_data),
         VMSTATE_STRUCT(cancelled, USBRedirDevice,
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 7418c64..d695244 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -218,6 +218,21 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = offsetof(_state, _field),                        \
 }

+/*
+ *  We have a field that is opencoded in old style, but we want to use
+ *  it with VMSTATE.  Well, just create a vmstate_info struct, and a
+ *  name.  VMSTATE don't know what is behind it, it is unsafe,
+ *  anything can happens.
+ */
+
+#define VMSTATE_OPENCODED_UNSAFE(_name, _info) {                     \
+    .name         = (_name),                                         \
+    .info         = &(_info),                                        \
+    .size         = 0,                                               \
+    .flags        = VMS_SINGLE,                                      \
+    .offset       = 0,                                               \
+}
+
 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _test, _info, _type) { \
     .name         = (stringify(_field)),                                      \
     .field_exists = (_test),                                                  \
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (78 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 79/97] vmstate: Create VMSTATE_OPENCODED_UNSAFE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  8:32   ` Dr. David Alan Gilbert
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 81/97] vmstate: version_id is gone from fields Juan Quintela
                   ` (18 subsequent siblings)
  98 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

It is used for fields that don't exist on the State.  They are
generated on the fly for migration.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 14 ++++++++++++++
 target-alpha/machine.c      | 16 +++-------------
 target-arm/machine.c        | 18 ++----------------
 3 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index d695244..12020d9 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -201,6 +201,20 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_value(_state, _field, _type),     \
 }

+/*
+ * This is used for fields synthetized from the state, but that don't
+ * exist as such.  That is the reaso of offset 0.  They get the whole
+ * struct.
+ */
+
+#define VMSTATE_SYNTHETIC(_name, _info, _size) {                     \
+    .name         = (_name),                                         \
+    .size         = (_size),                                         \
+    .info         = &(_info),                                        \
+    .flags        = VMS_SINGLE,                                      \
+    .offset       = 0,                                               \
+}
+
 #define VMSTATE_POINTER(_field, _state, _test, _info, _type) {  \
     .name         = (stringify(_field)),                             \
     .info         = &(_info),                                        \
diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index 5e69b1e..a5db209 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -23,20 +23,10 @@ static const VMStateInfo vmstate_fpcr = {
 static VMStateField vmstate_env_fields[] = {
     VMSTATE_UINTTL_ARRAY(ir, CPUAlphaState, 31),
     VMSTATE_UINTTL_ARRAY(fir, CPUAlphaState, 31),
+
     /* Save the architecture value of the fpcr, not the internally
-       expanded version.  Since this architecture value does not
-       exist in memory to be stored, this requires a but of hoop
-       jumping.  We want OFFSET=0 so that we effectively pass ENV
-       to the helper functions, and we need to fill in the name by
-       hand since there's no field of that name.  */
-    {
-        .name = "fpcr",
-        .version_id = 0,
-        .size = sizeof(uint64_t),
-        .info = &vmstate_fpcr,
-        .flags = VMS_SINGLE,
-        .offset = 0
-    },
+       expanded version.  */
+    VMSTATE_SYNTHETIC("fpcr", vmstate_fpcr, sizeof(uint64_t)),
     VMSTATE_UINTTL(pc, CPUAlphaState),
     VMSTATE_UINTTL(unique, CPUAlphaState),
     VMSTATE_UINTTL(lock_addr, CPUAlphaState),
diff --git a/target-arm/machine.c b/target-arm/machine.c
index 3f2c485..fd01e99 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -47,14 +47,7 @@ static const VMStateDescription vmstate_vfp = {
          */
         VMSTATE_UINT32(env.vfp.xregs[0], ARMCPU),
         VMSTATE_UINT32_SUB_ARRAY(env.vfp.xregs, ARMCPU, 2, 14),
-        {
-            .name = "fpscr",
-            .version_id = 0,
-            .size = sizeof(uint32_t),
-            .info = &vmstate_fpscr,
-            .flags = VMS_SINGLE,
-            .offset = 0,
-        },
+        VMSTATE_SYNTHETIC("fpscr", vmstate_fpscr, sizeof(uint32)),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -224,14 +217,7 @@ const VMStateDescription vmstate_arm_cpu = {
     .post_load = cpu_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16),
-        {
-            .name = "cpsr",
-            .version_id = 0,
-            .size = sizeof(uint32_t),
-            .info = &vmstate_cpsr,
-            .flags = VMS_SINGLE,
-            .offset = 0,
-        },
+        VMSTATE_SYNTHETIC("cpsr", vmstate_cpsr, sizeof(uint32_t)),
         VMSTATE_UINT32(env.spsr, ARMCPU),
         VMSTATE_UINT32_ARRAY(env.banked_spsr, ARMCPU, 6),
         VMSTATE_UINT32_ARRAY(env.banked_r13, ARMCPU, 6),
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 81/97] vmstate: version_id is gone from fields
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (79 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 82/97] vmstate: Test for VMSTATE_SYNTHETIC Juan Quintela
                   ` (17 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

And after all this work, fields don't have version_id anymore.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 1 -
 vmstate.c                   | 5 +----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 12020d9..84533eb 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -112,7 +112,6 @@ typedef struct {
     const VMStateInfo *info;
     enum VMStateFlags flags;
     const VMStateDescription *vmsd;
-    int version_id;
     bool (*field_exists)(void *opaque, int version_id);
 } VMStateField;

diff --git a/vmstate.c b/vmstate.c
index ce197d2..ca6691b 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -74,10 +74,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
         }
     }
     while (field->name) {
-        if ((field->field_exists &&
-             field->field_exists(opaque, version_id)) ||
-            (!field->field_exists &&
-             field->version_id <= version_id)) {
+        if (!field->field_exists || field->field_exists(opaque, version_id)) {
             void *base_addr = vmstate_base_addr(opaque, field);
             int i, n_elems = vmstate_n_elems(opaque, field);
             int size = vmstate_size(opaque, field);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 82/97] vmstate: Test for VMSTATE_SYNTHETIC
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (80 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 81/97] vmstate: version_id is gone from fields Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 83/97] vmstate: Test for VMSTATE_UINT8_SUB_ARRAY Juan Quintela
                   ` (16 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f51c887..b3d77a2 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -95,6 +95,29 @@ TestSimple obj_simple = {
     .f64 = float64_pi,
 };

+static int get_42_as_uint32(QEMUFile *f, void *pv, size_t size)
+{
+    uint64_t v;
+    v = qemu_get_be32(f);
+    if (v != 42) {
+        printf("We haven't received 42!!!!'");
+        return -1;
+    }
+    return 0;
+}
+
+static void put_42_as_uint32(QEMUFile *f, void *pv, size_t size)
+{
+    uint64_t v = 42;
+    qemu_put_be32(f, v);
+}
+
+static const VMStateInfo vmstate_42_as_uint32 = {
+    .name = "42_as_uint32",
+    .get  = get_42_as_uint32,
+    .put  = put_42_as_uint32,
+};
+
 /* Description of the values.  If you add a primitive type
    you are expected to add a test here */

@@ -119,6 +142,7 @@ static const VMStateDescription vmstate_simple_primitive = {
         VMSTATE_INT64(i64_2, TestSimple),
         VMSTATE_FLOAT64(f64, TestSimple),
         VMSTATE_UNUSED(5),
+        VMSTATE_SYNTHETIC("synthetic", vmstate_42_as_uint32, sizeof(uint32)),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -152,6 +176,7 @@ uint8_t wire_simple_primitive[] = {
     /* i64_2 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x0b, 0x84,
     /* f64 */   0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18,
     /* unused */0x00, 0x00, 0x00, 0x00, 0x00,
+    /* synthe */0x00, 0x00, 0x00, 0x2a,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 83/97] vmstate: Test for VMSTATE_UINT8_SUB_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (81 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 82/97] vmstate: Test for VMSTATE_SYNTHETIC Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 84/97] vmstate: Test for VMSTATE_UINT32_SUB_ARRAY Juan Quintela
                   ` (15 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index b3d77a2..49e98a8 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -864,6 +864,81 @@ static void test_array_test(void)
         ELEM_NOT_ASSERT(i32_2, i);
     }
 }
+
+static const VMStateDescription vmstate_array_sub = {
+    .name = "array/test",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8_SUB_ARRAY(u8_1, TestArray, 0, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT8_SUB_ARRAY(u8_2, TestArray, 2 , 2),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_array_sub[] = {
+    /* u8_1 */         0x01, 0x02, 0x03, 0x04, 0x05,
+    /* u8_2 {3,4} */               0x03, 0x02,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_array_sub(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+    int i;
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_array_sub, &obj_array);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_array_sub)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_array_sub, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_array_sub, sizeof(wire_array_sub));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestArray obj;
+    SUCCESS(vmstate_load_state(loading, &vmstate_array_sub, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+
+    qemu_fclose(loading);
+
+    for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
+        ELEM_ASSERT(u8_1, i);
+    }
+    for (i = 0; i < 2; i++) {
+        ELEM_NOT_ASSERT(u8_2, i);
+    }
+    for (i = 2; i < 4; i++) {
+        ELEM_ASSERT(u8_2, i);
+    }
+    for (i = 4; i < VMSTATE_ARRAY_SIZE; i++) {
+        ELEM_NOT_ASSERT(u8_2, i);
+    }
+}
 #undef FIELD_ASSERT
 #undef ELEM_ASSERT
 #undef ELEM_NOT_ASSERT
@@ -1092,6 +1167,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/simple/bitmap", test_simple_bitmap);
     g_test_add_func("/vmstate/array/primitive", test_array_primitive);
     g_test_add_func("/vmstate/array/test", test_array_test);
+    g_test_add_func("/vmstate/array/sub", test_array_sub);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 84/97] vmstate: Test for VMSTATE_UINT32_SUB_ARRAY
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (82 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 83/97] vmstate: Test for VMSTATE_UINT8_SUB_ARRAY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 85/97] vmstate: Test for VMSTATE_BUFFER Juan Quintela
                   ` (14 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 49e98a8..a087007 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -873,6 +873,8 @@ static const VMStateDescription vmstate_array_sub = {
     .fields = (VMStateField[]) {
         VMSTATE_UINT8_SUB_ARRAY(u8_1, TestArray, 0, VMSTATE_ARRAY_SIZE),
         VMSTATE_UINT8_SUB_ARRAY(u8_2, TestArray, 2 , 2),
+        VMSTATE_UINT32_SUB_ARRAY(u32_1, TestArray, 0, VMSTATE_ARRAY_SIZE),
+        VMSTATE_UINT32_SUB_ARRAY(u32_2, TestArray, 2 , 2),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -880,6 +882,10 @@ static const VMStateDescription vmstate_array_sub = {
 uint8_t wire_array_sub[] = {
     /* u8_1 */         0x01, 0x02, 0x03, 0x04, 0x05,
     /* u8_2 {3,4} */               0x03, 0x02,
+    /* u32_1 */        0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
+                       0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
+                       0x00, 0x00, 0x00, 0x19,
+    /* u32_2 {3,4}*/   0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x16,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -928,15 +934,19 @@ static void test_array_sub(void)

     for (i = 0; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_ASSERT(u8_1, i);
+        ELEM_ASSERT(u32_1, i);
     }
     for (i = 0; i < 2; i++) {
         ELEM_NOT_ASSERT(u8_2, i);
+        ELEM_NOT_ASSERT(u32_2, i);
     }
     for (i = 2; i < 4; i++) {
         ELEM_ASSERT(u8_2, i);
+        ELEM_ASSERT(u32_2, i);
     }
     for (i = 4; i < VMSTATE_ARRAY_SIZE; i++) {
         ELEM_NOT_ASSERT(u8_2, i);
+        ELEM_NOT_ASSERT(u32_2, i);
     }
 }
 #undef FIELD_ASSERT
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 85/97] vmstate: Test for VMSTATE_BUFFER
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (83 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 84/97] vmstate: Test for VMSTATE_UINT32_SUB_ARRAY Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 86/97] vmstate: Test for VMSTATE_PARTIAL_BUFFER Juan Quintela
                   ` (13 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index a087007..2fbcc02 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -949,10 +949,78 @@ static void test_array_sub(void)
         ELEM_NOT_ASSERT(u32_2, i);
     }
 }
-#undef FIELD_ASSERT
 #undef ELEM_ASSERT
 #undef ELEM_NOT_ASSERT

+typedef struct TestBuffer {
+    uint8_t  buffer[6];
+} TestBuffer;
+
+TestBuffer obj_buffer = {
+    .buffer = "hello",
+};
+
+static const VMStateDescription vmstate_buffer_simple = {
+    .name = "array/test",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_BUFFER(buffer, TestBuffer),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_buffer_simple[] = {
+    /* buffer */       0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_buffer_simple(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_buffer_simple, &obj_buffer);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_buffer_simple)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_buffer_simple, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_buffer_simple, sizeof(wire_buffer_simple));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestBuffer obj;
+    SUCCESS(vmstate_load_state(loading, &vmstate_buffer_simple, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+
+    qemu_fclose(loading);
+    SUCCESS(memcmp(obj.buffer, obj_buffer.buffer, sizeof(obj.buffer)));
+}
+#undef FIELD_ASSERT
+

 typedef struct TestStruct {
     uint32_t a, b, c, e;
@@ -1178,6 +1246,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/array/primitive", test_array_primitive);
     g_test_add_func("/vmstate/array/test", test_array_test);
     g_test_add_func("/vmstate/array/sub", test_array_sub);
+    g_test_add_func("/vmstate/buffer/simple", test_buffer_simple);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 86/97] vmstate: Test for VMSTATE_PARTIAL_BUFFER
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (84 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 85/97] vmstate: Test for VMSTATE_BUFFER Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 87/97] vmstate: Test for VMSTATE_BUFFER_START_MIDDLE Juan Quintela
                   ` (12 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 2fbcc02..7b49dda 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -954,10 +954,12 @@ static void test_array_sub(void)

 typedef struct TestBuffer {
     uint8_t  buffer[6];
+    uint8_t  partial[13];
 } TestBuffer;

 TestBuffer obj_buffer = {
     .buffer = "hello",
+    .partial = "This is Juan",
 };

 static const VMStateDescription vmstate_buffer_simple = {
@@ -967,12 +969,14 @@ static const VMStateDescription vmstate_buffer_simple = {
     .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_BUFFER(buffer, TestBuffer),
+        VMSTATE_PARTIAL_BUFFER(partial, TestBuffer, 4),
         VMSTATE_END_OF_LIST()
     }
 };

 uint8_t wire_buffer_simple[] = {
     /* buffer */       0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
+    /* partial */      0x54, 0x68, 0x69, 0x73,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -1018,6 +1022,8 @@ static void test_buffer_simple(void)

     qemu_fclose(loading);
     SUCCESS(memcmp(obj.buffer, obj_buffer.buffer, sizeof(obj.buffer)));
+    SUCCESS(memcmp(obj.partial, obj_buffer.partial, 4));
+    FAILURE(memcmp(obj.partial+4, obj_buffer.partial+4, sizeof(obj.partial)-4));
 }
 #undef FIELD_ASSERT

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 87/97] vmstate: Test for VMSTATE_BUFFER_START_MIDDLE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (85 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 86/97] vmstate: Test for VMSTATE_PARTIAL_BUFFER Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 88/97] vmstate: Add tests for VMSTATE_BUFFER_TEST Juan Quintela
                   ` (11 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 7b49dda..5609ff0 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -955,11 +955,13 @@ static void test_array_sub(void)
 typedef struct TestBuffer {
     uint8_t  buffer[6];
     uint8_t  partial[13];
+    uint8_t  middle[13];
 } TestBuffer;

 TestBuffer obj_buffer = {
     .buffer = "hello",
     .partial = "This is Juan",
+    .middle = "hello world!"
 };

 static const VMStateDescription vmstate_buffer_simple = {
@@ -970,6 +972,7 @@ static const VMStateDescription vmstate_buffer_simple = {
     .fields = (VMStateField[]) {
         VMSTATE_BUFFER(buffer, TestBuffer),
         VMSTATE_PARTIAL_BUFFER(partial, TestBuffer, 4),
+        VMSTATE_BUFFER_START_MIDDLE(middle, TestBuffer, 6),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -977,6 +980,7 @@ static const VMStateDescription vmstate_buffer_simple = {
 uint8_t wire_buffer_simple[] = {
     /* buffer */       0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
     /* partial */      0x54, 0x68, 0x69, 0x73,
+    /* middle */       0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -1024,6 +1028,8 @@ static void test_buffer_simple(void)
     SUCCESS(memcmp(obj.buffer, obj_buffer.buffer, sizeof(obj.buffer)));
     SUCCESS(memcmp(obj.partial, obj_buffer.partial, 4));
     FAILURE(memcmp(obj.partial+4, obj_buffer.partial+4, sizeof(obj.partial)-4));
+    FAILURE(memcmp(obj.middle, obj_buffer.middle, 6));
+    SUCCESS(memcmp(obj.middle+6, obj_buffer.middle+6, sizeof(obj.middle)-6));
 }
 #undef FIELD_ASSERT

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 88/97] vmstate: Add tests for VMSTATE_BUFFER_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (86 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 87/97] vmstate: Test for VMSTATE_BUFFER_START_MIDDLE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 89/97] vmstate: Use VMSTATE_UINT8_2DARRAY instead of VMSTATE_BUFFER_TEST Juan Quintela
                   ` (10 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 5609ff0..afcfbde 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1031,6 +1031,68 @@ static void test_buffer_simple(void)
     FAILURE(memcmp(obj.middle, obj_buffer.middle, 6));
     SUCCESS(memcmp(obj.middle+6, obj_buffer.middle+6, sizeof(obj.middle)-6));
 }
+
+static const VMStateDescription vmstate_buffer_test = {
+    .name = "buffer/test",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_BUFFER_TEST(buffer, TestBuffer, test_true),
+        VMSTATE_BUFFER_TEST(partial, TestBuffer, test_false),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_buffer_test[] = {
+    /* buffer */       0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_buffer_test(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_buffer_test, &obj_buffer);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_buffer_test)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_buffer_test, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_buffer_test, sizeof(wire_buffer_test));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestBuffer obj;
+    SUCCESS(vmstate_load_state(loading, &vmstate_buffer_test, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+
+    qemu_fclose(loading);
+    SUCCESS(memcmp(obj.buffer, obj_buffer.buffer, sizeof(obj.buffer)));
+    FAILURE(memcmp(obj.partial, obj_buffer.partial, sizeof(obj.partial)));
+}
 #undef FIELD_ASSERT


@@ -1259,6 +1321,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/array/test", test_array_test);
     g_test_add_func("/vmstate/array/sub", test_array_sub);
     g_test_add_func("/vmstate/buffer/simple", test_buffer_simple);
+    g_test_add_func("/vmstate/buffer/test", test_buffer_test);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 89/97] vmstate: Use VMSTATE_UINT8_2DARRAY instead of VMSTATE_BUFFER_TEST
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (87 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 88/97] vmstate: Add tests for VMSTATE_BUFFER_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 90/97] vmstate: Test for VMSTATE_BUFFER_UNSAFE Juan Quintela
                   ` (9 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

In this two cases we have a 2D array, result is exactly the same, and
one typechecks and the other don't, so change it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/display/g364fb.c | 4 ++--
 hw/net/smc91c111.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index b1a7985..4196fb1 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -462,8 +462,8 @@ static const VMStateDescription vmstate_g364fb = {
     .post_load = g364fb_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_VBUFFER_UINT32(vram, G364State, vram_size),
-        VMSTATE_BUFFER_UNSAFE(color_palette, G364State, 256 * 3),
-        VMSTATE_BUFFER_UNSAFE(cursor_palette, G364State, 9),
+        VMSTATE_UINT8_2DARRAY(color_palette, G364State, 256, 3),
+        VMSTATE_UINT8_2DARRAY(cursor_palette, G364State, 3, 3),
         VMSTATE_UINT16_ARRAY(cursor, G364State, 512),
         VMSTATE_UINT32(cursor_position, G364State),
         VMSTATE_UINT32(ctla, G364State),
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index e74142e..215eebb 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -72,7 +72,7 @@ static const VMStateDescription vmstate_smc91c111 = {
         VMSTATE_INT32_ARRAY(rx_fifo, smc91c111_state, NUM_PACKETS),
         VMSTATE_INT32(tx_fifo_done_len, smc91c111_state),
         VMSTATE_INT32_ARRAY(tx_fifo_done, smc91c111_state, NUM_PACKETS),
-        VMSTATE_BUFFER_UNSAFE(data, smc91c111_state, NUM_PACKETS * 2048),
+        VMSTATE_UINT8_2DARRAY(data, smc91c111_state, NUM_PACKETS, 2048),
         VMSTATE_UINT8(int_level, smc91c111_state),
         VMSTATE_UINT8(int_mask, smc91c111_state),
         VMSTATE_END_OF_LIST()
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 90/97] vmstate: Test for VMSTATE_BUFFER_UNSAFE
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (88 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 89/97] vmstate: Use VMSTATE_UINT8_2DARRAY instead of VMSTATE_BUFFER_TEST Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 91/97] vmstate: Remove unused VMSTATE_SUB_VBUFFER Juan Quintela
                   ` (8 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index afcfbde..92e6bcc 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -956,12 +956,14 @@ typedef struct TestBuffer {
     uint8_t  buffer[6];
     uint8_t  partial[13];
     uint8_t  middle[13];
+    uint32_t scratch[5];
 } TestBuffer;

 TestBuffer obj_buffer = {
     .buffer = "hello",
     .partial = "This is Juan",
-    .middle = "hello world!"
+    .middle = "hello world!",
+    .scratch = {21, 22, 23, 24, 25},
 };

 static const VMStateDescription vmstate_buffer_simple = {
@@ -973,6 +975,7 @@ static const VMStateDescription vmstate_buffer_simple = {
         VMSTATE_BUFFER(buffer, TestBuffer),
         VMSTATE_PARTIAL_BUFFER(partial, TestBuffer, 4),
         VMSTATE_BUFFER_START_MIDDLE(middle, TestBuffer, 6),
+        VMSTATE_BUFFER_UNSAFE(scratch, TestBuffer, 5 * sizeof(uint32_t)),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -981,6 +984,9 @@ uint8_t wire_buffer_simple[] = {
     /* buffer */       0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
     /* partial */      0x54, 0x68, 0x69, 0x73,
     /* middle */       0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x00,
+    /* scratch */      0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
+                       0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+                       0x19, 0x00, 0x00, 0x00,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -1030,6 +1036,7 @@ static void test_buffer_simple(void)
     FAILURE(memcmp(obj.partial+4, obj_buffer.partial+4, sizeof(obj.partial)-4));
     FAILURE(memcmp(obj.middle, obj_buffer.middle, 6));
     SUCCESS(memcmp(obj.middle+6, obj_buffer.middle+6, sizeof(obj.middle)-6));
+    SUCCESS(memcmp(obj.scratch, obj_buffer.scratch, sizeof(obj.scratch)));
 }

 static const VMStateDescription vmstate_buffer_test = {
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 91/97] vmstate: Remove unused VMSTATE_SUB_VBUFFER
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (89 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 90/97] vmstate: Test for VMSTATE_BUFFER_UNSAFE Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 92/97] vmstate: Remove unused VMSTATE_PARTIAL_VBUFFER_UINT32 Juan Quintela
                   ` (7 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 84533eb..af38da7 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -644,9 +644,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size)                        \
     VMSTATE_VBUFFER_UINT32(_f, _s, _size)

-#define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size)                    \
-    VMSTATE_VBUFFER(_f, _s, NULL, _start, _size)
-
 #define VMSTATE_BUFFER_TEST(_f, _s, _test)                            \
     VMSTATE_STATIC_BUFFER(_f, _s, _test, 0, sizeof(typeof_field(_s, _f)))

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 92/97] vmstate: Remove unused VMSTATE_PARTIAL_VBUFFER_UINT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (90 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 91/97] vmstate: Remove unused VMSTATE_SUB_VBUFFER Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 93/97] vmstate: Test for VMSTATE_PARTIAL_VBUFFER Juan Quintela
                   ` (6 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index af38da7..6c7c751 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -641,9 +641,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size)                        \
     VMSTATE_VBUFFER(_f, _s, NULL, 0, _size)

-#define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size)                        \
-    VMSTATE_VBUFFER_UINT32(_f, _s, _size)
-
 #define VMSTATE_BUFFER_TEST(_f, _s, _test)                            \
     VMSTATE_STATIC_BUFFER(_f, _s, _test, 0, sizeof(typeof_field(_s, _f)))

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 93/97] vmstate: Test for VMSTATE_PARTIAL_VBUFFER
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (91 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 92/97] vmstate: Remove unused VMSTATE_PARTIAL_VBUFFER_UINT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 94/97] vmstate: ename VMSTATE_PARTIAL_VBUFFER to VMSTATE_VBUFFER_INT32 Juan Quintela
                   ` (5 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 92e6bcc..6d8545c 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1100,6 +1100,84 @@ static void test_buffer_test(void)
     SUCCESS(memcmp(obj.buffer, obj_buffer.buffer, sizeof(obj.buffer)));
     FAILURE(memcmp(obj.partial, obj_buffer.partial, sizeof(obj.partial)));
 }
+
+typedef struct TestVBuffer {
+    int32_t size;
+    uint8_t  *buffer;
+} TestVBuffer;
+
+uint8_t test_buffer[VMSTATE_ARRAY_SIZE] = { 1, 2, 3, 4, 5};
+
+TestVBuffer obj_vbuffer = {
+    .size = VMSTATE_ARRAY_SIZE,
+    .buffer = test_buffer,
+};
+
+static const VMStateDescription vmstate_vbuffer_simple = {
+    .name = "array/test",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(size, TestVBuffer),
+        VMSTATE_PARTIAL_VBUFFER(buffer, TestVBuffer, size),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+uint8_t wire_vbuffer_simple[] = {
+    /* size */    0x00, 0x00, 0x00, 0x05,
+    /* buffer */  0x01, 0x02, 0x03, 0x04, 0x05,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void test_vbuffer_simple(void)
+{
+    QEMUFile *fsave = open_test_file(true);
+
+    /* Save file with vmstate */
+    vmstate_save_state(fsave, &vmstate_vbuffer_simple, &obj_vbuffer);
+    g_assert(!qemu_file_get_error(fsave));
+    qemu_fclose(fsave);
+
+    QEMUFile *loading = open_test_file(false);
+    /* we don't need QEMU_VM_EOF */
+    uint8_t result[sizeof(wire_vbuffer_simple)-1];
+
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+                    sizeof(result));
+    g_assert(!qemu_file_get_error(loading));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire_vbuffer_simple, sizeof(result)));
+
+    /* Must reach EOF */
+    qemu_get_byte(loading);
+    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+
+    qemu_fclose(loading);
+
+    /* We save the file again.  We want the EOF this time */
+
+    fsave = open_test_file(true);
+    qemu_put_buffer(fsave, wire_vbuffer_simple, sizeof(wire_vbuffer_simple));
+    qemu_fclose(fsave);
+
+    loading = open_test_file(false);
+    TestVBuffer obj;
+    uint8_t local[VMSTATE_ARRAY_SIZE];
+
+    obj.buffer = local;
+    SUCCESS(vmstate_load_state(loading, &vmstate_vbuffer_simple, &obj, 1));
+    g_assert(!qemu_file_get_error(loading));
+
+    qemu_fclose(loading);
+
+    SUCCESS(memcmp(obj.buffer, obj_vbuffer.buffer, VMSTATE_ARRAY_SIZE));
+}
 #undef FIELD_ASSERT


@@ -1329,6 +1407,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/array/sub", test_array_sub);
     g_test_add_func("/vmstate/buffer/simple", test_buffer_simple);
     g_test_add_func("/vmstate/buffer/test", test_buffer_test);
+    g_test_add_func("/vmstate/vbuffer/simple", test_vbuffer_simple);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 94/97] vmstate: ename VMSTATE_PARTIAL_VBUFFER to VMSTATE_VBUFFER_INT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (92 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 93/97] vmstate: Test for VMSTATE_PARTIAL_VBUFFER Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 95/97] vmstate: Create VMS_VBUFFER_UINT32 Juan Quintela
                   ` (4 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

This is more consistent with VMSTATE_VBUFFER_UINT32 that also exist

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/block/onenand.c          | 2 +-
 include/migration/vmstate.h | 7 +------
 tests/test-vmstate.c        | 2 +-
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index 87fbf00..6a97925 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -185,7 +185,7 @@ static const VMStateDescription vmstate_onenand = {
         VMSTATE_UINT16(intstatus, OneNANDState),
         VMSTATE_UINT16(wpstatus, OneNANDState),
         VMSTATE_INT32(secs_cur, OneNANDState),
-        VMSTATE_PARTIAL_VBUFFER(blockwp, OneNANDState, blocks),
+        VMSTATE_VBUFFER_INT32(blockwp, OneNANDState, blocks),
         VMSTATE_UINT8(ecc.cp, OneNANDState),
         VMSTATE_UINT16_ARRAY(ecc.lp, OneNANDState, 2),
         VMSTATE_UINT16(ecc.count, OneNANDState),
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 6c7c751..6c503d9 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -431,14 +431,12 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = vmstate_offset_buffer(_state, _field) + _start,  \
 }

-#define VMSTATE_VBUFFER(_field, _state, _test, _start, _field_size) { \
+#define VMSTATE_VBUFFER_INT32(_field, _state, _field_size) { \
     .name         = (stringify(_field)),                             \
-    .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_VBUFFER_UINT32(_field, _state, _field_size) { \
@@ -638,9 +636,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \
     VMSTATE_STATIC_BUFFER(_f, _s, NULL, _start, sizeof(typeof_field(_s, _f)))

-#define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size)                        \
-    VMSTATE_VBUFFER(_f, _s, NULL, 0, _size)
-
 #define VMSTATE_BUFFER_TEST(_f, _s, _test)                            \
     VMSTATE_STATIC_BUFFER(_f, _s, _test, 0, sizeof(typeof_field(_s, _f)))

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 6d8545c..ea24f26 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1120,7 +1120,7 @@ static const VMStateDescription vmstate_vbuffer_simple = {
     .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(size, TestVBuffer),
-        VMSTATE_PARTIAL_VBUFFER(buffer, TestVBuffer, size),
+        VMSTATE_VBUFFER_INT32(buffer, TestVBuffer, size),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 95/97] vmstate: Create VMS_VBUFFER_UINT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (93 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 94/97] vmstate: ename VMSTATE_PARTIAL_VBUFFER to VMSTATE_VBUFFER_INT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency Juan Quintela
                   ` (3 subsequent siblings)
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

We were dereferencing an uint32_t as int32_t.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 3 ++-
 vmstate.c                   | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 6c503d9..976d83e 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -97,6 +97,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_VBUFFER_UINT32   = 0x200,  /* Buffer with size in uint32_t field */
     VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
     VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
 };
@@ -443,7 +444,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     .name         = (stringify(_field)),                             \
     .size_offset  = vmstate_offset_value(_state, _field_size, uint32_t),\
     .info         = &vmstate_info_buffer,                            \
-    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
+    .flags        = VMS_VBUFFER_UINT32|VMS_POINTER,                  \
     .offset       = offsetof(_state, _field),                        \
 }

diff --git a/vmstate.c b/vmstate.c
index ca6691b..da5c49d 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -35,6 +35,8 @@ static int vmstate_size(void *opaque, VMStateField *field)

     if (field->flags & VMS_VBUFFER) {
         size = *(int32_t *)(opaque+field->size_offset);
+    } else if (field->flags & VMS_VBUFFER_UINT32) {
+        size = *(uint32_t *)(opaque+field->size_offset);
     }

     return size;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (94 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 95/97] vmstate: Create VMS_VBUFFER_UINT32 Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  8:45   ` Dr. David Alan Gilbert
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 97/97] vmstate: Test for VMSTATE_VBUFFER_UINT32 Juan Quintela
                   ` (2 subsequent siblings)
  98 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 6 +++---
 vmstate.c                   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 976d83e..145c198 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -96,7 +96,7 @@ 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 */
+    VMS_VBUFFER_INT32    = 0x100,  /* Buffer with size in int32_t field */
     VMS_VBUFFER_UINT32   = 0x200,  /* Buffer with size in uint32_t field */
     VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
     VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
@@ -436,7 +436,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     .name         = (stringify(_field)),                             \
     .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
     .info         = &vmstate_info_buffer,                            \
-    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
+    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
     .offset       = offsetof(_state, _field),                        \
 }

@@ -480,7 +480,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     .name         = (stringify(_field)),                             \
     .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
     .info         = &vmstate_info_bitmap,                            \
-    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
+    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
     .offset       = offsetof(_state, _field),                        \
 }

diff --git a/vmstate.c b/vmstate.c
index da5c49d..b1ff280 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -33,7 +33,7 @@ static int vmstate_size(void *opaque, VMStateField *field)
 {
     int size = field->size;

-    if (field->flags & VMS_VBUFFER) {
+    if (field->flags & VMS_VBUFFER_INT32) {
         size = *(int32_t *)(opaque+field->size_offset);
     } else if (field->flags & VMS_VBUFFER_UINT32) {
         size = *(uint32_t *)(opaque+field->size_offset);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* [Qemu-devel] [PATCH 97/97] vmstate: Test for VMSTATE_VBUFFER_UINT32
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (95 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency Juan Quintela
@ 2014-04-07  3:21 ` Juan Quintela
  2014-04-07  9:35 ` [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Dr. David Alan Gilbert
  2014-04-07 13:19 ` Marcel Apfelbaum
  98 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  3:21 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/test-vmstate.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index ea24f26..4fa235d 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1104,13 +1104,18 @@ static void test_buffer_test(void)
 typedef struct TestVBuffer {
     int32_t size;
     uint8_t  *buffer;
+    uint32_t size2;
+    uint8_t  *buffer2;
 } TestVBuffer;

 uint8_t test_buffer[VMSTATE_ARRAY_SIZE] = { 1, 2, 3, 4, 5};
+uint8_t test_buffer2[VMSTATE_ARRAY_SIZE] = { 6, 7, 8, 9, 10};

 TestVBuffer obj_vbuffer = {
     .size = VMSTATE_ARRAY_SIZE,
     .buffer = test_buffer,
+    .size2 = VMSTATE_ARRAY_SIZE,
+    .buffer2 = test_buffer2,
 };

 static const VMStateDescription vmstate_vbuffer_simple = {
@@ -1120,14 +1125,18 @@ static const VMStateDescription vmstate_vbuffer_simple = {
     .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_INT32(size, TestVBuffer),
+        VMSTATE_UINT32(size2, TestVBuffer),
         VMSTATE_VBUFFER_INT32(buffer, TestVBuffer, size),
+        VMSTATE_VBUFFER_UINT32(buffer2, TestVBuffer, size2),
         VMSTATE_END_OF_LIST()
     }
 };

 uint8_t wire_vbuffer_simple[] = {
     /* size */    0x00, 0x00, 0x00, 0x05,
+    /* size2 */   0x00, 0x00, 0x00, 0x05,
     /* buffer */  0x01, 0x02, 0x03, 0x04, 0x05,
+    /* buffer2 */ 0x06, 0x07, 0x08, 0x09, 0x0a,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -1169,14 +1178,17 @@ static void test_vbuffer_simple(void)
     loading = open_test_file(false);
     TestVBuffer obj;
     uint8_t local[VMSTATE_ARRAY_SIZE];
+    uint8_t local2[VMSTATE_ARRAY_SIZE];

     obj.buffer = local;
+    obj.buffer2 = local2;
     SUCCESS(vmstate_load_state(loading, &vmstate_vbuffer_simple, &obj, 1));
     g_assert(!qemu_file_get_error(loading));

     qemu_fclose(loading);

     SUCCESS(memcmp(obj.buffer, obj_vbuffer.buffer, VMSTATE_ARRAY_SIZE));
+    SUCCESS(memcmp(obj.buffer2, obj_vbuffer.buffer2, VMSTATE_ARRAY_SIZE));
 }
 #undef FIELD_ASSERT

-- 
1.9.0

^ permalink raw reply related	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 03/97] vmstate: return error in case of error
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 03/97] vmstate: return error in case of error Juan Quintela
@ 2014-04-07  8:19   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 116+ messages in thread
From: Dr. David Alan Gilbert @ 2014-04-07  8:19 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> If there is an error while loading a field, we should stop reading and
> not continue with the rest of fields.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  vmstate.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/vmstate.c b/vmstate.c
> index bfa34cc..d82cccf 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -74,6 +74,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>                      ret = field->info->get(f, addr, size);
> 
>                  }
> +                if (ret >= 0) {
> +                    ret = qemu_file_get_error(f);
> +                }
>                  if (ret < 0) {
>                      trace_vmstate_load_field_error(field->name, ret);
>                      return ret;
> -- 
> 1.9.0
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC Juan Quintela
@ 2014-04-07  8:32   ` Dr. David Alan Gilbert
  2014-04-07  9:50     ` Juan Quintela
  0 siblings, 1 reply; 116+ messages in thread
From: Dr. David Alan Gilbert @ 2014-04-07  8:32 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> It is used for fields that don't exist on the State.  They are
> generated on the fly for migration.

While it's nicer than what's there before, I don't think this is the
right fix for these fields, and I'd rather not encourage new uses
like this.

It still hides the type from the VMSTATE mechanism and ends up with
the target-* code calling qemu_get*/qemu_put* on simple integers that VMSTATE
does support.

I was thinking something like:
  a) Set a .flags entry that this is a synthetic
  b) Change the .get/.put to post_load/pre_save
  c) Change the vmstate code to use a temporary if the synthetic flag is
     set, but then still call the pre_save/post_load on it passing the
     address of the temporary and of the real data somehow.

That way the vmstate code still sees integers that it knows the type of,
and we don't use qemu_get/qemu_put any more.

Dave


> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  include/migration/vmstate.h | 14 ++++++++++++++
>  target-alpha/machine.c      | 16 +++-------------
>  target-arm/machine.c        | 18 ++----------------
>  3 files changed, 19 insertions(+), 29 deletions(-)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index d695244..12020d9 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -201,6 +201,20 @@ extern const VMStateInfo vmstate_info_bitmap;
>      .offset       = vmstate_offset_value(_state, _field, _type),     \
>  }
> 
> +/*
> + * This is used for fields synthetized from the state, but that don't
> + * exist as such.  That is the reaso of offset 0.  They get the whole
> + * struct.
> + */
> +
> +#define VMSTATE_SYNTHETIC(_name, _info, _size) {                     \
> +    .name         = (_name),                                         \
> +    .size         = (_size),                                         \
> +    .info         = &(_info),                                        \
> +    .flags        = VMS_SINGLE,                                      \
> +    .offset       = 0,                                               \
> +}
> +
>  #define VMSTATE_POINTER(_field, _state, _test, _info, _type) {  \
>      .name         = (stringify(_field)),                             \
>      .info         = &(_info),                                        \
> diff --git a/target-alpha/machine.c b/target-alpha/machine.c
> index 5e69b1e..a5db209 100644
> --- a/target-alpha/machine.c
> +++ b/target-alpha/machine.c
> @@ -23,20 +23,10 @@ static const VMStateInfo vmstate_fpcr = {
>  static VMStateField vmstate_env_fields[] = {
>      VMSTATE_UINTTL_ARRAY(ir, CPUAlphaState, 31),
>      VMSTATE_UINTTL_ARRAY(fir, CPUAlphaState, 31),
> +
>      /* Save the architecture value of the fpcr, not the internally
> -       expanded version.  Since this architecture value does not
> -       exist in memory to be stored, this requires a but of hoop
> -       jumping.  We want OFFSET=0 so that we effectively pass ENV
> -       to the helper functions, and we need to fill in the name by
> -       hand since there's no field of that name.  */
> -    {
> -        .name = "fpcr",
> -        .version_id = 0,
> -        .size = sizeof(uint64_t),
> -        .info = &vmstate_fpcr,
> -        .flags = VMS_SINGLE,
> -        .offset = 0
> -    },
> +       expanded version.  */
> +    VMSTATE_SYNTHETIC("fpcr", vmstate_fpcr, sizeof(uint64_t)),
>      VMSTATE_UINTTL(pc, CPUAlphaState),
>      VMSTATE_UINTTL(unique, CPUAlphaState),
>      VMSTATE_UINTTL(lock_addr, CPUAlphaState),
> diff --git a/target-arm/machine.c b/target-arm/machine.c
> index 3f2c485..fd01e99 100644
> --- a/target-arm/machine.c
> +++ b/target-arm/machine.c
> @@ -47,14 +47,7 @@ static const VMStateDescription vmstate_vfp = {
>           */
>          VMSTATE_UINT32(env.vfp.xregs[0], ARMCPU),
>          VMSTATE_UINT32_SUB_ARRAY(env.vfp.xregs, ARMCPU, 2, 14),
> -        {
> -            .name = "fpscr",
> -            .version_id = 0,
> -            .size = sizeof(uint32_t),
> -            .info = &vmstate_fpscr,
> -            .flags = VMS_SINGLE,
> -            .offset = 0,
> -        },
> +        VMSTATE_SYNTHETIC("fpscr", vmstate_fpscr, sizeof(uint32)),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> @@ -224,14 +217,7 @@ const VMStateDescription vmstate_arm_cpu = {
>      .post_load = cpu_post_load,
>      .fields = (VMStateField[]) {
>          VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16),
> -        {
> -            .name = "cpsr",
> -            .version_id = 0,
> -            .size = sizeof(uint32_t),
> -            .info = &vmstate_cpsr,
> -            .flags = VMS_SINGLE,
> -            .offset = 0,
> -        },
> +        VMSTATE_SYNTHETIC("cpsr", vmstate_cpsr, sizeof(uint32_t)),
>          VMSTATE_UINT32(env.spsr, ARMCPU),
>          VMSTATE_UINT32_ARRAY(env.banked_spsr, ARMCPU, 6),
>          VMSTATE_UINT32_ARRAY(env.banked_r13, ARMCPU, 6),
> -- 
> 1.9.0
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency Juan Quintela
@ 2014-04-07  8:45   ` Dr. David Alan Gilbert
  2014-04-07  9:54     ` Juan Quintela
  0 siblings, 1 reply; 116+ messages in thread
From: Dr. David Alan Gilbert @ 2014-04-07  8:45 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  include/migration/vmstate.h | 6 +++---
>  vmstate.c                   | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 976d83e..145c198 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -96,7 +96,7 @@ 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 */
> +    VMS_VBUFFER_INT32    = 0x100,  /* Buffer with size in int32_t field */
>      VMS_VBUFFER_UINT32   = 0x200,  /* Buffer with size in uint32_t field */
>      VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
>      VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
> @@ -436,7 +436,7 @@ extern const VMStateInfo vmstate_info_bitmap;
>      .name         = (stringify(_field)),                             \
>      .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
>      .info         = &vmstate_info_buffer,                            \
> -    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
> +    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \

Are there any real users of the code where it's really an INT32 value - can
we just not kill off the silly idea of signed buffer sizes altogether?

(The only case I can follow through is onenand.c that has a PARTIAL_VBUFFER
based on an 'int' called 'blocks', that's derived during init from an unsigned
value and passed to things like mallocs and memsets, so it's never going to be
negative).

Dave

>      .offset       = offsetof(_state, _field),                        \
>  }
> 
> @@ -480,7 +480,7 @@ extern const VMStateInfo vmstate_info_bitmap;
>      .name         = (stringify(_field)),                             \
>      .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
>      .info         = &vmstate_info_bitmap,                            \
> -    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
> +    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
>      .offset       = offsetof(_state, _field),                        \
>  }
> 
> diff --git a/vmstate.c b/vmstate.c
> index da5c49d..b1ff280 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -33,7 +33,7 @@ static int vmstate_size(void *opaque, VMStateField *field)
>  {
>      int size = field->size;
> 
> -    if (field->flags & VMS_VBUFFER) {
> +    if (field->flags & VMS_VBUFFER_INT32) {
>          size = *(int32_t *)(opaque+field->size_offset);
>      } else if (field->flags & VMS_VBUFFER_UINT32) {
>          size = *(uint32_t *)(opaque+field->size_offset);
> -- 
> 1.9.0
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive)
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (96 preceding siblings ...)
  2014-04-07  3:21 ` [Qemu-devel] [PATCH 97/97] vmstate: Test for VMSTATE_VBUFFER_UINT32 Juan Quintela
@ 2014-04-07  9:35 ` Dr. David Alan Gilbert
  2014-04-07 10:00   ` Juan Quintela
  2014-04-07 13:19 ` Marcel Apfelbaum
  98 siblings, 1 reply; 116+ messages in thread
From: Dr. David Alan Gilbert @ 2014-04-07  9:35 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> Hi
> 
>   Look at the diffstat.  Almost all the additions are at
> test-vmstate.c. That is the reason why it is called a simplification.
> 
> What this series does:
> - peter removal of version_minimum_id_old field when not needed (Peter)
> - cleanup: based on the previous one, I removed all the unneeded
>   the uses on the tree.  This should make your compiles
>   a couple of nanoseconds faster.
> - once there, fixed the indentation of the .fields line, to a canonical
>     .fields = (VMStateField[])
> - mst simplifications for vmstate engine
> 
> And now, the big cleanup.
> - Patches only do one thing, to make easy the review.
> 
> - Added test for all VMSTATE_FOO() definitions
>   (well, I am lying, VMSTATE_STRUCT* are still missing, will come soon)
> - We had two ways to make a field optional
>    VMSTATE_INT64_V(field, state, version)
>   and
>    VMSTATE_INT64_TEST(field, state, test)
> 
>   We can do the version one with one test like:
> 
> static inline bool vmstate_5_plus(void *opaque, int version_id)
> {
>     return version_id >= 5;
> }
> 
>   and then change:
>   VMSTATE_INT64_V(field, state, 5);
> 
>   into
>   VMSTATE_INT64_TEST(field, state, vmstate_5_plus);

I'm not sure if I like this; while I'm OK with the idea of changing the
implementation of VMSTATE_INT64_V to use that function trick internally,
it seems like we're discouraging providing easy to parse/record versionining
info out of the tree.

Dave
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC
  2014-04-07  8:32   ` Dr. David Alan Gilbert
@ 2014-04-07  9:50     ` Juan Quintela
  0 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  9:50 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel

"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> It is used for fields that don't exist on the State.  They are
>> generated on the fly for migration.
>
> While it's nicer than what's there before, I don't think this is the
> right fix for these fields, and I'd rather not encourage new uses
> like this.
>
> It still hides the type from the VMSTATE mechanism and ends up with
> the target-* code calling qemu_get*/qemu_put* on simple integers that VMSTATE
> does support.
>
> I was thinking something like:
>   a) Set a .flags entry that this is a synthetic
>   b) Change the .get/.put to post_load/pre_save
>   c) Change the vmstate code to use a temporary if the synthetic flag is
>      set, but then still call the pre_save/post_load on it passing the
>      address of the temporary and of the real data somehow.
>
> That way the vmstate code still sees integers that it knows the type of,
> and we don't use qemu_get/qemu_put any more.

That is what I proposed on the introduction email.  That would also
solve mst VMS_VALIDATE plroblems.

Later, Juan.

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency
  2014-04-07  8:45   ` Dr. David Alan Gilbert
@ 2014-04-07  9:54     ` Juan Quintela
  0 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07  9:54 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel

"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  include/migration/vmstate.h | 6 +++---
>>  vmstate.c                   | 2 +-
>>  2 files changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
>> index 976d83e..145c198 100644
>> --- a/include/migration/vmstate.h
>> +++ b/include/migration/vmstate.h
>> @@ -96,7 +96,7 @@ 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 */
>> +    VMS_VBUFFER_INT32    = 0x100,  /* Buffer with size in int32_t field */
>>      VMS_VBUFFER_UINT32   = 0x200,  /* Buffer with size in uint32_t field */
>>      VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
>>      VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
>> @@ -436,7 +436,7 @@ extern const VMStateInfo vmstate_info_bitmap;
>>      .name         = (stringify(_field)),                             \
>>      .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
>>      .info         = &vmstate_info_buffer,                            \
>> -    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
>> +    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
>
> Are there any real users of the code where it's really an INT32 value - can
> we just not kill off the silly idea of signed buffer sizes altogether?
>
> (The only case I can follow through is onenand.c that has a PARTIAL_VBUFFER
> based on an 'int' called 'blocks', that's derived during init from an unsigned
> value and passed to things like mallocs and memsets, so it's never going to be
> negative).

There is one user :-(

Note the VARRAY thing, where there are more.  And normally it depends on
the target device if it is signed or not

Later, Juan.

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive)
  2014-04-07  9:35 ` [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Dr. David Alan Gilbert
@ 2014-04-07 10:00   ` Juan Quintela
  2014-04-07 16:18     ` Andreas Färber
  0 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07 10:00 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel

"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> Hi
>> 
>>   Look at the diffstat.  Almost all the additions are at
>> test-vmstate.c. That is the reason why it is called a simplification.
>> 
>> What this series does:
>> - peter removal of version_minimum_id_old field when not needed (Peter)
>> - cleanup: based on the previous one, I removed all the unneeded
>>   the uses on the tree.  This should make your compiles
>>   a couple of nanoseconds faster.
>> - once there, fixed the indentation of the .fields line, to a canonical
>>     .fields = (VMStateField[])
>> - mst simplifications for vmstate engine
>> 
>> And now, the big cleanup.
>> - Patches only do one thing, to make easy the review.
>> 
>> - Added test for all VMSTATE_FOO() definitions
>>   (well, I am lying, VMSTATE_STRUCT* are still missing, will come soon)
>> - We had two ways to make a field optional
>>    VMSTATE_INT64_V(field, state, version)
>>   and
>>    VMSTATE_INT64_TEST(field, state, test)
>> 
>>   We can do the version one with one test like:
>> 
>> static inline bool vmstate_5_plus(void *opaque, int version_id)
>> {
>>     return version_id >= 5;
>> }
>> 
>>   and then change:
>>   VMSTATE_INT64_V(field, state, 5);
>> 
>>   into
>>   VMSTATE_INT64_TEST(field, state, vmstate_5_plus);
>
> I'm not sure if I like this; while I'm OK with the idea of changing the
> implementation of VMSTATE_INT64_V to use that function trick internally,
> it seems like we're discouraging providing easy to parse/record versionining
> info out of the tree.

That information is not exported Today.  And if we want to export them,
export v = 5 or test == vmstat_5_plus is exactly the same dificulty.
The information is still there, what has changed is the removal of one
mechanism.

#define VMSTATE_UINT64_V(field, state, X) \
     VMSTATE_UINT64_TEST(field, state, vmstate_##X##_plus)

The same that we could do for maintaining the macro, we can do to export
the information to whatever format we want.  I just wanted to remove one
of the mechanism (the less powerful one).

Later, Juan.

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive) Juan Quintela
@ 2014-04-07 11:00   ` Peter Maydell
  2014-04-07 11:47     ` Juan Quintela
  0 siblings, 1 reply; 116+ messages in thread
From: Peter Maydell @ 2014-04-07 11:00 UTC (permalink / raw)
  To: Juan Quintela; +Cc: QEMU Developers

On 7 April 2014 04:20, Juan Quintela <quintela@redhat.com> wrote:
> After previous Peter patch, they are redundant.  This way we don't asign them
> except when needed.  Once there, there were lots of case where the ".fields"
> indentation was wrong:
>
>      .fields = (VMStateField []) {
> and
>      .fields =      (VMStateField []) {
>
> Change all the combinations to:
>
>      .fields = (VMStateField[]){
>
> The biggest problem (appart of aesthetics) was that checkpatch complained
> when we copy&pasted the code from one place to another.
>
>  211 files changed, 289 insertions(+), 621 deletions(-)

I'm really not a fan of this kind of single patch that
touches a huge number of files at once. They're basically
impossible to review and they introduce the possibility
of conflicts between submaintainer tree changes and the
big patch. There's no reason to have all these changes
in a single patch -- I'd much rather see one patch per
subsystem sent to the relevant submaintainers, plus
one for all the unmaintained stuff which can go via
the migration tree.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07 11:00   ` Peter Maydell
@ 2014-04-07 11:47     ` Juan Quintela
  2014-04-07 11:50       ` Peter Maydell
  0 siblings, 1 reply; 116+ messages in thread
From: Juan Quintela @ 2014-04-07 11:47 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers

Peter Maydell <peter.maydell@linaro.org> wrote:
> On 7 April 2014 04:20, Juan Quintela <quintela@redhat.com> wrote:
>> After previous Peter patch, they are redundant.  This way we don't asign them
>> except when needed.  Once there, there were lots of case where the ".fields"
>> indentation was wrong:
>>
>>      .fields = (VMStateField []) {
>> and
>>      .fields =      (VMStateField []) {
>>
>> Change all the combinations to:
>>
>>      .fields = (VMStateField[]){
>>
>> The biggest problem (appart of aesthetics) was that checkpatch complained
>> when we copy&pasted the code from one place to another.
>>
>>  211 files changed, 289 insertions(+), 621 deletions(-)
>
> I'm really not a fan of this kind of single patch that
> touches a huge number of files at once. They're basically
> impossible to review and they introduce the possibility
> of conflicts between submaintainer tree changes and the
> big patch. There's no reason to have all these changes
> in a single patch -- I'd much rather see one patch per
> subsystem sent to the relevant submaintainers, plus
> one for all the unmaintained stuff which can go via
> the migration tree.

If you say how to split, I am all for it.  But remomeber that all this
changes go inside VMSTateDescription descriptions, touch nothing else
outside of that.  And that is not something that is touched a lot to
have lots of conflicts.

My problem with leaving things as are, is that people continue to copy
from the ones that still use the old system/format :-(

Later, Juan.

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07 11:47     ` Juan Quintela
@ 2014-04-07 11:50       ` Peter Maydell
  2014-04-07 12:21         ` Markus Armbruster
  0 siblings, 1 reply; 116+ messages in thread
From: Peter Maydell @ 2014-04-07 11:50 UTC (permalink / raw)
  To: Juan Quintela; +Cc: QEMU Developers

On 7 April 2014 12:47, Juan Quintela <quintela@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> wrote:
>> I'm really not a fan of this kind of single patch that
>> touches a huge number of files at once. They're basically
>> impossible to review and they introduce the possibility
>> of conflicts between submaintainer tree changes and the
>> big patch. There's no reason to have all these changes
>> in a single patch -- I'd much rather see one patch per
>> subsystem sent to the relevant submaintainers, plus
>> one for all the unmaintained stuff which can go via
>> the migration tree.
>
> If you say how to split, I am all for it.

Like I said, one patch per maintained subsystem,
one patch for the leftovers.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07 11:50       ` Peter Maydell
@ 2014-04-07 12:21         ` Markus Armbruster
  2014-04-07 12:39           ` Peter Maydell
  2014-04-07 12:45           ` Juan Quintela
  0 siblings, 2 replies; 116+ messages in thread
From: Markus Armbruster @ 2014-04-07 12:21 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Juan Quintela

Peter Maydell <peter.maydell@linaro.org> writes:

> On 7 April 2014 12:47, Juan Quintela <quintela@redhat.com> wrote:
>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>> I'm really not a fan of this kind of single patch that
>>> touches a huge number of files at once. They're basically
>>> impossible to review and they introduce the possibility
>>> of conflicts between submaintainer tree changes and the
>>> big patch. There's no reason to have all these changes
>>> in a single patch -- I'd much rather see one patch per
>>> subsystem sent to the relevant submaintainers, plus
>>> one for all the unmaintained stuff which can go via
>>> the migration tree.
>>
>> If you say how to split, I am all for it.
>
> Like I said, one patch per maintained subsystem,
> one patch for the leftovers.

Easier said than done.  MAINTAINERS has more than 100 sections, yet it
leaves more than 1200 files uncovered, roughly half of them C sources.
I doubt splitting mechanically along those sections plus a catch-all
patch for the "unmaintained" files would be appreciated.

Could you give some guidance on splitting?

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07 12:21         ` Markus Armbruster
@ 2014-04-07 12:39           ` Peter Maydell
  2014-04-07 12:46             ` Juan Quintela
  2014-04-07 12:45           ` Juan Quintela
  1 sibling, 1 reply; 116+ messages in thread
From: Peter Maydell @ 2014-04-07 12:39 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers, Juan Quintela

On 7 April 2014 13:21, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> On 7 April 2014 12:47, Juan Quintela <quintela@redhat.com> wrote:
>>> Peter Maydell <peter.maydell@linaro.org> wrote:
>> Like I said, one patch per maintained subsystem,
>> one patch for the leftovers.
>
> Easier said than done.  MAINTAINERS has more than 100 sections, yet it
> leaves more than 1200 files uncovered, roughly half of them C sources.
> I doubt splitting mechanically along those sections plus a catch-all
> patch for the "unmaintained" files would be appreciated.
>
> Could you give some guidance on splitting?

Well, I would just eyeball the filenames. If you had
a patch with the ARM related stuff, a patch for the
things that are x86 PC devices, one for the PPC
devices, and a USB patch, that ought to whittle the
list down a fair amount.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07 12:21         ` Markus Armbruster
  2014-04-07 12:39           ` Peter Maydell
@ 2014-04-07 12:45           ` Juan Quintela
  1 sibling, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07 12:45 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Peter Maydell, QEMU Developers

Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> On 7 April 2014 12:47, Juan Quintela <quintela@redhat.com> wrote:
>>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>>> I'm really not a fan of this kind of single patch that
>>>> touches a huge number of files at once. They're basically
>>>> impossible to review and they introduce the possibility
>>>> of conflicts between submaintainer tree changes and the
>>>> big patch. There's no reason to have all these changes
>>>> in a single patch -- I'd much rather see one patch per
>>>> subsystem sent to the relevant submaintainers, plus
>>>> one for all the unmaintained stuff which can go via
>>>> the migration tree.
>>>
>>> If you say how to split, I am all for it.
>>
>> Like I said, one patch per maintained subsystem,
>> one patch for the leftovers.
>
> Easier said than done.  MAINTAINERS has more than 100 sections, yet it
> leaves more than 1200 files uncovered, roughly half of them C sources.
> I doubt splitting mechanically along those sections plus a catch-all
> patch for the "unmaintained" files would be appreciated.
>
> Could you give some guidance on splitting?

+1

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive)
  2014-04-07 12:39           ` Peter Maydell
@ 2014-04-07 12:46             ` Juan Quintela
  0 siblings, 0 replies; 116+ messages in thread
From: Juan Quintela @ 2014-04-07 12:46 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Markus Armbruster, QEMU Developers

Peter Maydell <peter.maydell@linaro.org> wrote:
> On 7 April 2014 13:21, Markus Armbruster <armbru@redhat.com> wrote:
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>
>>> On 7 April 2014 12:47, Juan Quintela <quintela@redhat.com> wrote:
>>>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>> Like I said, one patch per maintained subsystem,
>>> one patch for the leftovers.
>>
>> Easier said than done.  MAINTAINERS has more than 100 sections, yet it
>> leaves more than 1200 files uncovered, roughly half of them C sources.
>> I doubt splitting mechanically along those sections plus a catch-all
>> patch for the "unmaintained" files would be appreciated.
>>
>> Could you give some guidance on splitting?
>
> Well, I would just eyeball the filenames. If you had
> a patch with the ARM related stuff, a patch for the
> things that are x86 PC devices, one for the PPC
> devices, and a USB patch, that ought to whittle the
> list down a fair amount.

Thanks.  Will do.

Later, Juan.

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive)
  2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
                   ` (97 preceding siblings ...)
  2014-04-07  9:35 ` [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Dr. David Alan Gilbert
@ 2014-04-07 13:19 ` Marcel Apfelbaum
  98 siblings, 0 replies; 116+ messages in thread
From: Marcel Apfelbaum @ 2014-04-07 13:19 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On Mon, 2014-04-07 at 05:20 +0200, Juan Quintela wrote:
> Hi
> 
>   Look at the diffstat.  Almost all the additions are at
> test-vmstate.c. That is the reason why it is called a simplification.
> 
> What this series does:
> - peter removal of version_minimum_id_old field when not needed (Peter)
> - cleanup: based on the previous one, I removed all the unneeded
>   the uses on the tree.  This should make your compiles
>   a couple of nanoseconds faster.
How did you do it :) ?
I tried it with coccinelle but they have a problem handling compound literals :(.

I opened a discussion on their mailing list hoping I will find a solution... 
https://systeme.lip6.fr/pipermail/cocci/2014-April/000794.html

Thanks,
Marcel 

> - once there, fixed the indentation of the .fields line, to a canonical
>     .fields = (VMStateField[])
[...]

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive)
  2014-04-07 10:00   ` Juan Quintela
@ 2014-04-07 16:18     ` Andreas Färber
  0 siblings, 0 replies; 116+ messages in thread
From: Andreas Färber @ 2014-04-07 16:18 UTC (permalink / raw)
  To: Juan Quintela; +Cc: Dr. David Alan Gilbert, qemu-devel

Am 07.04.2014 12:00, schrieb Juan Quintela:
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
>> * Juan Quintela (quintela@redhat.com) wrote:
>>> Hi
>>>
>>>   Look at the diffstat.  Almost all the additions are at
>>> test-vmstate.c. That is the reason why it is called a simplification.
>>>
>>> What this series does:
>>> - peter removal of version_minimum_id_old field when not needed (Peter)
>>> - cleanup: based on the previous one, I removed all the unneeded
>>>   the uses on the tree.  This should make your compiles
>>>   a couple of nanoseconds faster.
>>> - once there, fixed the indentation of the .fields line, to a canonical
>>>     .fields = (VMStateField[])
>>> - mst simplifications for vmstate engine
>>>
>>> And now, the big cleanup.
>>> - Patches only do one thing, to make easy the review.
>>>
>>> - Added test for all VMSTATE_FOO() definitions
>>>   (well, I am lying, VMSTATE_STRUCT* are still missing, will come soon)
>>> - We had two ways to make a field optional
>>>    VMSTATE_INT64_V(field, state, version)
>>>   and
>>>    VMSTATE_INT64_TEST(field, state, test)
>>>
>>>   We can do the version one with one test like:
>>>
>>> static inline bool vmstate_5_plus(void *opaque, int version_id)
>>> {
>>>     return version_id >= 5;
>>> }
>>>
>>>   and then change:
>>>   VMSTATE_INT64_V(field, state, 5);
>>>
>>>   into
>>>   VMSTATE_INT64_TEST(field, state, vmstate_5_plus);
>>
>> I'm not sure if I like this; while I'm OK with the idea of changing the
>> implementation of VMSTATE_INT64_V to use that function trick internally,
>> it seems like we're discouraging providing easy to parse/record versionining
>> info out of the tree.
> 
> That information is not exported Today.  And if we want to export them,
> export v = 5 or test == vmstat_5_plus is exactly the same dificulty.

That's not quite true. My code can easily compare an integer field in
VMStateDescription, but for any .test function callback I am in the
blind: Without executing the test on a specific set of data, I cannot
reason whether incoming data will be compatible with the VMSD.

> The information is still there, what has changed is the removal of one
> mechanism.
> 
> #define VMSTATE_UINT64_V(field, state, X) \
>      VMSTATE_UINT64_TEST(field, state, vmstate_##X##_plus)

If these were a fixed set of global test functions, it could work, by
special-casing function pointer comparisons.

> The same that we could do for maintaining the macro, we can do to export
> the information to whatever format we want.  I just wanted to remove one
> of the mechanism (the less powerful one).


On another matter, I still haven't heard from you on my QOM VMState
simplification series from last July:

https://lists.nongnu.org/archive/html/qemu-devel/2014-02/msg01072.html

If we fix the NVEC issue I discovered in February and add qtests for the
remaining optional devices to assure there are no further dc->vmsd
overriding devices, would that approach be acceptable to you? Or do you
have a better suggestion?

Thanks,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 05/97] vmstate: refactor opening of files
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 05/97] vmstate: refactor opening of files Juan Quintela
@ 2014-04-07 17:34   ` Eduardo Habkost
  0 siblings, 0 replies; 116+ messages in thread
From: Eduardo Habkost @ 2014-04-07 17:34 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On Mon, Apr 07, 2014 at 05:20:23AM +0200, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

^ permalink raw reply	[flat|nested] 116+ messages in thread

* Re: [Qemu-devel] [PATCH 06/97] vmstate: Refactor & increase tests for primitive types
  2014-04-07  3:20 ` [Qemu-devel] [PATCH 06/97] vmstate: Refactor & increase tests for primitive types Juan Quintela
@ 2014-04-07 17:57   ` Eduardo Habkost
  0 siblings, 0 replies; 116+ messages in thread
From: Eduardo Habkost @ 2014-04-07 17:57 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On Mon, Apr 07, 2014 at 05:20:24AM +0200, Juan Quintela wrote:
> This commit refactor the simple tests to test all integer types. We
> move to hex because it is easier to read values of different types.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  tests/test-vmstate.c | 195 +++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 150 insertions(+), 45 deletions(-)
> 
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index 8b242c4..39a769e 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -54,80 +54,186 @@ static QEMUFile *open_test_file(bool write)
>      return qemu_fdopen(fd, write ? "wb" : "rb");
>  }
> 
> -typedef struct TestSruct {
> -    uint32_t a, b, c, e;
> -    uint64_t d, f;
> -    bool skip_c_e;
> -} TestStruct;
> +/* Test struct that we are going to use for our tests */
> +
> +typedef struct TestSimple {
> +    bool     b_1,   b_2;
> +    uint8_t  u8_1,  u8_2;
> +    uint16_t u16_1, u16_2;
> +    uint32_t u32_1, u32_2;
> +    uint64_t u64_1, u64_2;
> +    int8_t   i8_1,  i8_2;
> +    int16_t  i16_1, i16_2;
> +    int32_t  i32_1, i32_2;
> +    int64_t  i64_1, i64_2;
> +} TestSimple;
> +
> +/* Object instantiation, we are going to use it in more than one test */
> +
> +TestSimple obj_simple = {
> +    .b_1 = true,
> +    .b_2 = false,
> +    .u8_1 = 129,
> +    .u8_1 = 130,
> +    .u16_1 = 512,
> +    .u16_2 = 45000,
> +    .u32_1 = 70000,
> +    .u32_2 = 100000,
> +    .u64_1 = 12121212,
> +    .u64_2 = 23232323,
> +    .i8_1 = 65,
> +    .i8_2 = -65,
> +    .i16_1 = 512,
> +    .i16_2 = -512,
> +    .i32_1 = 70000,
> +    .i32_2 = -70000,
> +    .i64_1 = 12121212,
> +    .i64_2 = -12121212,
> +};
> 
> +/* Description of the values.  If you add a primitive type
> +   you are expected to add a test here */
> 
> -static const VMStateDescription vmstate_simple = {
> -    .name = "test",
> +static const VMStateDescription vmstate_simple_primitive = {
> +    .name = "simple/primitive",
>      .version_id = 1,
>      .minimum_version_id = 1,
>      .fields = (VMStateField[]) {
> -        VMSTATE_UINT32(a, TestStruct),
> -        VMSTATE_UINT32(b, TestStruct),
> -        VMSTATE_UINT32(c, TestStruct),
> -        VMSTATE_UINT64(d, TestStruct),
> +        VMSTATE_BOOL(b_1, TestSimple),
> +        VMSTATE_BOOL(b_2, TestSimple),
> +        VMSTATE_UINT8(u8_1, TestSimple),
> +        VMSTATE_UINT16(u16_1, TestSimple),
> +        VMSTATE_UINT32(u32_1, TestSimple),
> +        VMSTATE_UINT64(u64_1, TestSimple),
> +        VMSTATE_INT8(i8_1, TestSimple),
> +        VMSTATE_INT8(i8_2, TestSimple),
> +        VMSTATE_INT16(i16_1, TestSimple),
> +        VMSTATE_INT16(i16_2, TestSimple),
> +        VMSTATE_INT32(i32_1, TestSimple),
> +        VMSTATE_INT32(i32_2, TestSimple),
> +        VMSTATE_INT64(i64_1, TestSimple),
> +        VMSTATE_INT64(i64_2, TestSimple),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> 
> -static void test_simple_save(void)
> +/* It describes what goes through the wire.  Our tests are basically:
> +
> +   * save test
> +     - save a struct a vmstate to a file
> +     - read that file back (binary read, no vmstate)
> +     - compare it with what we expect to be on the wire
> +   * load test
> +     - save to the file what we expect to be on the wire
> +     - read struct back with vmstate in a different
> +     - compare back with the original struct
> +*/
> +
> +uint8_t wire_simple_primitive[] = {
> +    /* b_1 */   0x01,
> +    /* b_2 */   0x00,
> +    /* u8_1 */  0x82,
> +    /* u16_1 */ 0x02, 0x00,
> +    /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
> +    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
> +    /* i8_1 */  0x41,
> +    /* i8_2 */  0xbf,
> +    /* i16_1 */ 0x02, 0x00,
> +    /* i16_2 */ 0xfe, 0x0,
> +    /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
> +    /* i32_2 */ 0xff, 0xfe, 0xee, 0x90,
> +    /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
> +    /* i64_2 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x0b, 0x84,
> +    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> +};

Nice job. I was too lazy to test every single type. :-)

> +
> +#define SUCCESS(val) \
> +    g_assert_cmpint((val), ==, 0)

Isn't this the same as g_assert(!val)?

> +
> +#define FAILURE(val) \
> +    g_assert_cmpint((val), !=, 0)

Isn't this the same as g_assert(val)?

I know, it is my fault as I have written the g_assert_cmpint(..., 0)
code in the first place. :)


> +
> +static void test_simple_primitive(void)
>  {
>      QEMUFile *fsave = open_test_file(true);
> -    TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4 };
> -    vmstate_save_state(fsave, &vmstate_simple, &obj);
> +
> +    /* Save file with vmstate */
> +    vmstate_save_state(fsave, &vmstate_simple_primitive, &obj_simple);
>      g_assert(!qemu_file_get_error(fsave));
>      qemu_fclose(fsave);
> 
>      QEMUFile *loading = open_test_file(false);
> -    uint8_t expected[] = {
> -        0, 0, 0, 1, /* a */
> -        0, 0, 0, 2, /* b */
> -        0, 0, 0, 3, /* c */
> -        0, 0, 0, 0, 0, 0, 0, 4, /* d */
> -    };
> -    uint8_t result[sizeof(expected)];
> +    /* we don't need QEMU_VM_EOF */
> +    uint8_t result[sizeof(wire_simple_primitive)-1];
> +
> +    /* read back as binary */
> +
>      g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
>                      sizeof(result));
>      g_assert(!qemu_file_get_error(loading));
> -    g_assert_cmpint(memcmp(result, expected, sizeof(result)), ==, 0);
> +
> +    /* Compare that what is on the file is the same that what we
> +       expected to be there */
> +    SUCCESS(memcmp(result, wire_simple_primitive, sizeof(result)));
> 
>      /* Must reach EOF */
>      qemu_get_byte(loading);
>      g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
> 
>      qemu_fclose(loading);
> -}
> 
> -static void test_simple_load(void)
> -{
> -    QEMUFile *fsave = open_test_file(true);
> -    uint8_t buf[] = {
> -        0, 0, 0, 10,             /* a */
> -        0, 0, 0, 20,             /* b */
> -        0, 0, 0, 30,             /* c */
> -        0, 0, 0, 0, 0, 0, 0, 40, /* d */
> -        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> -    };
> -    qemu_put_buffer(fsave, buf, sizeof(buf));
> +    /* We save the file again.  We want the EOF this time */
> +
> +    fsave = open_test_file(true);
> +    qemu_put_buffer(fsave, wire_simple_primitive,
> +                    sizeof(wire_simple_primitive));
>      qemu_fclose(fsave);
> 
> -    QEMUFile *loading = open_test_file(false);
> -    TestStruct obj;
> -    vmstate_load_state(loading, &vmstate_simple, &obj, 1);
> +    loading = open_test_file(false);
> +    TestSimple obj;
> +    SUCCESS(vmstate_load_state(loading, &vmstate_simple_primitive, &obj, 1));
>      g_assert(!qemu_file_get_error(loading));
> -    g_assert_cmpint(obj.a, ==, 10);
> -    g_assert_cmpint(obj.b, ==, 20);
> -    g_assert_cmpint(obj.c, ==, 30);
> -    g_assert_cmpint(obj.d, ==, 40);
> +
> +#define FIELD_ASSERT(name)   g_assert_cmpint(obj.name, ==, obj_simple.name)
> +    FIELD_ASSERT(b_1);
> +    FIELD_ASSERT(b_2);
> +    FIELD_ASSERT(u8_1);
> +    FIELD_ASSERT(u16_1);
> +    FIELD_ASSERT(u32_1);
> +    FIELD_ASSERT(u64_1);
> +    FIELD_ASSERT(i8_1);
> +    FIELD_ASSERT(i8_2);
> +    FIELD_ASSERT(i16_1);
> +    FIELD_ASSERT(i16_2);
> +    FIELD_ASSERT(i32_1);
> +    FIELD_ASSERT(i32_2);
> +    FIELD_ASSERT(i64_1);
> +    FIELD_ASSERT(i64_2);
> +#undef FIELD_ASSERT

I wonder if we could do something to allow us to safely simplify this to
use memcmp(). Looks good, anyway.

> +
> +    /* We save the file again.  We want the EOF this time */
> +
> +    fsave = open_test_file(true);
> +    /* this time we don't write the whole file */
> +    qemu_put_buffer(fsave, wire_simple_primitive, 10);
> +    qemu_fclose(fsave);

What about not just testing if it fails with 10 bytes, but checking all
possible lengths from 0 to N-1 bytes? With this check we are only
testing if the u64 loader handles EOF as expected. If subtle bugs are
going to be introduced in EOF checking, I find them more likely in
corner cases such as length==0, length==1 and lenght==N-1.

> +
> +    loading = open_test_file(false);
> +    FAILURE(vmstate_load_state(loading, &vmstate_simple_primitive, &obj, 1));
> +
> +    /* Now it has to have an error */
> +    g_assert(qemu_file_get_error(loading));
>      qemu_fclose(loading);
>  }
> 
> +typedef struct TestStruct {
> +    uint32_t a, b, c, e;
> +    uint64_t d, f;
> +    bool skip_c_e;
> +} TestStruct;
> +
>  static const VMStateDescription vmstate_versioned = {
> -    .name = "test",
> +    .name = "test/versioned",
>      .version_id = 2,
>      .minimum_version_id = 1,
>      .fields = (VMStateField[]) {
> @@ -202,7 +308,7 @@ static bool test_skip(void *opaque, int version_id)
>  }
> 
>  static const VMStateDescription vmstate_skipping = {
> -    .name = "test",
> +    .name = "test/skip",
>      .version_id = 2,
>      .minimum_version_id = 1,
>      .fields = (VMStateField[]) {
> @@ -337,8 +443,7 @@ int main(int argc, char **argv)
>      temp_fd = mkstemp(temp_file);
> 
>      g_test_init(&argc, &argv, NULL);
> -    g_test_add_func("/vmstate/simple/save", test_simple_save);
> -    g_test_add_func("/vmstate/simple/load", test_simple_load);
> +    g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
>      g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
>      g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
>      g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
> -- 
> 1.9.0
> 
> 

-- 
Eduardo

^ permalink raw reply	[flat|nested] 116+ messages in thread

end of thread, other threads:[~2014-04-07 17:57 UTC | newest]

Thread overview: 116+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-07  3:20 [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 01/97] savevm: Ignore minimum_version_id_old if there is no load_state_old Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 02/97] savevm: Remove all the unneded version_minimum_id_old (Massive) Juan Quintela
2014-04-07 11:00   ` Peter Maydell
2014-04-07 11:47     ` Juan Quintela
2014-04-07 11:50       ` Peter Maydell
2014-04-07 12:21         ` Markus Armbruster
2014-04-07 12:39           ` Peter Maydell
2014-04-07 12:46             ` Juan Quintela
2014-04-07 12:45           ` Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 03/97] vmstate: return error in case of error Juan Quintela
2014-04-07  8:19   ` Dr. David Alan Gilbert
2014-04-07  3:20 ` [Qemu-devel] [PATCH 04/97] vmstate: reduce code duplication Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 05/97] vmstate: refactor opening of files Juan Quintela
2014-04-07 17:34   ` Eduardo Habkost
2014-04-07  3:20 ` [Qemu-devel] [PATCH 06/97] vmstate: Refactor & increase tests for primitive types Juan Quintela
2014-04-07 17:57   ` Eduardo Habkost
2014-04-07  3:20 ` [Qemu-devel] [PATCH 07/97] vmstate: create test functions for versions until 15 Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 08/97] vmstate: Remove VMSTATE_UINTL_EQUAL_V Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 09/97] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 10/97] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 11/97] vmstate: Test for VMSTATE_BOOL_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 12/97] vmstate: Test for VMSTATE_INT8_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 13/97] vmstate: Test for VMSTATE_INT16_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 14/97] vmstate: Test for VMSTATE_INT32_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 15/97] vmstate: test for VMSTATE_INT64_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 16/97] vmstate: Test for VMSTATE_UINT8_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 17/97] vmstate: Test for VMSTATE_UINT16_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 18/97] vmstate: Test for VMSTATE_UINT32_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 19/97] vmstate: Test for VMSTATE_UINT64_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 20/97] vmstate: Test for VMSTATE_FLOAT64 Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 21/97] vmstate: Test for VMSTATE_UNUSED Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 22/97] vmstate: Test for VMSTATE_BITMAP Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 23/97] vmstate: Test for VMSTATE_UINT8_EQUAL Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 24/97] vmstate: Test for VMSTATE_UINT16_EQUAL Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 25/97] vmstate: Test for VMSTATE_UINT32_EQUAL Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 26/97] vmstate: Test for VMSTATE_UINT64_EQUAL Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 27/97] vmstate: Test for VMSTATE_INT32_EQUAL Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 28/97] vmstate: Test for VMSTATE_INT32_LE Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 29/97] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 30/97] vmstate: Move VMSTATE_TIMER_V to VMSTATE_TIMER_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 31/97] vmstate: Test for VMSTATE_ARRAY_BOOL_TEST Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 32/97] vmstate: Test for VMSTATE_UINT8_ARRAY Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 33/97] vmstate: Test for VMSTATE_UINT16_ARRAY Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 34/97] vmstate: Test for VMSTATE_UINT32_ARRAY{_TEST} Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 35/97] vmstate: Test for VMSTATE_UINT64_ARRAY{_TEST} Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 36/97] vmstate: Test for VMSTATE_INT16_ARRAY Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 37/97] vmstate: Test for VMSTATE_INT32_ARRAY{_TEST} Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 38/97] vmstate: Test for VMSTATE_INT64_ARRAY Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 39/97] vmstate: Test for VMSTATE_FLOAT64_ARRAY Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 40/97] vmstate: Test for VMSTATE_UINT8_2DARRAY Juan Quintela
2014-04-07  3:20 ` [Qemu-devel] [PATCH 41/97] vmstate: Test for VMSTATE_UINT16_2DARRAY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 42/97] vmstate: Test for VMSTATE_UINT32_2DARRAY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 43/97] vmstate: Remove unused VMSTATE_BUFFER_V Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 44/97] vmstate: Remove version from VMSTATE_BUFFER_UNSAFE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 45/97] vmstate: Remove unused version fields from ARM Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 46/97] vmstate: All ptimers users were at least at version 1 or more Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 47/97] vmstate: remove version from all variants of VMSTATE_STRUCT_POINTER* Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 48/97] vmstate: Port last 3 users of VMSTATE_ARRAY to VMSTATE_ARRAY_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 49/97] vmstate: Port last user of VMSTATE_SINGLE to VMSTATE_SINGLE_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 50/97] vmstate: Remove unused VMSTATE_POINTER Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 51/97] vmstate: Rename VMSTATE_SINGLE_TEST to VMSTATE_SINGLE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 52/97] vmstate: Move VMSTATE_2DARRAY to use _test Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 53/97] vmstate: Rename VMSTATE_POINTER_TEST without _TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 54/97] vmstate: Rename VMSTATE_ARRAY_TEST to VMSTATE_ARRAY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 55/97] vmstate: Remove version_id from VMSTATE_VBUFFER Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 56/97] vmstate: Remove version_id fields that were not used Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 57/97] vmstate: Remove version_id from VMSTATE_SUB_ARRAY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 58/97] vmstate: Remove version parameter from VMSTATE_VARRAY_INT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 59/97] vmstate: Remove version_id from VMSTATE_VARRAY_UINT16_UNSAFE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 60/97] vmstate: VMSTATE_ARRAY_OF_POINTER didn't used the version_id field Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 61/97] vmstate: remove version parameter from VMSTATE_BUFFER_POINTER_UNSAFE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 62/97] vmstate: Remove version, test and start parameter from VMSTATE_VBUFFER_UINT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 63/97] vmstate: Remove version paramenter from VMSTATE_ARRAY_OF_POINTER_TO_STRUCT Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 64/97] vmstate: Remove VMSTATE_BUFFER_MULTIPLY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 65/97] vmstate: Remove version parameter from VMSTATE_STATIC_BUFFER Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 66/97] vmstate: Remove version field from VMSTATE_STRUCT_VARRAY_UINT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 67/97] vmstate: Move all users of versioning of VMSTATE_STRUCT_ARRAY to _TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 68/97] vmstate: Remove version paramenter from VMSTATE_STRUCT_ARRAY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 69/97] vmstate: Remove version parameter from VMSTATE_STRUCT_ARRAY_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 70/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_INT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 71/97] vmstate: Remove unused version parameter from VMSTATE_STRUCT_VARRAY_UINT8 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 72/97] vmstate: Introduce VMSTATE_VARRAY_UINT32_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 73/97] vmstate: Remove version parameter from VMSTATE_VARRAY_UINT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 74/97] vmstate: Remove version parameter from VMSTATE_STRUCT_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 75/97] vmstate: Move all users of versioning to VMSTATE_STRUCT_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 76/97] vmstate: Remove version from all VMSTATE_STRUCT calls Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 77/97] vmstate: Create VMSTATE_VARRAY macro Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 78/97] vmstate: Create VMSTATE_POINTER_UNSAFE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 79/97] vmstate: Create VMSTATE_OPENCODED_UNSAFE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 80/97] vmstate: Create VMSTATE_SYNTHETIC Juan Quintela
2014-04-07  8:32   ` Dr. David Alan Gilbert
2014-04-07  9:50     ` Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 81/97] vmstate: version_id is gone from fields Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 82/97] vmstate: Test for VMSTATE_SYNTHETIC Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 83/97] vmstate: Test for VMSTATE_UINT8_SUB_ARRAY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 84/97] vmstate: Test for VMSTATE_UINT32_SUB_ARRAY Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 85/97] vmstate: Test for VMSTATE_BUFFER Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 86/97] vmstate: Test for VMSTATE_PARTIAL_BUFFER Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 87/97] vmstate: Test for VMSTATE_BUFFER_START_MIDDLE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 88/97] vmstate: Add tests for VMSTATE_BUFFER_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 89/97] vmstate: Use VMSTATE_UINT8_2DARRAY instead of VMSTATE_BUFFER_TEST Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 90/97] vmstate: Test for VMSTATE_BUFFER_UNSAFE Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 91/97] vmstate: Remove unused VMSTATE_SUB_VBUFFER Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 92/97] vmstate: Remove unused VMSTATE_PARTIAL_VBUFFER_UINT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 93/97] vmstate: Test for VMSTATE_PARTIAL_VBUFFER Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 94/97] vmstate: ename VMSTATE_PARTIAL_VBUFFER to VMSTATE_VBUFFER_INT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 95/97] vmstate: Create VMS_VBUFFER_UINT32 Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency Juan Quintela
2014-04-07  8:45   ` Dr. David Alan Gilbert
2014-04-07  9:54     ` Juan Quintela
2014-04-07  3:21 ` [Qemu-devel] [PATCH 97/97] vmstate: Test for VMSTATE_VBUFFER_UINT32 Juan Quintela
2014-04-07  9:35 ` [Qemu-devel] [PATCH for 2.1 00/97] VMState simplification (massive) Dr. David Alan Gilbert
2014-04-07 10:00   ` Juan Quintela
2014-04-07 16:18     ` Andreas Färber
2014-04-07 13:19 ` Marcel Apfelbaum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.