qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 18/97] vmstate: Test for VMSTATE_UINT32_TEST


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 18/97] vmstate: Test for VMSTATE_UINT32_TEST
Date: Mon, 7 Apr 2014 05:20:36 +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        | 12 ++++++++----
 15 files changed, 42 insertions(+), 38 deletions(-)

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

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

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

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

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

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

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

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

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

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




reply via email to

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