yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From 1886b0146de0847ff5f81e5d89ba3893bbab63fc Mon Sep 17 00:00:00 2001
From: Michael S. Tsirkin <mst@redhat.com>
Date: Wed, 14 May 2014 08:24:33 +0200
Subject: [PATCH 11/30] vmstate: add VMSTATE_VALIDATE

RH-Author: Michael S. Tsirkin <mst@redhat.com>
Message-id: <1400055633-6261-3-git-send-email-mst@redhat.com>
Patchwork-id: 58850
O-Subject: [PATCH qemu-kvm RHEL7.0.z 3/5] vmstate: add VMSTATE_VALIDATE
Bugzilla: 1095706
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