[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/26] migration: Perform vmsd structure check during tests
From: |
Juan Quintela |
Subject: |
[PULL 23/26] migration: Perform vmsd structure check during tests |
Date: |
Thu, 2 Feb 2023 17:06:37 +0100 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Perform a check on vmsd structures during test runs in the hope
of catching any missing terminators and other simple screwups.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/savevm.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/migration/savevm.c b/migration/savevm.c
index 5c3e5b1bb5..e9cf4999ad 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -66,6 +66,7 @@
#include "net/announce.h"
#include "qemu/yank.h"
#include "yank_functions.h"
+#include "sysemu/qtest.h"
const unsigned int postcopy_ram_discard_version;
@@ -804,6 +805,42 @@ void unregister_savevm(VMStateIf *obj, const char *idstr,
void *opaque)
}
}
+/*
+ * Perform some basic checks on vmsd's at registration
+ * time.
+ */
+static void vmstate_check(const VMStateDescription *vmsd)
+{
+ const VMStateField *field = vmsd->fields;
+ const VMStateDescription **subsection = vmsd->subsections;
+
+ if (field) {
+ while (field->name) {
+ if (field->flags & (VMS_STRUCT | VMS_VSTRUCT)) {
+ /* Recurse to sub structures */
+ vmstate_check(field->vmsd);
+ }
+ /* Carry on */
+ field++;
+ }
+ /* Check for the end of field list canary */
+ if (field->flags != VMS_END) {
+ error_report("VMSTATE not ending with VMS_END: %s", vmsd->name);
+ g_assert_not_reached();
+ }
+ }
+
+ while (subsection && *subsection) {
+ /*
+ * The name of a subsection should start with the name of the
+ * current object.
+ */
+ assert(!strncmp(vmsd->name, (*subsection)->name, strlen(vmsd->name)));
+ vmstate_check(*subsection);
+ subsection++;
+ }
+}
+
int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id,
const VMStateDescription *vmsd,
void *opaque, int alias_id,
@@ -849,6 +886,11 @@ int vmstate_register_with_alias_id(VMStateIf *obj,
uint32_t instance_id,
} else {
se->instance_id = instance_id;
}
+
+ /* Perform a recursive sanity check during the test runs */
+ if (qtest_enabled()) {
+ vmstate_check(vmsd);
+ }
assert(!se->compat || se->instance_id == 0);
savevm_state_handler_insert(se);
return 0;
--
2.39.1
- [PULL 13/26] migration/savevm: Prepare vmdesc json writer in qemu_savevm_state_setup(), (continued)
- [PULL 13/26] migration/savevm: Prepare vmdesc json writer in qemu_savevm_state_setup(), Juan Quintela, 2023/02/02
- [PULL 14/26] migration/savevm: Allow immutable device state to be migrated early (i.e., before RAM), Juan Quintela, 2023/02/02
- [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 <=
- [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, 2023/02/02
- [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