9ae3a8
From 9d268999694b9743808fb9454a4f1ab7a941b8a6 Mon Sep 17 00:00:00 2001
9ae3a8
From: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Date: Wed, 14 May 2014 08:52:51 +0200
9ae3a8
Subject: [PATCH 22/31] vmstate: add VMSTATE_VALIDATE
9ae3a8
9ae3a8
RH-Author: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Message-id: <1400057538-6975-4-git-send-email-mst@redhat.com>
9ae3a8
Patchwork-id: 58870
9ae3a8
O-Subject: [PATCH qemu-kvm RHEL7.1 3/5] vmstate: add VMSTATE_VALIDATE
9ae3a8
Bugzilla: 1095716
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
9ae3a8
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Juan Quintela <quintela@redhat.com>
9ae3a8
9ae3a8
Validate state using VMS_ARRAY with num = 0 and VMS_MUST_EXIST
9ae3a8
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
(cherry picked from commit 4082f0889ba04678fc14816c53e1b9251ea9207e)
9ae3a8
---
9ae3a8
 include/migration/vmstate.h | 8 ++++++++
9ae3a8
 1 file changed, 8 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 include/migration/vmstate.h |    8 ++++++++
9ae3a8
 1 files changed, 8 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
9ae3a8
index 95d1ce6..f2652e6 100644
9ae3a8
--- a/include/migration/vmstate.h
9ae3a8
+++ b/include/migration/vmstate.h
9ae3a8
@@ -202,6 +202,14 @@ extern const VMStateInfo vmstate_info_bitmap;
9ae3a8
     .offset       = vmstate_offset_value(_state, _field, _type),     \
9ae3a8
 }
9ae3a8
 
9ae3a8
+/* Validate state using a boolean predicate. */
9ae3a8
+#define VMSTATE_VALIDATE(_name, _test) { \
9ae3a8
+    .name         = (_name),                                         \
9ae3a8
+    .field_exists = (_test),                                         \
9ae3a8
+    .flags        = VMS_ARRAY | VMS_MUST_EXIST,                      \
9ae3a8
+    .num          = 0, /* 0 elements: no data, only run _test */     \
9ae3a8
+}
9ae3a8
+
9ae3a8
 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) {    \
9ae3a8
     .name       = (stringify(_field)),                               \
9ae3a8
     .version_id = (_version),                                        \
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8