qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 17/27] vmstate: Test for VMSTATE_UINT64_TEST


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 17/27] vmstate: Test for VMSTATE_UINT64_TEST
Date: Mon, 16 Jun 2014 11:58:13 +0200

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

Signed-off-by: Juan Quintela <address@hidden>
---
 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




reply via email to

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