qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: peterx@redhat.com, "Prasad Pandit" <ppandit@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 24/26] migration: Add Error** argument to add_bitmaps_to_list()
Date: Tue, 23 Apr 2024 18:38:11 -0400	[thread overview]
Message-ID: <20240423223813.3237060-25-peterx@redhat.com> (raw)
In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com>

From: Cédric Le Goater <clg@redhat.com>

This allows to report more precise errors in the migration handler
dirty_bitmap_save_setup().

Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Link: https://lore.kernel.org/r/20240329105627.311227-1-clg@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/block-dirty-bitmap.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index 542a8c297b..a7d55048c2 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -481,13 +481,13 @@ static void dirty_bitmap_do_save_cleanup(DBMSaveState *s)
 
 /* Called with the BQL taken. */
 static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
-                               const char *bs_name, GHashTable *alias_map)
+                               const char *bs_name, GHashTable *alias_map,
+                               Error **errp)
 {
     BdrvDirtyBitmap *bitmap;
     SaveBitmapState *dbms;
     GHashTable *bitmap_aliases;
     const char *node_alias, *bitmap_name, *bitmap_alias;
-    Error *local_err = NULL;
 
     /* When an alias map is given, @bs_name must be @bs's node name */
     assert(!alias_map || !strcmp(bs_name, bdrv_get_node_name(bs)));
@@ -504,8 +504,8 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
     bitmap_name = bdrv_dirty_bitmap_name(bitmap);
 
     if (!bs_name || strcmp(bs_name, "") == 0) {
-        error_report("Bitmap '%s' in unnamed node can't be migrated",
-                     bitmap_name);
+        error_setg(errp, "Bitmap '%s' in unnamed node can't be migrated",
+                   bitmap_name);
         return -1;
     }
 
@@ -525,9 +525,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
     }
 
     if (node_alias[0] == '#') {
-        error_report("Bitmap '%s' in a node with auto-generated "
-                     "name '%s' can't be migrated",
-                     bitmap_name, node_alias);
+        error_setg(errp, "Bitmap '%s' in a node with auto-generated "
+                   "name '%s' can't be migrated",
+                   bitmap_name, node_alias);
         return -1;
     }
 
@@ -538,8 +538,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
             continue;
         }
 
-        if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, &local_err)) {
-            error_report_err(local_err);
+        if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
             return -1;
         }
 
@@ -558,9 +557,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
             }
         } else {
             if (strlen(bitmap_name) > UINT8_MAX) {
-                error_report("Cannot migrate bitmap '%s' on node '%s': "
-                             "Name is longer than %u bytes",
-                             bitmap_name, bs_name, UINT8_MAX);
+                error_setg(errp, "Cannot migrate bitmap '%s' on node '%s': "
+                           "Name is longer than %u bytes",
+                           bitmap_name, bs_name, UINT8_MAX);
                 return -1;
             }
             bitmap_alias = bitmap_name;
@@ -599,7 +598,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
 }
 
 /* Called with the BQL taken. */
-static int init_dirty_bitmap_migration(DBMSaveState *s)
+static int init_dirty_bitmap_migration(DBMSaveState *s, Error **errp)
 {
     BlockDriverState *bs;
     SaveBitmapState *dbms;
@@ -643,7 +642,7 @@ static int init_dirty_bitmap_migration(DBMSaveState *s)
             }
 
             if (bs && bs->drv && !bs->drv->is_filter) {
-                if (add_bitmaps_to_list(s, bs, name, NULL)) {
+                if (add_bitmaps_to_list(s, bs, name, NULL, errp)) {
                     goto fail;
                 }
                 g_hash_table_add(handled_by_blk, bs);
@@ -656,7 +655,8 @@ static int init_dirty_bitmap_migration(DBMSaveState *s)
             continue;
         }
 
-        if (add_bitmaps_to_list(s, bs, bdrv_get_node_name(bs), alias_map)) {
+        if (add_bitmaps_to_list(s, bs, bdrv_get_node_name(bs), alias_map,
+                                errp)) {
             goto fail;
         }
     }
@@ -1218,9 +1218,7 @@ static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque, Error **errp)
     DBMSaveState *s = &((DBMState *)opaque)->save;
     SaveBitmapState *dbms = NULL;
 
-    if (init_dirty_bitmap_migration(s) < 0) {
-        error_setg(errp,
-                   "Failed to initialize dirty tracking bitmap for blocks");
+    if (init_dirty_bitmap_migration(s, errp) < 0) {
         return -1;
     }
 
-- 
2.44.0



  parent reply	other threads:[~2024-04-23 22:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 22:37 [PULL 00/26] Migration 20240423 patches Peter Xu
2024-04-23 22:37 ` [PULL 01/26] tests/qtest/migration: Add 'to' object into migrate_qmp() Peter Xu
2024-04-23 22:37 ` [PULL 02/26] tests/qtest/migration: Replace connect_uri and move migrate_get_socket_address inside migrate_qmp Peter Xu
2024-04-23 22:37 ` [PULL 03/26] tests/qtest/migration: Replace migrate_get_connect_uri inplace of migrate_get_socket_address Peter Xu
2024-04-23 22:37 ` [PULL 04/26] tests/qtest/migration: Add channels parameter in migrate_qmp_fail Peter Xu
2024-04-23 22:37 ` [PULL 05/26] tests/qtest/migration: Add migrate_set_ports into migrate_qmp to update migration port value Peter Xu
2024-04-23 22:37 ` [PULL 06/26] tests/qtest/migration: Add channels parameter in migrate_qmp Peter Xu
2024-04-23 22:37 ` [PULL 07/26] tests/qtest/migration: Add multifd_tcp_plain test using list of channels instead of uri Peter Xu
2024-04-23 22:37 ` [PULL 08/26] tests/qtest/migration: Add negative tests to validate migration QAPIs Peter Xu
2024-04-23 22:37 ` [PULL 09/26] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str Peter Xu
2024-04-23 22:37 ` [PULL 10/26] s390/stattrib: Add Error** argument to set_migrationmode() handler Peter Xu
2024-04-23 22:37 ` [PULL 11/26] vfio: Always report an error in vfio_save_setup() Peter Xu
2024-04-23 22:37 ` [PULL 12/26] migration: Always report an error in block_save_setup() Peter Xu
2024-04-23 22:38 ` [PULL 13/26] migration: Always report an error in ram_save_setup() Peter Xu
2024-04-23 22:38 ` [PULL 14/26] migration: Add Error** argument to vmstate_save() Peter Xu
2024-04-23 22:38 ` [PULL 15/26] migration: Add Error** argument to qemu_savevm_state_setup() Peter Xu
2024-04-23 22:38 ` [PULL 16/26] migration: Add Error** argument to .save_setup() handler Peter Xu
2024-04-23 22:38 ` [PULL 17/26] migration: Add Error** argument to .load_setup() handler Peter Xu
2024-04-23 22:38 ` [PULL 18/26] memory: Add Error** argument to .log_global_start() handler Peter Xu
2024-04-23 22:38 ` [PULL 19/26] migration: Introduce ram_bitmaps_destroy() Peter Xu
2024-04-23 22:38 ` [PULL 20/26] memory: Add Error** argument to the global_dirty_log routines Peter Xu
2024-04-23 22:38 ` [PULL 21/26] migration: Add Error** argument to ram_state_init() Peter Xu
2024-04-23 22:38 ` [PULL 22/26] migration: Add Error** argument to xbzrle_init() Peter Xu
2024-04-23 22:38 ` [PULL 23/26] migration: Modify ram_init_bitmaps() to report dirty tracking errors Peter Xu
2024-04-23 22:38 ` Peter Xu [this message]
2024-04-23 22:38 ` [PULL 25/26] migration/multifd: solve zero page causing multiple page faults Peter Xu
2024-04-23 22:38 ` [PULL 26/26] migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion `!qemu_in_coroutine()' failed Peter Xu
2024-04-24  6:50 ` [PULL 00/26] Migration 20240423 patches Richard Henderson

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=20240423223813.3237060-25-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=clg@redhat.com \
    --cc=farosas@suse.de \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /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).