dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0003-vmstate-add-VMSTATE_VALIDATE.patch

70114f
From d9e0cb134eefe5104b404b91eaf969a2cd74bd9f Mon Sep 17 00:00:00 2001
70114f
From: "Michael S. Tsirkin" <mst@redhat.com>
70114f
Date: Thu, 3 Apr 2014 19:50:35 +0300
70114f
Subject: [PATCH] vmstate: add VMSTATE_VALIDATE
70114f
70114f
Validate state using VMS_ARRAY with num = 0 and VMS_MUST_EXIST
70114f
70114f
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
70114f
Signed-off-by: Juan Quintela <quintela@redhat.com>
70114f
(cherry picked from commit 4082f0889ba04678fc14816c53e1b9251ea9207e)
70114f
---
70114f
 include/migration/vmstate.h | 8 ++++++++
70114f
 1 file changed, 8 insertions(+)
70114f
70114f
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
70114f
index de970ab..5b71370 100644
70114f
--- a/include/migration/vmstate.h
70114f
+++ b/include/migration/vmstate.h
70114f
@@ -204,6 +204,14 @@ extern const VMStateInfo vmstate_info_bitmap;
70114f
     .offset       = vmstate_offset_value(_state, _field, _type),     \
70114f
 }
70114f
 
70114f
+/* Validate state using a boolean predicate. */
70114f
+#define VMSTATE_VALIDATE(_name, _test) { \
70114f
+    .name         = (_name),                                         \
70114f
+    .field_exists = (_test),                                         \
70114f
+    .flags        = VMS_ARRAY | VMS_MUST_EXIST,                      \
70114f
+    .num          = 0, /* 0 elements: no data, only run _test */     \
70114f
+}
70114f
+
70114f
 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) {    \
70114f
     .name       = (stringify(_field)),                               \
70114f
     .version_id = (_version),                                        \