From: Arun Menon <armenon@redhat.com>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: qemu-devel@nongnu.org, "Peter Xu" <peterx@redhat.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
"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>,
"Thomas Huth" <thuth@redhat.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"David Hildenbrand" <david@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Fam Zheng" <fam@euphon.net>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Steve Sistare" <steven.sistare@oracle.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,
"Hailiang Zhang" <zhanghailiang@xfusion.com>,
"Stefan Berger" <stefanb@linux.vnet.ibm.com>
Subject: Re: [PATCH v9 07/27] migration: push Error **errp into qemu_loadvm_state()
Date: Thu, 7 Aug 2025 11:37:08 +0530 [thread overview]
Message-ID: <aJRCjLGbSFzWyy2C@armenon-kvm.bengluru.csb> (raw)
In-Reply-To: <07eebc10-a6e0-4fb8-a364-09f026a4a342@rsg.ci.i.u-tokyo.ac.jp>
Hi Akihiko,
Thanks for the review.
On Wed, Aug 06, 2025 at 02:17:02PM +0900, Akihiko Odaki wrote:
> On 2025/08/06 3:25, Arun Menon 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 qemu_loadvm_state() must report an error
> > in errp, in case of failure.
> >
> > When postcopy live migration runs, the device states are loaded by
> > both the qemu coroutine process_incoming_migration_co() and the
> > postcopy_ram_listen_thread(). Therefore, it is important that the
> > coroutine also reports the error in case of failure, with
> > error_report_err(). Otherwise, the source qemu will not display
> > any errors before going into the postcopy pause state.
> >
> > Signed-off-by: Arun Menon <armenon@redhat.com>
> > ---
> > migration/migration.c | 7 ++++---
> > migration/savevm.c | 31 +++++++++++++++++++------------
> > migration/savevm.h | 2 +-
> > 3 files changed, 24 insertions(+), 16 deletions(-)
> >
> > diff --git a/migration/migration.c b/migration/migration.c
> > index 10c216d25dec01f206eacad2edd24d21f00e614c..bb7d5e1dee52692cbea1d2c8fdca541e6a75bedb 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -881,7 +881,7 @@ process_incoming_migration_co(void *opaque)
> > MIGRATION_STATUS_ACTIVE);
> > mis->loadvm_co = qemu_coroutine_self();
> > - ret = qemu_loadvm_state(mis->from_src_file);
> > + ret = qemu_loadvm_state(mis->from_src_file, &local_err);
> > mis->loadvm_co = NULL;
> > trace_vmstate_downtime_checkpoint("dst-precopy-loadvm-completed");
> > @@ -908,7 +908,8 @@ process_incoming_migration_co(void *opaque)
> > }
> > if (ret < 0) {
> > - error_setg(&local_err, "load of migration failed: %s", strerror(-ret));
> > + error_prepend(&local_err, "load of migration failed: %s: ",
> > + strerror(-ret));
> > goto fail;
> > }
> > @@ -924,7 +925,7 @@ fail:
> > migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
> > MIGRATION_STATUS_FAILED);
> > migrate_set_error(s, local_err);
> > - error_free(local_err);
> > + error_report_err(local_err);
>
> There is "error_report_err(s->error)" after this so this can result in
> duplicate error printing.
Yes, we can replace this with error_free(s->error).
>
> > migration_incoming_state_destroy();
> > diff --git a/migration/savevm.c b/migration/savevm.c
> > index 1bd27efe437d4d911728d776e995490d0a45dcf5..ca166ebd397ad80836ed2f9cb20a92f704fd4ed5 100644
> > --- a/migration/savevm.c
> > +++ b/migration/savevm.c
> > @@ -3149,28 +3149,24 @@ out:
> > return ret;
> > }
> > -int qemu_loadvm_state(QEMUFile *f)
> > +int qemu_loadvm_state(QEMUFile *f, Error **errp)
> > {
> > MigrationState *s = migrate_get_current();
> > MigrationIncomingState *mis = migration_incoming_get_current();
> > - Error *local_err = NULL;
> > int ret;
> > - if (qemu_savevm_state_blocked(&local_err)) {
> > - error_report_err(local_err);
> > + if (qemu_savevm_state_blocked(errp)) {
> > return -EINVAL;
> > }
> > qemu_loadvm_thread_pool_create(mis);
> > - ret = qemu_loadvm_state_header(f, &local_err);
> > + ret = qemu_loadvm_state_header(f, errp);
> > if (ret) {
> > - error_report_err(local_err);
> > return ret;
> > }
> > - if (qemu_loadvm_state_setup(f, &local_err) != 0) {
> > - error_report_err(local_err);
> > + if (qemu_loadvm_state_setup(f, errp) != 0) {
> > return -EINVAL;
> > }
> > @@ -3181,6 +3177,9 @@ int qemu_loadvm_state(QEMUFile *f)
> > cpu_synchronize_all_pre_loadvm();
> > ret = qemu_loadvm_state_main(f, mis);
> > + if (ret < 0) {
> > + error_setg(errp, "Load VM state failed: %d", ret);
> > + }
> > qemu_event_set(&mis->main_thread_load_event);
> > trace_qemu_loadvm_state_post_main(ret);
> > @@ -3198,8 +3197,14 @@ int qemu_loadvm_state(QEMUFile *f)
> > if (migrate_has_error(migrate_get_current()) ||
> > !qemu_loadvm_thread_pool_wait(s, mis)) {
> > ret = -EINVAL;
> > + error_setg(errp,
> > + "Error while loading VM state: "
> > + "Migration stream has error");
> > } else {
> > ret = qemu_file_get_error(f);
> > + if (ret < 0) {
> > + error_setg(errp, "Error while loading vmstate : %d", ret);
> > + }
> > }
> > }
> > /*
> > @@ -3464,6 +3469,7 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
> > void qmp_xen_load_devices_state(const char *filename, Error **errp)
> > {
> > + ERRP_GUARD();
> > QEMUFile *f;
> > QIOChannelFile *ioc;
> > int ret;
> > @@ -3485,10 +3491,10 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp)
> > f = qemu_file_new_input(QIO_CHANNEL(ioc));
> > object_unref(OBJECT(ioc));
> > - ret = qemu_loadvm_state(f);
> > + ret = qemu_loadvm_state(f, errp);
> > qemu_fclose(f);
> > if (ret < 0) {
> > - error_setg(errp, "loading Xen device state failed");
> > + error_prepend(errp, "loading Xen device state failed: ");
> > }
> > migration_incoming_state_destroy();
> > }
> > @@ -3496,6 +3502,7 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp)
> > bool load_snapshot(const char *name, const char *vmstate,
> > bool has_devices, strList *devices, Error **errp)
> > {
> > + ERRP_GUARD();
> > BlockDriverState *bs_vm_state;
> > QEMUSnapshotInfo sn;
> > QEMUFile *f;
> > @@ -3559,13 +3566,13 @@ bool load_snapshot(const char *name, const char *vmstate,
> > ret = -EINVAL;
> > goto err_drain;
> > }
> > - ret = qemu_loadvm_state(f);
> > + ret = qemu_loadvm_state(f, errp);
> > migration_incoming_state_destroy();
> > bdrv_drain_all_end();
> > if (ret < 0) {
> > - error_setg(errp, "Error %d while loading VM state", ret);
> > + error_prepend(errp, "Error %d while loading VM state: ", ret);
> > return false;
> > }
> > diff --git a/migration/savevm.h b/migration/savevm.h
> > index 2d5e9c716686f06720325e82fe90c75335ced1de..b80770b7461a60e2ad6ba5e24a7baeae73d90955 100644
> > --- a/migration/savevm.h
> > +++ b/migration/savevm.h
> > @@ -64,7 +64,7 @@ void qemu_savevm_send_colo_enable(QEMUFile *f);
> > void qemu_savevm_live_state(QEMUFile *f);
> > int qemu_save_device_state(QEMUFile *f);
> > -int qemu_loadvm_state(QEMUFile *f);
> > +int qemu_loadvm_state(QEMUFile *f, Error **errp);
> > void qemu_loadvm_state_cleanup(MigrationIncomingState *mis);
> > int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis);
> > int qemu_load_device_state(QEMUFile *f);
> >
>
Regards,
Arun Menon
next prev parent reply other threads:[~2025-08-07 6:08 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 18:25 [PATCH v9 00/27] migration: propagate vTPM errors using Error objects Arun Menon
2025-08-05 18:25 ` [PATCH v9 01/27] migration: push Error **errp into vmstate_subsection_load() Arun Menon
2025-08-05 18:25 ` [PATCH v9 02/27] migration: push Error **errp into vmstate_load_state() Arun Menon
2025-08-06 8:31 ` Marc-André Lureau
2025-08-06 9:47 ` Arun Menon
2025-08-10 4:47 ` Akihiko Odaki
2025-08-05 18:25 ` [PATCH v9 03/27] migration: push Error **errp into qemu_loadvm_state_header() Arun Menon
2025-08-05 18:25 ` [PATCH v9 04/27] migration: push Error **errp into vmstate_load() Arun Menon
2025-08-05 18:25 ` [PATCH v9 05/27] migration: push Error **errp into loadvm_process_command() Arun Menon
2025-08-06 8:31 ` Marc-André Lureau
2025-08-06 9:46 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 06/27] migration: push Error **errp into loadvm_handle_cmd_packaged() Arun Menon
2025-08-05 18:25 ` [PATCH v9 07/27] migration: push Error **errp into qemu_loadvm_state() Arun Menon
2025-08-06 5:17 ` Akihiko Odaki
2025-08-07 6:07 ` Arun Menon [this message]
2025-08-06 7:24 ` Marc-André Lureau
2025-08-05 18:25 ` [PATCH v9 08/27] migration: push Error **errp into qemu_load_device_state() Arun Menon
2025-08-06 7:27 ` Marc-André Lureau
2025-08-05 18:25 ` [PATCH v9 09/27] migration: push Error **errp into qemu_loadvm_state_main() Arun Menon
2025-08-06 5:14 ` Akihiko Odaki
2025-08-06 7:34 ` Marc-André Lureau
2025-08-06 7:43 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 10/27] migration: push Error **errp into qemu_loadvm_section_start_full() Arun Menon
2025-08-06 7:37 ` Marc-André Lureau
2025-08-05 18:25 ` [PATCH v9 11/27] migration: push Error **errp into qemu_loadvm_section_part_end() Arun Menon
2025-08-06 7:46 ` Marc-André Lureau
2025-08-05 18:25 ` [PATCH v9 12/27] migration: Update qemu_file_get_return_path() docs and remove dead checks Arun Menon
2025-08-08 13:07 ` Fabiano Rosas
2025-08-05 18:25 ` [PATCH v9 13/27] migration: make loadvm_postcopy_handle_resume() void Arun Menon
2025-08-08 13:08 ` Fabiano Rosas
2025-08-05 18:25 ` [PATCH v9 14/27] migration: push Error **errp into ram_postcopy_incoming_init() Arun Menon
2025-08-05 18:25 ` [PATCH v9 15/27] migration: push Error **errp into loadvm_postcopy_handle_advise() Arun Menon
2025-08-05 18:25 ` [PATCH v9 16/27] migration: push Error **errp into loadvm_postcopy_handle_listen() Arun Menon
2025-08-05 18:25 ` [PATCH v9 17/27] migration: push Error **errp into loadvm_postcopy_handle_run() Arun Menon
2025-08-05 18:25 ` [PATCH v9 18/27] migration: push Error **errp into loadvm_postcopy_ram_handle_discard() Arun Menon
2025-08-06 7:54 ` Marc-André Lureau
2025-08-07 6:06 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 19/27] migration: push Error **errp into loadvm_handle_recv_bitmap() Arun Menon
2025-08-05 18:25 ` [PATCH v9 20/27] migration: push Error **errp into loadvm_process_enable_colo() Arun Menon
2025-08-06 8:07 ` Marc-André Lureau
2025-08-06 9:56 ` Arun Menon
2025-08-06 10:04 ` Marc-André Lureau
2025-08-06 10:19 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 21/27] migration: push Error **errp into loadvm_postcopy_handle_switchover_start() Arun Menon
2025-08-05 18:25 ` [PATCH v9 22/27] migration: Capture error in postcopy_ram_listen_thread() Arun Menon
2025-08-08 13:27 ` Fabiano Rosas
2025-08-05 18:25 ` [PATCH v9 23/27] migration: Refactor vmstate_save_state_v() function Arun Menon
2025-08-06 5:10 ` Akihiko Odaki
2025-08-06 8:19 ` Marc-André Lureau
2025-08-06 9:45 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 24/27] migration: Propagate last encountered error in " Arun Menon
2025-08-06 5:24 ` Akihiko Odaki
2025-08-07 6:07 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 25/27] migration: Remove error variant of vmstate_save_state() function Arun Menon
2025-08-06 8:28 ` Marc-André Lureau
2025-08-06 9:46 ` Arun Menon
2025-08-06 10:01 ` Marc-André Lureau
2025-08-06 10:30 ` Arun Menon
2025-08-06 11:16 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 26/27] migration: Add error-parameterized function variants in VMSD struct Arun Menon
2025-08-06 5:45 ` Akihiko Odaki
2025-08-06 7:27 ` Arun Menon
2025-08-05 18:25 ` [PATCH v9 27/27] 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=aJRCjLGbSFzWyy2C@armenon-kvm.bengluru.csb \
--to=armenon@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=clg@redhat.com \
--cc=cohuck@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.