qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: "Arun Menon" <armenon@redhat.com>,
	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>,
	"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 v7 01/24] migration: push Error **errp into vmstate_subsection_load()
Date: Mon, 28 Jul 2025 11:06:57 +0100	[thread overview]
Message-ID: <aIdLwSMPs0xsCgT6@redhat.com> (raw)
In-Reply-To: <CAJ+F1CK1_zVY-az5XF+ds+82Vq=3hi-_yLf4nw4obtPSySwqow@mail.gmail.com>

On Mon, Jul 28, 2025 at 01:59:40PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Mon, Jul 28, 2025 at 1:06 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Mon, Jul 28, 2025 at 12:44:53PM +0400, Marc-André Lureau wrote:
> > > Hi
> > >
> > > On Fri, Jul 25, 2025 at 5:46 PM Marc-André Lureau <
> > > marcandre.lureau@redhat.com> wrote:
> > >
> > > >
> > > >
> > > > On Fri, Jul 25, 2025 at 4:19 PM Arun Menon <armenon@redhat.com> wrote:
> > > >
> > > >> 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.
> > > >>
> > > >> Signed-off-by: Arun Menon <armenon@redhat.com>
> > > >> ---
> > > >>  migration/vmstate.c | 11 ++++++++---
> > > >>  1 file changed, 8 insertions(+), 3 deletions(-)
> > > >>
> > > >> diff --git a/migration/vmstate.c b/migration/vmstate.c
> > > >> index
> > > >> 5feaa3244d259874f03048326b2497e7db32e47c..aeffeafaa4fa7582076a4f2747906ddf9aca891b
> > > >> 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
> > > >> @@ -225,7 +225,7 @@ 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, NULL);
> > > >>      if (ret != 0) {
> > > >>          qemu_file_set_error(f, ret);
> > > >>          return ret;
> > > >> @@ -566,7 +566,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 +598,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 +610,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",
> > > >>
> > > >
> > > > extra space before ":"
> > > >
> > > > other than that
> > > > Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > >
> > >
> > > Actually, almost systematically when you introduce an extra **errp
> > > argument, you should ERRP_GUARD() in the function (see include/qapi/error.h
> > > doc). Was this discussed before? Can you update the following patches too?
> >
> > ERRP_GUARD is only needed in functions which derefence errp, which should
> > very rarely be needed when all functions are non-void return value.
> 
> But also, it avoids this pitfall with @errp argument:
> 
> * - It should not be passed to error_prepend(), error_vprepend(), or
>  *   error_append_hint(), because that doesn't work with &error_fatal.

Oh, i forgot about that gotcha :-(

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 :|



  reply	other threads:[~2025-07-28 10:07 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 12:18 [PATCH v7 00/24] migration: propagate vTPM errors using Error objects Arun Menon
2025-07-25 12:18 ` [PATCH v7 01/24] migration: push Error **errp into vmstate_subsection_load() Arun Menon
2025-07-25 13:46   ` Marc-André Lureau
2025-07-28  8:44     ` Marc-André Lureau
2025-07-28  9:01       ` Daniel P. Berrangé
2025-07-28  9:59         ` Marc-André Lureau
2025-07-28 10:06           ` Daniel P. Berrangé [this message]
2025-07-29  7:23       ` Arun Menon
2025-07-25 12:18 ` [PATCH v7 02/24] migration: push Error **errp into vmstate_load_state() Arun Menon
2025-07-25 13:48   ` Marc-André Lureau
2025-07-28 10:14     ` Marc-André Lureau
2025-07-29  7:24       ` Arun Menon
2025-07-25 12:18 ` [PATCH v7 03/24] migration: push Error **errp into qemu_loadvm_state_header() Arun Menon
2025-07-25 13:51   ` Marc-André Lureau
2025-07-25 12:18 ` [PATCH v7 04/24] migration: push Error **errp into vmstate_load() Arun Menon
2025-07-25 13:56   ` Marc-André Lureau
2025-07-25 12:18 ` [PATCH v7 05/24] migration: push Error **errp into qemu_loadvm_section_start_full() Arun Menon
2025-07-25 12:18 ` [PATCH v7 06/24] migration: push Error **errp into qemu_loadvm_section_part_end() Arun Menon
2025-07-25 12:18 ` [PATCH v7 07/24] migration: Update qemu_file_get_return_path() docs and remove dead checks Arun Menon
2025-07-28  8:46   ` Marc-André Lureau
2025-07-25 12:18 ` [PATCH v7 08/24] migration: make loadvm_postcopy_handle_resume() void Arun Menon
2025-07-28 10:25   ` Marc-André Lureau
2025-07-29  7:25     ` Arun Menon
2025-07-25 12:18 ` [PATCH v7 09/24] migration: push Error **errp into loadvm_process_command() Arun Menon
2025-07-28  8:53   ` Marc-André Lureau
2025-07-28  9:05     ` Daniel P. Berrangé
2025-07-25 12:18 ` [PATCH v7 10/24] migration: push Error **errp into loadvm_handle_cmd_packaged() Arun Menon
2025-07-25 12:18 ` [PATCH v7 11/24] migration: push Error **errp into ram_postcopy_incoming_init() Arun Menon
2025-07-28 10:00   ` Marc-André Lureau
2025-07-25 12:18 ` [PATCH v7 12/24] migration: push Error **errp into loadvm_postcopy_handle_advise() Arun Menon
2025-07-28 10:04   ` Marc-André Lureau
2025-07-25 12:18 ` [PATCH v7 13/24] migration: push Error **errp into loadvm_postcopy_handle_listen() Arun Menon
2025-07-25 12:18 ` [PATCH v7 14/24] migration: push Error **errp into loadvm_postcopy_handle_run() Arun Menon
2025-07-25 12:18 ` [PATCH v7 15/24] migration: push Error **errp into loadvm_postcopy_ram_handle_discard() Arun Menon
2025-07-25 12:18 ` [PATCH v7 16/24] migration: push Error **errp into loadvm_handle_recv_bitmap() Arun Menon
2025-07-25 12:18 ` [PATCH v7 17/24] migration: push Error **errp into loadvm_process_enable_colo() Arun Menon
2025-07-25 12:18 ` [PATCH v7 18/24] migration: push Error **errp into loadvm_postcopy_handle_switchover_start() Arun Menon
2025-07-25 12:18 ` [PATCH v7 19/24] migration: push Error **errp into qemu_loadvm_state_main() Arun Menon
2025-07-25 12:18 ` [PATCH v7 20/24] migration: push Error **errp into qemu_loadvm_state() Arun Menon
2025-07-25 12:19 ` [PATCH v7 21/24] migration: push Error **errp into qemu_load_device_state() Arun Menon
2025-07-25 12:19 ` [PATCH v7 22/24] migration: Capture error in postcopy_ram_listen_thread() Arun Menon
2025-07-28 10:34   ` Marc-André Lureau
2025-07-25 12:19 ` [PATCH v7 23/24] migration: Add error-parameterized function variants in VMSD struct Arun Menon
2025-07-26 12:48   ` Akihiko Odaki
2025-07-28 10:54     ` Arun Menon
2025-07-29  8:24       ` Akihiko Odaki
2025-07-28 11:07   ` Marc-André Lureau
2025-07-28 15:20     ` Arun Menon
2025-07-25 12:19 ` [PATCH v7 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=aIdLwSMPs0xsCgT6@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@gmail.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).