mirror of https://github.com/xemu-project/xemu.git
migration: Add canary to VMSTATE_END_OF_LIST
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>
This commit is contained in:
parent
74ecf6ac2b
commit
89c5684891
|
@ -147,6 +147,9 @@ enum VMStateFlags {
|
||||||
* VMStateField.struct_version_id to tell which version of the
|
* VMStateField.struct_version_id to tell which version of the
|
||||||
* structure we are referencing to use. */
|
* structure we are referencing to use. */
|
||||||
VMS_VSTRUCT = 0x8000,
|
VMS_VSTRUCT = 0x8000,
|
||||||
|
|
||||||
|
/* Marker for end of list */
|
||||||
|
VMS_END = 0x10000
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -1183,7 +1186,9 @@ extern const VMStateInfo vmstate_info_qlist;
|
||||||
VMSTATE_UNUSED_BUFFER(_test, 0, _size)
|
VMSTATE_UNUSED_BUFFER(_test, 0, _size)
|
||||||
|
|
||||||
#define VMSTATE_END_OF_LIST() \
|
#define VMSTATE_END_OF_LIST() \
|
||||||
{}
|
{ \
|
||||||
|
.flags = VMS_END, \
|
||||||
|
}
|
||||||
|
|
||||||
int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
|
int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
|
||||||
void *opaque, int version_id);
|
void *opaque, int version_id);
|
||||||
|
|
|
@ -585,6 +585,7 @@ static void dump_vmstate_vmsd(FILE *out_file,
|
||||||
field++;
|
field++;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
assert(field->flags == VMS_END);
|
||||||
fprintf(out_file, "\n%*s]", indent, "");
|
fprintf(out_file, "\n%*s]", indent, "");
|
||||||
}
|
}
|
||||||
if (vmsd->subsections != NULL) {
|
if (vmsd->subsections != NULL) {
|
||||||
|
|
|
@ -154,6 +154,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
|
||||||
}
|
}
|
||||||
field++;
|
field++;
|
||||||
}
|
}
|
||||||
|
assert(field->flags == VMS_END);
|
||||||
ret = vmstate_subsection_load(f, vmsd, opaque);
|
ret = vmstate_subsection_load(f, vmsd, opaque);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -408,6 +409,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
|
||||||
}
|
}
|
||||||
field++;
|
field++;
|
||||||
}
|
}
|
||||||
|
assert(field->flags == VMS_END);
|
||||||
|
|
||||||
if (vmdesc) {
|
if (vmdesc) {
|
||||||
json_writer_end_array(vmdesc);
|
json_writer_end_array(vmdesc);
|
||||||
|
|
Loading…
Reference in New Issue