[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/38] migration: Add canary to VMSTATE_END_OF_LIST
From: |
Juan Quintela |
Subject: |
[PULL 23/38] migration: Add canary to VMSTATE_END_OF_LIST |
Date: |
Thu, 27 Jan 2022 16:05:33 +0100 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
We fairly regularly forget VMSTATE_END_OF_LIST markers off descriptions;
given that the current check is only for ->name being NULL, sometimes
we get unlucky and the code apparently works and no one spots the error.
Explicitly add a flag, VMS_END that should be set, and assert it is
set during the traversal.
Note: This can't go in until we update the copy of vmstate.h in slirp.
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
include/migration/vmstate.h | 7 ++++++-
migration/savevm.c | 1 +
migration/vmstate.c | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 017c03675c..b50708e57a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -147,6 +147,9 @@ enum VMStateFlags {
* VMStateField.struct_version_id to tell which version of the
* structure we are referencing to use. */
VMS_VSTRUCT = 0x8000,
+
+ /* Marker for end of list */
+ VMS_END = 0x10000
};
typedef enum {
@@ -1163,7 +1166,9 @@ extern const VMStateInfo vmstate_info_qlist;
VMSTATE_UNUSED_BUFFER(_test, 0, _size)
#define VMSTATE_END_OF_LIST() \
- {}
+ { \
+ .flags = VMS_END, \
+ }
int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, int version_id);
diff --git a/migration/savevm.c b/migration/savevm.c
index 1599b02fbc..b17e624d3f 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -620,6 +620,7 @@ static void dump_vmstate_vmsd(FILE *out_file,
field++;
first = false;
}
+ assert(field->flags == VMS_END);
fprintf(out_file, "\n%*s]", indent, "");
}
if (vmsd->subsections != NULL) {
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 05f87cdddc..181ba08c7d 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -160,6 +160,7 @@ int vmstate_load_state(QEMUFile *f, const
VMStateDescription *vmsd,
}
field++;
}
+ assert(field->flags == VMS_END);
ret = vmstate_subsection_load(f, vmsd, opaque);
if (ret != 0) {
return ret;
@@ -413,6 +414,7 @@ int vmstate_save_state_v(QEMUFile *f, const
VMStateDescription *vmsd,
}
field++;
}
+ assert(field->flags == VMS_END);
if (vmdesc) {
json_writer_end_array(vmdesc);
--
2.34.1
- [PULL 13/38] multifd: Unfold "used" variable by its value, (continued)
- [PULL 13/38] multifd: Unfold "used" variable by its value, Juan Quintela, 2022/01/27
- [PULL 14/38] multifd: Use normal pages array on the send side, Juan Quintela, 2022/01/27
- [PULL 16/38] multifd: recv side only needs the RAMBlock host address, Juan Quintela, 2022/01/27
- [PULL 15/38] multifd: Use normal pages array on the recv side, Juan Quintela, 2022/01/27
- [PULL 17/38] multifd: Rename pages_used to normal_pages, Juan Quintela, 2022/01/27
- [PULL 18/38] Remove unnecessary minimum_version_id_old fields, Juan Quintela, 2022/01/27
- [PULL 19/38] migration/migration.c: Add missed default error handler for migration state, Juan Quintela, 2022/01/27
- [PULL 20/38] migration/migration.c: Avoid COLO boot in postcopy migration, Juan Quintela, 2022/01/27
- [PULL 21/38] migration/migration.c: Remove the MIGRATION_STATUS_ACTIVE when migration finished, Juan Quintela, 2022/01/27
- [PULL 22/38] migration: Report the error returned when save_live_iterate fails, Juan Quintela, 2022/01/27
- [PULL 23/38] migration: Add canary to VMSTATE_END_OF_LIST,
Juan Quintela <=
- [PULL 25/38] migration/ram: clean up unused comment., Juan Quintela, 2022/01/27
- [PULL 26/38] migration: Drop dead code of ram_debug_dump_bitmap(), Juan Quintela, 2022/01/27
- [PULL 24/38] migration: Perform vmsd structure check during tests, Juan Quintela, 2022/01/27
- [PULL 28/38] migration: Drop postcopy_chunk_hostpages(), Juan Quintela, 2022/01/27
- [PULL 27/38] migration: Don't return for postcopy_chunk_hostpages(), Juan Quintela, 2022/01/27
- [PULL 29/38] migration: Do chunk page in postcopy_each_ram_send_discard(), Juan Quintela, 2022/01/27
- [PULL 30/38] migration: Drop return code for disgard ram process, Juan Quintela, 2022/01/27
- [PULL 31/38] migration: Don't return for postcopy_send_discard_bm_ram(), Juan Quintela, 2022/01/27
- [PULL 32/38] migration: Introduce ram_transferred_add(), Juan Quintela, 2022/01/27
- [PULL 33/38] migration: Tally pre-copy, downtime and post-copy bytes independently, Juan Quintela, 2022/01/27