Blob Blame Raw
From 9d268999694b9743808fb9454a4f1ab7a941b8a6 Mon Sep 17 00:00:00 2001
From: Michael S. Tsirkin <mst@redhat.com>
Date: Wed, 14 May 2014 08:52:51 +0200
Subject: [PATCH 22/31] vmstate: add VMSTATE_VALIDATE

RH-Author: Michael S. Tsirkin <mst@redhat.com>
Message-id: <1400057538-6975-4-git-send-email-mst@redhat.com>
Patchwork-id: 58870
O-Subject: [PATCH qemu-kvm RHEL7.1 3/5] vmstate: add VMSTATE_VALIDATE
Bugzilla: 1095716
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>

Validate state using VMS_ARRAY with num = 0 and VMS_MUST_EXIST

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit 4082f0889ba04678fc14816c53e1b9251ea9207e)
---
 include/migration/vmstate.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 include/migration/vmstate.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 95d1ce6..f2652e6 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -202,6 +202,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),                                        \
-- 
1.7.1