From 5bf81c8d63db0216a4d29dc87f9ce530bb791dd1 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 3 Apr 2014 19:50:31 +0300 Subject: vmstate: add VMS_MUST_EXIST Can be used to verify a required field exists or validate state in some other way. Signed-off-by: Michael S. Tsirkin Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- include/migration/vmstate.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/migration/vmstate.h') diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index e7e1705..de970ab 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -100,6 +100,7 @@ enum VMStateFlags { VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/ VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ + VMS_MUST_EXIST = 0x1000, /* Field must exist in input */ }; typedef struct { -- cgit v1.1 From 4082f0889ba04678fc14816c53e1b9251ea9207e Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 3 Apr 2014 19:50:35 +0300 Subject: vmstate: add VMSTATE_VALIDATE Validate state using VMS_ARRAY with num = 0 and VMS_MUST_EXIST Signed-off-by: Michael S. Tsirkin Signed-off-by: Juan Quintela --- include/migration/vmstate.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/migration/vmstate.h') diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index de970ab..5b71370 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -204,6 +204,14 @@ extern const VMStateInfo vmstate_info_bitmap; .offset = vmstate_offset_value(_state, _field, _type), \ } +/* Validate state using a boolean predicate. */ +#define VMSTATE_VALIDATE(_name, _test) { \ + .name = (_name), \ + .field_exists = (_test), \ + .flags = VMS_ARRAY | VMS_MUST_EXIST, \ + .num = 0, /* 0 elements: no data, only run _test */ \ +} + #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ -- cgit v1.1 From 3476436a44c29725efef0cabf5b3ea4e70054d57 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 3 Apr 2014 19:52:21 +0300 Subject: vmstate: s/VMSTATE_INT32_LE/VMSTATE_INT32_POSITIVE_LE/ As the macro verifies the value is positive, rename it to make the function clearer. Signed-off-by: Michael S. Tsirkin Signed-off-by: Juan Quintela --- include/migration/vmstate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/migration/vmstate.h') diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 5b71370..7e45048 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -601,7 +601,7 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_UINT64_EQUAL(_f, _s) \ VMSTATE_UINT64_EQUAL_V(_f, _s, 0) -#define VMSTATE_INT32_LE(_f, _s) \ +#define VMSTATE_INT32_POSITIVE_LE(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) #define VMSTATE_UINT8_TEST(_f, _s, _t) \ -- cgit v1.1