qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Arun Menon <armenon@redhat.com>, qemu-devel@nongnu.org
Cc: "Peter Xu" <peterx@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>,
	"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>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Arun Menon" <armenon@redhat.com>
Subject: Re: [PATCH v11 07/27] migration: push Error **errp into qemu_loadvm_state()
Date: Fri, 15 Aug 2025 15:55:19 -0300	[thread overview]
Message-ID: <87a540za7c.fsf@suse.de> (raw)
In-Reply-To: <20250813-propagate_tpm_error-v11-7-b470a374b42d@redhat.com>

Arun Menon <armenon@redhat.com> writes:

> 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.
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Arun Menon <armenon@redhat.com>
> ---
>  migration/migration.c |  9 +++++----
>  migration/savevm.c    | 31 +++++++++++++++++++------------
>  migration/savevm.h    |  2 +-
>  3 files changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 10c216d25dec01f206eacad2edd24d21f00e614c..c6768d88f45c870c7fad9b9957300766ff69effc 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,13 +925,13 @@ 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);
>  
>      migration_incoming_state_destroy();
>  
>      if (mis->exit_on_error) {
>          WITH_QEMU_LOCK_GUARD(&s->error_mutex) {
> -            error_report_err(s->error);
> +            error_free(s->error);
>              s->error = NULL;
>          }
>  
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 4f8c40e284a1b199d12f3c7dd61212b3e0e057c9..05dc392bdf4e19f340bc72bf66ba0543d56868a5 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -3159,28 +3159,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;
>      }
>  
> @@ -3191,6 +3187,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);
> @@ -3208,8 +3207,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");

The stream error is the one below. Just keep a generic message here
because we'll propagate the error from qemu_loadvm_state_main() later in
the series.

>          } else {
>              ret = qemu_file_get_error(f);
> +            if (ret < 0) {
> +                error_setg(errp, "Error while loading vmstate : %d", ret);

+ stream error:

> +            }
>          }
>      }
>      /*
> @@ -3474,6 +3479,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;
> @@ -3495,10 +3501,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();
>  }
> @@ -3506,6 +3512,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;
> @@ -3569,13 +3576,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);

This message will get redundant, leave it out.

>          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);


  parent reply	other threads:[~2025-08-15 18:56 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250813-propagate_tpm_error-v11-0-b470a374b42d@redhat.com>
     [not found] ` <20250813-propagate_tpm_error-v11-1-b470a374b42d@redhat.com>
2025-08-15 14:44   ` [PATCH v11 01/27] migration: push Error **errp into vmstate_subsection_load() Fabiano Rosas
2025-08-15 20:06     ` Fabiano Rosas
2025-08-20 17:43       ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-2-b470a374b42d@redhat.com>
2025-08-15 15:41   ` [PATCH v11 02/27] migration: push Error **errp into vmstate_load_state() Fabiano Rosas
2025-08-20  8:12     ` Arun Menon
2025-08-20 15:24       ` Fabiano Rosas
2025-08-20 17:07         ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-3-b470a374b42d@redhat.com>
2025-08-15 15:58   ` [PATCH v11 03/27] migration: push Error **errp into qemu_loadvm_state_header() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-4-b470a374b42d@redhat.com>
2025-08-15 16:41   ` [PATCH v11 04/27] migration: push Error **errp into vmstate_load() Fabiano Rosas
2025-08-20 17:31     ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-5-b470a374b42d@redhat.com>
2025-08-15 18:35   ` [PATCH v11 05/27] migration: push Error **errp into loadvm_process_command() Fabiano Rosas
2025-08-20  9:08     ` Arun Menon
2025-08-20 13:42     ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-6-b470a374b42d@redhat.com>
2025-08-15 18:39   ` [PATCH v11 06/27] migration: push Error **errp into loadvm_handle_cmd_packaged() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-7-b470a374b42d@redhat.com>
2025-08-15 18:55   ` Fabiano Rosas [this message]
2025-08-20 17:36     ` [PATCH v11 07/27] migration: push Error **errp into qemu_loadvm_state() Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-8-b470a374b42d@redhat.com>
2025-08-15 18:58   ` [PATCH v11 08/27] migration: push Error **errp into qemu_load_device_state() Fabiano Rosas
2025-08-20 17:36     ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-9-b470a374b42d@redhat.com>
2025-08-15 19:23   ` [PATCH v11 09/27] migration: push Error **errp into qemu_loadvm_state_main() Fabiano Rosas
2025-08-20 17:27     ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-10-b470a374b42d@redhat.com>
2025-08-15 19:29   ` [PATCH v11 10/27] migration: push Error **errp into qemu_loadvm_section_start_full() Fabiano Rosas
2025-08-20 17:35     ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-11-b470a374b42d@redhat.com>
2025-08-15 19:35   ` [PATCH v11 11/27] migration: push Error **errp into qemu_loadvm_section_part_end() Fabiano Rosas
2025-08-20 17:34     ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-14-b470a374b42d@redhat.com>
2025-08-15 19:37   ` [PATCH v11 14/27] migration: push Error **errp into ram_postcopy_incoming_init() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-15-b470a374b42d@redhat.com>
2025-08-15 19:40   ` [PATCH v11 15/27] migration: push Error **errp into loadvm_postcopy_handle_advise() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-16-b470a374b42d@redhat.com>
2025-08-15 19:41   ` [PATCH v11 16/27] migration: push Error **errp into loadvm_postcopy_handle_listen() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-17-b470a374b42d@redhat.com>
2025-08-15 19:41   ` [PATCH v11 17/27] migration: push Error **errp into loadvm_postcopy_handle_run() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-18-b470a374b42d@redhat.com>
2025-08-15 19:42   ` [PATCH v11 18/27] migration: push Error **errp into loadvm_postcopy_ram_handle_discard() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-19-b470a374b42d@redhat.com>
2025-08-15 19:51   ` [PATCH v11 19/27] migration: push Error **errp into loadvm_handle_recv_bitmap() Fabiano Rosas
2025-08-20 17:32     ` Arun Menon
     [not found] ` <20250813-propagate_tpm_error-v11-20-b470a374b42d@redhat.com>
2025-08-15 19:51   ` [PATCH v11 20/27] migration: Return -1 on memory allocation failure in ram.c Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-21-b470a374b42d@redhat.com>
2025-08-15 19:53   ` [PATCH v11 21/27] migration: push Error **errp into loadvm_process_enable_colo() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-22-b470a374b42d@redhat.com>
2025-08-15 19:53   ` [PATCH v11 22/27] migration: push Error **errp into loadvm_postcopy_handle_switchover_start() Fabiano Rosas
     [not found] ` <20250813-propagate_tpm_error-v11-23-b470a374b42d@redhat.com>
2025-08-15 19:57   ` [PATCH v11 23/27] migration: Capture error in postcopy_ram_listen_thread() Fabiano Rosas
2025-08-20 17:37     ` 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=87a540za7c.fsf@suse.de \
    --to=farosas@suse.de \
    --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=david@redhat.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=fam@euphon.net \
    --cc=farman@linux.ibm.com \
    --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=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --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).