migration: Add Error** argument to vmstate_save()

This will prepare ground for future changes adding an Error** argument
to qemu_savevm_state_setup().

Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/r/20240320064911.545001-6-clg@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
Cédric Le Goater 2024-03-20 07:49:01 +01:00 committed by Peter Xu
parent 76936bbc31
commit 6138d43ab2

View File

@ -1009,11 +1009,10 @@ static void save_section_footer(QEMUFile *f, SaveStateEntry *se)
}
}
static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc)
static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc,
Error **errp)
{
int ret;
Error *local_err = NULL;
MigrationState *s = migrate_get_current();
if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
return 0;
@ -1035,10 +1034,9 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc)
if (!se->vmsd) {
vmstate_save_old_style(f, se, vmdesc);
} else {
ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc, &local_err);
ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc,
errp);
if (ret) {
migrate_set_error(s, local_err);
error_report_err(local_err);
return ret;
}
}
@ -1325,8 +1323,10 @@ void qemu_savevm_state_setup(QEMUFile *f)
trace_savevm_state_setup();
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (se->vmsd && se->vmsd->early_setup) {
ret = vmstate_save(f, se, ms->vmdesc);
ret = vmstate_save(f, se, ms->vmdesc, &local_err);
if (ret) {
migrate_set_error(ms, local_err);
error_report_err(local_err);
qemu_file_set_error(f, ret);
break;
}
@ -1542,6 +1542,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
JSONWriter *vmdesc = ms->vmdesc;
int vmdesc_len;
SaveStateEntry *se;
Error *local_err = NULL;
int ret;
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
@ -1552,8 +1553,10 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
start_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME);
ret = vmstate_save(f, se, vmdesc);
ret = vmstate_save(f, se, vmdesc, &local_err);
if (ret) {
migrate_set_error(ms, local_err);
error_report_err(local_err);
qemu_file_set_error(f, ret);
return ret;
}
@ -1568,7 +1571,6 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
* bdrv_activate_all() on the other end won't fail. */
ret = bdrv_inactivate_all();
if (ret) {
Error *local_err = NULL;
error_setg(&local_err, "%s: bdrv_inactivate_all() failed (%d)",
__func__, ret);
migrate_set_error(ms, local_err);
@ -1764,6 +1766,8 @@ void qemu_savevm_live_state(QEMUFile *f)
int qemu_save_device_state(QEMUFile *f)
{
MigrationState *ms = migrate_get_current();
Error *local_err = NULL;
SaveStateEntry *se;
if (!migration_in_colo_state()) {
@ -1778,8 +1782,10 @@ int qemu_save_device_state(QEMUFile *f)
if (se->is_ram) {
continue;
}
ret = vmstate_save(f, se, NULL);
ret = vmstate_save(f, se, NULL, &local_err);
if (ret) {
migrate_set_error(ms, local_err);
error_report_err(local_err);
return ret;
}
}