mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
migration: push Error **errp into vmstate_load()
This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that vmstate_load() must report an error in errp, in case of failure. The errors are temporarily reported using error_report_err(). This is removed in the subsequent patches in this series when we are actually able to propagate the error to the calling function. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Arun Menon <armenon@redhat.com> Tested-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Link: https://lore.kernel.org/r/20250918-propagate_tpm_error-v14-4-36f11a6fb9d3@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
+15
-7
@@ -963,14 +963,20 @@ void vmstate_unregister(VMStateIf *obj, const VMStateDescription *vmsd,
|
||||
}
|
||||
}
|
||||
|
||||
static int vmstate_load(QEMUFile *f, SaveStateEntry *se)
|
||||
static int vmstate_load(QEMUFile *f, SaveStateEntry *se, Error **errp)
|
||||
{
|
||||
int ret;
|
||||
trace_vmstate_load(se->idstr, se->vmsd ? se->vmsd->name : "(old)");
|
||||
if (!se->vmsd) { /* Old style */
|
||||
return se->ops->load_state(f, se->opaque, se->load_version_id);
|
||||
ret = se->ops->load_state(f, se->opaque, se->load_version_id);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "Failed to load vmstate version_id: %d, ret: %d",
|
||||
se->load_version_id, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id,
|
||||
&error_fatal);
|
||||
errp);
|
||||
}
|
||||
|
||||
static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se,
|
||||
@@ -2692,6 +2698,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type)
|
||||
SaveStateEntry *se;
|
||||
char idstr[256];
|
||||
int ret;
|
||||
Error *local_err = NULL;
|
||||
|
||||
/* Read section start */
|
||||
section_id = qemu_get_be32(f);
|
||||
@@ -2741,10 +2748,11 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type)
|
||||
start_ts = qemu_clock_get_us(QEMU_CLOCK_REALTIME);
|
||||
}
|
||||
|
||||
ret = vmstate_load(f, se);
|
||||
ret = vmstate_load(f, se, &local_err);
|
||||
if (ret < 0) {
|
||||
error_report("error while loading state for instance 0x%"PRIx32" of"
|
||||
" device '%s'", instance_id, idstr);
|
||||
error_report_err(local_err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2769,6 +2777,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t type)
|
||||
uint32_t section_id;
|
||||
SaveStateEntry *se;
|
||||
int ret;
|
||||
Error *local_err = NULL;
|
||||
|
||||
section_id = qemu_get_be32(f);
|
||||
|
||||
@@ -2794,10 +2803,9 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t type)
|
||||
start_ts = qemu_clock_get_us(QEMU_CLOCK_REALTIME);
|
||||
}
|
||||
|
||||
ret = vmstate_load(f, se);
|
||||
ret = vmstate_load(f, se, &local_err);
|
||||
if (ret < 0) {
|
||||
error_report("error while loading state section id %d(%s)",
|
||||
section_id, se->idstr);
|
||||
error_report_err(local_err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user