From nobody Sun Feb 8 17:21:23 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1576745722; cv=none; d=zohomail.com; s=zohoarc; b=epwfgo9mxaBZxnv8hAT6ZJTAVhR67K+ce0dQ0Iury+ENjc4SaKo8s5LhOnv+Qq2HcGGL9h5AaIzZlRZaxjKGcYRt1k6s7x0OirijowLoySQpxH9RWRi0IiKHNl6rH9e/Gr6T78ERFjD3kaIRcsE6swQqHXGGT2XrECsXDtrzReM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576745722; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xGlmqhfW74JJd/QiIedRBCpZa97txxbH5jLyP3JBByM=; b=M0Tb0QbzppM4PO9yUfyXmemxxIMpUxBTyEp8R4032FM8FPr+v8Rn9b5RCrNamDEwrkuKNeYcWjni4hm9qmkcr7gYwPoQId2Cf7LlVPkH4kDKqMjGf4jf1jXlg98of+ZJmgSqk3ntfV/uI977Snh0/D3dGh+/6ujiYNwwvkd0vkw= ARC-Authentication-Results: i=1; mx.zohomail.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576745722749654.9904750685577; Thu, 19 Dec 2019 00:55:22 -0800 (PST) Received: from localhost ([::1]:37424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihrab-000473-Mm for importer@patchew.org; Thu, 19 Dec 2019 03:55:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36599) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihrWk-00071h-4l for qemu-devel@nongnu.org; Thu, 19 Dec 2019 03:51:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihrWi-00051d-N8 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 03:51:21 -0500 Received: from relay.sw.ru ([185.231.240.75]:55348) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihrWf-0004Xk-5s; Thu, 19 Dec 2019 03:51:17 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1ihrWU-0004DF-UN; Thu, 19 Dec 2019 11:51:07 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v2 2/5] migretion/block-dirty-bitmap: refactor init_dirty_bitmap_migration Date: Thu, 19 Dec 2019 11:51:03 +0300 Message-Id: <20191219085106.22309-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191219085106.22309-1-vsementsov@virtuozzo.com> References: <20191219085106.22309-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, quintela@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, stefanha@redhat.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Split out handling one bs, it is needed for the following commit, which will handle BlockBackends in separate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- migration/block-dirty-bitmap.c | 89 +++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 7eafface61..7e93718086 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -268,57 +268,66 @@ static void dirty_bitmap_mig_cleanup(void) } =20 /* Called with iothread lock taken. */ -static int init_dirty_bitmap_migration(void) +static int add_bitmaps_to_list(BlockDriverState *bs, const char *bs_name) { - BlockDriverState *bs; BdrvDirtyBitmap *bitmap; DirtyBitmapMigBitmapState *dbms; Error *local_err =3D NULL; =20 - dirty_bitmap_mig_state.bulk_completed =3D false; - dirty_bitmap_mig_state.prev_bs =3D NULL; - dirty_bitmap_mig_state.prev_bitmap =3D NULL; - dirty_bitmap_mig_state.no_bitmaps =3D false; + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { + if (!bdrv_dirty_bitmap_name(bitmap)) { + continue; + } =20 - for (bs =3D bdrv_next_all_states(NULL); bs; bs =3D bdrv_next_all_state= s(bs)) { - const char *name =3D bdrv_get_device_or_node_name(bs); + if (!bs_name || strcmp(bs_name, "") =3D=3D 0) { + error_report("Found bitmap '%s' in unnamed node %p. It can't " + "be migrated", bdrv_dirty_bitmap_name(bitmap), bs= ); + return -1; + } =20 - FOR_EACH_DIRTY_BITMAP(bs, bitmap) { - if (!bdrv_dirty_bitmap_name(bitmap)) { - continue; - } + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, &local_er= r)) { + error_report_err(local_err); + return -1; + } =20 - if (!name || strcmp(name, "") =3D=3D 0) { - error_report("Found bitmap '%s' in unnamed node %p. It can= 't " - "be migrated", bdrv_dirty_bitmap_name(bitmap)= , bs); - goto fail; - } + bdrv_ref(bs); + bdrv_dirty_bitmap_set_busy(bitmap, true); + + dbms =3D g_new0(DirtyBitmapMigBitmapState, 1); + dbms->bs =3D bs; + dbms->node_name =3D bs_name; + dbms->bitmap =3D bitmap; + dbms->total_sectors =3D bdrv_nb_sectors(bs); + dbms->sectors_per_chunk =3D CHUNK_SIZE * 8 * + bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS; + if (bdrv_dirty_bitmap_enabled(bitmap)) { + dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_ENABLED; + } + if (bdrv_dirty_bitmap_get_persistence(bitmap)) { + dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT; + } =20 - if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, - &local_err)) { - error_report_err(local_err); - goto fail; - } + QSIMPLEQ_INSERT_TAIL(&dirty_bitmap_mig_state.dbms_list, + dbms, entry); + } =20 - bdrv_ref(bs); - bdrv_dirty_bitmap_set_busy(bitmap, true); - - dbms =3D g_new0(DirtyBitmapMigBitmapState, 1); - dbms->bs =3D bs; - dbms->node_name =3D name; - dbms->bitmap =3D bitmap; - dbms->total_sectors =3D bdrv_nb_sectors(bs); - dbms->sectors_per_chunk =3D CHUNK_SIZE * 8 * - bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS; - if (bdrv_dirty_bitmap_enabled(bitmap)) { - dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_ENABLED; - } - if (bdrv_dirty_bitmap_get_persistence(bitmap)) { - dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT; - } + return 0; +} + +/* Called with iothread lock taken. */ +static int init_dirty_bitmap_migration(void) +{ + BlockDriverState *bs; + DirtyBitmapMigBitmapState *dbms; + + dirty_bitmap_mig_state.bulk_completed =3D false; + dirty_bitmap_mig_state.prev_bs =3D NULL; + dirty_bitmap_mig_state.prev_bitmap =3D NULL; + dirty_bitmap_mig_state.no_bitmaps =3D false; =20 - QSIMPLEQ_INSERT_TAIL(&dirty_bitmap_mig_state.dbms_list, - dbms, entry); + for (bs =3D bdrv_next_all_states(NULL); bs; bs =3D bdrv_next_all_state= s(bs)) { + if (add_bitmaps_to_list(bs, bdrv_get_device_or_node_name(bs))) { + goto fail; } } =20 --=20 2.21.0