diff mbox

[5/5] vmstate: Add max_version_id field to VMStateDescription

Message ID 1381769148-22400-6-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Oct. 14, 2013, 4:45 p.m. UTC
This will allow us to load data that has a high version_id, while using
a lower version_id when saving.

Useful in case we need to revert vmstate changes but keep compatibility
with QEMU versions that had a higher version_id.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/migration/vmstate.h | 1 +
 savevm.c                    | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 9d09e60..cc9dbb4 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -126,6 +126,7 @@  struct VMStateDescription {
     const char *name;
     int unmigratable;
     int version_id;
+    int max_version_id;
     int minimum_version_id;
     int minimum_version_id_old;
     LoadStateHandler *load_state_old;
diff --git a/savevm.c b/savevm.c
index 87773ad..89d20d0 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1679,7 +1679,7 @@  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
     VMStateField *field;
     int ret;
 
-    if (version_id > vmsd->version_id) {
+    if (version_id > MAX(vmsd->version_id, vmsd->max_version_id)) {
         return -EINVAL;
     }
     if (version_id < vmsd->minimum_version_id_old) {