From nobody Sat May 18 06:50:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1711709843; cv=none; d=zohomail.com; s=zohoarc; b=lmmReE7On/rl/GC/zCvhccfawK4kvlL9sUbxtWZAI7XkfQhGQ6GgWXJzasWJgsroritASfYMyfXwO/Lowp+BoSpjywVaDRYa9hBSxhh+f3ILf/nSk7g6XP5/A/rRlgwTcMqV8pR6yNbAiowNWApnCRZN8AFSNy1WMq3JA9U4IGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711709843; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZYIAOBsQkX7kNMyCajWSK7qclNBeZ6tqd40Neilx0oU=; b=WvJsZjZA49ysnGY6xcW1iElCuPA3EW7IQDnO9ubBYJr0gr5d0CBxRwjQxGN82D+490E1I2CD+nAZX/LhcD6RVlZScwijr/e8D3bgnpOOx84aq6PFnyfWaBhqqMIMhVculU0ivfOo3Zt1IbLbCVTDX7ys3s2XDOVBdOcW9IzvKO8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171170984335940.92080811575033; Fri, 29 Mar 2024 03:57:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rq9uw-00067w-QI; Fri, 29 Mar 2024 06:57:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq9uu-00067g-Mh for qemu-devel@nongnu.org; Fri, 29 Mar 2024 06:57:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq9us-0003be-Uh for qemu-devel@nongnu.org; Fri, 29 Mar 2024 06:57:00 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-347-2nYWGSnGNTaVy8UIT-N91A-1; Fri, 29 Mar 2024 06:56:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BBB6800266; Fri, 29 Mar 2024 10:56:54 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CADC111E3F3; Fri, 29 Mar 2024 10:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711709818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZYIAOBsQkX7kNMyCajWSK7qclNBeZ6tqd40Neilx0oU=; b=ep1NtgeXiI5TXo+wNeijEn8ovUlEU1BvRVCg6QVc5yARpZ3wlLjNu38sjKdYd8cRd027T0 +ekYmoRSSw7TD96scuQuv9tThjUhJAk902eoJ7gIx9bZzBFJFixlN8kHK+tjGP68cwNqUD /bku0GcW8MfpKBbwTZacomNMd8Wqc+c= X-MC-Unique: 2nYWGSnGNTaVy8UIT-N91A-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Stefan Hajnoczi , Fam Zheng , Peter Xu , Fabiano Rosas Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH for-9.1] migration: Add Error** argument to add_bitmaps_to_list() Date: Fri, 29 Mar 2024 11:56:27 +0100 Message-ID: <20240329105627.311227-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.08, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1711709845289100001 This allows to report more precise errors in the migration handler dirty_bitmap_save_setup(). Suggested-by Vladimir Sementsov-Ogievskiy =20 Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Vladimir Sementsov-Ogievskiy Suggested-by Vladimir Sementsov-Ogievskiy =20 --- To apply on top of :=20 https://lore.kernel.org/qemu-devel/20240320064911.545001-1-clg@redhat.com/ =20 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 542a8c297b329abc30d1b3a205d29340fa59a961..a7d55048c23505fde565ca784ce= c3c917dca37e5 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) =20 /* 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 =3D NULL; =20 /* 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, BlockDr= iverState *bs, bitmap_name =3D bdrv_dirty_bitmap_name(bitmap); =20 if (!bs_name || strcmp(bs_name, "") =3D=3D 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; } =20 @@ -525,9 +525,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, } =20 if (node_alias[0] =3D=3D '#') { - 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; } =20 @@ -538,8 +538,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, continue; } =20 - if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, &local_er= r)) { - error_report_err(local_err); + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { return -1; } =20 @@ -558,9 +557,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *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 =3D bitmap_name; @@ -599,7 +598,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, } =20 /* 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) } =20 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; } =20 - 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 =3D &((DBMState *)opaque)->save; SaveBitmapState *dbms =3D NULL; =20 - 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; } =20 --=20 2.44.0