qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 16/27] vmstate: Test for VMSTATE_UINT32_TEST


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

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

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




reply via email to

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