aboutsummaryrefslogtreecommitdiff
path: root/include/migration/vmstate.h
diff options
context:
space:
mode:
authorHalil Pasic <pasic@linux.vnet.ibm.com>2017-06-23 16:48:23 +0200
committerJuan Quintela <quintela@redhat.com>2017-06-28 11:18:44 +0200
commitd2164ad35c411d97abd2aa5c6f160283d215e214 (patch)
treefffb1821aade0b81089fc02cd5d6880024a265b0 /include/migration/vmstate.h
parent01f6e14c78f480ade5521139019fdf930a7affaa (diff)
downloadqemu-d2164ad35c411d97abd2aa5c6f160283d215e214.zip
qemu-d2164ad35c411d97abd2aa5c6f160283d215e214.tar.gz
qemu-d2164ad35c411d97abd2aa5c6f160283d215e214.tar.bz2
vmstate: error hint for failed equal checks
In some cases a failing VMSTATE_*_EQUAL does not mean we detected a bug, but it's actually the best we can do. Especially in these cases a verbose error message is required. Let's introduce infrastructure for specifying a error hint to be used if equal check fails. Let's do this by adding a parameter to the _EQUAL macros called _err_hint. Also change all current users to pass NULL as last parameter so nothing changes for them. Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com> Message-Id: <20170623144823.42936-1-pasic@linux.vnet.ibm.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'include/migration/vmstate.h')
-rw-r--r--include/migration/vmstate.h51
1 files changed, 35 insertions, 16 deletions
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index e85fbd8..85e43da 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -155,6 +155,7 @@ typedef enum {
struct VMStateField {
const char *name;
+ const char *err_hint;
size_t offset;
size_t size;
size_t start;
@@ -256,6 +257,18 @@ extern const VMStateInfo vmstate_info_qtailq;
.offset = vmstate_offset_value(_state, _field, _type), \
}
+#define VMSTATE_SINGLE_FULL(_field, _state, _test, _version, _info, \
+ _type, _err_hint) { \
+ .name = (stringify(_field)), \
+ .err_hint = (_err_hint), \
+ .version_id = (_version), \
+ .field_exists = (_test), \
+ .size = sizeof(_type), \
+ .info = &(_info), \
+ .flags = VMS_SINGLE, \
+ .offset = vmstate_offset_value(_state, _field, _type), \
+}
+
/* Validate state using a boolean predicate. */
#define VMSTATE_VALIDATE(_name, _test) { \
.name = (_name), \
@@ -762,29 +775,35 @@ extern const VMStateInfo vmstate_info_qtailq;
#define VMSTATE_UINT64(_f, _s) \
VMSTATE_UINT64_V(_f, _s, 0)
-#define VMSTATE_UINT8_EQUAL(_f, _s) \
- VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
+#define VMSTATE_UINT8_EQUAL(_f, _s, _err_hint) \
+ VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
+ vmstate_info_uint8_equal, uint8_t, _err_hint)
-#define VMSTATE_UINT16_EQUAL(_f, _s) \
- VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t)
+#define VMSTATE_UINT16_EQUAL(_f, _s, _err_hint) \
+ VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
+ vmstate_info_uint16_equal, uint16_t, _err_hint)
-#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \
- VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t)
+#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v, _err_hint) \
+ VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
+ vmstate_info_uint16_equal, uint16_t, _err_hint)
-#define VMSTATE_INT32_EQUAL(_f, _s) \
- VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t)
+#define VMSTATE_INT32_EQUAL(_f, _s, _err_hint) \
+ VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \
+ vmstate_info_int32_equal, int32_t, _err_hint)
-#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v) \
- VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32_equal, uint32_t)
+#define VMSTATE_UINT32_EQUAL_V(_f, _s, _v, _err_hint) \
+ VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
+ vmstate_info_uint32_equal, uint32_t, _err_hint)
-#define VMSTATE_UINT32_EQUAL(_f, _s) \
- VMSTATE_UINT32_EQUAL_V(_f, _s, 0)
+#define VMSTATE_UINT32_EQUAL(_f, _s, _err_hint) \
+ VMSTATE_UINT32_EQUAL_V(_f, _s, 0, _err_hint)
-#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v) \
- VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t)
+#define VMSTATE_UINT64_EQUAL_V(_f, _s, _v, _err_hint) \
+ VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \
+ vmstate_info_uint64_equal, uint64_t, _err_hint)
-#define VMSTATE_UINT64_EQUAL(_f, _s) \
- VMSTATE_UINT64_EQUAL_V(_f, _s, 0)
+#define VMSTATE_UINT64_EQUAL(_f, _s, _err_hint) \
+ VMSTATE_UINT64_EQUAL_V(_f, _s, 0, _err_hint)
#define VMSTATE_INT32_POSITIVE_LE(_f, _s) \
VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)