105 lines
4.2 KiB
Diff
105 lines
4.2 KiB
Diff
From e11e10cd73c27ae4cc1589846dd3b04f6e99c842 Mon Sep 17 00:00:00 2001
|
|
From: Arun Menon <armenon@redhat.com>
|
|
Date: Thu, 18 Sep 2025 20:53:18 +0530
|
|
Subject: [PATCH 085/116] migration: push Error **errp into
|
|
vmstate_subsection_load()
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Rodolfo Vick <None>
|
|
RH-MergeRequest: 486: Add DMABUF support
|
|
RH-Jira: RHEL-138494
|
|
RH-Acked-by: Cédric Le Goater <clg@redhat.com>
|
|
RH-Acked-by: Eric Auger <eric.auger@redhat.com>
|
|
RH-Commit: [69/100] 59881451411ab7db67f43a53706e5bb6c861eef1 (rovick1/qemu-kvm)
|
|
|
|
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_subsection_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 using errp.
|
|
|
|
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-1-36f11a6fb9d3@redhat.com
|
|
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
(cherry picked from commit 73b42fc58d035cb2fcfe90083d6b33aeb4fa1b2a)
|
|
Signed-off-by: Eric Auger <eric.auger@redhat.com>
|
|
---
|
|
migration/vmstate.c | 13 ++++++++++---
|
|
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/migration/vmstate.c b/migration/vmstate.c
|
|
index 5feaa3244d..08f2b562e3 100644
|
|
--- a/migration/vmstate.c
|
|
+++ b/migration/vmstate.c
|
|
@@ -25,7 +25,7 @@ static int vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
|
|
void *opaque, JSONWriter *vmdesc,
|
|
Error **errp);
|
|
static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
|
|
- void *opaque);
|
|
+ void *opaque, Error **errp);
|
|
|
|
/* Whether this field should exist for either save or load the VM? */
|
|
static bool
|
|
@@ -136,6 +136,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
|
|
{
|
|
const VMStateField *field = vmsd->fields;
|
|
int ret = 0;
|
|
+ Error *local_err = NULL;
|
|
|
|
trace_vmstate_load_state(vmsd->name, version_id);
|
|
if (version_id > vmsd->version_id) {
|
|
@@ -225,9 +226,10 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
|
|
field++;
|
|
}
|
|
assert(field->flags == VMS_END);
|
|
- ret = vmstate_subsection_load(f, vmsd, opaque);
|
|
+ ret = vmstate_subsection_load(f, vmsd, opaque, &local_err);
|
|
if (ret != 0) {
|
|
qemu_file_set_error(f, ret);
|
|
+ error_report_err(local_err);
|
|
return ret;
|
|
}
|
|
if (vmsd->post_load) {
|
|
@@ -566,7 +568,7 @@ vmstate_get_subsection(const VMStateDescription * const *sub,
|
|
}
|
|
|
|
static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
|
|
- void *opaque)
|
|
+ void *opaque, Error **errp)
|
|
{
|
|
trace_vmstate_subsection_load(vmsd->name);
|
|
|
|
@@ -598,6 +600,8 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
|
|
sub_vmsd = vmstate_get_subsection(vmsd->subsections, idstr);
|
|
if (sub_vmsd == NULL) {
|
|
trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(lookup)");
|
|
+ error_setg(errp, "VM subsection '%s' in '%s' does not exist",
|
|
+ idstr, vmsd->name);
|
|
return -ENOENT;
|
|
}
|
|
qemu_file_skip(f, 1); /* subsection */
|
|
@@ -608,6 +612,9 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
|
|
ret = vmstate_load_state(f, sub_vmsd, opaque, version_id);
|
|
if (ret) {
|
|
trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(child)");
|
|
+ error_setg(errp,
|
|
+ "Loading VM subsection '%s' in '%s' failed: %d",
|
|
+ idstr, vmsd->name, ret);
|
|
return ret;
|
|
}
|
|
}
|
|
--
|
|
2.52.0
|
|
|