From nobody Wed May 8 00:31:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537919514331517.3116909898342; Tue, 25 Sep 2018 16:51:54 -0700 (PDT) Received: from localhost ([::1]:55726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x7L-0000ZX-Dn for importer@patchew.org; Tue, 25 Sep 2018 19:51:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x5G-0007jz-D1 for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4x5F-0007lo-GE for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g4x59-0007f8-Lu; Tue, 25 Sep 2018 19:49:31 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7AFB88315; Tue, 25 Sep 2018 23:49:30 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-171.bos.redhat.com [10.18.17.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00061D67C9; Tue, 25 Sep 2018 23:49:29 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 25 Sep 2018 19:49:20 -0400 Message-Id: <20180925234924.14338-2-jsnow@redhat.com> In-Reply-To: <20180925234924.14338-1-jsnow@redhat.com> References: <20180925234924.14338-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 25 Sep 2018 23:49:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 1/5] block/dirty-bitmaps: add user_modifiable status checker X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, Fam Zheng , Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of both frozen and qmp_locked checks, wrap it into one check. frozen implies the bitmap is split in two (for backup), and shouldn't be modified. qmp_locked implies it's being used by another operation, like being exported over NBD. In both cases it means we shouldn't allow the user to modify it in any meaningful way. Replace any usages where we check both frozen and qmp_locked with the new check. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/dirty-bitmap.c | 6 ++++++ blockdev.c | 29 ++++++++--------------------- include/block/dirty-bitmap.h | 1 + 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 8ac933cf1c..fc10543ab0 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -176,6 +176,12 @@ bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap) return bitmap->successor; } =20 +/* Both conditions disallow user-modification via QMP. */ +bool bdrv_dirty_bitmap_user_modifiable(BdrvDirtyBitmap *bitmap) { + return !(bdrv_dirty_bitmap_frozen(bitmap) || + bdrv_dirty_bitmap_qmp_locked(bitmap)); +} + void bdrv_dirty_bitmap_set_qmp_locked(BdrvDirtyBitmap *bitmap, bool qmp_lo= cked) { qemu_mutex_lock(bitmap->mutex); diff --git a/blockdev.c b/blockdev.c index 670ae5bbde..dedcebb0fa 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2009,11 +2009,8 @@ static void block_dirty_bitmap_clear_prepare(BlkActi= onState *common, return; } =20 - if (bdrv_dirty_bitmap_frozen(state->bitmap)) { - error_setg(errp, "Cannot modify a frozen bitmap"); - return; - } else if (bdrv_dirty_bitmap_qmp_locked(state->bitmap)) { - error_setg(errp, "Cannot modify a locked bitmap"); + if (!bdrv_dirty_bitmap_user_modifiable(state->bitmap)) { + error_setg(errp, "Cannot modify a bitmap in-use by another operati= on"); return; } else if (!bdrv_dirty_bitmap_enabled(state->bitmap)) { error_setg(errp, "Cannot clear a disabled bitmap"); @@ -2882,15 +2879,10 @@ void qmp_block_dirty_bitmap_remove(const char *node= , const char *name, return; } =20 - if (bdrv_dirty_bitmap_frozen(bitmap)) { + if (!bdrv_dirty_bitmap_user_modifiable(bitmap)) { error_setg(errp, - "Bitmap '%s' is currently frozen and cannot be removed", - name); - return; - } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) { - error_setg(errp, - "Bitmap '%s' is currently locked and cannot be removed", - name); + "Bitmap '%s' is currently in-use by another operation a= nd" + " cannot be removed", name); return; } =20 @@ -2920,15 +2912,10 @@ void qmp_block_dirty_bitmap_clear(const char *node,= const char *name, return; } =20 - if (bdrv_dirty_bitmap_frozen(bitmap)) { + if (!bdrv_dirty_bitmap_user_modifiable(bitmap)) { error_setg(errp, - "Bitmap '%s' is currently frozen and cannot be modified= ", - name); - return; - } else if (bdrv_dirty_bitmap_qmp_locked(bitmap)) { - error_setg(errp, - "Bitmap '%s' is currently locked and cannot be modified= ", - name); + "Bitmap '%s' is currently in-use by another operation" + " and cannot be cleared", name); return; } else if (!bdrv_dirty_bitmap_enabled(bitmap)) { error_setg(errp, diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 201ff7f20b..92cf7e39d2 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -94,6 +94,7 @@ bool bdrv_has_readonly_bitmaps(BlockDriverState *bs); bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap); bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap); bool bdrv_dirty_bitmap_qmp_locked(BdrvDirtyBitmap *bitmap); +bool bdrv_dirty_bitmap_user_modifiable(BdrvDirtyBitmap *bitmap); bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs); BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs, BdrvDirtyBitmap *bitmap); --=20 2.14.4 From nobody Wed May 8 00:31:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537919514400979.5643760899126; Tue, 25 Sep 2018 16:51:54 -0700 (PDT) Received: from localhost ([::1]:55725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x7H-0000Vt-C1 for importer@patchew.org; Tue, 25 Sep 2018 19:51:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x5F-0007ju-S0 for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4x5F-0007lH-6Q for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48742) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g4x5A-0007gH-NW; Tue, 25 Sep 2018 19:49:32 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BAA030820C2; Tue, 25 Sep 2018 23:49:32 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-171.bos.redhat.com [10.18.17.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1496BD67C9; Tue, 25 Sep 2018 23:49:31 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 25 Sep 2018 19:49:21 -0400 Message-Id: <20180925234924.14338-3-jsnow@redhat.com> In-Reply-To: <20180925234924.14338-1-jsnow@redhat.com> References: <20180925234924.14338-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 25 Sep 2018 23:49:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 2/5] block/dirty-bitmaps: fix merge permissions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, Fam Zheng , Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We wish to prohibit merging to read-only bitmaps and frozen bitmaps, but "disabled" bitmaps only preclude their recording of live, new information. It does not prohibit them from manual writes at the behest of the user, as is the case for merge operations. Allow the merge to "disabled" bitmaps, and prohibit merging to "locked" ones. Reported-by: Eric Blake Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/dirty-bitmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index fc10543ab0..53b7d282c4 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -806,9 +806,9 @@ void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, con= st BdrvDirtyBitmap *src, =20 qemu_mutex_lock(dest->mutex); =20 - if (bdrv_dirty_bitmap_frozen(dest)) { - error_setg(errp, "Bitmap '%s' is frozen and cannot be modified", - dest->name); + if (!bdrv_dirty_bitmap_user_modifiable(dest)) { + error_setg(errp, "Bitmap '%s' is currently in-use by another" + " operation and cannot be modified", dest->name); goto out; } =20 --=20 2.14.4 From nobody Wed May 8 00:31:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537919546981341.13364010894134; Tue, 25 Sep 2018 16:52:26 -0700 (PDT) Received: from localhost ([::1]:55728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x7u-000102-Ki for importer@patchew.org; Tue, 25 Sep 2018 19:52:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x5G-0007jw-3O for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4x5F-0007lZ-BZ for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g4x5B-0007hG-Pc; Tue, 25 Sep 2018 19:49:33 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2082988304; Tue, 25 Sep 2018 23:49:33 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-171.bos.redhat.com [10.18.17.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29B97D67C9; Tue, 25 Sep 2018 23:49:32 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 25 Sep 2018 19:49:22 -0400 Message-Id: <20180925234924.14338-4-jsnow@redhat.com> In-Reply-To: <20180925234924.14338-1-jsnow@redhat.com> References: <20180925234924.14338-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 25 Sep 2018 23:49:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 3/5] block/dirty-bitmaps: allow clear on disabled bitmaps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, Fam Zheng , Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Similarly to merge, it's OK to allow clear operations on disabled bitmaps, as this condition only means that they are not recording new writes. We are free to clear it if the user requests it. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/dirty-bitmap.c | 1 - blockdev.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 53b7d282c4..ff4a86cea6 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -625,7 +625,6 @@ void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap, =20 void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out) { - assert(bdrv_dirty_bitmap_enabled(bitmap)); assert(!bdrv_dirty_bitmap_readonly(bitmap)); bdrv_dirty_bitmap_lock(bitmap); if (!out) { diff --git a/blockdev.c b/blockdev.c index dedcebb0fa..e178aae178 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2012,9 +2012,6 @@ static void block_dirty_bitmap_clear_prepare(BlkActio= nState *common, if (!bdrv_dirty_bitmap_user_modifiable(state->bitmap)) { error_setg(errp, "Cannot modify a bitmap in-use by another operati= on"); return; - } else if (!bdrv_dirty_bitmap_enabled(state->bitmap)) { - error_setg(errp, "Cannot clear a disabled bitmap"); - return; } else if (bdrv_dirty_bitmap_readonly(state->bitmap)) { error_setg(errp, "Cannot clear a readonly bitmap"); return; @@ -2917,11 +2914,6 @@ void qmp_block_dirty_bitmap_clear(const char *node, = const char *name, "Bitmap '%s' is currently in-use by another operation" " and cannot be cleared", name); return; - } else if (!bdrv_dirty_bitmap_enabled(bitmap)) { - error_setg(errp, - "Bitmap '%s' is currently disabled and cannot be cleare= d", - name); - return; } else if (bdrv_dirty_bitmap_readonly(bitmap)) { error_setg(errp, "Bitmap '%s' is readonly and cannot be cleared", = name); return; --=20 2.14.4 From nobody Wed May 8 00:31:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15379196270201007.451411693754; Tue, 25 Sep 2018 16:53:47 -0700 (PDT) Received: from localhost ([::1]:55736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x9G-00035q-2u for importer@patchew.org; Tue, 25 Sep 2018 19:53:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x5G-0007jy-5r for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4x5F-0007lf-CQ for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g4x5C-0007iF-Rx; Tue, 25 Sep 2018 19:49:34 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 377183082131; Tue, 25 Sep 2018 23:49:34 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-171.bos.redhat.com [10.18.17.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40E6DD6BF8; Tue, 25 Sep 2018 23:49:33 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 25 Sep 2018 19:49:23 -0400 Message-Id: <20180925234924.14338-5-jsnow@redhat.com> In-Reply-To: <20180925234924.14338-1-jsnow@redhat.com> References: <20180925234924.14338-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 25 Sep 2018 23:49:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 4/5] block/dirty-bitmaps: prohibit enable/disable on locked/frozen bitmaps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, Fam Zheng , Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We're not being consistent about this. If it's in use by an operation, the user should not be able to change the behavior of that bitmap. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index e178aae178..751e153557 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2058,6 +2058,13 @@ static void block_dirty_bitmap_enable_prepare(BlkAct= ionState *common, return; } =20 + if (!bdrv_dirty_bitmap_user_modifiable(state->bitmap)) { + error_setg(errp, + "Bitmap '%s' is currently in-use by another operation" + " and cannot be enabled", action->name); + return; + } + state->was_enabled =3D bdrv_dirty_bitmap_enabled(state->bitmap); bdrv_enable_dirty_bitmap(state->bitmap); } @@ -2092,6 +2099,13 @@ static void block_dirty_bitmap_disable_prepare(BlkAc= tionState *common, return; } =20 + if (!bdrv_dirty_bitmap_user_modifiable(state->bitmap)) { + error_setg(errp, + "Bitmap '%s' is currently in-use by another operation" + " and cannot be disabled", action->name); + return; + } + state->was_enabled =3D bdrv_dirty_bitmap_enabled(state->bitmap); bdrv_disable_dirty_bitmap(state->bitmap); } @@ -2933,10 +2947,10 @@ void qmp_x_block_dirty_bitmap_enable(const char *no= de, const char *name, return; } =20 - if (bdrv_dirty_bitmap_frozen(bitmap)) { + if (!bdrv_dirty_bitmap_user_modifiable(bitmap)) { error_setg(errp, - "Bitmap '%s' is currently frozen and cannot be enabled", - name); + "Bitmap '%s' is currently in-use by another operation" + " and cannot be enabled", name); return; } =20 @@ -2954,10 +2968,10 @@ void qmp_x_block_dirty_bitmap_disable(const char *n= ode, const char *name, return; } =20 - if (bdrv_dirty_bitmap_frozen(bitmap)) { + if (!bdrv_dirty_bitmap_user_modifiable(bitmap)) { error_setg(errp, - "Bitmap '%s' is currently frozen and cannot be disabled= ", - name); + "Bitmap '%s' is currently in-use by another operation" + " and cannot be disabled", name); return; } =20 --=20 2.14.4 From nobody Wed May 8 00:31:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537919698143101.7330857773527; Tue, 25 Sep 2018 16:54:58 -0700 (PDT) Received: from localhost ([::1]:55739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4xAP-0003hS-4t for importer@patchew.org; Tue, 25 Sep 2018 19:54:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4x5G-0007k8-Mm for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4x5F-0007mR-Vw for qemu-devel@nongnu.org; Tue, 25 Sep 2018 19:49:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52614) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g4x5D-0007jF-Um; Tue, 25 Sep 2018 19:49:36 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ABA1C025D12; Tue, 25 Sep 2018 23:49:35 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-171.bos.redhat.com [10.18.17.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5699CD67C9; Tue, 25 Sep 2018 23:49:34 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 25 Sep 2018 19:49:24 -0400 Message-Id: <20180925234924.14338-6-jsnow@redhat.com> In-Reply-To: <20180925234924.14338-1-jsnow@redhat.com> References: <20180925234924.14338-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 25 Sep 2018 23:49:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 5/5] block/backup: prohibit backup from using in-use bitmaps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , vsementsov@virtuozzo.com, Fam Zheng , Markus Armbruster , Max Reitz , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the bitmap is locked, we shouldn't touch it. Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 751e153557..c998336a43 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3512,10 +3512,10 @@ static BlockJob *do_drive_backup(DriveBackup *backu= p, JobTxn *txn, bdrv_unref(target_bs); goto out; } - if (bdrv_dirty_bitmap_qmp_locked(bmap)) { + if (!bdrv_dirty_bitmap_user_modifiable(bmap)) { error_setg(errp, - "Bitmap '%s' is currently locked and cannot be used= for " - "backup", backup->bitmap); + "Bitmap '%s' is currently in-use by another operati= on" + " and cannot be used for backup", backup->bitmap); goto out; } } @@ -3620,10 +3620,10 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup= , JobTxn *txn, error_setg(errp, "Bitmap '%s' could not be found", backup->bit= map); goto out; } - if (bdrv_dirty_bitmap_qmp_locked(bmap)) { + if (!bdrv_dirty_bitmap_user_modifiable(bmap)) { error_setg(errp, - "Bitmap '%s' is currently locked and cannot be used= for " - "backup", backup->bitmap); + "Bitmap '%s' is currently in-use by another operati= on" + " and cannot be used for backup", backup->bitmap); goto out; } } --=20 2.14.4