qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 040/124] vmstate: Test for VMSTATE_UINT64_ARRAY{_TES


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 040/124] vmstate: Test for VMSTATE_UINT64_ARRAY{_TEST}
Date: Mon, 21 Apr 2014 16:40:20 +0200

CHange users of _V to _TEST.

Signed-off-by: Juan Quintela <address@hidden>
---
 include/migration/vmstate.h | 12 ++++++------
 target-i386/machine.c       |  5 +++--
 tests/test-vmstate.c        | 24 ++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 8 deletions(-)

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

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

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

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

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

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

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

@@ -572,6 +582,8 @@ static void obj_array_copy(void *arg1, void *arg2)
         target->u16_1[i] = source->u16_1[i];
         target->u32_1[i] = source->u32_1[i];
         target->u32_2[i] = source->u32_2[i];
+        target->u64_1[i] = source->u64_1[i];
+        target->u64_2[i] = source->u64_2[i];
     }
 }

@@ -604,6 +616,7 @@ static void test_array_primitive(void)
         ELEM_NOT_EQUAL(u8_2, i);
         ELEM_EQUAL(u16_1, i);
         ELEM_EQUAL(u32_1, i);
+        ELEM_EQUAL(u64_1, i);
     }
 }

@@ -620,6 +633,10 @@ static const VMStateDescription vmstate_array_test = {
                                   test_true),
         VMSTATE_UINT32_ARRAY_TEST(u32_2, TestArray, VMSTATE_ARRAY_SIZE,
                                   test_false),
+        VMSTATE_UINT64_ARRAY_TEST(u64_1, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_true),
+        VMSTATE_UINT64_ARRAY_TEST(u64_2, TestArray, VMSTATE_ARRAY_SIZE,
+                                  test_false),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -630,6 +647,11 @@ uint8_t wire_array_test[] = {
     /* u32_1 */ 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16,
                 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18,
                 0x00, 0x00, 0x00, 0x19,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

@@ -654,6 +676,8 @@ static void test_array_test(void)
         ELEM_EQUAL(b_1, i);
         ELEM_EQUAL(u32_1, i);
         ELEM_NOT_EQUAL(u32_2, i);
+        ELEM_EQUAL(u64_1, i);
+        ELEM_NOT_EQUAL(u64_2, i);
     }
 }
 #undef FIELD_EQUAL
-- 
1.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]