All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/27] vmstate-simplification queue
@ 2014-06-16  9:57 Juan Quintela
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 01/27] migration: Remove unneeded minimum_version_id_old Juan Quintela
                   ` (26 more replies)
  0 siblings, 27 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:57 UTC (permalink / raw)
  To: qemu-devel

Hi

As agreed on previous email, this is the next part for the VMSTATE SIMPLICATION series.

- Added another removal of minimum_version_id_old
- Improve error detection as discussed with David.
- Port existing tests and add tests for primitive types (integers)
- Add tests for _TEST() for primitieve types
- Add tests for FLOAT64/BITMAP/UNUSED
- Add tests for equal comparisons

Please, review.


The following changes since commit db80facefa62dff42bb50c73b0f03eda5f732b49:

  migration: catch unknown flags in ram_load (2014-06-16 04:55:27 +0200)

are available in the git repository at:

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

for you to fetch changes up to ea8060b30d1db88ab8e7904279264ad55842c835:

  vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ (2014-06-16 05:38:42 +0200)

----------------------------------------------------------------
vmstate-simplification/next for 20140616

----------------------------------------------------------------
Juan Quintela (26):
      migration: Remove unneeded minimum_version_id_old
      vmstate: Return error in case of error
      vmstate: Refactor & increase tests for primitive types
      vmstate: Port versioned tests to new format
      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

Michael S. Tsirkin (1):
      vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/

 cpus.c                      |   2 +-
 hw/arm/stellaris.c          |   2 +-
 hw/char/serial.c            |   4 +-
 hw/display/pl110.c          |   2 +-
 hw/gpio/pl061.c             |   2 +-
 hw/ide/core.c               |   2 +-
 hw/input/ps2.c              |   2 +-
 hw/intc/ioapic_common.c     |   5 +-
 hw/misc/arm_sysctl.c        |  10 +-
 hw/net/lan9118.c            |  18 +-
 hw/net/ne2000.c             |   2 +-
 hw/net/rtl8139.c            |   2 +-
 hw/nvram/eeprom93xx.c       |   7 +-
 hw/nvram/fw_cfg.c           |   2 +-
 hw/sd/sd.c                  |   2 +-
 hw/timer/ds1338.c           |   2 +-
 hw/timer/hpet.c             |   2 +-
 hw/timer/i8254_common.c     |   3 +-
 hw/timer/mc146818rtc.c      |  12 +-
 hw/usb/hcd-ehci.c           |   4 +-
 hw/usb/hcd-ohci.c           |   7 +-
 hw/usb/hcd-uhci.c           |   4 +-
 include/hw/hw.h             |  31 +-
 include/migration/vmstate.h | 132 ++++---
 target-i386/machine.c       |  66 ++--
 tests/test-vmstate.c        | 854 ++++++++++++++++++++++++++++++++------------
 vmstate.c                   |  26 ++
 27 files changed, 809 insertions(+), 398 deletions(-)

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

* [Qemu-devel] [PATCH 01/27] migration: Remove unneeded minimum_version_id_old
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
@ 2014-06-16  9:57 ` Juan Quintela
  2014-06-17 10:44   ` Dr. David Alan Gilbert
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 02/27] vmstate: Return error in case of error Juan Quintela
                   ` (25 subsequent siblings)
  26 siblings, 1 reply; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:57 UTC (permalink / raw)
  To: qemu-devel

Once there, make checkpatch happy.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/usb/hcd-ohci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index cd87074..cace945 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1988,8 +1988,7 @@ static const VMStateDescription vmstate_ohci_state_port = {
     .name = "ohci-core/port",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, OHCIPort),
         VMSTATE_END_OF_LIST()
     },
@@ -2015,9 +2014,8 @@ static const VMStateDescription vmstate_ohci_eof_timer = {
     .name = "ohci-core/eof-timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_load = ohci_eof_timer_pre_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_TIMER(eof_timer, OHCIState),
         VMSTATE_END_OF_LIST()
     },
@@ -2078,7 +2076,6 @@ static const VMStateDescription vmstate_ohci = {
     .name = "ohci",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, OHCIPCIState),
         VMSTATE_STRUCT(state, OHCIPCIState, 1, vmstate_ohci_state, OHCIState),
-- 
1.9.3

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

* [Qemu-devel] [PATCH 02/27] vmstate: Return error in case of error
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 01/27] migration: Remove unneeded minimum_version_id_old Juan Quintela
@ 2014-06-16  9:57 ` Juan Quintela
  2014-06-17 10:43   ` Dr. David Alan Gilbert
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 03/27] vmstate: Refactor & increase tests for primitive types Juan Quintela
                   ` (24 subsequent siblings)
  26 siblings, 1 reply; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:57 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.  And we should also set an error
in qemu_file.

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

diff --git a/vmstate.c b/vmstate.c
index b5882fa..c996520 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -98,7 +98,11 @@ 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) {
+                    qemu_file_set_error(f, ret);
                     trace_vmstate_load_field_error(field->name, ret);
                     return ret;
                 }
-- 
1.9.3

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

* [Qemu-devel] [PATCH 03/27] vmstate: Refactor & increase tests for primitive types
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 01/27] migration: Remove unneeded minimum_version_id_old Juan Quintela
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 02/27] vmstate: Return error in case of error Juan Quintela
@ 2014-06-16  9:57 ` Juan Quintela
  2014-06-17 11:34   ` Dr. David Alan Gilbert
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format Juan Quintela
                   ` (23 subsequent siblings)
  26 siblings, 1 reply; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:57 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 | 273 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 212 insertions(+), 61 deletions(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 8b242c4..a462335 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -54,80 +54,232 @@ 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;
+#define SUCCESS(val) \
+    g_assert_cmpint((val), ==, 0)

+#define FAILURE(val) \
+    g_assert_cmpint((val), !=, 0)

-static const VMStateDescription vmstate_simple = {
-    .name = "test",
-    .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_END_OF_LIST()
-    }
-};
+static void save_vmstate(const VMStateDescription *desc, void *obj)
+{
+    QEMUFile *f = open_test_file(true);
+
+    /* Save file with vmstate */
+    vmstate_save_state(f, desc, obj);
+    qemu_put_byte(f, QEMU_VM_EOF);
+    g_assert(!qemu_file_get_error(f));
+    qemu_fclose(f);
+}

-static void test_simple_save(void)
+static void compare_vmstate(uint8_t *wire, size_t size)
 {
-    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 *f = open_test_file(false);
+    uint8_t result[size];

-    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)];
-    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==,
                     sizeof(result));
-    g_assert(!qemu_file_get_error(loading));
-    g_assert_cmpint(memcmp(result, expected, sizeof(result)), ==, 0);
+    g_assert(!qemu_file_get_error(f));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire, sizeof(result)));

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

-    qemu_fclose(loading);
+    qemu_fclose(f);
 }

-static void test_simple_load(void)
+static int load_vmstate_one(const VMStateDescription *desc, void *obj,
+                            int version, uint8_t *wire, size_t size)
 {
-    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));
-    qemu_fclose(fsave);
+    QEMUFile *f;
+    int ret;
+
+    f = open_test_file(true);
+    qemu_put_buffer(f, wire, size);
+    qemu_fclose(f);
+
+    f = open_test_file(false);
+    ret = vmstate_load_state(f, desc, obj, version);
+    if (ret) {
+        g_assert(qemu_file_get_error(f));
+    } else{
+        g_assert(!qemu_file_get_error(f));
+    }
+    qemu_fclose(f);
+    return ret;
+}

-    QEMUFile *loading = open_test_file(false);
-    TestStruct obj;
-    vmstate_load_state(loading, &vmstate_simple, &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);
-    qemu_fclose(loading);
+
+static int load_vmstate(const VMStateDescription *desc,
+                        void *obj, void *obj_clone,
+                        void (*obj_copy)(void *, void*),
+                        int version, uint8_t *wire, size_t size)
+{
+    /* We test with zero size */
+    obj_copy(obj_clone, obj);
+    FAILURE(load_vmstate_one(desc, obj, version, wire, 0));
+
+    /* Stream ends with QEMU_EOF, so we need at least 3 bytes to be
+     * able to test in the middle */
+
+    if (size > 3) {
+
+        /* We test with size - 2. We can't test size - 1 due to EOF tricks */
+        obj_copy(obj, obj_clone);
+        FAILURE(load_vmstate_one(desc, obj, version, wire, size - 2));
+
+        /* Test with size/2, first half of real state */
+        obj_copy(obj, obj_clone);
+        FAILURE(load_vmstate_one(desc, obj, version, wire, size/2));
+
+        /* Test with size/2, second half of real state */
+        obj_copy(obj, obj_clone);
+        FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2));
+
+    }
+    obj_copy(obj, obj_clone);
+    return load_vmstate_one(desc, obj, version, wire, size);
+}
+
+/* Test struct that we are going to use for our tests */
+
+typedef struct TestSimple {
+    bool     b_1,   b_2;
+    uint8_t  u8_1;
+    uint16_t u16_1;
+    uint32_t u32_1;
+    uint64_t u64_1;
+    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 = 130,
+    .u16_1 = 512,
+    .u32_1 = 70000,
+    .u64_1 = 12121212,
+    .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_primitive = {
+    .name = "simple/primitive",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        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()
+    }
+};
+
+/* 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 */
+};
+
+static void obj_simple_copy(void *target, void *source)
+{
+    memcpy(target, source, sizeof(TestSimple));
+}
+
+static void test_simple_primitive(void)
+{
+    TestSimple obj, obj_clone;
+
+    memset(&obj, 0, sizeof(obj));
+    save_vmstate(&vmstate_simple_primitive, &obj_simple);
+
+    compare_vmstate(wire_simple_primitive, sizeof(wire_simple_primitive));
+
+    SUCCESS(load_vmstate(&vmstate_simple_primitive, &obj, &obj_clone,
+                         obj_simple_copy, 1, wire_simple_primitive,
+                         sizeof(wire_simple_primitive)));
+
+#define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_simple.name)
+
+    FIELD_EQUAL(b_1);
+    FIELD_EQUAL(b_2);
+    FIELD_EQUAL(u8_1);
+    FIELD_EQUAL(u16_1);
+    FIELD_EQUAL(u32_1);
+    FIELD_EQUAL(u64_1);
+    FIELD_EQUAL(i8_1);
+    FIELD_EQUAL(i8_2);
+    FIELD_EQUAL(i16_1);
+    FIELD_EQUAL(i16_2);
+    FIELD_EQUAL(i32_1);
+    FIELD_EQUAL(i32_2);
+    FIELD_EQUAL(i64_1);
+    FIELD_EQUAL(i64_2);
 }
+#undef FIELD_EQUAL
+
+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 +354,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 +489,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.3

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

* [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (2 preceding siblings ...)
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 03/27] vmstate: Refactor & increase tests for primitive types Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-17 11:56   ` Dr. David Alan Gilbert
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 05/27] vmstate: Create test functions for versions until 15 Juan Quintela
                   ` (22 subsequent siblings)
  26 siblings, 1 reply; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 UTC (permalink / raw)
  To: qemu-devel

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

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index a462335..d0839c3 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -272,217 +272,226 @@ static void test_simple_primitive(void)
 }
 #undef FIELD_EQUAL

-typedef struct TestStruct {
+typedef struct TestVersioned {
     uint32_t a, b, c, e;
     uint64_t d, f;
     bool skip_c_e;
-} TestStruct;
+} TestVersioned;
+
+TestVersioned obj_versioned = {
+    .a = 10,
+    .b = 200,
+    .c = 30,
+    .d = 40,
+    .e = 500,
+    .f = 600,
+    .skip_c_e = true,
+};

-static const VMStateDescription vmstate_versioned = {
+static const VMStateDescription vmstate_simple_versioned = {
     .name = "test/versioned",
     .version_id = 2,
     .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.
-                                             */
-        VMSTATE_UINT32(c, TestStruct),
-        VMSTATE_UINT64(d, TestStruct),
-        VMSTATE_UINT32_V(e, TestStruct, 2),
-        VMSTATE_UINT64_V(f, TestStruct, 2),
+        VMSTATE_UINT32(a, TestVersioned),
+        /* Versioned field in the middle, so we catch bugs more
+         * easily. */
+        VMSTATE_UINT32_V(b, TestVersioned, 2),
+        VMSTATE_UINT32(c, TestVersioned),
+        VMSTATE_UINT64(d, TestVersioned),
+        VMSTATE_UINT32_V(e, TestVersioned, 2),
+        VMSTATE_UINT64_V(f, TestVersioned, 2),
         VMSTATE_END_OF_LIST()
     }
 };

-static void test_load_v1(void)
+uint8_t wire_simple_v1[] = {
+    /* a */ 0x00, 0x00, 0x00, 0x0a,
+    /* c */ 0x00, 0x00, 0x00, 0x1e,
+    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+uint8_t wire_simple_v2[] = {
+    /* a */ 0x00, 0x00, 0x00, 0x0a,
+    /* b */ 0x00, 0x00, 0x00, 0xc8,
+    /* c */ 0x00, 0x00, 0x00, 0x1e,
+    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
+    /* e */ 0x00, 0x00, 0x01, 0xf4,
+    /* f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x58,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void obj_versioned_copy(void *arg1, void *arg2)
 {
-    QEMUFile *fsave = open_test_file(true);
-    uint8_t buf[] = {
-        0, 0, 0, 10,             /* a */
-        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));
-    qemu_fclose(fsave);
-
-    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));
-    g_assert_cmpint(obj.a, ==, 10);
-    g_assert_cmpint(obj.b, ==, 200);
-    g_assert_cmpint(obj.c, ==, 30);
-    g_assert_cmpint(obj.d, ==, 40);
-    g_assert_cmpint(obj.e, ==, 500);
-    g_assert_cmpint(obj.f, ==, 600);
-    qemu_fclose(loading);
+    TestVersioned *target = arg1;
+    TestVersioned *source = arg2;
+
+    target->a = source->a;
+    target->b = source->b;
+    target->c = source->c;
+    target->d = source->d;
+    target->e = source->e;
+    target->f = source->f;
+    target->skip_c_e = source->skip_c_e;
 }

-static void test_load_v2(void)
+static void test_simple_v2(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 */
-        0, 0, 0, 50,             /* e */
-        0, 0, 0, 0, 0, 0, 0, 60, /* f */
-        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
-    };
-    qemu_put_buffer(fsave, buf, sizeof(buf));
-    qemu_fclose(fsave);
-
-    QEMUFile *loading = open_test_file(false);
-    TestStruct obj;
-    vmstate_load_state(loading, &vmstate_versioned, &obj, 2);
-    g_assert_cmpint(obj.a, ==, 10);
-    g_assert_cmpint(obj.b, ==, 20);
-    g_assert_cmpint(obj.c, ==, 30);
-    g_assert_cmpint(obj.d, ==, 40);
-    g_assert_cmpint(obj.e, ==, 50);
-    g_assert_cmpint(obj.f, ==, 60);
-    qemu_fclose(loading);
+    TestVersioned obj, obj_clone;
+
+    memset(&obj, 0, sizeof(obj));
+    save_vmstate(&vmstate_simple_versioned, &obj_versioned);
+
+    compare_vmstate(wire_simple_v2, sizeof(wire_simple_v2));
+
+    SUCCESS(load_vmstate(&vmstate_simple_versioned, &obj, &obj_clone,
+                         obj_versioned_copy, 2, wire_simple_v2,
+                         sizeof(wire_simple_v2)));
+
+#define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_versioned.name)
+#define FIELD_NOT_EQUAL(name) \
+    g_assert_cmpint(obj.name, !=, obj_versioned.name)
+    FIELD_EQUAL(a);
+    FIELD_EQUAL(b);
+    FIELD_EQUAL(c);
+    FIELD_EQUAL(d);
+    FIELD_EQUAL(e);
+    FIELD_EQUAL(f);
+}
+
+static void test_simple_v1(void)
+{
+    TestVersioned obj, obj_clone;
+
+    memset(&obj, 0, sizeof(obj));
+    SUCCESS(load_vmstate(&vmstate_simple_versioned, &obj, &obj_clone,
+                         obj_versioned_copy, 1, wire_simple_v1,
+                         sizeof(wire_simple_v1)));
+
+    FIELD_EQUAL(a);
+    FIELD_NOT_EQUAL(b);
+    FIELD_EQUAL(c);
+    FIELD_EQUAL(d);
+    FIELD_NOT_EQUAL(e);
+    FIELD_NOT_EQUAL(f);
 }

 static bool test_skip(void *opaque, int version_id)
 {
-    TestStruct *t = (TestStruct *)opaque;
+    TestVersioned *t = opaque;
     return !t->skip_c_e;
 }

-static const VMStateDescription vmstate_skipping = {
-    .name = "test/skip",
+static const VMStateDescription vmstate_simple_skipping = {
+    .name = "simple/skip",
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT32(a, TestStruct),
-        VMSTATE_UINT32(b, TestStruct),
-        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_BOOL(skip_c_e, TestVersioned),
+        VMSTATE_UINT32(a, TestVersioned),
+        VMSTATE_UINT32(b, TestVersioned),
+        VMSTATE_UINT32_TEST(c, TestVersioned, test_skip),
+        VMSTATE_UINT64(d, TestVersioned),
+        VMSTATE_UINT32_TEST(e, TestVersioned, test_skip),
+        VMSTATE_UINT64_V(f, TestVersioned, 2),
         VMSTATE_END_OF_LIST()
     }
 };

+uint8_t wire_simple_no_skip[] = {
+    /* s */ 0x00,
+    /* a */ 0x00, 0x00, 0x00, 0x0a,
+    /* b */ 0x00, 0x00, 0x00, 0xc8,
+    /* c */ 0x00, 0x00, 0x00, 0x1e,
+    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
+    /* e */ 0x00, 0x00, 0x01, 0xf4,
+    /* f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x58,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};

-static void test_save_noskip(void)
-{
-    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 = 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 */
-        0, 0, 0, 5,             /* e */
-        0, 0, 0, 0, 0, 0, 0, 6, /* f */
-    };
-    uint8_t result[sizeof(expected)];
-    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);
-
-    /* Must reach EOF */
-    qemu_get_byte(loading);
-    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
-
-    qemu_fclose(loading);
-}
+uint8_t wire_simple_skip[] = {
+    /* s */ 0x01,
+    /* a */ 0x00, 0x00, 0x00, 0x0a,
+    /* b */ 0x00, 0x00, 0x00, 0xc8,
+    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
+    /* f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x58,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};

-static void test_save_skip(void)
+static void test_simple_no_skip(void)
 {
-    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 = open_test_file(false);
-    uint8_t expected[] = {
-        0, 0, 0, 1,             /* a */
-        0, 0, 0, 2,             /* b */
-        0, 0, 0, 0, 0, 0, 0, 4, /* d */
-        0, 0, 0, 0, 0, 0, 0, 6, /* f */
-    };
-    uint8_t result[sizeof(expected)];
-    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);
+    TestVersioned obj, obj_clone;

-
-    /* Must reach EOF */
-    qemu_get_byte(loading);
-    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
-
-    qemu_fclose(loading);
+    memset(&obj, 0, sizeof(obj));
+    obj_versioned.skip_c_e = false;
+    save_vmstate(&vmstate_simple_skipping, &obj_versioned);
+
+    compare_vmstate(wire_simple_no_skip, sizeof(wire_simple_no_skip));
+
+    /* We abuse the fact that f has a 0x00 value in the right position */
+    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
+                         obj_versioned_copy, 1, wire_simple_no_skip,
+                         sizeof(wire_simple_no_skip) - 8));
+
+    FIELD_EQUAL(skip_c_e);
+    FIELD_EQUAL(a);
+    FIELD_EQUAL(b);
+    FIELD_EQUAL(c);
+    FIELD_EQUAL(d);
+    FIELD_EQUAL(e);
+    FIELD_NOT_EQUAL(f);
+
+    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
+                         obj_versioned_copy, 2, wire_simple_no_skip,
+                         sizeof(wire_simple_no_skip)));
+
+    FIELD_EQUAL(skip_c_e);
+    FIELD_EQUAL(a);
+    FIELD_EQUAL(b);
+    FIELD_EQUAL(c);
+    FIELD_EQUAL(d);
+    FIELD_EQUAL(e);
+    FIELD_EQUAL(f);
 }

-static void test_load_noskip(void)
+static void test_simple_skip(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 */
-        0, 0, 0, 50,             /* e */
-        0, 0, 0, 0, 0, 0, 0, 60, /* f */
-        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
-    };
-    qemu_put_buffer(fsave, buf, sizeof(buf));
-    qemu_fclose(fsave);
-
-    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));
-    g_assert_cmpint(obj.a, ==, 10);
-    g_assert_cmpint(obj.b, ==, 20);
-    g_assert_cmpint(obj.c, ==, 30);
-    g_assert_cmpint(obj.d, ==, 40);
-    g_assert_cmpint(obj.e, ==, 50);
-    g_assert_cmpint(obj.f, ==, 60);
-    qemu_fclose(loading);
-}
+    TestVersioned obj, obj_clone;

-static void test_load_skip(void)
-{
-    QEMUFile *fsave = open_test_file(true);
-    uint8_t buf[] = {
-        0, 0, 0, 10,             /* a */
-        0, 0, 0, 20,             /* b */
-        0, 0, 0, 0, 0, 0, 0, 40, /* d */
-        0, 0, 0, 0, 0, 0, 0, 60, /* f */
-        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
-    };
-    qemu_put_buffer(fsave, buf, sizeof(buf));
-    qemu_fclose(fsave);
-
-    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));
-    g_assert_cmpint(obj.a, ==, 10);
-    g_assert_cmpint(obj.b, ==, 20);
-    g_assert_cmpint(obj.c, ==, 300);
-    g_assert_cmpint(obj.d, ==, 40);
-    g_assert_cmpint(obj.e, ==, 500);
-    g_assert_cmpint(obj.f, ==, 60);
-    qemu_fclose(loading);
+    memset(&obj, 0, sizeof(obj));
+    obj_versioned.skip_c_e = true;
+    save_vmstate(&vmstate_simple_skipping, &obj_versioned);
+
+    compare_vmstate(wire_simple_skip, sizeof(wire_simple_skip));
+
+    /* We abuse the fact that f has a 0x00 value in the right position */
+    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
+                         obj_versioned_copy, 1, wire_simple_skip,
+                         sizeof(wire_simple_skip) - 8));
+
+    FIELD_EQUAL(skip_c_e);
+    FIELD_EQUAL(a);
+    FIELD_EQUAL(b);
+    FIELD_NOT_EQUAL(c);
+    FIELD_EQUAL(d);
+    FIELD_NOT_EQUAL(e);
+    FIELD_NOT_EQUAL(f);
+
+    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
+                         obj_versioned_copy, 2, wire_simple_skip,
+                         sizeof(wire_simple_skip)));
+
+    FIELD_EQUAL(skip_c_e);
+    FIELD_EQUAL(a);
+    FIELD_EQUAL(b);
+    FIELD_NOT_EQUAL(c);
+    FIELD_EQUAL(d);
+    FIELD_NOT_EQUAL(e);
+    FIELD_EQUAL(f);
 }
+#undef FIELD_EQUAL
+#undef FIELD_NOT_EQUAL

 int main(int argc, char **argv)
 {
@@ -490,12 +499,10 @@ 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/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);
-    g_test_add_func("/vmstate/field_exists/load/skip", test_load_skip);
-    g_test_add_func("/vmstate/field_exists/save/noskip", test_save_noskip);
-    g_test_add_func("/vmstate/field_exists/save/skip", test_save_skip);
+    g_test_add_func("/vmstate/simple/v1", test_simple_v1);
+    g_test_add_func("/vmstate/simple/v2", test_simple_v2);
+    g_test_add_func("/vmstate/simple/skip", test_simple_skip);
+    g_test_add_func("/vmstate/simple/no_skip", test_simple_no_skip);
     g_test_run();

     close(temp_fd);
-- 
1.9.3

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

* [Qemu-devel] [PATCH 05/27] vmstate: Create test functions for versions until 15
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (3 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 06/27] vmstate: Remove VMSTATE_UINTL_EQUAL_V Juan Quintela
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 | 16 ++++++++++++++++
 vmstate.c                   | 22 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 7e45048..ea00bae 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -778,4 +778,20 @@ 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);

+/* Return true if version_id > X */
+bool vmstate_2_plus(void *opaque, int version_id);
+bool vmstate_3_plus(void *opaque, int version_id);
+bool vmstate_4_plus(void *opaque, int version_id);
+bool vmstate_5_plus(void *opaque, int version_id);
+bool vmstate_6_plus(void *opaque, int version_id);
+bool vmstate_7_plus(void *opaque, int version_id);
+bool vmstate_8_plus(void *opaque, int version_id);
+bool vmstate_9_plus(void *opaque, int version_id);
+bool vmstate_10_plus(void *opaque, int version_id);
+bool vmstate_11_plus(void *opaque, int version_id);
+bool vmstate_12_plus(void *opaque, int version_id);
+bool vmstate_13_plus(void *opaque, int version_id);
+bool vmstate_14_plus(void *opaque, int version_id);
+bool vmstate_15_plus(void *opaque, int version_id);
+
 #endif
diff --git a/vmstate.c b/vmstate.c
index c996520..bca15a8 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -671,3 +671,25 @@ const VMStateInfo vmstate_info_bitmap = {
     .get = get_bitmap,
     .put = put_bitmap,
 };
+
+/* version is X or bigger */
+#define VMSTATE_X_PLUS(X)\
+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)
-- 
1.9.3

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

* [Qemu-devel] [PATCH 06/27] vmstate: Remove VMSTATE_UINTL_EQUAL_V
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (4 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 05/27] vmstate: Create test functions for versions until 15 Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 07/27] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST Juan Quintela
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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.3

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

* [Qemu-devel] [PATCH 07/27] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (5 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 06/27] vmstate: Remove VMSTATE_UINTL_EQUAL_V Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 08/27] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V Juan Quintela
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 ea00bae..4d9c974 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -613,6 +613,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 b8dcd2f..a684d75 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -632,8 +632,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.3

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

* [Qemu-devel] [PATCH 08/27] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (6 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 07/27] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 09/27] vmstate: Test for VMSTATE_BOOL_TEST Juan Quintela
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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.3

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

* [Qemu-devel] [PATCH 09/27] vmstate: Test for VMSTATE_BOOL_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (7 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 08/27] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 10/27] vmstate: Test for VMSTATE_INT8_TEST Juan Quintela
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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        | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 4d9c974..4932d50 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -535,8 +535,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)
@@ -557,7 +557,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 d0839c3..52b4945 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -270,6 +270,49 @@ static void test_simple_primitive(void)
     FIELD_EQUAL(i64_1);
     FIELD_EQUAL(i64_2);
 }
+
+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)
+{
+    TestSimple obj, obj_clone;
+
+    memset(&obj, 0, sizeof(obj));
+    save_vmstate(&vmstate_simple_test, &obj_simple);
+
+    compare_vmstate(wire_simple_test, sizeof(wire_simple_test));
+
+    SUCCESS(load_vmstate(&vmstate_simple_test, &obj, &obj_clone,
+                         obj_simple_copy, 1, wire_simple_test,
+                         sizeof(wire_simple_test)));
+
+    FIELD_EQUAL(b_1);
+}
 #undef FIELD_EQUAL

 typedef struct TestVersioned {
@@ -503,6 +546,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/simple/v2", test_simple_v2);
     g_test_add_func("/vmstate/simple/skip", test_simple_skip);
     g_test_add_func("/vmstate/simple/no_skip", test_simple_no_skip);
+    g_test_add_func("/vmstate/simple/test", test_simple_test);
     g_test_run();

     close(temp_fd);
-- 
1.9.3

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

* [Qemu-devel] [PATCH 10/27] vmstate: Test for VMSTATE_INT8_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (8 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 09/27] vmstate: Test for VMSTATE_BOOL_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 11/27] vmstate: Test for VMSTATE_INT16_TEST Juan Quintela
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 4932d50..a962735 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -538,8 +538,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)                                   \
@@ -560,7 +560,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 52b4945..c62e22c 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -289,12 +289,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 */
 };

@@ -312,6 +315,7 @@ static void test_simple_test(void)
                          sizeof(wire_simple_test)));

     FIELD_EQUAL(b_1);
+    FIELD_EQUAL(i8_1);
 }
 #undef FIELD_EQUAL

-- 
1.9.3

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

* [Qemu-devel] [PATCH 11/27] vmstate: Test for VMSTATE_INT16_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (9 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 10/27] vmstate: Test for VMSTATE_INT8_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 12/27] vmstate: Test for VMSTATE_INT32_TEST Juan Quintela
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 a962735..d8febd5 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -540,8 +540,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)                                   \
@@ -562,7 +562,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 c62e22c..e0b2147 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -291,6 +291,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()
     }
 };
@@ -298,6 +300,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 */
 };

@@ -316,6 +319,7 @@ static void test_simple_test(void)

     FIELD_EQUAL(b_1);
     FIELD_EQUAL(i8_1);
+    FIELD_EQUAL(i16_1);
 }
 #undef FIELD_EQUAL

-- 
1.9.3

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

* [Qemu-devel] [PATCH 12/27] vmstate: Test for VMSTATE_INT32_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (10 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 11/27] vmstate: Test for VMSTATE_INT16_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 13/27] vmstate: test for VMSTATE_INT64_TEST Juan Quintela
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 a466e25..a672ed6 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -700,7 +700,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 d8febd5..e01a399 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_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)

@@ -564,7 +564,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 a684d75..7e80b52 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -679,10 +679,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 e0b2147..6f47f0c 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -293,6 +293,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()
     }
 };
@@ -301,6 +303,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 */
 };

@@ -320,6 +323,7 @@ static void test_simple_test(void)
     FIELD_EQUAL(b_1);
     FIELD_EQUAL(i8_1);
     FIELD_EQUAL(i16_1);
+    FIELD_EQUAL(i32_1);
 }
 #undef FIELD_EQUAL

-- 
1.9.3

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

* [Qemu-devel] [PATCH 13/27] vmstate: test for VMSTATE_INT64_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (11 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 12/27] vmstate: Test for VMSTATE_INT32_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 14/27] vmstate: Test for VMSTATE_UINT8_TEST Juan Quintela
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 dd7ac13..4f2ea64 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 1201f90..5a2de40 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 c3bf72c..77af60b 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -423,7 +423,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 e01a399..f37d033 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_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)
@@ -566,7 +566,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 6f47f0c..1302aee 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -295,6 +295,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()
     }
 };
@@ -304,6 +306,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 */
 };

@@ -324,6 +327,7 @@ static void test_simple_test(void)
     FIELD_EQUAL(i8_1);
     FIELD_EQUAL(i16_1);
     FIELD_EQUAL(i32_1);
+    FIELD_EQUAL(i64_1);
 }
 #undef FIELD_EQUAL

-- 
1.9.3

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

* [Qemu-devel] [PATCH 14/27] vmstate: Test for VMSTATE_UINT8_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (12 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 13/27] vmstate: test for VMSTATE_INT64_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 15/27] vmstate: Test for VMSTATE_UINT16_TEST Juan Quintela
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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        |  7 ++++++-
 8 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index d17da16..4ec0164 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -612,7 +612,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 1cac5f5..2441e33 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 e160e8f..f5da662 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -315,7 +315,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_VALIDATE("num_timers in range", hpet_validate_num_timers),
         VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0,
                                     vmstate_hpet_timer, HPETTimer),
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index f37d033..b66e540 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -547,8 +547,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)                                  \
@@ -569,7 +569,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)                                        \
@@ -604,9 +604,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_POSITIVE_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 7e80b52..8f52c0e 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -673,7 +673,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),
@@ -683,10 +683,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 1302aee..8678df4 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -150,7 +150,7 @@ static int load_vmstate(const VMStateDescription *desc,

 typedef struct TestSimple {
     bool     b_1,   b_2;
-    uint8_t  u8_1;
+    uint8_t  u8_1, u8_2;
     uint16_t u16_1;
     uint32_t u32_1;
     uint64_t u64_1;
@@ -166,6 +166,7 @@ TestSimple obj_simple = {
     .b_1 = true,
     .b_2 = false,
     .u8_1 = 130,
+    .u8_2 = 222,
     .u16_1 = 512,
     .u32_1 = 70000,
     .u64_1 = 12121212,
@@ -297,6 +298,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()
     }
 };
@@ -307,6 +310,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 */
 };

@@ -328,6 +332,7 @@ static void test_simple_test(void)
     FIELD_EQUAL(i16_1);
     FIELD_EQUAL(i32_1);
     FIELD_EQUAL(i64_1);
+    FIELD_EQUAL(u8_1);
 }
 #undef FIELD_EQUAL

-- 
1.9.3

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

* [Qemu-devel] [PATCH 15/27] vmstate: Test for VMSTATE_UINT16_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (13 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 14/27] vmstate: Test for VMSTATE_UINT8_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 16/27] vmstate: Test for VMSTATE_UINT32_TEST Juan Quintela
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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        | 7 ++++++-
 5 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 4ec0164..681ab46 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -603,7 +603,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 b66e540..c2047e7 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -549,8 +549,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)                                  \
@@ -571,7 +571,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)                                        \
@@ -604,9 +604,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_POSITIVE_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 8f52c0e..d3deea5 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -668,10 +668,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 8678df4..60dc360 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -151,7 +151,7 @@ static int load_vmstate(const VMStateDescription *desc,
 typedef struct TestSimple {
     bool     b_1,   b_2;
     uint8_t  u8_1, u8_2;
-    uint16_t u16_1;
+    uint16_t u16_1, u16_2;
     uint32_t u32_1;
     uint64_t u64_1;
     int8_t   i8_1,  i8_2;
@@ -168,6 +168,7 @@ TestSimple obj_simple = {
     .u8_1 = 130,
     .u8_2 = 222,
     .u16_1 = 512,
+    .u16_2 = 666,
     .u32_1 = 70000,
     .u64_1 = 12121212,
     .i8_1 = 65,
@@ -300,6 +301,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()
     }
 };
@@ -311,6 +314,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 */
 };

@@ -333,6 +337,7 @@ static void test_simple_test(void)
     FIELD_EQUAL(i32_1);
     FIELD_EQUAL(i64_1);
     FIELD_EQUAL(u8_1);
+    FIELD_EQUAL(u16_1);
 }
 #undef FIELD_EQUAL

-- 
1.9.3

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

* [Qemu-devel] [PATCH 16/27] vmstate: Test for VMSTATE_UINT32_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (14 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 15/27] vmstate: Test for VMSTATE_UINT16_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 17/27] vmstate: Test for VMSTATE_UINT64_TEST Juan Quintela
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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        | 14 +++++++++-----
 15 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 80028e8..82e2da6 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -657,7 +657,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 5a2de40..2b0ac0c 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 a00a93c..de24a91 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2419,8 +2419,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 77af60b..22e30bf 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -424,7 +424,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 c2047e7..694dec4 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -551,8 +551,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)

@@ -573,7 +573,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)

@@ -604,9 +604,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_POSITIVE_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 d3deea5..31ad29c 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -658,10 +658,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),
@@ -672,7 +672,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),
@@ -680,14 +680,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 60dc360..3754e85 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -152,7 +152,7 @@ typedef struct TestSimple {
     bool     b_1,   b_2;
     uint8_t  u8_1, u8_2;
     uint16_t u16_1, u16_2;
-    uint32_t u32_1;
+    uint32_t u32_1, u32_2;
     uint64_t u64_1;
     int8_t   i8_1,  i8_2;
     int16_t  i16_1, i16_2;
@@ -170,6 +170,7 @@ TestSimple obj_simple = {
     .u16_1 = 512,
     .u16_2 = 666,
     .u32_1 = 70000,
+    .u32_2 = 88888,
     .u64_1 = 12121212,
     .i8_1 = 65,
     .i8_2 = -65,
@@ -303,6 +304,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()
     }
 };
@@ -315,6 +318,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 */
 };

@@ -338,6 +342,7 @@ static void test_simple_test(void)
     FIELD_EQUAL(i64_1);
     FIELD_EQUAL(u8_1);
     FIELD_EQUAL(u16_1);
+    FIELD_EQUAL(u32_1);
 }
 #undef FIELD_EQUAL

@@ -363,12 +368,11 @@ static const VMStateDescription vmstate_simple_versioned = {
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(a, TestVersioned),
-        /* Versioned field in the middle, so we catch bugs more
-         * easily. */
-        VMSTATE_UINT32_V(b, TestVersioned, 2),
+        /* Versioned field in the middle, so we catch bugs more easily. */
+        VMSTATE_UINT32_TEST(b, TestVersioned, vmstate_2_plus),
         VMSTATE_UINT32(c, TestVersioned),
         VMSTATE_UINT64(d, TestVersioned),
-        VMSTATE_UINT32_V(e, TestVersioned, 2),
+        VMSTATE_UINT32_TEST(e, TestVersioned, vmstate_2_plus),
         VMSTATE_UINT64_V(f, TestVersioned, 2),
         VMSTATE_END_OF_LIST()
     }
-- 
1.9.3

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

* [Qemu-devel] [PATCH 17/27] vmstate: Test for VMSTATE_UINT64_TEST
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (15 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 16/27] vmstate: Test for VMSTATE_UINT32_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 18/27] vmstate: Test for VMSTATE_FLOAT64 Juan Quintela
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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        | 11 ++++++++---
 4 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 2b0ac0c..fd2acd1 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 694dec4..35b5663 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -553,8 +553,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)
@@ -575,7 +575,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)
@@ -604,9 +604,6 @@ extern const VMStateInfo vmstate_info_bitmap;
 #define VMSTATE_INT32_POSITIVE_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 31ad29c..f8626db 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -660,14 +660,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),
@@ -676,12 +676,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),
@@ -689,18 +689,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 3754e85..0d9335c 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -153,7 +153,7 @@ typedef struct TestSimple {
     uint8_t  u8_1, u8_2;
     uint16_t u16_1, u16_2;
     uint32_t u32_1, u32_2;
-    uint64_t u64_1;
+    uint64_t u64_1, u64_2;
     int8_t   i8_1,  i8_2;
     int16_t  i16_1, i16_2;
     int32_t  i32_1, i32_2;
@@ -172,6 +172,7 @@ TestSimple obj_simple = {
     .u32_1 = 70000,
     .u32_2 = 88888,
     .u64_1 = 12121212,
+    .u64_2 = 34343434,
     .i8_1 = 65,
     .i8_2 = -65,
     .i16_1 = 512,
@@ -306,6 +307,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()
     }
 };
@@ -319,6 +322,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 */
 };

@@ -343,6 +347,7 @@ static void test_simple_test(void)
     FIELD_EQUAL(u8_1);
     FIELD_EQUAL(u16_1);
     FIELD_EQUAL(u32_1);
+    FIELD_EQUAL(u64_1);
 }
 #undef FIELD_EQUAL

@@ -373,7 +378,7 @@ static const VMStateDescription vmstate_simple_versioned = {
         VMSTATE_UINT32(c, TestVersioned),
         VMSTATE_UINT64(d, TestVersioned),
         VMSTATE_UINT32_TEST(e, TestVersioned, vmstate_2_plus),
-        VMSTATE_UINT64_V(f, TestVersioned, 2),
+        VMSTATE_UINT64_TEST(f, TestVersioned, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -467,7 +472,7 @@ static const VMStateDescription vmstate_simple_skipping = {
         VMSTATE_UINT32_TEST(c, TestVersioned, test_skip),
         VMSTATE_UINT64(d, TestVersioned),
         VMSTATE_UINT32_TEST(e, TestVersioned, test_skip),
-        VMSTATE_UINT64_V(f, TestVersioned, 2),
+        VMSTATE_UINT64_TEST(f, TestVersioned, vmstate_2_plus),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
1.9.3

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

* [Qemu-devel] [PATCH 18/27] vmstate: Test for VMSTATE_FLOAT64
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (16 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 17/27] vmstate: Test for VMSTATE_UINT64_TEST Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 19/27] vmstate: Test for VMSTATE_UNUSED Juan Quintela
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 35b5663..c877b16 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -605,11 +605,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 0d9335c..27a3ad4 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -158,6 +158,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 */
@@ -181,6 +182,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
@@ -205,6 +207,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()
     }
 };
@@ -236,6 +239,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 */
 };

@@ -273,6 +277,7 @@ static void test_simple_primitive(void)
     FIELD_EQUAL(i32_2);
     FIELD_EQUAL(i64_1);
     FIELD_EQUAL(i64_2);
+    FIELD_EQUAL(f64);
 }

 static bool test_true(void *opaque, int version_id)
-- 
1.9.3

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

* [Qemu-devel] [PATCH 19/27] vmstate: Test for VMSTATE_UNUSED
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (17 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 18/27] vmstate: Test for VMSTATE_FLOAT64 Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 20/27] vmstate: Test for VMSTATE_BITMAP Juan Quintela
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 c877b16..16f9865 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -491,10 +491,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,                                      \
@@ -728,14 +727,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 27a3ad4..07aa5e8 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -208,6 +208,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()
     }
 };
@@ -240,6 +241,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 */
 };

@@ -314,6 +316,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()
     }
 };
@@ -328,6 +332,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.3

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

* [Qemu-devel] [PATCH 20/27] vmstate: Test for VMSTATE_BITMAP
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (18 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 19/27] vmstate: Test for VMSTATE_UNUSED Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 21/27] vmstate: Test for VMSTATE_UINT8_EQUAL Juan Quintela
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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        | 75 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 5efe8c1..10e7176 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -456,7 +456,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 16f9865..a229b46 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -502,9 +502,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 07aa5e8..83dbb34 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;
@@ -361,6 +362,79 @@ static void test_simple_test(void)
 }
 #undef FIELD_EQUAL

+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_EQUAL(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 obj_bitmap_copy(void *arg1, void *arg2)
+{
+    TestBitmap *target = arg1;
+    TestBitmap *source = arg2;
+
+    target->bitmap_size = source->bitmap_size;
+    memcpy(target->bitmap, source->bitmap, VMSTATE_BITMAP_SIZE / sizeof(long));
+}
+
+static TestBitmap *create_bitmap(void)
+{
+    TestBitmap *obj = g_malloc0(sizeof(*obj));
+    obj->bitmap_size = VMSTATE_BITMAP_SIZE;
+    obj->bitmap = bitmap_new(VMSTATE_BITMAP_SIZE);
+
+    return obj;
+}
+
+static void test_simple_bitmap(void)
+{
+    TestBitmap *obj_bitmap, *obj, *obj_clone;
+
+    obj_bitmap = create_bitmap();
+    obj = create_bitmap();
+    obj_clone = create_bitmap();
+
+    set_bit(0, obj_bitmap->bitmap);
+    set_bit(22, obj_bitmap->bitmap);
+    set_bit(30, obj_bitmap->bitmap);
+    set_bit(62, obj_bitmap->bitmap);
+
+    save_vmstate(&vmstate_simple_bitmap, obj_bitmap);
+
+    compare_vmstate(wire_simple_bitmap, sizeof(wire_simple_bitmap));
+
+    SUCCESS(load_vmstate(&vmstate_simple_bitmap, obj, obj_clone,
+                         obj_bitmap_copy, 1, wire_simple_bitmap,
+                         sizeof(wire_simple_bitmap)));
+
+#define FIELD_EQUAL(name)   g_assert_cmpint(obj->name, ==, obj_bitmap->name)
+    FIELD_EQUAL(bitmap_size);
+    g_assert_cmpint(bitmap_equal(obj->bitmap, obj_bitmap->bitmap,
+                                 VMSTATE_BITMAP_SIZE), ==, 1);
+#undef FIELD_EQUAL
+}
+
 typedef struct TestVersioned {
     uint32_t a, b, c, e;
     uint64_t d, f;
@@ -592,6 +666,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/simple/skip", test_simple_skip);
     g_test_add_func("/vmstate/simple/no_skip", test_simple_no_skip);
     g_test_add_func("/vmstate/simple/test", test_simple_test);
+    g_test_add_func("/vmstate/simple/bitmap", test_simple_bitmap);
     g_test_run();

     close(temp_fd);
-- 
1.9.3

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

* [Qemu-devel] [PATCH 21/27] vmstate: Test for VMSTATE_UINT8_EQUAL
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (19 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 20/27] vmstate: Test for VMSTATE_BITMAP Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 22/27] vmstate: Test for VMSTATE_UINT16_EQUAL Juan Quintela
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 UTC (permalink / raw)
  To: qemu-devel

We introduce another full test.

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

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index a229b46..b81d5ac 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -577,7 +577,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 83dbb34..0d98bbb 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -360,6 +360,47 @@ static void test_simple_test(void)
     FIELD_EQUAL(u32_1);
     FIELD_EQUAL(u64_1);
 }
+
+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)
+{
+    TestSimple obj, obj_clone;
+
+    memset(&obj, 0, sizeof(obj));
+    save_vmstate(&vmstate_simple_compare, &obj_simple);
+
+    compare_vmstate(wire_simple_compare, sizeof(wire_simple_compare));
+
+
+    /* we are testing that values are the same, we need to
+       have the same value */
+    memcpy(&obj, &obj_simple, sizeof(obj));
+    SUCCESS(load_vmstate(&vmstate_simple_compare, &obj, &obj_clone,
+                         obj_simple_copy, 1, wire_simple_compare,
+                         sizeof(wire_simple_compare)));
+
+    /* we change the value, so it is not equal anymore */
+    memcpy(&obj, &obj_simple, sizeof(obj));
+    obj.u8_1 = 27;
+    FAILURE(load_vmstate(&vmstate_simple_compare, &obj, &obj_clone,
+                         obj_simple_copy, 1, wire_simple_compare,
+                         sizeof(wire_simple_compare)));
+}
 #undef FIELD_EQUAL

 typedef struct TestBitmap {
@@ -666,6 +707,7 @@ int main(int argc, char **argv)
     g_test_add_func("/vmstate/simple/skip", test_simple_skip);
     g_test_add_func("/vmstate/simple/no_skip", test_simple_no_skip);
     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_run();

-- 
1.9.3

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

* [Qemu-devel] [PATCH 22/27] vmstate: Test for VMSTATE_UINT16_EQUAL
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (20 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 21/27] vmstate: Test for VMSTATE_UINT8_EQUAL Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 23/27] vmstate: Test for VMSTATE_UINT32_EQUAL Juan Quintela
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 b81d5ac..e06a091 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -579,11 +579,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 0d98bbb..370bea1 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -152,7 +152,7 @@ static int load_vmstate(const VMStateDescription *desc,
 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;
@@ -171,6 +171,7 @@ TestSimple obj_simple = {
     .u8_2 = 222,
     .u16_1 = 512,
     .u16_2 = 666,
+    .u16_3 = 513,
     .u32_1 = 70000,
     .u32_2 = 88888,
     .u64_1 = 12121212,
@@ -368,12 +369,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, 0x01,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.3

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

* [Qemu-devel] [PATCH 23/27] vmstate: Test for VMSTATE_UINT32_EQUAL
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (21 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 22/27] vmstate: Test for VMSTATE_UINT16_EQUAL Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 24/27] vmstate: Test for VMSTATE_UINT64_EQUAL Juan Quintela
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 e06a091..73fd6c6 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -585,15 +585,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 370bea1..a2b707e 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -372,6 +372,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()
     }
 };
@@ -380,6 +381,7 @@ uint8_t wire_simple_compare[] = {
     /* u8_1 */  0x82,
     /* u16_1 */ 0x02, 0x00,
     /* u16_3 */ 0x02, 0x01,
+    /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.3

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

* [Qemu-devel] [PATCH 24/27] vmstate: Test for VMSTATE_UINT64_EQUAL
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (22 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 23/27] vmstate: Test for VMSTATE_UINT32_EQUAL Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 25/27] vmstate: Test for VMSTATE_INT32_EQUAL Juan Quintela
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 UTC (permalink / raw)
  To: qemu-devel

Remove unused VMSTATE_UINT64_EQUAL_V.

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

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 73fd6c6..4fe199a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -588,19 +588,15 @@ 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_POSITIVE_LE(_f, _s)                             \
     VMSTATE_SINGLE(_f, _s, 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/tests/test-vmstate.c b/tests/test-vmstate.c
index a2b707e..4e7f951 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -373,6 +373,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()
     }
 };
@@ -382,6 +383,7 @@ uint8_t wire_simple_compare[] = {
     /* u16_1 */ 0x02, 0x00,
     /* u16_3 */ 0x02, 0x01,
     /* 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.3

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

* [Qemu-devel] [PATCH 25/27] vmstate: Test for VMSTATE_INT32_EQUAL
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (23 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 24/27] vmstate: Test for VMSTATE_UINT64_EQUAL Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 26/27] vmstate: Test for VMSTATE_INT32_LE Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 27/27] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ Juan Quintela
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 4fe199a..4aef1cf 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -592,7 +592,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_POSITIVE_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 4e7f951..9472850 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -374,6 +374,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()
     }
 };
@@ -384,6 +385,7 @@ uint8_t wire_simple_compare[] = {
     /* u16_3 */ 0x02, 0x01,
     /* 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.3

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

* [Qemu-devel] [PATCH 26/27] vmstate: Test for VMSTATE_INT32_LE
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (24 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 25/27] vmstate: Test for VMSTATE_INT32_EQUAL Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 27/27] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ Juan Quintela
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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 |  2 +-
 tests/test-vmstate.c        | 20 +++++++++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 4aef1cf..d7bd023 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -595,7 +595,7 @@ extern const VMStateInfo vmstate_info_bitmap;
     VMSTATE_SINGLE_TEST(_f, _s, NULL, 0, vmstate_info_int32_equal, int32_t)

 #define VMSTATE_INT32_POSITIVE_LE(_f, _s)                             \
-    VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)
+    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/tests/test-vmstate.c b/tests/test-vmstate.c
index 9472850..f2f59c9 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -374,7 +374,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()
     }
 };
@@ -385,6 +386,7 @@ uint8_t wire_simple_compare[] = {
     /* u16_3 */ 0x02, 0x01,
     /* 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 */
 };
@@ -412,6 +414,22 @@ static void test_simple_compare(void)
     FAILURE(load_vmstate(&vmstate_simple_compare, &obj, &obj_clone,
                          obj_simple_copy, 1, wire_simple_compare,
                          sizeof(wire_simple_compare)));
+
+    /* testing less equal */
+
+    /* we change the value, so it is not equal anymore */
+    memcpy(&obj, &obj_simple, sizeof(obj));
+    obj.i32_1 = 8000;
+    FAILURE(load_vmstate(&vmstate_simple_compare, &obj, &obj_clone,
+                         obj_simple_copy, 1, wire_simple_compare,
+                         sizeof(wire_simple_compare)));
+
+    /* we change the value, so it is not equal anymore */
+    memcpy(&obj, &obj_simple, sizeof(obj));
+    obj.i32_1 = 80000;
+    SUCCESS(load_vmstate(&vmstate_simple_compare, &obj, &obj_clone,
+                         obj_simple_copy, 1, wire_simple_compare,
+                         sizeof(wire_simple_compare)));
 }
 #undef FIELD_EQUAL

-- 
1.9.3

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

* [Qemu-devel] [PATCH 27/27] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/
  2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
                   ` (25 preceding siblings ...)
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 26/27] vmstate: Test for VMSTATE_INT32_LE Juan Quintela
@ 2014-06-16  9:58 ` Juan Quintela
  26 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-16  9:58 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>
---
 tests/test-vmstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f2f59c9..8b735c3 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -375,7 +375,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.3

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

* Re: [Qemu-devel] [PATCH 02/27] vmstate: Return error in case of error
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 02/27] vmstate: Return error in case of error Juan Quintela
@ 2014-06-17 10:43   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 35+ messages in thread
From: Dr. David Alan Gilbert @ 2014-06-17 10:43 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.  And we should also set an error
> in qemu_file.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

> ---
>  vmstate.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/vmstate.c b/vmstate.c
> index b5882fa..c996520 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -98,7 +98,11 @@ 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) {
> +                    qemu_file_set_error(f, ret);
>                      trace_vmstate_load_field_error(field->name, ret);
>                      return ret;
>                  }

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

I wonder about turning that trace into an error_report; the process is doomed
anyway at this point and it would be nice to know why.

Dave
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH 01/27] migration: Remove unneeded minimum_version_id_old
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 01/27] migration: Remove unneeded minimum_version_id_old Juan Quintela
@ 2014-06-17 10:44   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 35+ messages in thread
From: Dr. David Alan Gilbert @ 2014-06-17 10:44 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> Once there, make checkpatch happy.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  hw/usb/hcd-ohci.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
> index cd87074..cace945 100644
> --- a/hw/usb/hcd-ohci.c
> +++ b/hw/usb/hcd-ohci.c
> @@ -1988,8 +1988,7 @@ static const VMStateDescription vmstate_ohci_state_port = {
>      .name = "ohci-core/port",
>      .version_id = 1,
>      .minimum_version_id = 1,
> -    .minimum_version_id_old = 1,
> -    .fields = (VMStateField []) {
> +    .fields = (VMStateField[]) {
>          VMSTATE_UINT32(ctrl, OHCIPort),
>          VMSTATE_END_OF_LIST()
>      },
> @@ -2015,9 +2014,8 @@ static const VMStateDescription vmstate_ohci_eof_timer = {
>      .name = "ohci-core/eof-timer",
>      .version_id = 1,
>      .minimum_version_id = 1,
> -    .minimum_version_id_old = 1,
>      .pre_load = ohci_eof_timer_pre_load,
> -    .fields = (VMStateField []) {
> +    .fields = (VMStateField[]) {
>          VMSTATE_TIMER(eof_timer, OHCIState),
>          VMSTATE_END_OF_LIST()
>      },
> @@ -2078,7 +2076,6 @@ static const VMStateDescription vmstate_ohci = {
>      .name = "ohci",
>      .version_id = 1,
>      .minimum_version_id = 1,
> -    .minimum_version_id_old = 1,
>      .fields = (VMStateField[]) {
>          VMSTATE_PCI_DEVICE(parent_obj, OHCIPCIState),
>          VMSTATE_STRUCT(state, OHCIPCIState, 1, vmstate_ohci_state, OHCIState),
> -- 
> 1.9.3
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH 03/27] vmstate: Refactor & increase tests for primitive types
  2014-06-16  9:57 ` [Qemu-devel] [PATCH 03/27] vmstate: Refactor & increase tests for primitive types Juan Quintela
@ 2014-06-17 11:34   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 35+ messages in thread
From: Dr. David Alan Gilbert @ 2014-06-17 11:34 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) 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>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  tests/test-vmstate.c | 273 +++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 212 insertions(+), 61 deletions(-)
> 
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index 8b242c4..a462335 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -54,80 +54,232 @@ 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;
> +#define SUCCESS(val) \
> +    g_assert_cmpint((val), ==, 0)
> 
> +#define FAILURE(val) \
> +    g_assert_cmpint((val), !=, 0)
> 
> -static const VMStateDescription vmstate_simple = {
> -    .name = "test",
> -    .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_END_OF_LIST()
> -    }
> -};
> +static void save_vmstate(const VMStateDescription *desc, void *obj)
> +{
> +    QEMUFile *f = open_test_file(true);
> +
> +    /* Save file with vmstate */
> +    vmstate_save_state(f, desc, obj);
> +    qemu_put_byte(f, QEMU_VM_EOF);
> +    g_assert(!qemu_file_get_error(f));
> +    qemu_fclose(f);
> +}
> 
> -static void test_simple_save(void)
> +static void compare_vmstate(uint8_t *wire, size_t size)
>  {
> -    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 *f = open_test_file(false);
> +    uint8_t result[size];
> 
> -    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)];
> -    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
> +    /* read back as binary */
> +
> +    g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==,
>                      sizeof(result));
> -    g_assert(!qemu_file_get_error(loading));
> -    g_assert_cmpint(memcmp(result, expected, sizeof(result)), ==, 0);
> +    g_assert(!qemu_file_get_error(f));
> +
> +    /* Compare that what is on the file is the same that what we
> +       expected to be there */
> +    SUCCESS(memcmp(result, wire, sizeof(result)));
> 
>      /* Must reach EOF */
> -    qemu_get_byte(loading);
> -    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
> +    qemu_get_byte(f);
> +    g_assert_cmpint(qemu_file_get_error(f), ==, -EIO);
> 
> -    qemu_fclose(loading);
> +    qemu_fclose(f);
>  }
> 
> -static void test_simple_load(void)
> +static int load_vmstate_one(const VMStateDescription *desc, void *obj,
> +                            int version, uint8_t *wire, size_t size)
>  {
> -    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));
> -    qemu_fclose(fsave);
> +    QEMUFile *f;
> +    int ret;
> +
> +    f = open_test_file(true);
> +    qemu_put_buffer(f, wire, size);
> +    qemu_fclose(f);
> +
> +    f = open_test_file(false);
> +    ret = vmstate_load_state(f, desc, obj, version);
> +    if (ret) {
> +        g_assert(qemu_file_get_error(f));
> +    } else{
> +        g_assert(!qemu_file_get_error(f));
> +    }
> +    qemu_fclose(f);
> +    return ret;
> +}
> 
> -    QEMUFile *loading = open_test_file(false);
> -    TestStruct obj;
> -    vmstate_load_state(loading, &vmstate_simple, &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);
> -    qemu_fclose(loading);
> +
> +static int load_vmstate(const VMStateDescription *desc,
> +                        void *obj, void *obj_clone,
> +                        void (*obj_copy)(void *, void*),
> +                        int version, uint8_t *wire, size_t size)
> +{
> +    /* We test with zero size */
> +    obj_copy(obj_clone, obj);
> +    FAILURE(load_vmstate_one(desc, obj, version, wire, 0));
> +
> +    /* Stream ends with QEMU_EOF, so we need at least 3 bytes to be
> +     * able to test in the middle */
> +
> +    if (size > 3) {
> +
> +        /* We test with size - 2. We can't test size - 1 due to EOF tricks */
> +        obj_copy(obj, obj_clone);
> +        FAILURE(load_vmstate_one(desc, obj, version, wire, size - 2));
> +
> +        /* Test with size/2, first half of real state */
> +        obj_copy(obj, obj_clone);
> +        FAILURE(load_vmstate_one(desc, obj, version, wire, size/2));
> +
> +        /* Test with size/2, second half of real state */
> +        obj_copy(obj, obj_clone);
> +        FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2));
> +
> +    }
> +    obj_copy(obj, obj_clone);
> +    return load_vmstate_one(desc, obj, version, wire, size);
> +}
> +
> +/* Test struct that we are going to use for our tests */
> +
> +typedef struct TestSimple {
> +    bool     b_1,   b_2;
> +    uint8_t  u8_1;
> +    uint16_t u16_1;
> +    uint32_t u32_1;
> +    uint64_t u64_1;
> +    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 = 130,
> +    .u16_1 = 512,
> +    .u32_1 = 70000,
> +    .u64_1 = 12121212,
> +    .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_primitive = {
> +    .name = "simple/primitive",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .fields = (VMStateField[]) {
> +        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()
> +    }
> +};
> +
> +/* 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 */
> +};
> +
> +static void obj_simple_copy(void *target, void *source)
> +{
> +    memcpy(target, source, sizeof(TestSimple));
> +}
> +
> +static void test_simple_primitive(void)
> +{
> +    TestSimple obj, obj_clone;
> +
> +    memset(&obj, 0, sizeof(obj));
> +    save_vmstate(&vmstate_simple_primitive, &obj_simple);
> +
> +    compare_vmstate(wire_simple_primitive, sizeof(wire_simple_primitive));
> +
> +    SUCCESS(load_vmstate(&vmstate_simple_primitive, &obj, &obj_clone,
> +                         obj_simple_copy, 1, wire_simple_primitive,
> +                         sizeof(wire_simple_primitive)));
> +
> +#define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_simple.name)
> +
> +    FIELD_EQUAL(b_1);
> +    FIELD_EQUAL(b_2);
> +    FIELD_EQUAL(u8_1);
> +    FIELD_EQUAL(u16_1);
> +    FIELD_EQUAL(u32_1);
> +    FIELD_EQUAL(u64_1);
> +    FIELD_EQUAL(i8_1);
> +    FIELD_EQUAL(i8_2);
> +    FIELD_EQUAL(i16_1);
> +    FIELD_EQUAL(i16_2);
> +    FIELD_EQUAL(i32_1);
> +    FIELD_EQUAL(i32_2);
> +    FIELD_EQUAL(i64_1);
> +    FIELD_EQUAL(i64_2);
>  }
> +#undef FIELD_EQUAL
> +
> +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 +354,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 +489,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.3
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format
  2014-06-16  9:58 ` [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format Juan Quintela
@ 2014-06-17 11:56   ` Dr. David Alan Gilbert
  2014-06-25 13:00     ` Juan Quintela
  0 siblings, 1 reply; 35+ messages in thread
From: Dr. David Alan Gilbert @ 2014-06-17 11:56 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  tests/test-vmstate.c | 363 ++++++++++++++++++++++++++-------------------------
>  1 file changed, 185 insertions(+), 178 deletions(-)
> 
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index a462335..d0839c3 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -272,217 +272,226 @@ static void test_simple_primitive(void)
>  }
>  #undef FIELD_EQUAL
> 
> -typedef struct TestStruct {
> +typedef struct TestVersioned {
>      uint32_t a, b, c, e;
>      uint64_t d, f;
>      bool skip_c_e;
> -} TestStruct;
> +} TestVersioned;
> +
> +TestVersioned obj_versioned = {
> +    .a = 10,
> +    .b = 200,
> +    .c = 30,
> +    .d = 40,
> +    .e = 500,
> +    .f = 600,
> +    .skip_c_e = true,
> +};
> 
> -static const VMStateDescription vmstate_versioned = {
> +static const VMStateDescription vmstate_simple_versioned = {
>      .name = "test/versioned",
>      .version_id = 2,
>      .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.
> -                                             */
> -        VMSTATE_UINT32(c, TestStruct),
> -        VMSTATE_UINT64(d, TestStruct),
> -        VMSTATE_UINT32_V(e, TestStruct, 2),
> -        VMSTATE_UINT64_V(f, TestStruct, 2),
> +        VMSTATE_UINT32(a, TestVersioned),
> +        /* Versioned field in the middle, so we catch bugs more
> +         * easily. */
> +        VMSTATE_UINT32_V(b, TestVersioned, 2),
> +        VMSTATE_UINT32(c, TestVersioned),
> +        VMSTATE_UINT64(d, TestVersioned),
> +        VMSTATE_UINT32_V(e, TestVersioned, 2),
> +        VMSTATE_UINT64_V(f, TestVersioned, 2),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> 
> -static void test_load_v1(void)
> +uint8_t wire_simple_v1[] = {
> +    /* a */ 0x00, 0x00, 0x00, 0x0a,
> +    /* c */ 0x00, 0x00, 0x00, 0x1e,
> +    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
> +    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> +};
> +
> +uint8_t wire_simple_v2[] = {
> +    /* a */ 0x00, 0x00, 0x00, 0x0a,
> +    /* b */ 0x00, 0x00, 0x00, 0xc8,
> +    /* c */ 0x00, 0x00, 0x00, 0x1e,
> +    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
> +    /* e */ 0x00, 0x00, 0x01, 0xf4,
> +    /* f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x58,
> +    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> +};
> +
> +static void obj_versioned_copy(void *arg1, void *arg2)
>  {
> -    QEMUFile *fsave = open_test_file(true);
> -    uint8_t buf[] = {
> -        0, 0, 0, 10,             /* a */
> -        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));
> -    qemu_fclose(fsave);
> -
> -    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));
> -    g_assert_cmpint(obj.a, ==, 10);
> -    g_assert_cmpint(obj.b, ==, 200);
> -    g_assert_cmpint(obj.c, ==, 30);
> -    g_assert_cmpint(obj.d, ==, 40);
> -    g_assert_cmpint(obj.e, ==, 500);
> -    g_assert_cmpint(obj.f, ==, 600);
> -    qemu_fclose(loading);
> +    TestVersioned *target = arg1;
> +    TestVersioned *source = arg2;
> +
> +    target->a = source->a;
> +    target->b = source->b;
> +    target->c = source->c;
> +    target->d = source->d;
> +    target->e = source->e;
> +    target->f = source->f;
> +    target->skip_c_e = source->skip_c_e;

Why's that not simply *target = *source?

>  }
> 
> -static void test_load_v2(void)
> +static void test_simple_v2(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 */
> -        0, 0, 0, 50,             /* e */
> -        0, 0, 0, 0, 0, 0, 0, 60, /* f */
> -        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> -    };
> -    qemu_put_buffer(fsave, buf, sizeof(buf));
> -    qemu_fclose(fsave);
> -
> -    QEMUFile *loading = open_test_file(false);
> -    TestStruct obj;
> -    vmstate_load_state(loading, &vmstate_versioned, &obj, 2);
> -    g_assert_cmpint(obj.a, ==, 10);
> -    g_assert_cmpint(obj.b, ==, 20);
> -    g_assert_cmpint(obj.c, ==, 30);
> -    g_assert_cmpint(obj.d, ==, 40);
> -    g_assert_cmpint(obj.e, ==, 50);
> -    g_assert_cmpint(obj.f, ==, 60);
> -    qemu_fclose(loading);
> +    TestVersioned obj, obj_clone;
> +
> +    memset(&obj, 0, sizeof(obj));
> +    save_vmstate(&vmstate_simple_versioned, &obj_versioned);
> +
> +    compare_vmstate(wire_simple_v2, sizeof(wire_simple_v2));
> +
> +    SUCCESS(load_vmstate(&vmstate_simple_versioned, &obj, &obj_clone,
> +                         obj_versioned_copy, 2, wire_simple_v2,
> +                         sizeof(wire_simple_v2)));
> +
> +#define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_versioned.name)
> +#define FIELD_NOT_EQUAL(name) \
> +    g_assert_cmpint(obj.name, !=, obj_versioned.name)

Given that macro is shared with the next few functions it would be seem
to declare it outside of the function.

> +    FIELD_EQUAL(a);
> +    FIELD_EQUAL(b);
> +    FIELD_EQUAL(c);
> +    FIELD_EQUAL(d);
> +    FIELD_EQUAL(e);
> +    FIELD_EQUAL(f);
> +}
> +
> +static void test_simple_v1(void)
> +{
> +    TestVersioned obj, obj_clone;
> +
> +    memset(&obj, 0, sizeof(obj));
> +    SUCCESS(load_vmstate(&vmstate_simple_versioned, &obj, &obj_clone,
> +                         obj_versioned_copy, 1, wire_simple_v1,
> +                         sizeof(wire_simple_v1)));
> +
> +    FIELD_EQUAL(a);
> +    FIELD_NOT_EQUAL(b);
> +    FIELD_EQUAL(c);
> +    FIELD_EQUAL(d);
> +    FIELD_NOT_EQUAL(e);
> +    FIELD_NOT_EQUAL(f);
>  }
> 
>  static bool test_skip(void *opaque, int version_id)
>  {
> -    TestStruct *t = (TestStruct *)opaque;
> +    TestVersioned *t = opaque;
>      return !t->skip_c_e;
>  }
> 
> -static const VMStateDescription vmstate_skipping = {
> -    .name = "test/skip",
> +static const VMStateDescription vmstate_simple_skipping = {
> +    .name = "simple/skip",
>      .version_id = 2,
>      .minimum_version_id = 1,
>      .fields = (VMStateField[]) {
> -        VMSTATE_UINT32(a, TestStruct),
> -        VMSTATE_UINT32(b, TestStruct),
> -        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_BOOL(skip_c_e, TestVersioned),
> +        VMSTATE_UINT32(a, TestVersioned),
> +        VMSTATE_UINT32(b, TestVersioned),
> +        VMSTATE_UINT32_TEST(c, TestVersioned, test_skip),
> +        VMSTATE_UINT64(d, TestVersioned),
> +        VMSTATE_UINT32_TEST(e, TestVersioned, test_skip),
> +        VMSTATE_UINT64_V(f, TestVersioned, 2),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> 
> +uint8_t wire_simple_no_skip[] = {
> +    /* s */ 0x00,
> +    /* a */ 0x00, 0x00, 0x00, 0x0a,
> +    /* b */ 0x00, 0x00, 0x00, 0xc8,
> +    /* c */ 0x00, 0x00, 0x00, 0x1e,
> +    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
> +    /* e */ 0x00, 0x00, 0x01, 0xf4,
> +    /* f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x58,
> +    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> +};
> 
> -static void test_save_noskip(void)
> -{
> -    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 = 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 */
> -        0, 0, 0, 5,             /* e */
> -        0, 0, 0, 0, 0, 0, 0, 6, /* f */
> -    };
> -    uint8_t result[sizeof(expected)];
> -    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);
> -
> -    /* Must reach EOF */
> -    qemu_get_byte(loading);
> -    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
> -
> -    qemu_fclose(loading);
> -}
> +uint8_t wire_simple_skip[] = {
> +    /* s */ 0x01,
> +    /* a */ 0x00, 0x00, 0x00, 0x0a,
> +    /* b */ 0x00, 0x00, 0x00, 0xc8,
> +    /* d */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28,
> +    /* f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x58,
> +    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> +};
> 
> -static void test_save_skip(void)
> +static void test_simple_no_skip(void)
>  {
> -    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 = open_test_file(false);
> -    uint8_t expected[] = {
> -        0, 0, 0, 1,             /* a */
> -        0, 0, 0, 2,             /* b */
> -        0, 0, 0, 0, 0, 0, 0, 4, /* d */
> -        0, 0, 0, 0, 0, 0, 0, 6, /* f */
> -    };
> -    uint8_t result[sizeof(expected)];
> -    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);
> +    TestVersioned obj, obj_clone;
> 
> -
> -    /* Must reach EOF */
> -    qemu_get_byte(loading);
> -    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
> -
> -    qemu_fclose(loading);
> +    memset(&obj, 0, sizeof(obj));
> +    obj_versioned.skip_c_e = false;
> +    save_vmstate(&vmstate_simple_skipping, &obj_versioned);
> +
> +    compare_vmstate(wire_simple_no_skip, sizeof(wire_simple_no_skip));
> +
> +    /* We abuse the fact that f has a 0x00 value in the right position */

A bit nasty.

> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
> +                         obj_versioned_copy, 1, wire_simple_no_skip,
> +                         sizeof(wire_simple_no_skip) - 8));
> +
> +    FIELD_EQUAL(skip_c_e);
> +    FIELD_EQUAL(a);
> +    FIELD_EQUAL(b);
> +    FIELD_EQUAL(c);
> +    FIELD_EQUAL(d);
> +    FIELD_EQUAL(e);
> +    FIELD_NOT_EQUAL(f);
> +
> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
> +                         obj_versioned_copy, 2, wire_simple_no_skip,
> +                         sizeof(wire_simple_no_skip)));
> +
> +    FIELD_EQUAL(skip_c_e);
> +    FIELD_EQUAL(a);
> +    FIELD_EQUAL(b);
> +    FIELD_EQUAL(c);
> +    FIELD_EQUAL(d);
> +    FIELD_EQUAL(e);
> +    FIELD_EQUAL(f);
>  }
> 
> -static void test_load_noskip(void)
> +static void test_simple_skip(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 */
> -        0, 0, 0, 50,             /* e */
> -        0, 0, 0, 0, 0, 0, 0, 60, /* f */
> -        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> -    };
> -    qemu_put_buffer(fsave, buf, sizeof(buf));
> -    qemu_fclose(fsave);
> -
> -    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));
> -    g_assert_cmpint(obj.a, ==, 10);
> -    g_assert_cmpint(obj.b, ==, 20);
> -    g_assert_cmpint(obj.c, ==, 30);
> -    g_assert_cmpint(obj.d, ==, 40);
> -    g_assert_cmpint(obj.e, ==, 50);
> -    g_assert_cmpint(obj.f, ==, 60);
> -    qemu_fclose(loading);
> -}
> +    TestVersioned obj, obj_clone;
> 
> -static void test_load_skip(void)
> -{
> -    QEMUFile *fsave = open_test_file(true);
> -    uint8_t buf[] = {
> -        0, 0, 0, 10,             /* a */
> -        0, 0, 0, 20,             /* b */
> -        0, 0, 0, 0, 0, 0, 0, 40, /* d */
> -        0, 0, 0, 0, 0, 0, 0, 60, /* f */
> -        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
> -    };
> -    qemu_put_buffer(fsave, buf, sizeof(buf));
> -    qemu_fclose(fsave);
> -
> -    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));
> -    g_assert_cmpint(obj.a, ==, 10);
> -    g_assert_cmpint(obj.b, ==, 20);
> -    g_assert_cmpint(obj.c, ==, 300);
> -    g_assert_cmpint(obj.d, ==, 40);
> -    g_assert_cmpint(obj.e, ==, 500);
> -    g_assert_cmpint(obj.f, ==, 60);
> -    qemu_fclose(loading);
> +    memset(&obj, 0, sizeof(obj));
> +    obj_versioned.skip_c_e = true;
> +    save_vmstate(&vmstate_simple_skipping, &obj_versioned);
> +
> +    compare_vmstate(wire_simple_skip, sizeof(wire_simple_skip));
> +
> +    /* We abuse the fact that f has a 0x00 value in the right position */
> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
> +                         obj_versioned_copy, 1, wire_simple_skip,
> +                         sizeof(wire_simple_skip) - 8));
> +
> +    FIELD_EQUAL(skip_c_e);
> +    FIELD_EQUAL(a);
> +    FIELD_EQUAL(b);
> +    FIELD_NOT_EQUAL(c);
> +    FIELD_EQUAL(d);
> +    FIELD_NOT_EQUAL(e);
> +    FIELD_NOT_EQUAL(f);
> +
> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
> +                         obj_versioned_copy, 2, wire_simple_skip,
> +                         sizeof(wire_simple_skip)));
> +
> +    FIELD_EQUAL(skip_c_e);
> +    FIELD_EQUAL(a);
> +    FIELD_EQUAL(b);
> +    FIELD_NOT_EQUAL(c);
> +    FIELD_EQUAL(d);
> +    FIELD_NOT_EQUAL(e);
> +    FIELD_EQUAL(f);
>  }

Couldn't those functions just be merged and take a flag?

> +#undef FIELD_EQUAL
> +#undef FIELD_NOT_EQUAL
> 
>  int main(int argc, char **argv)
>  {
> @@ -490,12 +499,10 @@ 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/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);
> -    g_test_add_func("/vmstate/field_exists/load/skip", test_load_skip);
> -    g_test_add_func("/vmstate/field_exists/save/noskip", test_save_noskip);
> -    g_test_add_func("/vmstate/field_exists/save/skip", test_save_skip);
> +    g_test_add_func("/vmstate/simple/v1", test_simple_v1);
> +    g_test_add_func("/vmstate/simple/v2", test_simple_v2);
> +    g_test_add_func("/vmstate/simple/skip", test_simple_skip);
> +    g_test_add_func("/vmstate/simple/no_skip", test_simple_no_skip);
>      g_test_run();
> 
>      close(temp_fd);
> -- 
> 1.9.3
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format
  2014-06-17 11:56   ` Dr. David Alan Gilbert
@ 2014-06-25 13:00     ` Juan Quintela
  2014-06-25 13:14       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 35+ messages in thread
From: Juan Quintela @ 2014-06-25 13: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:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>

>> +static void obj_versioned_copy(void *arg1, void *arg2)
>>  {
>> -    QEMUFile *fsave = open_test_file(true);
>> -    uint8_t buf[] = {
>> -        0, 0, 0, 10,             /* a */
>> -        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));
>> -    qemu_fclose(fsave);
>> -
>> -    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));
>> -    g_assert_cmpint(obj.a, ==, 10);
>> -    g_assert_cmpint(obj.b, ==, 200);
>> -    g_assert_cmpint(obj.c, ==, 30);
>> -    g_assert_cmpint(obj.d, ==, 40);
>> -    g_assert_cmpint(obj.e, ==, 500);
>> -    g_assert_cmpint(obj.f, ==, 600);
>> -    qemu_fclose(loading);
>> +    TestVersioned *target = arg1;
>> +    TestVersioned *source = arg2;
>> +
>> +    target->a = source->a;
>> +    target->b = source->b;
>> +    target->c = source->c;
>> +    target->d = source->d;
>> +    target->e = source->e;
>> +    target->f = source->f;
>> +    target->skip_c_e = source->skip_c_e;
>
> Why's that not simply *target = *source?

To be able to only copy some of the fields, depending on what we want to
test O:-)

>> +    TestVersioned obj, obj_clone;
>> +
>> +    memset(&obj, 0, sizeof(obj));
>> +    save_vmstate(&vmstate_simple_versioned, &obj_versioned);
>> +
>> +    compare_vmstate(wire_simple_v2, sizeof(wire_simple_v2));
>> +
>> +    SUCCESS(load_vmstate(&vmstate_simple_versioned, &obj, &obj_clone,
>> +                         obj_versioned_copy, 2, wire_simple_v2,
>> +                         sizeof(wire_simple_v2)));
>> +
>> +#define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_versioned.name)
>> +#define FIELD_NOT_EQUAL(name) \
>> +    g_assert_cmpint(obj.name, !=, obj_versioned.name)
>
> Given that macro is shared with the next few functions it would be seem
> to declare it outside of the function.
>

It is not always the same (see the whole series otherwise).  I ended
finding easier to do it this way.  I ended defining it the 1st time that
I needed it.  That is coherent with the whole series, but I can change
it (don't really matter).


>> +    memset(&obj, 0, sizeof(obj));
>> +    obj_versioned.skip_c_e = false;
>> +    save_vmstate(&vmstate_simple_skipping, &obj_versioned);
>> +
>> +    compare_vmstate(wire_simple_no_skip, sizeof(wire_simple_no_skip));
>> +
>> +    /* We abuse the fact that f has a 0x00 value in the right position */
>
> A bit nasty.


Any better ideas?


>> +    compare_vmstate(wire_simple_skip, sizeof(wire_simple_skip));
>> +
>> +    /* We abuse the fact that f has a 0x00 value in the right position */
>> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
>> +                         obj_versioned_copy, 1, wire_simple_skip,
>> +                         sizeof(wire_simple_skip) - 8));
>> +
>> +    FIELD_EQUAL(skip_c_e);
>> +    FIELD_EQUAL(a);
>> +    FIELD_EQUAL(b);
>> +    FIELD_NOT_EQUAL(c);
>> +    FIELD_EQUAL(d);
>> +    FIELD_NOT_EQUAL(e);
>> +    FIELD_NOT_EQUAL(f);
>> +
>> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
>> +                         obj_versioned_copy, 2, wire_simple_skip,
>> +                         sizeof(wire_simple_skip)));
>> +
>> +    FIELD_EQUAL(skip_c_e);
>> +    FIELD_EQUAL(a);
>> +    FIELD_EQUAL(b);
>> +    FIELD_NOT_EQUAL(c);
>> +    FIELD_EQUAL(d);
>> +    FIELD_NOT_EQUAL(e);
>> +    FIELD_EQUAL(f);

>>  }
>
> Couldn't those functions just be merged and take a flag?
>I think it is clear this way, but that is the same to me.

FIELD_EQUAL(a)
FIELD_NOT_EQUAL(a)

vs

COMPARE_FIELD(a, true)
COMPARE_FILED(b, false)

For me, I don't need to go to the definition of the macro in the 1st
case, and I do on the second one.

Or do you mean anything different?

Thanks, Juan.

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

* Re: [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format
  2014-06-25 13:00     ` Juan Quintela
@ 2014-06-25 13:14       ` Dr. David Alan Gilbert
  2014-06-25 13:51         ` Juan Quintela
  0 siblings, 1 reply; 35+ messages in thread
From: Dr. David Alan Gilbert @ 2014-06-25 13:14 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> > * Juan Quintela (quintela@redhat.com) wrote:
> >> Signed-off-by: Juan Quintela <quintela@redhat.com>
> 
> >> +static void obj_versioned_copy(void *arg1, void *arg2)
> >>  {
> >> -    QEMUFile *fsave = open_test_file(true);
> >> -    uint8_t buf[] = {
> >> -        0, 0, 0, 10,             /* a */
> >> -        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));
> >> -    qemu_fclose(fsave);
> >> -
> >> -    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));
> >> -    g_assert_cmpint(obj.a, ==, 10);
> >> -    g_assert_cmpint(obj.b, ==, 200);
> >> -    g_assert_cmpint(obj.c, ==, 30);
> >> -    g_assert_cmpint(obj.d, ==, 40);
> >> -    g_assert_cmpint(obj.e, ==, 500);
> >> -    g_assert_cmpint(obj.f, ==, 600);
> >> -    qemu_fclose(loading);
> >> +    TestVersioned *target = arg1;
> >> +    TestVersioned *source = arg2;
> >> +
> >> +    target->a = source->a;
> >> +    target->b = source->b;
> >> +    target->c = source->c;
> >> +    target->d = source->d;
> >> +    target->e = source->e;
> >> +    target->f = source->f;
> >> +    target->skip_c_e = source->skip_c_e;
> >
> > Why's that not simply *target = *source?
> 
> To be able to only copy some of the fields, depending on what we want to
> test O:-)

But those last 7 lines do copy every field don't they?

> >> +    TestVersioned obj, obj_clone;
> >> +
> >> +    memset(&obj, 0, sizeof(obj));
> >> +    save_vmstate(&vmstate_simple_versioned, &obj_versioned);
> >> +
> >> +    compare_vmstate(wire_simple_v2, sizeof(wire_simple_v2));
> >> +
> >> +    SUCCESS(load_vmstate(&vmstate_simple_versioned, &obj, &obj_clone,
> >> +                         obj_versioned_copy, 2, wire_simple_v2,
> >> +                         sizeof(wire_simple_v2)));
> >> +
> >> +#define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_versioned.name)
> >> +#define FIELD_NOT_EQUAL(name) \
> >> +    g_assert_cmpint(obj.name, !=, obj_versioned.name)
> >
> > Given that macro is shared with the next few functions it would be seem
> > to declare it outside of the function.
> >
> 
> It is not always the same (see the whole series otherwise).  I ended
> finding easier to do it this way.  I ended defining it the 1st time that
> I needed it.  That is coherent with the whole series, but I can change
> it (don't really matter).

OK.

> >> +    memset(&obj, 0, sizeof(obj));
> >> +    obj_versioned.skip_c_e = false;
> >> +    save_vmstate(&vmstate_simple_skipping, &obj_versioned);
> >> +
> >> +    compare_vmstate(wire_simple_no_skip, sizeof(wire_simple_no_skip));
> >> +
> >> +    /* We abuse the fact that f has a 0x00 value in the right position */
> >
> > A bit nasty.
> 
> 
> Any better ideas?

Not really; but it's very reliant on the current format - although perhaps
demonstrates just how delicate that is.

> >> +    compare_vmstate(wire_simple_skip, sizeof(wire_simple_skip));
> >> +
> >> +    /* We abuse the fact that f has a 0x00 value in the right position */
> >> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
> >> +                         obj_versioned_copy, 1, wire_simple_skip,
> >> +                         sizeof(wire_simple_skip) - 8));
> >> +
> >> +    FIELD_EQUAL(skip_c_e);
> >> +    FIELD_EQUAL(a);
> >> +    FIELD_EQUAL(b);
> >> +    FIELD_NOT_EQUAL(c);
> >> +    FIELD_EQUAL(d);
> >> +    FIELD_NOT_EQUAL(e);
> >> +    FIELD_NOT_EQUAL(f);
> >> +
> >> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
> >> +                         obj_versioned_copy, 2, wire_simple_skip,
> >> +                         sizeof(wire_simple_skip)));
> >> +
> >> +    FIELD_EQUAL(skip_c_e);
> >> +    FIELD_EQUAL(a);
> >> +    FIELD_EQUAL(b);
> >> +    FIELD_NOT_EQUAL(c);
> >> +    FIELD_EQUAL(d);
> >> +    FIELD_NOT_EQUAL(e);
> >> +    FIELD_EQUAL(f);
> 
> >>  }
> >
> > Couldn't those functions just be merged and take a flag?
> >I think it is clear this way, but that is the same to me.
> 
> FIELD_EQUAL(a)
> FIELD_NOT_EQUAL(a)
> 
> vs
> 
> COMPARE_FIELD(a, true)
> COMPARE_FILED(b, false)
> 
> For me, I don't need to go to the definition of the macro in the 1st
> case, and I do on the second one.
> 
> Or do you mean anything different?

I meant test_simple_no_skip vs test_simple_skip; they seem to duplicate a lot.

Dave
> 
> Thanks, Juan.
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format
  2014-06-25 13:14       ` Dr. David Alan Gilbert
@ 2014-06-25 13:51         ` Juan Quintela
  0 siblings, 0 replies; 35+ messages in thread
From: Juan Quintela @ 2014-06-25 13:51 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:
>> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
>> > * Juan Quintela (quintela@redhat.com) wrote:
>> >> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> 
>> >> +static void obj_versioned_copy(void *arg1, void *arg2)
>> >>  {
>> >> -    QEMUFile *fsave = open_test_file(true);
>> >> -    uint8_t buf[] = {
>> >> -        0, 0, 0, 10,             /* a */
>> >> -        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));
>> >> -    qemu_fclose(fsave);
>> >> -
>> >> -    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));
>> >> -    g_assert_cmpint(obj.a, ==, 10);
>> >> -    g_assert_cmpint(obj.b, ==, 200);
>> >> -    g_assert_cmpint(obj.c, ==, 30);
>> >> -    g_assert_cmpint(obj.d, ==, 40);
>> >> -    g_assert_cmpint(obj.e, ==, 500);
>> >> -    g_assert_cmpint(obj.f, ==, 600);
>> >> -    qemu_fclose(loading);
>> >> +    TestVersioned *target = arg1;
>> >> +    TestVersioned *source = arg2;
>> >> +
>> >> +    target->a = source->a;
>> >> +    target->b = source->b;
>> >> +    target->c = source->c;
>> >> +    target->d = source->d;
>> >> +    target->e = source->e;
>> >> +    target->f = source->f;
>> >> +    target->skip_c_e = source->skip_c_e;
>> >
>> > Why's that not simply *target = *source?
>> 
>> To be able to only copy some of the fields, depending on what we want to
>> test O:-)
>
> But those last 7 lines do copy every field don't they?

They do.

>> >> +    TestVersioned obj, obj_clone;
>> >> +
>> >> +    memset(&obj, 0, sizeof(obj));
>> >> +    save_vmstate(&vmstate_simple_versioned, &obj_versioned);
>> >> +
>> >> +    compare_vmstate(wire_simple_v2, sizeof(wire_simple_v2));
>> >> +
>> >> +    SUCCESS(load_vmstate(&vmstate_simple_versioned, &obj, &obj_clone,
>> >> +                         obj_versioned_copy, 2, wire_simple_v2,
>> >> +                         sizeof(wire_simple_v2)));
>> >> +
>> >> +#define FIELD_EQUAL(name) g_assert_cmpint(obj.name, ==,
>> >> obj_versioned.name)
>> >> +#define FIELD_NOT_EQUAL(name) \
>> >> +    g_assert_cmpint(obj.name, !=, obj_versioned.name)
>> >
>> > Given that macro is shared with the next few functions it would be seem
>> > to declare it outside of the function.
>> >
>> 
>> It is not always the same (see the whole series otherwise).  I ended
>> finding easier to do it this way.  I ended defining it the 1st time that
>> I needed it.  That is coherent with the whole series, but I can change
>> it (don't really matter).
>
> OK.
>
>> >> +    memset(&obj, 0, sizeof(obj));
>> >> +    obj_versioned.skip_c_e = false;
>> >> +    save_vmstate(&vmstate_simple_skipping, &obj_versioned);
>> >> +
>> >> +    compare_vmstate(wire_simple_no_skip, sizeof(wire_simple_no_skip));
>> >> +
>> >> +    /* We abuse the fact that f has a 0x00 value in the right position */
>> >
>> > A bit nasty.
>> 
>> 
>> Any better ideas?
>
> Not really; but it's very reliant on the current format - although perhaps
> demonstrates just how delicate that is.

Yeap, anyways, that is how the test was written, nothing to do with the
refactoring.  Improvements on top welcome O:-)



>> >> +    compare_vmstate(wire_simple_skip, sizeof(wire_simple_skip));
>> >> +
>> >> +    /* We abuse the fact that f has a 0x00 value in the right position */
>> >> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
>> >> +                         obj_versioned_copy, 1, wire_simple_skip,
>> >> +                         sizeof(wire_simple_skip) - 8));
>> >> +
>> >> +    FIELD_EQUAL(skip_c_e);
>> >> +    FIELD_EQUAL(a);
>> >> +    FIELD_EQUAL(b);
>> >> +    FIELD_NOT_EQUAL(c);
>> >> +    FIELD_EQUAL(d);
>> >> +    FIELD_NOT_EQUAL(e);
>> >> +    FIELD_NOT_EQUAL(f);
>> >> +
>> >> +    SUCCESS(load_vmstate(&vmstate_simple_skipping, &obj, &obj_clone,
>> >> +                         obj_versioned_copy, 2, wire_simple_skip,
>> >> +                         sizeof(wire_simple_skip)));
>> >> +
>> >> +    FIELD_EQUAL(skip_c_e);
>> >> +    FIELD_EQUAL(a);
>> >> +    FIELD_EQUAL(b);
>> >> +    FIELD_NOT_EQUAL(c);
>> >> +    FIELD_EQUAL(d);
>> >> +    FIELD_NOT_EQUAL(e);
>> >> +    FIELD_EQUAL(f);
>> 
>> >>  }
>> >
>> > Couldn't those functions just be merged and take a flag?
>> >I think it is clear this way, but that is the same to me.
>> 
>> FIELD_EQUAL(a)
>> FIELD_NOT_EQUAL(a)
>> 
>> vs
>> 
>> COMPARE_FIELD(a, true)
>> COMPARE_FILED(b, false)
>> 
>> For me, I don't need to go to the definition of the macro in the 1st
>> case, and I do on the second one.
>> 
>> Or do you mean anything different?
>
> I meant test_simple_no_skip vs test_simple_skip; they seem to duplicate a lot.

They were there on the original test, i.e. doesn't mater for the
refactoring.  Basically we are doing is testing the "test" function O:-)

Later, Juan.

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

end of thread, other threads:[~2014-06-25 13:51 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-16  9:57 [Qemu-devel] [PATCH 00/27] vmstate-simplification queue Juan Quintela
2014-06-16  9:57 ` [Qemu-devel] [PATCH 01/27] migration: Remove unneeded minimum_version_id_old Juan Quintela
2014-06-17 10:44   ` Dr. David Alan Gilbert
2014-06-16  9:57 ` [Qemu-devel] [PATCH 02/27] vmstate: Return error in case of error Juan Quintela
2014-06-17 10:43   ` Dr. David Alan Gilbert
2014-06-16  9:57 ` [Qemu-devel] [PATCH 03/27] vmstate: Refactor & increase tests for primitive types Juan Quintela
2014-06-17 11:34   ` Dr. David Alan Gilbert
2014-06-16  9:58 ` [Qemu-devel] [PATCH 04/27] vmstate: Port versioned tests to new format Juan Quintela
2014-06-17 11:56   ` Dr. David Alan Gilbert
2014-06-25 13:00     ` Juan Quintela
2014-06-25 13:14       ` Dr. David Alan Gilbert
2014-06-25 13:51         ` Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 05/27] vmstate: Create test functions for versions until 15 Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 06/27] vmstate: Remove VMSTATE_UINTL_EQUAL_V Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 07/27] vmstate: Change VMSTATE_INTTL_V to VMSTATE_INTTL_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 08/27] vmstate: Remove unused VMSTATE_UINTTL_ARRAY_V Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 09/27] vmstate: Test for VMSTATE_BOOL_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 10/27] vmstate: Test for VMSTATE_INT8_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 11/27] vmstate: Test for VMSTATE_INT16_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 12/27] vmstate: Test for VMSTATE_INT32_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 13/27] vmstate: test for VMSTATE_INT64_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 14/27] vmstate: Test for VMSTATE_UINT8_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 15/27] vmstate: Test for VMSTATE_UINT16_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 16/27] vmstate: Test for VMSTATE_UINT32_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 17/27] vmstate: Test for VMSTATE_UINT64_TEST Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 18/27] vmstate: Test for VMSTATE_FLOAT64 Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 19/27] vmstate: Test for VMSTATE_UNUSED Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 20/27] vmstate: Test for VMSTATE_BITMAP Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 21/27] vmstate: Test for VMSTATE_UINT8_EQUAL Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 22/27] vmstate: Test for VMSTATE_UINT16_EQUAL Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 23/27] vmstate: Test for VMSTATE_UINT32_EQUAL Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 24/27] vmstate: Test for VMSTATE_UINT64_EQUAL Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 25/27] vmstate: Test for VMSTATE_INT32_EQUAL Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 26/27] vmstate: Test for VMSTATE_INT32_LE Juan Quintela
2014-06-16  9:58 ` [Qemu-devel] [PATCH 27/27] vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ Juan Quintela

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.