qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 82/97] vmstate: Test for VMSTATE_SYNTHETIC


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 82/97] vmstate: Test for VMSTATE_SYNTHETIC
Date: Mon, 7 Apr 2014 05:21:40 +0200

Signed-off-by: Juan Quintela <address@hidden>
---
 tests/test-vmstate.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f51c887..b3d77a2 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -95,6 +95,29 @@ TestSimple obj_simple = {
     .f64 = float64_pi,
 };

+static int get_42_as_uint32(QEMUFile *f, void *pv, size_t size)
+{
+    uint64_t v;
+    v = qemu_get_be32(f);
+    if (v != 42) {
+        printf("We haven't received 42!!!!'");
+        return -1;
+    }
+    return 0;
+}
+
+static void put_42_as_uint32(QEMUFile *f, void *pv, size_t size)
+{
+    uint64_t v = 42;
+    qemu_put_be32(f, v);
+}
+
+static const VMStateInfo vmstate_42_as_uint32 = {
+    .name = "42_as_uint32",
+    .get  = get_42_as_uint32,
+    .put  = put_42_as_uint32,
+};
+
 /* Description of the values.  If you add a primitive type
    you are expected to add a test here */

@@ -119,6 +142,7 @@ static const VMStateDescription vmstate_simple_primitive = {
         VMSTATE_INT64(i64_2, TestSimple),
         VMSTATE_FLOAT64(f64, TestSimple),
         VMSTATE_UNUSED(5),
+        VMSTATE_SYNTHETIC("synthetic", vmstate_42_as_uint32, sizeof(uint32)),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -152,6 +176,7 @@ uint8_t wire_simple_primitive[] = {
     /* 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,
+    /* synthe */0x00, 0x00, 0x00, 0x2a,
     QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
 };

-- 
1.9.0




reply via email to

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