@@ -1657,6 +1657,8 @@ typedef struct TestStruct2 {
SubStruct b[3];
int32_t size3;
SubStruct c[3];
+ uint16_t size4;
+ SubStruct *p_1;
} TestStruct2;
/*
@@ -1678,6 +1680,9 @@ static const VMStateDescription vmstate_struct_varray = {
VMSTATE_INT32_EQUAL(size3, TestStruct2),
VMSTATE_STRUCT_VARRAY_INT32(c, TestStruct2, size3,
vmstate_sub_struct, SubStruct),
+ VMSTATE_UINT16_EQUAL(size4, TestStruct2),
+ VMSTATE_STRUCT_VARRAY_POINTER_UINT16(p_1, TestStruct2, size4,
+ vmstate_sub_struct, SubStruct),
VMSTATE_STRUCT_VARRAY_UINT8(a, TestStruct2, size,
vmstate_sub_struct, SubStruct),
VMSTATE_END_OF_LIST()
@@ -1720,6 +1725,22 @@ uint8_t wire_struct_varray[] = {
/* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49,
/* buffer */ 0x62, 0x79, 0x65, 0x38, 0x20, 0x20, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x21, 0x00,
+ /* size4 */ 0x00, 0x03,
+ /* p_1[0] */
+ /* i32 */ 0x00, 0x00, 0x00, 0x51,
+ /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5b,
+ /* buffer */ 0x62, 0x79, 0x65, 0x30, 0x20, 0x20, 0x77, 0x6f,
+ 0x72, 0x6c, 0x64, 0x21, 0x00,
+ /* p_1[1] */
+ /* i32 */ 0x00, 0x00, 0x00, 0x52,
+ /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c,
+ /* buffer */ 0x62, 0x79, 0x65, 0x31, 0x20, 0x20, 0x77, 0x6f,
+ 0x72, 0x6c, 0x64, 0x21, 0x00,
+ /* p_1[2] */
+ /* i32 */ 0x00, 0x00, 0x00, 0x53,
+ /* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d,
+ /* buffer */ 0x62, 0x79, 0x65, 0x32, 0x20, 0x20, 0x77, 0x6f,
+ 0x72, 0x6c, 0x64, 0x21, 0x00,
/* a[0] */
/* i32 */ 0x00, 0x00, 0x00, 0x15,
/* i64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
@@ -1747,6 +1768,7 @@ static void obj_struct2_copy(void *arg1, void *arg2)
target->size = source->size;
target->size2 = source->size2;
target->size3 = source->size3;
+ target->size4 = source->size4;
for (i = 0; i < 3; i++) {
target->a[i].i32 = source->a[i].i32;
target->a[i].i64 = source->a[i].i64;
@@ -1757,6 +1779,9 @@ static void obj_struct2_copy(void *arg1, void *arg2)
target->c[i].i32 = source->c[i].i32;
target->c[i].i64 = source->c[i].i64;
memcpy(target->c[i].buffer, source->c[i].buffer, 13);
+ target->p_1[i].i32 = source->p_1[i].i32;
+ target->p_1[i].i64 = source->p_1[i].i64;
+ memcpy(target->p_1[i].buffer, source->p_1[i].buffer, 13);
}
}
@@ -1766,6 +1791,8 @@ static TestStruct2 *create_struct2(void)
obj->size = 3;
obj->size2 = 3;
obj->size3 = 3;
+ obj->size4 = 3;
+ obj->p_1 = g_malloc0(sizeof(SubStruct) * 3);
return obj;
}
@@ -1785,6 +1812,9 @@ static TestStruct2 *create_struct2_init(void)
obj->c[i].i32 = i + 61;
obj->c[i].i64 = i + 71;
snprintf((char *)obj->c[i].buffer, 13, "bye%d world!", i + 6);
+ obj->p_1[i].i32 = i + 81;
+ obj->p_1[i].i64 = i + 91;
+ snprintf((char *)obj->p_1[i].buffer, 13, "bye%d world!", i);
}
return obj;
@@ -1810,6 +1840,7 @@ static void test_struct_varray(void)
memset(obj->a, 0, sizeof(obj->a));
memset(obj->b, 0, sizeof(obj->b));
memset(obj->c, 0, sizeof(obj->c));
+ memset(obj->p_1, 0, sizeof(*obj->p_1) * 3);
obj->size = j;
obj_struct2->size = j;
wire_struct_varray[0] = j;
@@ -1827,6 +1858,7 @@ static void test_struct_varray(void)
for (i = 0; i < 3; i++) {
STRUCT_EQUAL((&obj->b[i]), (&obj_struct2->b[i]));
STRUCT_EQUAL((&obj->c[i]), (&obj_struct2->c[i]));
+ STRUCT_EQUAL((&obj->p_1[i]), (&obj_struct2->p_1[i]));
}
}
}
Signed-off-by: Juan Quintela <quintela@redhat.com> --- tests/test-vmstate.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)