[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/26] migration: Add canary to VMSTATE_END_OF_LIST
From: |
Juan Quintela |
Subject: |
[PULL 22/26] migration: Add canary to VMSTATE_END_OF_LIST |
Date: |
Thu, 2 Feb 2023 17:06:36 +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 28a3b92aa1..084f5e784a 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 {
@@ -1183,7 +1186,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 6d985ad4af..5c3e5b1bb5 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -585,6 +585,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 924494bda3..83ca4c7d3e 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -154,6 +154,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;
@@ -408,6 +409,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.39.1
- [PULL 16/26] migration/ram: Factor out check for advised postcopy, (continued)
- [PULL 16/26] migration/ram: Factor out check for advised postcopy, Juan Quintela, 2023/02/02
- [PULL 17/26] virtio-mem: Fail if a memory backend with "prealloc=on" is specified, Juan Quintela, 2023/02/02
- [PULL 06/26] util/userfaultfd: Add uffd_open(), Juan Quintela, 2023/02/02
- [PULL 03/26] migration: Split save_live_pending() into state_pending_*, Juan Quintela, 2023/02/02
- [PULL 15/26] migration/vmstate: Introduce VMSTATE_WITH_TMP_TEST() and VMSTATE_BITMAP_TEST(), Juan Quintela, 2023/02/02
- [PULL 18/26] virtio-mem: Migrate immutable properties early, Juan Quintela, 2023/02/02
- [PULL 19/26] virtio-mem: Proper support for preallocation with migration, Juan Quintela, 2023/02/02
- [PULL 11/26] migration/ram: Optimize ram_write_tracking_start() for RamDiscardManager, Juan Quintela, 2023/02/02
- [PULL 23/26] migration: Perform vmsd structure check during tests, Juan Quintela, 2023/02/02
- [PULL 20/26] migration: Show downtime during postcopy phase, Juan Quintela, 2023/02/02
- [PULL 22/26] migration: Add canary to VMSTATE_END_OF_LIST,
Juan Quintela <=
- [PULL 24/26] migration/dirtyrate: Show sample pages only in page-sampling mode, Juan Quintela, 2023/02/02
- [PULL 26/26] migration: check magic value for deciding the mapping of channels, Juan Quintela, 2023/02/02
- [PULL 21/26] migration/rdma: fix return value for qio_channel_rdma_{readv, writev}, Juan Quintela, 2023/02/02
- [PULL 25/26] io: Add support for MSG_PEEK for socket channel, Juan Quintela, 2023/02/02
- Re: [PULL 00/26] Next patches, Peter Maydell, 2023/02/04
- Re: [PULL 00/26] Next patches, Juan Quintela, 2023/02/06