From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Arun Menon <armenon@redhat.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"David Hildenbrand" <david@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Thomas Huth" <thuth@redhat.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Fam Zheng" <fam@euphon.net>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Peter Xu" <peterx@redhat.com>, "Fabiano Rosas" <farosas@suse.de>,
"Hailiang Zhang" <zhanghailiang@xfusion.com>,
"Steve Sistare" <steven.sistare@oracle.com>,
qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,
"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>
Subject: Re: [PATCH v6 23/24] migration: Add error-parameterized function variants in VMSD struct
Date: Mon, 21 Jul 2025 15:05:59 +0100 [thread overview]
Message-ID: <aH5JR-58iMk0ArSl@redhat.com> (raw)
In-Reply-To: <aH5Gj61ZmtZ0NzEv@armenon-kvm.bengluru.csb>
On Mon, Jul 21, 2025 at 07:24:23PM +0530, Arun Menon wrote:
> Hi,
> Thank you for the review.
>
> On Mon, Jul 21, 2025 at 02:32:48PM +0100, Daniel P. Berrangé wrote:
> > On Mon, Jul 21, 2025 at 04:59:28PM +0530, Arun Menon wrote:
> > > - We need to have good error reporting in the callbacks in
> > > VMStateDescription struct. Specifically pre_save, post_save,
> > > pre_load and post_load callbacks.
> > > - It is not possible to change these functions everywhere in one
> > > patch, therefore, we introduce a duplicate set of callbacks
> > > with Error object passed to them.
> > > - So, in this commit, we implement 'errp' variants of these callbacks,
> > > introducing an explicit Error object parameter.
> > > - This is a functional step towards transitioning the entire codebase
> > > to the new error-parameterized functions.
> > > - Deliberately called in mutual exclusion from their counterparts,
> > > to prevent conflicts during the transition.
> > > - New impls should preferentally use 'errp' variants of
> > > these methods, and existing impls incrementally converted.
> > > The variants without 'errp' are intended to be removed
> > > once all usage is converted.
> > >
> > > Signed-off-by: Arun Menon <armenon@redhat.com>
> > > ---
> > > include/migration/vmstate.h | 11 +++++++++++
> > > migration/vmstate.c | 47 +++++++++++++++++++++++++++++++++++++++------
> > > 2 files changed, 52 insertions(+), 6 deletions(-)
> > >
> >
> > > diff --git a/migration/vmstate.c b/migration/vmstate.c
> > > index 288b57e1ed778cce21247b64d5e97dfef41ad586..d96908d12ccffaef421e5d399a48e26cada2cb77 100644
> > > --- a/migration/vmstate.c
> > > +++ b/migration/vmstate.c
> >
> > > @@ -524,7 +548,12 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
> > > if (ret) {
> > > error_setg(errp, "Save of field %s/%s failed",
> > > vmsd->name, field->name);
> > > - if (vmsd->post_save) {
> > > + if (vmsd->post_save_errp) {
> > > + ret = vmsd->post_save_errp(opaque, &local_err);
> > > + if (ret < 0) {
> > > + error_propagate(errp, local_err);
> > > + }
> >
> > This is still broken. 'errp' is already set a few lines earlier, so you
> > can't propagate a new error over the top
>
> I was wondering that we should preserve the first error that was encountered.
> So even if local_err was set, and in case errp already has an error, then it will
> be a no-op and local_err will be freed.
We know that 'local_err' is definitely set when 'post_save_errp' is called,
because there's a call to 'error_setg' right above it.
> > > + } else if (vmsd->post_save) {
> > > vmsd->post_save(opaque);
> > > }
... pre-existing mistake not checking return value of
post_save.
> > > return ret;
> > > @@ -552,7 +581,13 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
> > >
> > > ret = vmstate_subsection_save(f, vmsd, opaque, vmdesc, errp);
> > >
> > > - if (vmsd->post_save) {
> > > + if (vmsd->post_save_errp) {
> > > + int ps_ret = vmsd->post_save_errp(opaque, &local_err);
> > > + if (!ret && ps_ret) {
> > > + ret = ps_ret;
> > > + error_propagate(errp, local_err);
> > > + }
> >
> > Again, propagating over the top of an existing error
>
> Sorry, correct me if I am wrong.
> Since we have 'if (!ret && ps_ret)' ,
> if vmstate_subsection_save() fails, the above condition will not hold true.
> Only if the first function call vmstate_subsection_save() is successful and the second one
> post_save_errp() fails then we try to propagate, again hoping to preserve the first error.
Opps, yes, you're right - I missed the 'ps_ret' check. That means this
code is a memory leak when 'ret' is non-zero, as nothing frees 'local_err'
in that case.
>
> >
> > > + } else if (vmsd->post_save) {
> > > int ps_ret = vmsd->post_save(opaque);
> > > if (!ret && ps_ret) {
> > > ret = ps_ret;
> > >
> > > --
> > > 2.50.0
> > >
> > >
> >
> > With regards,
> > Daniel
> > --
> > |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> > |: https://libvirt.org -o- https://fstop138.berrange.com :|
> > |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
> >
>
> Regards,
> Arun Menon
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2025-07-21 14:08 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 11:29 [PATCH v6 00/24] migration: propagate vTPM errors using Error objects Arun Menon
2025-07-21 11:29 ` [PATCH v6 01/24] migration: push Error **errp into vmstate_subsection_load() Arun Menon
2025-07-21 12:10 ` Akihiko Odaki
2025-07-25 7:09 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 02/24] migration: push Error **errp into vmstate_load_state() Arun Menon
2025-07-21 12:24 ` Akihiko Odaki
2025-07-25 7:11 ` Arun Menon
2025-07-21 12:30 ` Marc-André Lureau
2025-07-25 7:12 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 03/24] migration: push Error **errp into qemu_loadvm_state_header() Arun Menon
2025-07-21 12:34 ` Marc-André Lureau
2025-07-25 7:12 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 04/24] migration: push Error **errp into vmstate_load() Arun Menon
2025-07-21 11:29 ` [PATCH v6 05/24] migration: push Error **errp into qemu_loadvm_section_start_full() Arun Menon
2025-07-21 11:29 ` [PATCH v6 06/24] migration: push Error **errp into qemu_loadvm_section_part_end() Arun Menon
2025-07-21 11:29 ` [PATCH v6 07/24] migration: Update qemu_file_get_return_path() docs and remove dead checks Arun Menon
2025-07-21 12:24 ` Daniel P. Berrangé
2025-07-21 11:29 ` [PATCH v6 08/24] migration: push Error **errp into loadvm_process_command() Arun Menon
2025-07-21 12:38 ` Akihiko Odaki
2025-07-25 7:13 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 09/24] migration: push Error **errp into loadvm_handle_cmd_packaged() Arun Menon
2025-07-21 11:29 ` [PATCH v6 10/24] migration: push Error **errp into ram_postcopy_incoming_init() Arun Menon
2025-07-21 11:29 ` [PATCH v6 11/24] migration: push Error **errp into loadvm_postcopy_handle_advise() Arun Menon
2025-07-21 12:43 ` Akihiko Odaki
2025-07-25 7:14 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 12/24] migration: push Error **errp into loadvm_postcopy_handle_listen() Arun Menon
2025-07-21 11:29 ` [PATCH v6 13/24] migration: push Error **errp into loadvm_postcopy_handle_run() Arun Menon
2025-07-21 11:29 ` [PATCH v6 14/24] migration: push Error **errp into loadvm_postcopy_ram_handle_discard() Arun Menon
2025-07-21 11:29 ` [PATCH v6 15/24] migration: make loadvm_postcopy_handle_resume() void Arun Menon
2025-07-21 12:46 ` Akihiko Odaki
2025-07-25 7:15 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 16/24] migration: push Error **errp into loadvm_handle_recv_bitmap() Arun Menon
2025-07-21 11:29 ` [PATCH v6 17/24] migration: push Error **errp into loadvm_process_enable_colo() Arun Menon
2025-07-21 11:29 ` [PATCH v6 18/24] migration: push Error **errp into loadvm_postcopy_handle_switchover_start() Arun Menon
2025-07-21 11:29 ` [PATCH v6 19/24] migration: push Error **errp into qemu_loadvm_state_main() Arun Menon
2025-07-21 11:29 ` [PATCH v6 20/24] migration: push Error **errp into qemu_loadvm_state() Arun Menon
2025-07-21 13:01 ` Akihiko Odaki
2025-07-25 7:09 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 21/24] migration: push Error **errp into qemu_load_device_state() Arun Menon
2025-07-21 11:29 ` [PATCH v6 22/24] migration: Capture error in postcopy_ram_listen_thread() Arun Menon
2025-07-21 11:29 ` [PATCH v6 23/24] migration: Add error-parameterized function variants in VMSD struct Arun Menon
2025-07-21 13:14 ` Akihiko Odaki
2025-07-21 13:29 ` Daniel P. Berrangé
2025-07-21 15:15 ` Akihiko Odaki
2025-08-09 8:17 ` Markus Armbruster
2025-08-09 9:53 ` Akihiko Odaki
2025-08-09 14:30 ` Markus Armbruster
2025-08-10 4:59 ` Akihiko Odaki
2025-08-25 12:00 ` Markus Armbruster
2025-07-21 13:32 ` Daniel P. Berrangé
2025-07-21 13:54 ` Arun Menon
2025-07-21 14:05 ` Daniel P. Berrangé [this message]
2025-07-21 15:10 ` Arun Menon
2025-07-25 6:39 ` Arun Menon
2025-07-21 11:29 ` [PATCH v6 24/24] backends/tpm: Propagate vTPM error on migration failure Arun Menon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aH5JR-58iMk0ArSl@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=armenon@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=clg@redhat.com \
--cc=cohuck@redhat.com \
--cc=danielhb413@gmail.com \
--cc=david@redhat.com \
--cc=dmitry.osipenko@collabora.com \
--cc=fam@euphon.net \
--cc=farman@linux.ibm.com \
--cc=farosas@suse.de \
--cc=harshpb@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mjrosato@linux.ibm.com \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanb@linux.vnet.ibm.com \
--cc=steven.sistare@oracle.com \
--cc=thuth@redhat.com \
--cc=zhanghailiang@xfusion.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).