From nobody Wed Nov 5 19:57:18 2025 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 1537569063405718.0957709258088; Fri, 21 Sep 2018 15:31:03 -0700 (PDT) Received: from localhost ([::1]:57625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Twt-0000lH-90 for importer@patchew.org; Fri, 21 Sep 2018 18:30:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Tv5-0008Cz-Lu for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3Tv4-00059h-Td for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46588) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3Tv2-0004zx-H4; Fri, 21 Sep 2018 18:29:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA9163082A42; Fri, 21 Sep 2018 22:28:59 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-77.rdu2.redhat.com [10.10.121.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 827A11073033; Fri, 21 Sep 2018 22:28:57 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 21 Sep 2018 18:28:42 -0400 Message-Id: <20180921222847.1012-2-jsnow@redhat.com> In-Reply-To: <20180921222847.1012-1-jsnow@redhat.com> References: <20180921222847.1012-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 21 Sep 2018 22:28:59 +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] [RFC PATCH v2 1/6] dirty-bitmaps: allow merging to 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" 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. Reported-by: Eric Blake Signed-off-by: John Snow --- block/dirty-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index c9b8a6fd52..fa7e75e0af 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -798,7 +798,7 @@ void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, con= st BdrvDirtyBitmap *src, =20 qemu_mutex_lock(dest->mutex); =20 - assert(bdrv_dirty_bitmap_enabled(dest)); + assert(!bdrv_dirty_bitmap_frozen(dest)); assert(!bdrv_dirty_bitmap_readonly(dest)); =20 if (!hbitmap_merge(dest->bitmap, src->bitmap)) { --=20 2.14.4 From nobody Wed Nov 5 19:57:18 2025 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 1537569214503451.810716780945; Fri, 21 Sep 2018 15:33:34 -0700 (PDT) Received: from localhost ([::1]:57638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3TzR-0002jj-Bg for importer@patchew.org; Fri, 21 Sep 2018 18:33:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Tv8-0008FM-4Z for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3Tv7-0005BZ-Bq for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3Tv5-00059m-EV; Fri, 21 Sep 2018 18:29:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C58AA86672; Fri, 21 Sep 2018 22:29:02 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-77.rdu2.redhat.com [10.10.121.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 627391073033; Fri, 21 Sep 2018 22:28:59 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 21 Sep 2018 18:28:43 -0400 Message-Id: <20180921222847.1012-3-jsnow@redhat.com> In-Reply-To: <20180921222847.1012-1-jsnow@redhat.com> References: <20180921222847.1012-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 21 Sep 2018 22:29:02 +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] [RFC PATCH v2 2/6] 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 --- 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 fa7e75e0af..5c8a7bbf6f 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -619,7 +619,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 72f5347df5..bb8d75c832 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2015,9 +2015,6 @@ static void block_dirty_bitmap_clear_prepare(BlkActio= nState *common, } else if (bdrv_dirty_bitmap_qmp_locked(state->bitmap)) { error_setg(errp, "Cannot modify a locked bitmap"); 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; @@ -2889,11 +2886,6 @@ void qmp_block_dirty_bitmap_clear(const char *node, = const char *name, "Bitmap '%s' is currently locked and cannot be modified= ", 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 Nov 5 19:57:18 2025 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 15375692337763.597377722119063; Fri, 21 Sep 2018 15:33:53 -0700 (PDT) Received: from localhost ([::1]:57641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Tzk-0002yD-Mv for importer@patchew.org; Fri, 21 Sep 2018 18:33:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3TvD-0008IS-Sm for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3TvD-0005KQ-6P for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51702) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3Tv8-0005CQ-DB; Fri, 21 Sep 2018 18:29:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B892C5277D; Fri, 21 Sep 2018 22:29:05 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-77.rdu2.redhat.com [10.10.121.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17CC41073033; Fri, 21 Sep 2018 22:29:02 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 21 Sep 2018 18:28:44 -0400 Message-Id: <20180921222847.1012-4-jsnow@redhat.com> In-Reply-To: <20180921222847.1012-1-jsnow@redhat.com> References: <20180921222847.1012-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 21 Sep 2018 22:29:05 +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] [RFC PATCH v2 3/6] bitmaps: prohibit merge on locked 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" Like frozen, "qmp locked" bitmaps must not be modified by the user. Signed-off-by: John Snow --- block/dirty-bitmap.c | 1 + blockdev.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 5c8a7bbf6f..216baec388 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -798,6 +798,7 @@ void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, con= st BdrvDirtyBitmap *src, qemu_mutex_lock(dest->mutex); =20 assert(!bdrv_dirty_bitmap_frozen(dest)); + assert(!bdrv_dirty_bitmap_qmp_locked(dest)); assert(!bdrv_dirty_bitmap_readonly(dest)); =20 if (!hbitmap_merge(dest->bitmap, src->bitmap)) { diff --git a/blockdev.c b/blockdev.c index bb8d75c832..b21e635c68 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2955,6 +2955,10 @@ void qmp_x_block_dirty_bitmap_merge(const char *node= , const char *dst_name, error_setg(errp, "Bitmap '%s' is readonly and cannot be modified", dst_name); return; + } else if (bdrv_dirty_bitmap_qmp_locked(dst)) { + error_setg(errp, "Bitmap '%s' is in-use by an operation " + "and cannot be modified", dst_name); + return; } =20 src =3D bdrv_find_dirty_bitmap(bs, src_name); --=20 2.14.4 From nobody Wed Nov 5 19:57:18 2025 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 1537569229507429.8489194665166; Fri, 21 Sep 2018 15:33:49 -0700 (PDT) Received: from localhost ([::1]:57640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Tzg-0002uS-BB for importer@patchew.org; Fri, 21 Sep 2018 18:33:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3TvF-0008Jz-80 for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3TvE-0005OM-79 for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3TvB-0005HZ-Bv; Fri, 21 Sep 2018 18:29:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B487132B660; Fri, 21 Sep 2018 22:29:08 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-77.rdu2.redhat.com [10.10.121.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA40110A3948; Fri, 21 Sep 2018 22:29:05 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 21 Sep 2018 18:28:45 -0400 Message-Id: <20180921222847.1012-5-jsnow@redhat.com> In-Reply-To: <20180921222847.1012-1-jsnow@redhat.com> References: <20180921222847.1012-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 21 Sep 2018 22:29:08 +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] [RFC PATCH v2 4/6] 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 --- block/dirty-bitmap.c | 9 +++++++-- blockdev.c | 34 +++++++++------------------------- include/block/dirty-bitmap.h | 1 + 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 216baec388..36c95820af 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); @@ -797,8 +803,7 @@ void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, con= st BdrvDirtyBitmap *src, =20 qemu_mutex_lock(dest->mutex); =20 - assert(!bdrv_dirty_bitmap_frozen(dest)); - assert(!bdrv_dirty_bitmap_qmp_locked(dest)); + assert(bdrv_dirty_bitmap_user_modifiable(dest)); assert(!bdrv_dirty_bitmap_readonly(dest)); =20 if (!hbitmap_merge(dest->bitmap, src->bitmap)) { diff --git a/blockdev.c b/blockdev.c index b21e635c68..070180898f 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_readonly(state->bitmap)) { error_setg(errp, "Cannot clear a readonly bitmap"); @@ -2838,14 +2835,9 @@ 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", + "Bitmap '%s' is currently in-use by another operation a= nd cannot be removed", name); return; } @@ -2876,14 +2868,9 @@ 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= ", + "Bitmap '%s' is currently in-use by another operation a= nd cannot be cleared", name); return; } else if (bdrv_dirty_bitmap_readonly(bitmap)) { @@ -2947,18 +2934,15 @@ void qmp_x_block_dirty_bitmap_merge(const char *nod= e, const char *dst_name, return; } =20 - if (bdrv_dirty_bitmap_frozen(dst)) { - error_setg(errp, "Bitmap '%s' is frozen and cannot be modified", + if (!bdrv_dirty_bitmap_user_modifiable(dst)) { + error_setg(errp, + "Bitmap '%s' is currently in-use by another operation a= nd cannot be modified", dst_name); return; } else if (bdrv_dirty_bitmap_readonly(dst)) { error_setg(errp, "Bitmap '%s' is readonly and cannot be modified", dst_name); return; - } else if (bdrv_dirty_bitmap_qmp_locked(dst)) { - error_setg(errp, "Bitmap '%s' is in-use by an operation " - "and cannot be modified", dst_name); - return; } =20 src =3D bdrv_find_dirty_bitmap(bs, src_name); diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index 259bd27c40..e3e1c6126f 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 Nov 5 19:57:18 2025 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 153756937849212.531243253941398; Fri, 21 Sep 2018 15:36:18 -0700 (PDT) Received: from localhost ([::1]:57660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3U23-0005KA-Ea for importer@patchew.org; Fri, 21 Sep 2018 18:36:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3TvN-0008RK-6S for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3TvM-0005Yn-Fc for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41372) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3TvI-0005UO-7A; Fri, 21 Sep 2018 18:29:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BB19308403C; Fri, 21 Sep 2018 22:29:15 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-77.rdu2.redhat.com [10.10.121.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 191DC106A7B7; Fri, 21 Sep 2018 22:29:08 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 21 Sep 2018 18:28:46 -0400 Message-Id: <20180921222847.1012-6-jsnow@redhat.com> In-Reply-To: <20180921222847.1012-1-jsnow@redhat.com> References: <20180921222847.1012-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 21 Sep 2018 22:29:15 +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] [RFC PATCH v2 5/6] 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 --- blockdev.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 070180898f..651c50d1fa 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 a= nd 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 a= nd cannot be disabled", + action->name); + return; + } + state->was_enabled =3D bdrv_dirty_bitmap_enabled(state->bitmap); bdrv_disable_dirty_bitmap(state->bitmap); } @@ -2892,9 +2906,9 @@ void qmp_x_block_dirty_bitmap_enable(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 enabled", + "Bitmap '%s' is currently in-use by another operation a= nd cannot be enabled", name); return; } @@ -2913,9 +2927,9 @@ void qmp_x_block_dirty_bitmap_disable(const char *nod= e, 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= ", + "Bitmap '%s' is currently in-use by another operation a= nd cannot be disabled", name); return; } --=20 2.14.4 From nobody Wed Nov 5 19:57:18 2025 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 1537569372005563.1673973803939; Fri, 21 Sep 2018 15:36:12 -0700 (PDT) Received: from localhost ([::1]:57659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3U1m-000583-TO for importer@patchew.org; Fri, 21 Sep 2018 18:35:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3TvN-0008RD-2f for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3TvM-0005Ys-GY for qemu-devel@nongnu.org; Fri, 21 Sep 2018 18:29:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33254) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3TvL-0005Vu-11; Fri, 21 Sep 2018 18:29:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92376308125E; Fri, 21 Sep 2018 22:29:17 +0000 (UTC) Received: from probe.redhat.com (ovpn-121-77.rdu2.redhat.com [10.10.121.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAD9A106A794; Fri, 21 Sep 2018 22:29:15 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 21 Sep 2018 18:28:47 -0400 Message-Id: <20180921222847.1012-7-jsnow@redhat.com> In-Reply-To: <20180921222847.1012-1-jsnow@redhat.com> References: <20180921222847.1012-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 21 Sep 2018 22:29:17 +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] [RFC PATCH v2 6/6] 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 --- blockdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 651c50d1fa..1f03db0c3c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3435,10 +3435,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; } } --=20 2.14.4