All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Fam Zheng <fam@euphon.net>, Peter Xu <peterx@redhat.com>,
	Fabiano Rosas <farosas@suse.de>
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
	"Avihai Horon" <avihaih@nvidia.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Prasad Pandit" <pjp@fedoraproject.org>,
	"Cédric Le Goater" <clg@redhat.com>,
	qemu-block@nongnu.org
Subject: [PATCH for-9.1 v5 03/14] migration: Always report an error in block_save_setup()
Date: Wed, 20 Mar 2024 07:48:59 +0100	[thread overview]
Message-ID: <20240320064911.545001-4-clg@redhat.com> (raw)
In-Reply-To: <20240320064911.545001-1-clg@redhat.com>

This will prepare ground for future changes adding an Error** argument
to the save_setup() handler. We need to make sure that on failure,
block_save_setup() always sets a new error.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---

 Changes in v5:

 - Rebased on 2e128776dc56 ("migration: Skip only empty block devices")

 migration/block.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/migration/block.c b/migration/block.c
index 2b9054889ad2ba739828594c50cf047703757e96..f8a11beb37dac3df5c2cc654db6440509d1181ea 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -367,7 +367,7 @@ static void unset_dirty_tracking(void)
     }
 }
 
-static int init_blk_migration(QEMUFile *f)
+static int init_blk_migration(QEMUFile *f, Error **errp)
 {
     BlockDriverState *bs;
     BlkMigDevState *bmds;
@@ -378,7 +378,6 @@ static int init_blk_migration(QEMUFile *f)
         BlkMigDevState *bmds;
         BlockDriverState *bs;
     } *bmds_bs;
-    Error *local_err = NULL;
     int ret;
 
     GRAPH_RDLOCK_GUARD_MAINLOOP();
@@ -406,6 +405,8 @@ static int init_blk_migration(QEMUFile *f)
             continue;
         }
         if (sectors < 0) {
+            error_setg(errp, "Error getting length of block device %s",
+                       bdrv_get_device_name(bs));
             ret = sectors;
             bdrv_next_cleanup(&it);
             goto out;
@@ -442,9 +443,8 @@ static int init_blk_migration(QEMUFile *f)
         bs = bmds_bs[i].bs;
 
         if (bmds) {
-            ret = blk_insert_bs(bmds->blk, bs, &local_err);
+            ret = blk_insert_bs(bmds->blk, bs, errp);
             if (ret < 0) {
-                error_report_err(local_err);
                 goto out;
             }
 
@@ -714,6 +714,7 @@ static void block_migration_cleanup(void *opaque)
 static int block_save_setup(QEMUFile *f, void *opaque)
 {
     int ret;
+    Error *local_err = NULL;
 
     trace_migration_block_save("setup", block_mig_state.submitted,
                                block_mig_state.transferred);
@@ -721,18 +722,27 @@ static int block_save_setup(QEMUFile *f, void *opaque)
     warn_report("block migration is deprecated;"
                 " use blockdev-mirror with NBD instead");
 
-    ret = init_blk_migration(f);
+    ret = init_blk_migration(f, &local_err);
     if (ret < 0) {
+        error_report_err(local_err);
         return ret;
     }
 
     /* start track dirty blocks */
     ret = set_dirty_tracking();
     if (ret) {
+        error_setg_errno(&local_err, -ret,
+                         "Failed to start block dirty tracking");
+        error_report_err(local_err);
         return ret;
     }
 
     ret = flush_blks(f);
+    if (ret) {
+        error_setg_errno(&local_err, -ret, "Flushing block failed");
+        error_report_err(local_err);
+        return ret;
+    }
     blk_mig_reset_dirty_cursor();
     qemu_put_be64(f, BLK_MIG_FLAG_EOS);
 
-- 
2.44.0



  parent reply	other threads:[~2024-03-20  6:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  6:48 [PATCH for-9.1 v5 00/14] migration: Improve error reporting Cédric Le Goater
2024-03-20  6:48 ` [PATCH for-9.1 v5 01/14] s390/stattrib: Add Error** argument to set_migrationmode() handler Cédric Le Goater
2024-03-20  6:48 ` [PATCH for-9.1 v5 02/14] vfio: Always report an error in vfio_save_setup() Cédric Le Goater
2024-03-20  6:48 ` Cédric Le Goater [this message]
2024-03-20  6:49 ` [PATCH for-9.1 v5 04/14] migration: Always report an error in ram_save_setup() Cédric Le Goater
2024-03-20  6:49 ` [PATCH for-9.1 v5 05/14] migration: Add Error** argument to vmstate_save() Cédric Le Goater
2024-03-20  6:49 ` [PATCH for-9.1 v5 06/14] migration: Add Error** argument to qemu_savevm_state_setup() Cédric Le Goater
2024-03-20 14:29   ` Peter Xu
2024-03-20  6:49 ` [PATCH for-9.1 v5 07/14] migration: Add Error** argument to .save_setup() handler Cédric Le Goater
2024-03-29  9:32   ` Vladimir Sementsov-Ogievskiy
2024-03-29 10:53     ` Cédric Le Goater
2024-03-29 11:32       ` Vladimir Sementsov-Ogievskiy
2024-03-20  6:49 ` [PATCH for-9.1 v5 08/14] migration: Add Error** argument to .load_setup() handler Cédric Le Goater
2024-03-20  8:02   ` Markus Armbruster
2024-03-20  8:41     ` Cédric Le Goater
2024-03-20  6:49 ` [PATCH for-9.1 v5 09/14] memory: Add Error** argument to .log_global_start() handler Cédric Le Goater
2024-03-20 14:42   ` Peter Xu
2024-03-20 16:15     ` Cédric Le Goater
2024-03-20 17:39       ` Peter Xu
2024-03-20  6:49 ` [PATCH for-9.1 v5 10/14] migration: Introduce ram_bitmaps_destroy() Cédric Le Goater
2024-03-20 14:43   ` Peter Xu
2024-03-20 14:49   ` Fabiano Rosas
2024-03-20  6:49 ` [PATCH for-9.1 v5 11/14] memory: Add Error** argument to the global_dirty_log routines Cédric Le Goater
2024-03-20 14:53   ` Fabiano Rosas
2024-03-20 15:18   ` Peter Xu
2024-03-22  1:55     ` Yong Huang
2024-03-22 13:41       ` Peter Xu
2024-03-20  6:49 ` [PATCH for-9.1 v5 12/14] migration: Add Error** argument to ram_state_init() Cédric Le Goater
2024-03-20 14:59   ` Fabiano Rosas
2024-03-20  6:49 ` [PATCH for-9.1 v5 13/14] migration: Add Error** argument to xbzrle_init() Cédric Le Goater
2024-03-20 15:01   ` Fabiano Rosas
2024-03-20  6:49 ` [PATCH for-9.1 v5 14/14] migration: Modify ram_init_bitmaps() to report dirty tracking errors Cédric Le Goater
2024-03-20 15:05   ` Fabiano Rosas
2024-03-22 13:42 ` [PATCH for-9.1 v5 00/14] migration: Improve error reporting Peter Xu

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=20240320064911.545001-4-clg@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=avihaih@nvidia.com \
    --cc=fam@euphon.net \
    --cc=farosas@suse.de \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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.