migration: Make VMStateDescription.subsections const

Allow the array of pointers to itself be const.
Propagate this through the copies of this field.

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231221031652.119827-2-richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2023-12-21 14:15:42 +11:00
parent 7425b6277f
commit 2027001919
3 changed files with 15 additions and 13 deletions

View File

@ -209,7 +209,7 @@ struct VMStateDescription {
bool (*dev_unplug_pending)(void *opaque); bool (*dev_unplug_pending)(void *opaque);
const VMStateField *fields; const VMStateField *fields;
const VMStateDescription **subsections; const VMStateDescription * const *subsections;
}; };
extern const VMStateInfo vmstate_info_bool; extern const VMStateInfo vmstate_info_bool;

View File

@ -551,11 +551,11 @@ static void dump_vmstate_vmsf(FILE *out_file, const VMStateField *field,
} }
static void dump_vmstate_vmss(FILE *out_file, static void dump_vmstate_vmss(FILE *out_file,
const VMStateDescription **subsection, const VMStateDescription *subsection,
int indent) int indent)
{ {
if (*subsection != NULL) { if (subsection != NULL) {
dump_vmstate_vmsd(out_file, *subsection, indent, true); dump_vmstate_vmsd(out_file, subsection, indent, true);
} }
} }
@ -597,7 +597,7 @@ static void dump_vmstate_vmsd(FILE *out_file,
fprintf(out_file, "\n%*s]", indent, ""); fprintf(out_file, "\n%*s]", indent, "");
} }
if (vmsd->subsections != NULL) { if (vmsd->subsections != NULL) {
const VMStateDescription **subsection = vmsd->subsections; const VMStateDescription * const *subsection = vmsd->subsections;
bool first; bool first;
fprintf(out_file, ",\n%*s\"Subsections\": [\n", indent, ""); fprintf(out_file, ",\n%*s\"Subsections\": [\n", indent, "");
@ -606,7 +606,7 @@ static void dump_vmstate_vmsd(FILE *out_file,
if (!first) { if (!first) {
fprintf(out_file, ",\n"); fprintf(out_file, ",\n");
} }
dump_vmstate_vmss(out_file, subsection, indent + 2); dump_vmstate_vmss(out_file, *subsection, indent + 2);
subsection++; subsection++;
first = false; first = false;
} }
@ -831,7 +831,7 @@ void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque)
static void vmstate_check(const VMStateDescription *vmsd) static void vmstate_check(const VMStateDescription *vmsd)
{ {
const VMStateField *field = vmsd->fields; const VMStateField *field = vmsd->fields;
const VMStateDescription **subsection = vmsd->subsections; const VMStateDescription * const *subsection = vmsd->subsections;
if (field) { if (field) {
while (field->name) { while (field->name) {

View File

@ -452,13 +452,15 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
} }
static const VMStateDescription * static const VMStateDescription *
vmstate_get_subsection(const VMStateDescription **sub, char *idstr) vmstate_get_subsection(const VMStateDescription * const *sub,
const char *idstr)
{ {
while (sub && *sub) { if (sub) {
if (strcmp(idstr, (*sub)->name) == 0) { for (const VMStateDescription *s = *sub; s ; s = *++sub) {
return *sub; if (strcmp(idstr, s->name) == 0) {
return s;
}
} }
sub++;
} }
return NULL; return NULL;
} }
@ -517,7 +519,7 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd, static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, JSONWriter *vmdesc) void *opaque, JSONWriter *vmdesc)
{ {
const VMStateDescription **sub = vmsd->subsections; const VMStateDescription * const *sub = vmsd->subsections;
bool vmdesc_has_subsections = false; bool vmdesc_has_subsections = false;
int ret = 0; int ret = 0;