|
|
eb5a2f |
From 939cbb6cf8128369e0ca2ec21b33d2fc40699142 Mon Sep 17 00:00:00 2001
|
|
|
eb5a2f |
From: Michael S. Tsirkin <mst@redhat.com>
|
|
|
eb5a2f |
Date: Wed, 14 May 2014 08:24:29 +0200
|
|
|
eb5a2f |
Subject: [PATCH 10/30] vmstate: add VMS_MUST_EXIST
|
|
|
eb5a2f |
|
|
|
eb5a2f |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
eb5a2f |
Message-id: <1400055633-6261-2-git-send-email-mst@redhat.com>
|
|
|
eb5a2f |
Patchwork-id: 58849
|
|
|
eb5a2f |
O-Subject: [PATCH qemu-kvm RHEL7.0.z 2/5] vmstate: add VMS_MUST_EXIST
|
|
|
eb5a2f |
Bugzilla: 1095706
|
|
|
eb5a2f |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
eb5a2f |
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
eb5a2f |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
eb5a2f |
RH-Acked-by: Juan Quintela <quintela@redhat.com>
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Can be used to verify a required field exists or validate
|
|
|
eb5a2f |
state in some other way.
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
eb5a2f |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
eb5a2f |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
eb5a2f |
(cherry picked from commit 5bf81c8d63db0216a4d29dc87f9ce530bb791dd1)
|
|
|
eb5a2f |
---
|
|
|
eb5a2f |
include/migration/vmstate.h | 1 +
|
|
|
eb5a2f |
savevm.c | 10 ++++++++++
|
|
|
eb5a2f |
2 files changed, 11 insertions(+)
|
|
|
eb5a2f |
|
|
|
eb5a2f |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
eb5a2f |
---
|
|
|
eb5a2f |
include/migration/vmstate.h | 1 +
|
|
|
eb5a2f |
savevm.c | 10 ++++++++++
|
|
|
eb5a2f |
2 files changed, 11 insertions(+), 0 deletions(-)
|
|
|
eb5a2f |
|
|
|
eb5a2f |
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
|
|
|
eb5a2f |
index 11d93e1..95d1ce6 100644
|
|
|
eb5a2f |
--- a/include/migration/vmstate.h
|
|
|
eb5a2f |
+++ b/include/migration/vmstate.h
|
|
|
eb5a2f |
@@ -98,6 +98,7 @@ enum VMStateFlags {
|
|
|
eb5a2f |
VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */
|
|
|
eb5a2f |
VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/
|
|
|
eb5a2f |
VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/
|
|
|
eb5a2f |
+ VMS_MUST_EXIST = 0x1000, /* Field must exist in input */
|
|
|
eb5a2f |
};
|
|
|
eb5a2f |
|
|
|
eb5a2f |
typedef struct {
|
|
|
eb5a2f |
diff --git a/savevm.c b/savevm.c
|
|
|
eb5a2f |
index 6efbb75..5d1b563 100644
|
|
|
eb5a2f |
--- a/savevm.c
|
|
|
eb5a2f |
+++ b/savevm.c
|
|
|
eb5a2f |
@@ -1740,6 +1740,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
|
|
|
eb5a2f |
return ret;
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
+ } else if (field->flags & VMS_MUST_EXIST) {
|
|
|
eb5a2f |
+ fprintf(stderr, "Input validation failed: %s/%s\n",
|
|
|
eb5a2f |
+ vmsd->name, field->name);
|
|
|
eb5a2f |
+ return -1;
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
field++;
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
@@ -1800,6 +1804,12 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
|
|
|
eb5a2f |
field->info->put(f, addr, size);
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
+ } else {
|
|
|
eb5a2f |
+ if (field->flags & VMS_MUST_EXIST) {
|
|
|
eb5a2f |
+ fprintf(stderr, "Output state validation failed: %s/%s\n",
|
|
|
eb5a2f |
+ vmsd->name, field->name);
|
|
|
eb5a2f |
+ assert(!(field->flags & VMS_MUST_EXIST));
|
|
|
eb5a2f |
+ }
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
field++;
|
|
|
eb5a2f |
}
|
|
|
eb5a2f |
--
|
|
|
eb5a2f |
1.7.1
|
|
|
eb5a2f |
|