From nobody Thu Apr 25 23:30:18 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 1531163064591101.56697528984989; Mon, 9 Jul 2018 12:04:24 -0700 (PDT) Received: from localhost ([::1]:43985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbSR-0002hL-HQ for importer@patchew.org; Mon, 09 Jul 2018 15:04:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbMr-0007L2-BC for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcbMq-0002vo-Lj for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42790 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcbMn-0002uk-BG; Mon, 09 Jul 2018 14:58:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CEC6480401B6; Mon, 9 Jul 2018 18:58:32 +0000 (UTC) Received: from localhost (ovpn-204-98.brq.redhat.com [10.40.204.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77998111CB9A; Mon, 9 Jul 2018 18:58:32 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 9 Jul 2018 20:58:22 +0200 Message-Id: <20180709185828.4248-2-mreitz@redhat.com> In-Reply-To: <20180709185828.4248-1-mreitz@redhat.com> References: <20180709185828.4248-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 09 Jul 2018 18:58:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 09 Jul 2018 18:58:32 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/7] qcow2: Drop unused cluster_data 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Reported-by: Max Reitz Signed-off-by: Fam Zheng Message-id: 20180702025836.20957-2-famz@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- block/qcow2.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 33b61b7480..d4ba0f781a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3345,7 +3345,6 @@ qcow2_co_copy_range_to(BlockDriverState *bs, int ret; unsigned int cur_bytes; /* number of sectors in current iteration */ uint64_t cluster_offset; - uint8_t *cluster_data =3D NULL; QCowL2Meta *l2meta =3D NULL; =20 assert(!bs->encrypted); @@ -3404,7 +3403,6 @@ fail: =20 qemu_co_mutex_unlock(&s->lock); =20 - qemu_vfree(cluster_data); trace_qcow2_writev_done_req(qemu_coroutine_self(), ret); =20 return ret; --=20 2.17.1 From nobody Thu Apr 25 23:30:18 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 1531162841623120.0046055942397; Mon, 9 Jul 2018 12:00:41 -0700 (PDT) Received: from localhost ([::1]:43964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbOj-0008TK-1x for importer@patchew.org; Mon, 09 Jul 2018 15:00:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbMr-0007LS-Q8 for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcbMr-0002vy-3M for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58346 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcbMp-0002vI-7T; Mon, 09 Jul 2018 14:58:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4A1F402242D; Mon, 9 Jul 2018 18:58:34 +0000 (UTC) Received: from localhost (ovpn-204-98.brq.redhat.com [10.40.204.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F3D22156891; Mon, 9 Jul 2018 18:58:34 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 9 Jul 2018 20:58:23 +0200 Message-Id: <20180709185828.4248-3-mreitz@redhat.com> In-Reply-To: <20180709185828.4248-1-mreitz@redhat.com> References: <20180709185828.4248-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Jul 2018 18:58:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Jul 2018 18:58:34 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 2/7] file-posix: Fix fd_open check in raw_co_copy_range_to 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng One of them is a typo. But update both to be more readable. Reported-by: Kevin Wolf Signed-off-by: Fam Zheng Message-id: 20180702025836.20957-3-famz@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 98987b80f1..349f77a3af 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2611,7 +2611,7 @@ static int coroutine_fn raw_co_copy_range_to(BlockDri= verState *bs, } =20 src_s =3D src->bs->opaque; - if (fd_open(bs) < 0 || fd_open(bs) < 0) { + if (fd_open(src->bs) < 0 || fd_open(dst->bs) < 0) { return -EIO; } return paio_submit_co_full(bs, src_s->fd, src_offset, s->fd, dst_offse= t, --=20 2.17.1 From nobody Thu Apr 25 23:30:18 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 1531163049417432.1305648085381; Mon, 9 Jul 2018 12:04:09 -0700 (PDT) Received: from localhost ([::1]:43983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbSC-0002YX-Ae for importer@patchew.org; Mon, 09 Jul 2018 15:04:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbMy-0007Of-0e for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcbMw-0002xl-Mx for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58352 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcbMr-0002vv-3z; Mon, 09 Jul 2018 14:58:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95247402242D; Mon, 9 Jul 2018 18:58:36 +0000 (UTC) Received: from localhost (ovpn-204-98.brq.redhat.com [10.40.204.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 421592156891; Mon, 9 Jul 2018 18:58:36 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 9 Jul 2018 20:58:24 +0200 Message-Id: <20180709185828.4248-4-mreitz@redhat.com> In-Reply-To: <20180709185828.4248-1-mreitz@redhat.com> References: <20180709185828.4248-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Jul 2018 18:58:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Jul 2018 18:58:36 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 3/7] qcow2: Drop unreachable break 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Reported-by: Max Reitz Signed-off-by: Fam Zheng Message-id: 20180702025836.20957-4-famz@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- block/qcow2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index d4ba0f781a..f327116e52 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3299,7 +3299,6 @@ qcow2_co_copy_range_from(BlockDriverState *bs, case QCOW2_CLUSTER_COMPRESSED: ret =3D -ENOTSUP; goto out; - break; =20 case QCOW2_CLUSTER_NORMAL: child =3D bs->file; --=20 2.17.1 From nobody Thu Apr 25 23:30:18 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 1531163199900492.588791923495; Mon, 9 Jul 2018 12:06:39 -0700 (PDT) Received: from localhost ([::1]:44002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbUZ-0004V8-3W for importer@patchew.org; Mon, 09 Jul 2018 15:06:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbMy-0007Oe-0Y for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcbMw-0002xe-Li for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58080 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcbMs-0002wg-Vf; Mon, 09 Jul 2018 14:58:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7735D87A6C; Mon, 9 Jul 2018 18:58:38 +0000 (UTC) Received: from localhost (ovpn-204-98.brq.redhat.com [10.40.204.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 242367C4B; Mon, 9 Jul 2018 18:58:37 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 9 Jul 2018 20:58:25 +0200 Message-Id: <20180709185828.4248-5-mreitz@redhat.com> In-Reply-To: <20180709185828.4248-1-mreitz@redhat.com> References: <20180709185828.4248-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:38 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 4/7] raw: Drop superfluous semicolon 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Reported-by: Max Reitz Signed-off-by: Fam Zheng Message-id: 20180702025836.20957-5-famz@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- block/raw-format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/raw-format.c b/block/raw-format.c index b78da564d4..8e648a5666 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -177,7 +177,7 @@ static inline int raw_adjust_offset(BlockDriverState *b= s, uint64_t *offset, /* There's not enough space for the write, or the read request is * out-of-range. Don't read/write anything to prevent leaking out = of * the size specified in options. */ - return is_write ? -ENOSPC : -EINVAL;; + return is_write ? -ENOSPC : -EINVAL; } =20 if (*offset > INT64_MAX - s->offset) { --=20 2.17.1 From nobody Thu Apr 25 23:30:18 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 1531163189224650.373817337642; Mon, 9 Jul 2018 12:06:29 -0700 (PDT) Received: from localhost ([::1]:44000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbUS-0004QN-2J for importer@patchew.org; Mon, 09 Jul 2018 15:06:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbN0-0007SB-DY for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcbMz-0002yv-Ff for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58084 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcbMu-0002x1-RH; Mon, 09 Jul 2018 14:58:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52F2C87A6C; Mon, 9 Jul 2018 18:58:40 +0000 (UTC) Received: from localhost (ovpn-204-98.brq.redhat.com [10.40.204.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F412C7C4B; Mon, 9 Jul 2018 18:58:39 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 9 Jul 2018 20:58:26 +0200 Message-Id: <20180709185828.4248-6-mreitz@redhat.com> In-Reply-To: <20180709185828.4248-1-mreitz@redhat.com> References: <20180709185828.4248-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:40 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 5/7] vmdk: Fix possible segfault with non-VMDK backing 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" VMDK performs a probing check in vmdk_co_create_opts() to prevent the user from assigning non-VMDK files as a backing file, because it only supports VMDK backing files. However, with the @backing runtime option, it is possible to assign arbitrary nodes as backing nodes, regardless of what the image header says. Therefore, VMDK may not just access backing nodes assuming they are VMDK nodes -- which it does, because it needs to compare the backing file's CID with the overlay's parentCID value, and naturally the backing file only has a CID when it's a VMDK file. Instead, it should report the CID of non-VMDK backing files not to match the overlay because clearly a non-present CID does not match. Without this change, vmdk_read_cid() reads from the backing file's bs->file, which may be NULL (in which case we get a segfault). Also, it interprets bs->opaque as a BDRVVmdkState and then reads from the .desc_offset field, which usually will just return some arbitrary value which then results in either garbage to be read, or bdrv_pread() to return an error, both of which result in a non-matching CID to be reported. (In a very unlikely case, we could read something that looks like a VMDK descriptor, and then get a CID which might actually match. But that is highly unlikely, and the only result would be that VMDK accepts the backing file which is not too bad (albeit unintentional).) ((And in theory, the seek to .desc_offset might leak data from another block driver's opaque object. But then again, the user should realize very quickly that a non-VMDK backing file does not work (because the read will very likely fail, due to the reasons given above), so this should not be exploitable.)) Signed-off-by: Max Reitz Message-id: 20180702210721.4847-2-mreitz@redhat.com Reviewed-by: Fam Zheng Signed-off-by: Max Reitz --- block/vmdk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/vmdk.c b/block/vmdk.c index 84f8bbe480..a9d0084e36 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -333,6 +333,12 @@ static int vmdk_is_cid_valid(BlockDriverState *bs) if (!s->cid_checked && bs->backing) { BlockDriverState *p_bs =3D bs->backing->bs; =20 + if (strcmp(p_bs->drv->format_name, "vmdk")) { + /* Backing file is not in vmdk format, so it does not have + * a CID, which makes the overlay's parent CID invalid */ + return 0; + } + if (vmdk_read_cid(p_bs, 0, &cur_pcid) !=3D 0) { /* read failure: report as not valid */ return 0; --=20 2.17.1 From nobody Thu Apr 25 23:30:18 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 1531163310476242.48692161231554; Mon, 9 Jul 2018 12:08:30 -0700 (PDT) Received: from localhost ([::1]:44011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbWL-0005lG-Mk for importer@patchew.org; Mon, 09 Jul 2018 15:08:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbN1-0007TV-6u for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcbN0-0002zA-0j for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58090 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcbMw-0002xi-Uh; Mon, 09 Jul 2018 14:58:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 71E8887A6C; Mon, 9 Jul 2018 18:58:42 +0000 (UTC) Received: from localhost (ovpn-204-98.brq.redhat.com [10.40.204.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D653F111CB9A; Mon, 9 Jul 2018 18:58:41 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 9 Jul 2018 20:58:27 +0200 Message-Id: <20180709185828.4248-7-mreitz@redhat.com> In-Reply-To: <20180709185828.4248-1-mreitz@redhat.com> References: <20180709185828.4248-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:42 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 6/7] iotests: Add VMDK backing file correlation test 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This new test verifies that VMDK backing file reads fail when the backing file has a non-matching CID. This includes non-VMDK backing files. Signed-off-by: Max Reitz Message-id: 20180702210721.4847-3-mreitz@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/225 | 132 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/225.out | 24 +++++++ tests/qemu-iotests/group | 1 + 3 files changed, 157 insertions(+) create mode 100755 tests/qemu-iotests/225 create mode 100644 tests/qemu-iotests/225.out diff --git a/tests/qemu-iotests/225 b/tests/qemu-iotests/225 new file mode 100755 index 0000000000..f2ee715685 --- /dev/null +++ b/tests/qemu-iotests/225 @@ -0,0 +1,132 @@ +#!/bin/bash +# +# Test vmdk backing file correlation +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dmreitz@redhat.com + +seq=3D$(basename $0) +echo "QA output created by $seq" + +here=3D$PWD +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f "$TEST_IMG.not_base" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +# This tests vmdk-specific low-level functionality +_supported_fmt vmdk +_supported_proto file +_supported_os Linux +_unsupported_imgopts "subformat=3DmonolithicFlat" \ + "subformat=3DtwoGbMaxExtentFlat" \ + "subformat=3DtwoGbMaxExtentSparse" + +TEST_IMG=3D"$TEST_IMG.base" _make_test_img 1M +TEST_IMG=3D"$TEST_IMG.not_base" _make_test_img 1M +_make_test_img -b "$TEST_IMG.base" + +make_opts() +{ + node_name=3D$1 + filename=3D$2 + backing=3D$3 + + if [ -z "$backing" ]; then + backing=3D"null" + else + backing=3D"'$backing'" + fi + + echo "{ 'node-name': '$node_name', + 'driver': 'vmdk', + 'file': { + 'driver': 'file', + 'filename': '$filename' + }, + 'backing': $backing }" +} + +overlay_opts=3D$(make_opts overlay "$TEST_IMG" backing) +base_opts=3D$(make_opts backing "$TEST_IMG.base") +not_base_opts=3D$(make_opts backing "$TEST_IMG.not_base") + +not_vmdk_opts=3D"{ 'node-name': 'backing', 'driver': 'null-co' }" + +echo +echo '=3D=3D=3D Testing fitting VMDK backing image =3D=3D=3D' +echo + +qemu_comm_method=3Dmonitor \ + _launch_qemu -blockdev "$base_opts" -blockdev "$overlay_opts" + +# Should not return an error +_send_qemu_cmd $QEMU_HANDLE 'qemu-io overlay "read 0 512"' 'ops' + +_cleanup_qemu + + +echo +echo '=3D=3D=3D Testing unrelated VMDK backing image =3D=3D=3D' +echo + +qemu_comm_method=3Dmonitor \ + _launch_qemu -blockdev "$not_base_opts" -blockdev "$overlay_opts" + +# Should fail (gracefully) +_send_qemu_cmd $QEMU_HANDLE 'qemu-io overlay "read 0 512"' 'failed' + +_cleanup_qemu + + +echo +echo '=3D=3D=3D Testing non-VMDK backing image =3D=3D=3D' +echo + +# FIXME: This is the reason why we have to use two -blockdev +# invocations. You can only fully override the backing file options +# if you either specify a node reference (as done here) or the new +# options contain file.filename (which in this case they do not). +# In other cases, file.filename will be set to whatever the image +# header of the overlay contains (which we do not want). I consider +# this a FIXME because with -blockdev, you cannot specify "partial" +# options, so setting file.filename but leaving the rest as specified +# by the user does not make sense. +qemu_comm_method=3Dmonitor \ + _launch_qemu -blockdev "$not_vmdk_opts" -blockdev "$overlay_opts" + +# Should fail (gracefully) +_send_qemu_cmd $QEMU_HANDLE 'qemu-io overlay "read 0 512"' 'failed' + +_cleanup_qemu + + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/225.out b/tests/qemu-iotests/225.out new file mode 100644 index 0000000000..4dc8ee282f --- /dev/null +++ b/tests/qemu-iotests/225.out @@ -0,0 +1,24 @@ +QA output created by 225 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D1048576 +Formatting 'TEST_DIR/t.IMGFMT.not_base', fmt=3DIMGFMT size=3D1048576 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 backing_file= =3DTEST_DIR/t.IMGFMT.base + +=3D=3D=3D Testing fitting VMDK backing image =3D=3D=3D + +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) qemu-io overlay "read 0 512" +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Testing unrelated VMDK backing image =3D=3D=3D + +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) qemu-io overlay "read 0 512" +read failed: Invalid argument + +=3D=3D=3D Testing non-VMDK backing image =3D=3D=3D + +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) qemu-io overlay "read 0 512" +read failed: Invalid argument +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index af309ebba7..1c9f679821 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -222,3 +222,4 @@ 221 rw auto quick 222 rw auto quick 223 rw auto quick +225 rw auto quick --=20 2.17.1 From nobody Thu Apr 25 23:30:18 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 1531162858785796.5956256764405; Mon, 9 Jul 2018 12:00:58 -0700 (PDT) Received: from localhost ([::1]:43970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbP4-0000UH-Ng for importer@patchew.org; Mon, 09 Jul 2018 15:00:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcbN3-0007W1-Lw for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcbN2-000312-CS for qemu-devel@nongnu.org; Mon, 09 Jul 2018 14:58:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58094 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcbMz-0002yb-0j; Mon, 09 Jul 2018 14:58:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A75587A6C; Mon, 9 Jul 2018 18:58:44 +0000 (UTC) Received: from localhost (ovpn-204-98.brq.redhat.com [10.40.204.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 006132166BA2; Mon, 9 Jul 2018 18:58:43 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 9 Jul 2018 20:58:28 +0200 Message-Id: <20180709185828.4248-8-mreitz@redhat.com> In-Reply-To: <20180709185828.4248-1-mreitz@redhat.com> References: <20180709185828.4248-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Jul 2018 18:58:44 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 7/7] qcow2: add overlap check for bitmap directory 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Message-id: 20180705151515.779173-1-vsementsov@virtuozzo.com Signed-off-by: Max Reitz --- qapi/block-core.json | 21 +++++++++++--------- block/qcow2.h | 45 ++++++++++++++++++++++-------------------- block/qcow2-bitmap.c | 7 ++++++- block/qcow2-refcount.c | 10 ++++++++++ block/qcow2.c | 22 +++++++++++++-------- 5 files changed, 66 insertions(+), 39 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 38b31250f9..13798b982d 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2696,18 +2696,21 @@ # @template: Specifies a template mode which can be adjusted using the oth= er # flags, defaults to 'cached' # +# @bitmap-directory: since 3.0 +# # Since: 2.9 ## { 'struct': 'Qcow2OverlapCheckFlags', - 'data': { '*template': 'Qcow2OverlapCheckMode', - '*main-header': 'bool', - '*active-l1': 'bool', - '*active-l2': 'bool', - '*refcount-table': 'bool', - '*refcount-block': 'bool', - '*snapshot-table': 'bool', - '*inactive-l1': 'bool', - '*inactive-l2': 'bool' } } + 'data': { '*template': 'Qcow2OverlapCheckMode', + '*main-header': 'bool', + '*active-l1': 'bool', + '*active-l2': 'bool', + '*refcount-table': 'bool', + '*refcount-block': 'bool', + '*snapshot-table': 'bool', + '*inactive-l1': 'bool', + '*inactive-l2': 'bool', + '*bitmap-directory': 'bool' } } =20 ## # @Qcow2OverlapChecks: diff --git a/block/qcow2.h b/block/qcow2.h index d6aca687d6..81b844e936 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -94,6 +94,7 @@ #define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE "overlap-check.snapshot-table" #define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1" #define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2" +#define QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY "overlap-check.bitmap-directory" #define QCOW2_OPT_CACHE_SIZE "cache-size" #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size" #define QCOW2_OPT_L2_CACHE_ENTRY_SIZE "l2-cache-entry-size" @@ -400,34 +401,36 @@ typedef enum QCow2ClusterType { } QCow2ClusterType; =20 typedef enum QCow2MetadataOverlap { - QCOW2_OL_MAIN_HEADER_BITNR =3D 0, - QCOW2_OL_ACTIVE_L1_BITNR =3D 1, - QCOW2_OL_ACTIVE_L2_BITNR =3D 2, - QCOW2_OL_REFCOUNT_TABLE_BITNR =3D 3, - QCOW2_OL_REFCOUNT_BLOCK_BITNR =3D 4, - QCOW2_OL_SNAPSHOT_TABLE_BITNR =3D 5, - QCOW2_OL_INACTIVE_L1_BITNR =3D 6, - QCOW2_OL_INACTIVE_L2_BITNR =3D 7, - - QCOW2_OL_MAX_BITNR =3D 8, - - QCOW2_OL_NONE =3D 0, - QCOW2_OL_MAIN_HEADER =3D (1 << QCOW2_OL_MAIN_HEADER_BITNR), - QCOW2_OL_ACTIVE_L1 =3D (1 << QCOW2_OL_ACTIVE_L1_BITNR), - QCOW2_OL_ACTIVE_L2 =3D (1 << QCOW2_OL_ACTIVE_L2_BITNR), - QCOW2_OL_REFCOUNT_TABLE =3D (1 << QCOW2_OL_REFCOUNT_TABLE_BITNR), - QCOW2_OL_REFCOUNT_BLOCK =3D (1 << QCOW2_OL_REFCOUNT_BLOCK_BITNR), - QCOW2_OL_SNAPSHOT_TABLE =3D (1 << QCOW2_OL_SNAPSHOT_TABLE_BITNR), - QCOW2_OL_INACTIVE_L1 =3D (1 << QCOW2_OL_INACTIVE_L1_BITNR), + QCOW2_OL_MAIN_HEADER_BITNR =3D 0, + QCOW2_OL_ACTIVE_L1_BITNR =3D 1, + QCOW2_OL_ACTIVE_L2_BITNR =3D 2, + QCOW2_OL_REFCOUNT_TABLE_BITNR =3D 3, + QCOW2_OL_REFCOUNT_BLOCK_BITNR =3D 4, + QCOW2_OL_SNAPSHOT_TABLE_BITNR =3D 5, + QCOW2_OL_INACTIVE_L1_BITNR =3D 6, + QCOW2_OL_INACTIVE_L2_BITNR =3D 7, + QCOW2_OL_BITMAP_DIRECTORY_BITNR =3D 8, + + QCOW2_OL_MAX_BITNR =3D 9, + + QCOW2_OL_NONE =3D 0, + QCOW2_OL_MAIN_HEADER =3D (1 << QCOW2_OL_MAIN_HEADER_BITNR), + QCOW2_OL_ACTIVE_L1 =3D (1 << QCOW2_OL_ACTIVE_L1_BITNR), + QCOW2_OL_ACTIVE_L2 =3D (1 << QCOW2_OL_ACTIVE_L2_BITNR), + QCOW2_OL_REFCOUNT_TABLE =3D (1 << QCOW2_OL_REFCOUNT_TABLE_BITNR), + QCOW2_OL_REFCOUNT_BLOCK =3D (1 << QCOW2_OL_REFCOUNT_BLOCK_BITNR), + QCOW2_OL_SNAPSHOT_TABLE =3D (1 << QCOW2_OL_SNAPSHOT_TABLE_BITNR), + QCOW2_OL_INACTIVE_L1 =3D (1 << QCOW2_OL_INACTIVE_L1_BITNR), /* NOTE: Checking overlaps with inactive L2 tables will result in bdrv * reads. */ - QCOW2_OL_INACTIVE_L2 =3D (1 << QCOW2_OL_INACTIVE_L2_BITNR), + QCOW2_OL_INACTIVE_L2 =3D (1 << QCOW2_OL_INACTIVE_L2_BITNR), + QCOW2_OL_BITMAP_DIRECTORY =3D (1 << QCOW2_OL_BITMAP_DIRECTORY_BITNR), } QCow2MetadataOverlap; =20 /* Perform all overlap checks which can be done in constant time */ #define QCOW2_OL_CONSTANT \ (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE |= \ - QCOW2_OL_SNAPSHOT_TABLE) + QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_BITMAP_DIRECTORY) =20 /* Perform all overlap checks which don't require disk access */ #define QCOW2_OL_CACHED \ diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 69485aa1de..ba978ad2aa 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -775,7 +775,12 @@ static int bitmap_list_store(BlockDriverState *bs, Qco= w2BitmapList *bm_list, } } =20 - ret =3D qcow2_pre_write_overlap_check(bs, 0, dir_offset, dir_size); + /* Actually, even in in-place case ignoring QCOW2_OL_BITMAP_DIRECTORY = is not + * necessary, because we drop QCOW2_AUTOCLEAR_BITMAPS when updating bi= tmap + * directory in-place (actually, turn-off the extension), which is che= cked + * in qcow2_check_metadata_overlap() */ + ret =3D qcow2_pre_write_overlap_check( + bs, in_place ? QCOW2_OL_BITMAP_DIRECTORY : 0, dir_offset, dir_= size); if (ret < 0) { goto fail; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 18c729aa27..1b9ecb1ca0 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -2705,6 +2705,16 @@ int qcow2_check_metadata_overlap(BlockDriverState *b= s, int ign, int64_t offset, } } =20 + if ((chk & QCOW2_OL_BITMAP_DIRECTORY) && + (s->autoclear_features & QCOW2_AUTOCLEAR_BITMAPS)) + { + if (overlaps_with(s->bitmap_directory_offset, + s->bitmap_directory_size)) + { + return QCOW2_OL_BITMAP_DIRECTORY; + } + } + return 0; } =20 diff --git a/block/qcow2.c b/block/qcow2.c index f327116e52..5d668fc617 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -679,6 +679,11 @@ static QemuOptsList qcow2_runtime_opts =3D { .type =3D QEMU_OPT_BOOL, .help =3D "Check for unintended writes into an inactive L2 tab= le", }, + { + .name =3D QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY, + .type =3D QEMU_OPT_BOOL, + .help =3D "Check for unintended writes into the bitmap directo= ry", + }, { .name =3D QCOW2_OPT_CACHE_SIZE, .type =3D QEMU_OPT_SIZE, @@ -712,14 +717,15 @@ static QemuOptsList qcow2_runtime_opts =3D { }; =20 static const char *overlap_bool_option_names[QCOW2_OL_MAX_BITNR] =3D { - [QCOW2_OL_MAIN_HEADER_BITNR] =3D QCOW2_OPT_OVERLAP_MAIN_HEADER, - [QCOW2_OL_ACTIVE_L1_BITNR] =3D QCOW2_OPT_OVERLAP_ACTIVE_L1, - [QCOW2_OL_ACTIVE_L2_BITNR] =3D QCOW2_OPT_OVERLAP_ACTIVE_L2, - [QCOW2_OL_REFCOUNT_TABLE_BITNR] =3D QCOW2_OPT_OVERLAP_REFCOUNT_TABLE, - [QCOW2_OL_REFCOUNT_BLOCK_BITNR] =3D QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK, - [QCOW2_OL_SNAPSHOT_TABLE_BITNR] =3D QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE, - [QCOW2_OL_INACTIVE_L1_BITNR] =3D QCOW2_OPT_OVERLAP_INACTIVE_L1, - [QCOW2_OL_INACTIVE_L2_BITNR] =3D QCOW2_OPT_OVERLAP_INACTIVE_L2, + [QCOW2_OL_MAIN_HEADER_BITNR] =3D QCOW2_OPT_OVERLAP_MAIN_HEADER, + [QCOW2_OL_ACTIVE_L1_BITNR] =3D QCOW2_OPT_OVERLAP_ACTIVE_L1, + [QCOW2_OL_ACTIVE_L2_BITNR] =3D QCOW2_OPT_OVERLAP_ACTIVE_L2, + [QCOW2_OL_REFCOUNT_TABLE_BITNR] =3D QCOW2_OPT_OVERLAP_REFCOUNT_TABLE, + [QCOW2_OL_REFCOUNT_BLOCK_BITNR] =3D QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK, + [QCOW2_OL_SNAPSHOT_TABLE_BITNR] =3D QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE, + [QCOW2_OL_INACTIVE_L1_BITNR] =3D QCOW2_OPT_OVERLAP_INACTIVE_L1, + [QCOW2_OL_INACTIVE_L2_BITNR] =3D QCOW2_OPT_OVERLAP_INACTIVE_L2, + [QCOW2_OL_BITMAP_DIRECTORY_BITNR] =3D QCOW2_OPT_OVERLAP_BITMAP_DIRECTO= RY, }; =20 static void cache_clean_timer_cb(void *opaque) --=20 2.17.1