Message ID | 20170524085519.22856-2-quintela@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 24/05/2017 10:55, Juan Quintela wrote: > From: Juan Quintela <quintela@trasno.org> > > There is no reason for having the loadvm_handlers at all. There is > only one use, and we can use the savevm handlers. > > We will remove the loadvm handlers on a following patch. > > Signed-off-by: Juan Quintela <quintela@redhat.com> > --- > migration/savevm.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/migration/savevm.c b/migration/savevm.c > index d971e5e..55ac8c1 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -1792,7 +1792,7 @@ struct LoadStateEntry { > * Returns: true if the footer was good > * false if there is a problem (and calls error_report to say why) > */ > -static bool check_section_footer(QEMUFile *f, LoadStateEntry *le) > +static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) > { > uint8_t read_mark; > uint32_t read_section_id; > @@ -1805,15 +1805,15 @@ static bool check_section_footer(QEMUFile *f, LoadStateEntry *le) > read_mark = qemu_get_byte(f); > > if (read_mark != QEMU_VM_SECTION_FOOTER) { > - error_report("Missing section footer for %s", le->se->idstr); > + error_report("Missing section footer for %s", se->idstr); > return false; > } > > read_section_id = qemu_get_be32(f); > - if (read_section_id != le->section_id) { > + if (read_section_id != se->section_id) { > error_report("Mismatched section id in footer for %s -" > " read 0x%x expected 0x%x", > - le->se->idstr, read_section_id, le->section_id); > + se->idstr, read_section_id, se->section_id); > return false; > } > > @@ -1887,7 +1887,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) > " device '%s'", instance_id, idstr); > return ret; > } > - if (!check_section_footer(f, le)) { > + if (!check_section_footer(f, se)) { > return -EINVAL; > } > > @@ -1898,29 +1898,29 @@ static int > qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) > { > uint32_t section_id; > - LoadStateEntry *le; > + SaveStateEntry *se; > int ret; > > section_id = qemu_get_be32(f); > > trace_qemu_loadvm_state_section_partend(section_id); > - QLIST_FOREACH(le, &mis->loadvm_handlers, entry) { > - if (le->section_id == section_id) { > + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { > + if (se->section_id == section_id) { > break; > } > } > - if (le == NULL) { > + if (se == NULL) { > error_report("Unknown savevm section %d", section_id); > return -EINVAL; > } > > - ret = vmstate_load(f, le->se, le->version_id); > + ret = vmstate_load(f, se, se->version_id); Are you sure you can replace le->version_id by se->version? Because according to code in qemu_loadvm_section_start_full(), we can have le->version_id <= se->version_id. Thanks, Laurent
Laurent Vivier <lvivier@redhat.com> wrote: > On 24/05/2017 10:55, Juan Quintela wrote: >> From: Juan Quintela <quintela@trasno.org> >> >> There is no reason for having the loadvm_handlers at all. There is >> only one use, and we can use the savevm handlers. >> >> We will remove the loadvm handlers on a following patch. >> >> Signed-off-by: Juan Quintela <quintela@redhat.com> >> + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { >> + if (se->section_id == section_id) { >> break; >> } >> } >> - if (le == NULL) { >> + if (se == NULL) { >> error_report("Unknown savevm section %d", section_id); >> return -EINVAL; >> } >> >> - ret = vmstate_load(f, le->se, le->version_id); >> + ret = vmstate_load(f, se, se->version_id); > Are you sure you can replace le->version_id by se->version? > > Because according to code in qemu_loadvm_section_start_full(), > we can have le->version_id <= se->version_id. You are right. We don't use basically anymore version_id, but we used to use it. I will arrive to a different solution. Thanks a lot. Later, Juan.
diff --git a/migration/savevm.c b/migration/savevm.c index d971e5e..55ac8c1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1792,7 +1792,7 @@ struct LoadStateEntry { * Returns: true if the footer was good * false if there is a problem (and calls error_report to say why) */ -static bool check_section_footer(QEMUFile *f, LoadStateEntry *le) +static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) { uint8_t read_mark; uint32_t read_section_id; @@ -1805,15 +1805,15 @@ static bool check_section_footer(QEMUFile *f, LoadStateEntry *le) read_mark = qemu_get_byte(f); if (read_mark != QEMU_VM_SECTION_FOOTER) { - error_report("Missing section footer for %s", le->se->idstr); + error_report("Missing section footer for %s", se->idstr); return false; } read_section_id = qemu_get_be32(f); - if (read_section_id != le->section_id) { + if (read_section_id != se->section_id) { error_report("Mismatched section id in footer for %s -" " read 0x%x expected 0x%x", - le->se->idstr, read_section_id, le->section_id); + se->idstr, read_section_id, se->section_id); return false; } @@ -1887,7 +1887,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) " device '%s'", instance_id, idstr); return ret; } - if (!check_section_footer(f, le)) { + if (!check_section_footer(f, se)) { return -EINVAL; } @@ -1898,29 +1898,29 @@ static int qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) { uint32_t section_id; - LoadStateEntry *le; + SaveStateEntry *se; int ret; section_id = qemu_get_be32(f); trace_qemu_loadvm_state_section_partend(section_id); - QLIST_FOREACH(le, &mis->loadvm_handlers, entry) { - if (le->section_id == section_id) { + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (se->section_id == section_id) { break; } } - if (le == NULL) { + if (se == NULL) { error_report("Unknown savevm section %d", section_id); return -EINVAL; } - ret = vmstate_load(f, le->se, le->version_id); + ret = vmstate_load(f, se, se->version_id); if (ret < 0) { error_report("error while loading state section id %d(%s)", - section_id, le->se->idstr); + section_id, se->idstr); return ret; } - if (!check_section_footer(f, le)) { + if (!check_section_footer(f, se)) { return -EINVAL; }