From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513324800186.51360924824405; Thu, 11 May 2017 07:35:24 -0700 (PDT) Received: from localhost ([::1]:48509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBZ-00032x-SM for importer@patchew.org; Thu, 11 May 2017 10:35:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9e-0001GB-Vd for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9e-0006dg-3W for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3153) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9b-0006cE-Mh; Thu, 11 May 2017 10:33:19 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A174E804F1; Thu, 11 May 2017 14:33:18 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1E5D8A8CB; Thu, 11 May 2017 14:33:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A174E804F1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A174E804F1 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:04 +0200 Message-Id: <1494513181-7900-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 14:33:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/58] block: Make bdrv_perm_names public 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 It can be used outside of block.c for making user friendly messages. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block.c | 2 +- include/block/block.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index a45b9b5..e3aa7f0 100644 --- a/block.c +++ b/block.c @@ -1586,7 +1586,7 @@ static char *bdrv_child_user_desc(BdrvChild *c) return g_strdup("another user"); } =20 -static char *bdrv_perm_names(uint64_t perm) +char *bdrv_perm_names(uint64_t perm) { struct perm_name { uint64_t perm; diff --git a/include/block/block.h b/include/block/block.h index 862eb56..9fa0f23 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -224,6 +224,8 @@ enum { BLK_PERM_ALL =3D 0x1f, }; =20 +char *bdrv_perm_names(uint64_t perm); + /* disk I/O throttling */ void bdrv_init(void); void bdrv_init_with_whitelist(void); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513355696369.6764398550233; Thu, 11 May 2017 07:35:55 -0700 (PDT) Received: from localhost ([::1]:48518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pC3-0003bV-Qr for importer@patchew.org; Thu, 11 May 2017 10:35:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9n-0001Nl-Ba for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9m-0006ky-8N for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9d-0006d6-1n; Thu, 11 May 2017 10:33:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0AD8537EEC; Thu, 11 May 2017 14:33:20 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2CA78A8CB; Thu, 11 May 2017 14:33:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0AD8537EEC Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0AD8537EEC From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:05 +0200 Message-Id: <1494513181-7900-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 11 May 2017 14:33:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/58] block: Add, parse and store "force-share" option 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block.c | 17 +++++++++++++++++ include/block/block.h | 1 + include/block/block_int.h | 1 + qapi/block-core.json | 3 +++ 4 files changed, 22 insertions(+) diff --git a/block.c b/block.c index e3aa7f0..31d6d0b 100644 --- a/block.c +++ b/block.c @@ -800,6 +800,7 @@ static void bdrv_inherited_options(int *child_flags, QD= ict *child_options, * the parent. */ qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIREC= T); qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FL= USH); + qdict_copy_default(child_options, parent_options, BDRV_OPT_FORCE_SHARE= ); =20 /* Inherit the read-only option from the parent if it's not set */ qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY); @@ -908,6 +909,7 @@ static void bdrv_backing_options(int *child_flags, QDic= t *child_options, * which is only applied on the top level (BlockBackend) */ qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIREC= T); qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FL= USH); + qdict_copy_default(child_options, parent_options, BDRV_OPT_FORCE_SHARE= ); =20 /* backing files always opened read-only */ qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on"); @@ -1150,6 +1152,11 @@ QemuOptsList bdrv_runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "discard operation (ignore/off, unmap/on)", }, + { + .name =3D BDRV_OPT_FORCE_SHARE, + .type =3D QEMU_OPT_BOOL, + .help =3D "always accept other writers (default: off)", + }, { /* end of list */ } }, }; @@ -1189,6 +1196,16 @@ static int bdrv_open_common(BlockDriverState *bs, Bl= ockBackend *file, drv =3D bdrv_find_format(driver_name); assert(drv !=3D NULL); =20 + bs->force_share =3D qemu_opt_get_bool(opts, BDRV_OPT_FORCE_SHARE, fals= e); + + if (bs->force_share && (bs->open_flags & BDRV_O_RDWR)) { + error_setg(errp, + BDRV_OPT_FORCE_SHARE + "=3Don can only be used with read-only images"); + ret =3D -EINVAL; + goto fail_opts; + } + if (file !=3D NULL) { filename =3D blk_bs(file)->filename; } else { diff --git a/include/block/block.h b/include/block/block.h index 9fa0f23..877fbb0 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -109,6 +109,7 @@ typedef struct HDGeometry { #define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush" #define BDRV_OPT_READ_ONLY "read-only" #define BDRV_OPT_DISCARD "discard" +#define BDRV_OPT_FORCE_SHARE "force-share" =20 =20 #define BDRV_SECTOR_BITS 9 diff --git a/include/block/block_int.h b/include/block/block_int.h index 8773940..1b4d08e 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -518,6 +518,7 @@ struct BlockDriverState { bool valid_key; /* if true, a valid encryption key has been set */ bool sg; /* if true, the device is a /dev/sg* */ bool probed; /* if true, format was probed rather than specified */ + bool force_share; /* if true, always allow all shared permissions */ =20 BlockDriver *drv; /* NULL means no media */ void *opaque; diff --git a/qapi/block-core.json b/qapi/block-core.json index 614181b..30d5952 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2898,6 +2898,8 @@ # (default: false) # @detect-zeroes: detect and optimize zero writes (Since 2.1) # (default: off) +# @force-share: force share all permission on added nodes. +# Requires read-only=3Dtrue. (Since 2.10) # # Remaining options are determined by the block driver. # @@ -2909,6 +2911,7 @@ '*discard': 'BlockdevDiscardOptions', '*cache': 'BlockdevCacheOptions', '*read-only': 'bool', + '*force-share': 'bool', '*detect-zeroes': 'BlockdevDetectZeroesOptions' }, 'discriminator': 'driver', 'data': { --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149451349033671.59706469284902; Thu, 11 May 2017 07:38:10 -0700 (PDT) Received: from localhost ([::1]:48526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pEE-0005mI-Q6 for importer@patchew.org; Thu, 11 May 2017 10:38:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9m-0001Mt-KF for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9g-0006fK-NU for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9e-0006da-Do; Thu, 11 May 2017 10:33:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58128A0908; Thu, 11 May 2017 14:33:21 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A8B08A8CB; Thu, 11 May 2017 14:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 58128A0908 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 58128A0908 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:06 +0200 Message-Id: <1494513181-7900-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:33:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/58] block: Respect "force-share" in perm propagating 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/block.c b/block.c index 31d6d0b..1e00e31 100644 --- a/block.c +++ b/block.c @@ -1465,6 +1465,22 @@ static int bdrv_child_check_perm(BdrvChild *c, uint6= 4_t perm, uint64_t shared, static void bdrv_child_abort_perm_update(BdrvChild *c); static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shar= ed); =20 +static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_= bs, + BdrvChild *c, + const BdrvChildRole *role, + uint64_t parent_perm, uint64_t parent_shared, + uint64_t *nperm, uint64_t *nshared) +{ + if (bs->drv && bs->drv->bdrv_child_perm) { + bs->drv->bdrv_child_perm(bs, c, role, + parent_perm, parent_shared, + nperm, nshared); + } + if (child_bs && child_bs->force_share) { + *nshared =3D BLK_PERM_ALL; + } +} + /* * Check whether permissions on this node can be changed in a way that * @cumulative_perms and @cumulative_shared_perms are the new cumulative @@ -1509,9 +1525,9 @@ static int bdrv_check_perm(BlockDriverState *bs, uint= 64_t cumulative_perms, /* Check all children */ QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; - drv->bdrv_child_perm(bs, c, c->role, - cumulative_perms, cumulative_shared_perms, - &cur_perm, &cur_shared); + bdrv_child_perm(bs, c->bs, c, c->role, + cumulative_perms, cumulative_shared_perms, + &cur_perm, &cur_shared); ret =3D bdrv_child_check_perm(c, cur_perm, cur_shared, ignore_chil= dren, errp); if (ret < 0) { @@ -1571,9 +1587,9 @@ static void bdrv_set_perm(BlockDriverState *bs, uint6= 4_t cumulative_perms, /* Update all children */ QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; - drv->bdrv_child_perm(bs, c, c->role, - cumulative_perms, cumulative_shared_perms, - &cur_perm, &cur_shared); + bdrv_child_perm(bs, c->bs, c, c->role, + cumulative_perms, cumulative_shared_perms, + &cur_perm, &cur_shared); bdrv_child_set_perm(c, cur_perm, cur_shared); } } @@ -1908,8 +1924,8 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, =20 assert(parent_bs->drv); assert(bdrv_get_aio_context(parent_bs) =3D=3D bdrv_get_aio_context(chi= ld_bs)); - parent_bs->drv->bdrv_child_perm(parent_bs, NULL, child_role, - perm, shared_perm, &perm, &shared_perm= ); + bdrv_child_perm(parent_bs, child_bs, NULL, child_role, + perm, shared_perm, &perm, &shared_perm); =20 child =3D bdrv_root_attach_child(child_bs, child_name, child_role, perm, shared_perm, parent_bs, errp); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513592885851.4759920860236; Thu, 11 May 2017 07:39:52 -0700 (PDT) Received: from localhost ([::1]:48536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pFu-0007HG-8j for importer@patchew.org; Thu, 11 May 2017 10:39:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9w-0001Y8-2n for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9o-0006n7-Lv for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9h-0006fW-Kc; Thu, 11 May 2017 10:33:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EFD585541; Thu, 11 May 2017 14:33:24 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 931588A8CE; Thu, 11 May 2017 14:33:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8EFD585541 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8EFD585541 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:07 +0200 Message-Id: <1494513181-7900-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 14:33:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/58] qemu-img: Add --force-share option to subcommands 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 This will force the opened images to allow sharing all permissions with oth= er programs. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- qemu-img.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 117 insertions(+), 36 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index f3b0ab4..418f061 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -28,6 +28,7 @@ #include "qapi/qobject-output-visitor.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qjson.h" +#include "qapi/qmp/qbool.h" #include "qemu/cutils.h" #include "qemu/config-file.h" #include "qemu/option.h" @@ -283,12 +284,20 @@ static int img_open_password(BlockBackend *blk, const= char *filename, =20 static BlockBackend *img_open_opts(const char *optstr, QemuOpts *opts, int flags, bool writeth= rough, - bool quiet) + bool quiet, bool force_share) { QDict *options; Error *local_err =3D NULL; BlockBackend *blk; options =3D qemu_opts_to_qdict(opts, NULL); + if (force_share) { + if (qdict_haskey(options, BDRV_OPT_FORCE_SHARE) + && !qdict_get_bool(options, BDRV_OPT_FORCE_SHARE)) { + error_report("--force-share/-U conflicts with image options"); + return NULL; + } + qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true)); + } blk =3D blk_new_open(NULL, NULL, options, flags, &local_err); if (!blk) { error_reportf_err(local_err, "Could not open '%s': ", optstr); @@ -305,17 +314,20 @@ static BlockBackend *img_open_opts(const char *optstr, =20 static BlockBackend *img_open_file(const char *filename, const char *fmt, int flags, - bool writethrough, bool quiet) + bool writethrough, bool quiet, + bool force_share) { BlockBackend *blk; Error *local_err =3D NULL; - QDict *options =3D NULL; + QDict *options =3D qdict_new(); =20 if (fmt) { - options =3D qdict_new(); qdict_put_str(options, "driver", fmt); } =20 + if (force_share) { + qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true)); + } blk =3D blk_new_open(filename, NULL, options, flags, &local_err); if (!blk) { error_reportf_err(local_err, "Could not open '%s': ", filename); @@ -334,7 +346,7 @@ static BlockBackend *img_open_file(const char *filename, static BlockBackend *img_open(bool image_opts, const char *filename, const char *fmt, int flags, bool writethroug= h, - bool quiet) + bool quiet, bool force_share) { BlockBackend *blk; if (image_opts) { @@ -348,9 +360,11 @@ static BlockBackend *img_open(bool image_opts, if (!opts) { return NULL; } - blk =3D img_open_opts(filename, opts, flags, writethrough, quiet); + blk =3D img_open_opts(filename, opts, flags, writethrough, quiet, + force_share); } else { - blk =3D img_open_file(filename, fmt, flags, writethrough, quiet); + blk =3D img_open_file(filename, fmt, flags, writethrough, quiet, + force_share); } return blk; } @@ -650,6 +664,7 @@ static int img_check(int argc, char **argv) ImageCheck *check; bool quiet =3D false; bool image_opts =3D false; + bool force_share =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -664,9 +679,10 @@ static int img_check(int argc, char **argv) {"output", required_argument, 0, OPTION_OUTPUT}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:r:T:q", + c =3D getopt_long(argc, argv, ":hf:r:T:qU", long_options, &option_index); if (c =3D=3D -1) { break; @@ -705,6 +721,9 @@ static int img_check(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + force_share =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -744,7 +763,8 @@ static int img_check(int argc, char **argv) return 1; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + force_share); if (!blk) { return 1; } @@ -947,7 +967,8 @@ static int img_commit(int argc, char **argv) return 1; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + false); if (!blk) { return 1; } @@ -1206,6 +1227,7 @@ static int img_compare(int argc, char **argv) int c, pnum; uint64_t progress_base; bool image_opts =3D false; + bool force_share =3D false; =20 cache =3D BDRV_DEFAULT_CACHE; for (;;) { @@ -1213,9 +1235,10 @@ static int img_compare(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:F:T:pqs", + c =3D getopt_long(argc, argv, ":hf:F:T:pqsU", long_options, NULL); if (c =3D=3D -1) { break; @@ -1248,6 +1271,9 @@ static int img_compare(int argc, char **argv) case 's': strict =3D true; break; + case 'U': + force_share =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -1293,13 +1319,15 @@ static int img_compare(int argc, char **argv) goto out3; } =20 - blk1 =3D img_open(image_opts, filename1, fmt1, flags, writethrough, qu= iet); + blk1 =3D img_open(image_opts, filename1, fmt1, flags, writethrough, qu= iet, + force_share); if (!blk1) { ret =3D 2; goto out3; } =20 - blk2 =3D img_open(image_opts, filename2, fmt2, flags, writethrough, qu= iet); + blk2 =3D img_open(image_opts, filename2, fmt2, flags, writethrough, qu= iet, + force_share); if (!blk2) { ret =3D 2; goto out2; @@ -1902,6 +1930,7 @@ static int img_convert(int argc, char **argv) bool writethrough, src_writethrough, quiet =3D false, image_opts =3D f= alse, skip_create =3D false, progress =3D false; int64_t ret =3D -EINVAL; + bool force_share =3D false; =20 ImgConvertState s =3D (ImgConvertState) { /* Need at least 4k of zeros for sparse detection */ @@ -1916,9 +1945,10 @@ static int img_convert(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:O:B:ce6o:s:l:S:pt:T:qnm:W", + c =3D getopt_long(argc, argv, ":hf:O:B:ce6o:s:l:S:pt:T:qnm:WU", long_options, NULL); if (c =3D=3D -1) { break; @@ -2021,6 +2051,9 @@ static int img_convert(int argc, char **argv) case 'W': s.wr_in_order =3D false; break; + case 'U': + force_share =3D true; + break; case OPTION_OBJECT: { QemuOpts *object_opts; object_opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -2080,7 +2113,8 @@ static int img_convert(int argc, char **argv) =20 for (bs_i =3D 0; bs_i < s.src_num; bs_i++) { s.src[bs_i] =3D img_open(image_opts, argv[optind + bs_i], - fmt, src_flags, src_writethrough, quiet); + fmt, src_flags, src_writethrough, quiet, + force_share); if (!s.src[bs_i]) { ret =3D -1; goto out; @@ -2233,7 +2267,8 @@ static int img_convert(int argc, char **argv) * the bdrv_create() call which takes different params. * Not critical right now, so fix can wait... */ - s.target =3D img_open_file(out_filename, out_fmt, flags, writethrough,= quiet); + s.target =3D img_open_file(out_filename, out_fmt, flags, writethrough,= quiet, + false); if (!s.target) { ret =3D -1; goto out; @@ -2384,7 +2419,7 @@ static gboolean str_equal_func(gconstpointer a, gcons= tpointer b) static ImageInfoList *collect_image_info_list(bool image_opts, const char *filename, const char *fmt, - bool chain) + bool chain, bool force_share) { ImageInfoList *head =3D NULL; ImageInfoList **last =3D &head; @@ -2407,7 +2442,8 @@ static ImageInfoList *collect_image_info_list(bool im= age_opts, g_hash_table_insert(filenames, (gpointer)filename, NULL); =20 blk =3D img_open(image_opts, filename, fmt, - BDRV_O_NO_BACKING | BDRV_O_NO_IO, false, false); + BDRV_O_NO_BACKING | BDRV_O_NO_IO, false, false, + force_share); if (!blk) { goto err; } @@ -2459,6 +2495,7 @@ static int img_info(int argc, char **argv) const char *filename, *fmt, *output; ImageInfoList *list; bool image_opts =3D false; + bool force_share =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -2471,9 +2508,10 @@ static int img_info(int argc, char **argv) {"backing-chain", no_argument, 0, OPTION_BACKING_CHAIN}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:h", + c =3D getopt_long(argc, argv, ":f:hU", long_options, &option_index); if (c =3D=3D -1) { break; @@ -2491,6 +2529,9 @@ static int img_info(int argc, char **argv) case 'f': fmt =3D optarg; break; + case 'U': + force_share =3D true; + break; case OPTION_OUTPUT: output =3D optarg; break; @@ -2530,7 +2571,8 @@ static int img_info(int argc, char **argv) return 1; } =20 - list =3D collect_image_info_list(image_opts, filename, fmt, chain); + list =3D collect_image_info_list(image_opts, filename, fmt, chain, + force_share); if (!list) { return 1; } @@ -2676,6 +2718,7 @@ static int img_map(int argc, char **argv) MapEntry curr =3D { .length =3D 0 }, next; int ret =3D 0; bool image_opts =3D false; + bool force_share =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -2687,9 +2730,10 @@ static int img_map(int argc, char **argv) {"output", required_argument, 0, OPTION_OUTPUT}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:h", + c =3D getopt_long(argc, argv, ":f:hU", long_options, &option_index); if (c =3D=3D -1) { break; @@ -2707,6 +2751,9 @@ static int img_map(int argc, char **argv) case 'f': fmt =3D optarg; break; + case 'U': + force_share =3D true; + break; case OPTION_OUTPUT: output =3D optarg; break; @@ -2743,7 +2790,7 @@ static int img_map(int argc, char **argv) return 1; } =20 - blk =3D img_open(image_opts, filename, fmt, 0, false, false); + blk =3D img_open(image_opts, filename, fmt, 0, false, false, force_sha= re); if (!blk) { return 1; } @@ -2806,6 +2853,7 @@ static int img_snapshot(int argc, char **argv) bool quiet =3D false; Error *err =3D NULL; bool image_opts =3D false; + bool force_share =3D false; =20 bdrv_oflags =3D BDRV_O_RDWR; /* Parse commandline parameters */ @@ -2814,9 +2862,10 @@ static int img_snapshot(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":la:c:d:hq", + c =3D getopt_long(argc, argv, ":la:c:d:hqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -2866,6 +2915,9 @@ static int img_snapshot(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + force_share =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -2892,7 +2944,8 @@ static int img_snapshot(int argc, char **argv) } =20 /* Open the image */ - blk =3D img_open(image_opts, filename, NULL, bdrv_oflags, false, quiet= ); + blk =3D img_open(image_opts, filename, NULL, bdrv_oflags, false, quiet, + force_share); if (!blk) { return 1; } @@ -2956,6 +3009,7 @@ static int img_rebase(int argc, char **argv) int c, flags, src_flags, ret; bool writethrough, src_writethrough; int unsafe =3D 0; + bool force_share =3D false; int progress =3D 0; bool quiet =3D false; Error *local_err =3D NULL; @@ -2972,9 +3026,10 @@ static int img_rebase(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hf:F:b:upt:T:q", + c =3D getopt_long(argc, argv, ":hf:F:b:upt:T:qU", long_options, NULL); if (c =3D=3D -1) { break; @@ -3024,6 +3079,9 @@ static int img_rebase(int argc, char **argv) case OPTION_IMAGE_OPTS: image_opts =3D true; break; + case 'U': + force_share =3D true; + break; } } =20 @@ -3072,7 +3130,8 @@ static int img_rebase(int argc, char **argv) * Ignore the old backing file for unsafe rebase in case we want to co= rrect * the reference to a renamed or moved backing file. */ - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + false); if (!blk) { ret =3D -1; goto out; @@ -3097,6 +3156,13 @@ static int img_rebase(int argc, char **argv) qdict_put_str(options, "driver", bs->backing_format); } =20 + if (force_share) { + if (!options) { + options =3D qdict_new(); + } + qdict_put(options, BDRV_OPT_FORCE_SHARE, + qbool_from_bool(true)); + } bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); blk_old_backing =3D blk_new_open(backing_name, NULL, options, src_flags, &local_err); @@ -3109,11 +3175,12 @@ static int img_rebase(int argc, char **argv) } =20 if (out_baseimg[0]) { + options =3D qdict_new(); if (out_basefmt) { - options =3D qdict_new(); qdict_put_str(options, "driver", out_basefmt); - } else { - options =3D NULL; + } + if (force_share) { + qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true); } =20 blk_new_backing =3D blk_new_open(out_baseimg, NULL, @@ -3419,7 +3486,8 @@ static int img_resize(int argc, char **argv) qemu_opts_del(param); =20 blk =3D img_open(image_opts, filename, fmt, - BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet); + BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet, + false); if (!blk) { ret =3D -1; goto out; @@ -3573,7 +3641,8 @@ static int img_amend(int argc, char **argv) goto out; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + false); if (!blk) { ret =3D -1; goto out; @@ -3741,6 +3810,7 @@ static int img_bench(int argc, char **argv) bool writethrough =3D false; struct timeval t1, t2; int i; + bool force_share =3D false; =20 for (;;) { static const struct option long_options[] =3D { @@ -3749,9 +3819,10 @@ static int img_bench(int argc, char **argv) {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"pattern", required_argument, 0, OPTION_PATTERN}, {"no-drain", no_argument, 0, OPTION_NO_DRAIN}, + {"force-share", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":hc:d:f:no:qs:S:t:w", long_options,= NULL); + c =3D getopt_long(argc, argv, ":hc:d:f:no:qs:S:t:wU", long_options= , NULL); if (c =3D=3D -1) { break; } @@ -3845,6 +3916,9 @@ static int img_bench(int argc, char **argv) flags |=3D BDRV_O_RDWR; is_write =3D true; break; + case 'U': + force_share =3D true; + break; case OPTION_PATTERN: { unsigned long res; @@ -3892,7 +3966,8 @@ static int img_bench(int argc, char **argv) goto out; } =20 - blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet= ); + blk =3D img_open(image_opts, filename, fmt, flags, writethrough, quiet, + force_share); if (!blk) { ret =3D -1; goto out; @@ -4059,6 +4134,7 @@ static int img_dd(int argc, char **argv) const char *fmt =3D NULL; int64_t size =3D 0; int64_t block_count =3D 0, out_pos, in_pos; + bool force_share =3D false; struct DdInfo dd =3D { .flags =3D 0, .count =3D 0, @@ -4087,10 +4163,11 @@ static int img_dd(int argc, char **argv) const struct option long_options[] =3D { { "help", no_argument, 0, 'h'}, { "image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + { "force-share", no_argument, 0, 'U'}, { 0, 0, 0, 0 } }; =20 - while ((c =3D getopt_long(argc, argv, ":hf:O:", long_options, NULL))) { + while ((c =3D getopt_long(argc, argv, ":hf:O:U", long_options, NULL)))= { if (c =3D=3D EOF) { break; } @@ -4110,6 +4187,9 @@ static int img_dd(int argc, char **argv) case 'h': help(); break; + case 'U': + force_share =3D true; + break; case OPTION_IMAGE_OPTS: image_opts =3D true; break; @@ -4154,7 +4234,8 @@ static int img_dd(int argc, char **argv) ret =3D -1; goto out; } - blk1 =3D img_open(image_opts, in.filename, fmt, 0, false, false); + blk1 =3D img_open(image_opts, in.filename, fmt, 0, false, false, + force_share); =20 if (!blk1) { ret =3D -1; @@ -4222,7 +4303,7 @@ static int img_dd(int argc, char **argv) } =20 blk2 =3D img_open(image_opts, out.filename, out_fmt, BDRV_O_RDWR, - false, false); + false, false, false); =20 if (!blk2) { ret =3D -1; --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513360335270.9139034230602; Thu, 11 May 2017 07:36:00 -0700 (PDT) Received: from localhost ([::1]:48519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pCA-0003g8-OV for importer@patchew.org; Thu, 11 May 2017 10:35:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9o-0001PT-VP for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9n-0006mc-OI for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46004) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9i-0006fw-KU; Thu, 11 May 2017 10:33:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9639B7FD67; Thu, 11 May 2017 14:33:25 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA86088B24; Thu, 11 May 2017 14:33:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9639B7FD67 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9639B7FD67 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:08 +0200 Message-Id: <1494513181-7900-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 14:33:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/58] qemu-img: Update documentation for -U 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- qemu-img-cmds.hx | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index bf4ce59..e5bc28f 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -10,15 +10,15 @@ STEXI ETEXI =20 DEF("bench", img_bench, - "bench [-c count] [-d depth] [-f fmt] [--flush-interval=3Dflush_interv= al] [-n] [--no-drain] [-o offset] [--pattern=3Dpattern] [-q] [-s buffer_siz= e] [-S step_size] [-t cache] [-w] filename") + "bench [-c count] [-d depth] [-f fmt] [--flush-interval=3Dflush_interv= al] [-n] [--no-drain] [-o offset] [--pattern=3Dpattern] [-q] [-s buffer_siz= e] [-S step_size] [-t cache] [-w] [-U] filename") STEXI -@item bench [-c @var{count}] [-d @var{depth}] [-f @var{fmt}] [--flush-inte= rval=3D@var{flush_interval}] [-n] [--no-drain] [-o @var{offset}] [--pattern= =3D@var{pattern}] [-q] [-s @var{buffer_size}] [-S @var{step_size}] [-t @var= {cache}] [-w] @var{filename} +@item bench [-c @var{count}] [-d @var{depth}] [-f @var{fmt}] [--flush-inte= rval=3D@var{flush_interval}] [-n] [--no-drain] [-o @var{offset}] [--pattern= =3D@var{pattern}] [-q] [-s @var{buffer_size}] [-S @var{step_size}] [-t @var= {cache}] [-w] [-U] @var{filename} ETEXI =20 DEF("check", img_check, - "check [-q] [--object objectdef] [--image-opts] [-f fmt] [--output=3Do= fmt] [-r [leaks | all]] [-T src_cache] filename") + "check [-q] [--object objectdef] [--image-opts] [-f fmt] [--output=3Do= fmt] [-r [leaks | all]] [-T src_cache] [-U] filename") STEXI -@item check [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}] = [--output=3D@var{ofmt}] [-r [leaks | all]] [-T @var{src_cache}] @var{filena= me} +@item check [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}] = [--output=3D@var{ofmt}] [-r [leaks | all]] [-T @var{src_cache}] [-U] @var{f= ilename} ETEXI =20 DEF("create", img_create, @@ -34,45 +34,45 @@ STEXI ETEXI =20 DEF("compare", img_compare, - "compare [--object objectdef] [--image-opts] [-f fmt] [-F fmt] [-T src= _cache] [-p] [-q] [-s] filename1 filename2") + "compare [--object objectdef] [--image-opts] [-f fmt] [-F fmt] [-T src= _cache] [-p] [-q] [-s] [-U] filename1 filename2") STEXI -@item compare [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [-F= @var{fmt}] [-T @var{src_cache}] [-p] [-q] [-s] @var{filename1} @var{filena= me2} +@item compare [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [-F= @var{fmt}] [-T @var{src_cache}] [-p] [-q] [-s] [-U] @var{filename1} @var{f= ilename2} ETEXI =20 DEF("convert", img_convert, - "convert [--object objectdef] [--image-opts] [-c] [-p] [-q] [-n] [-f f= mt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options= ] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] [-m num_cor= outines] [-W] filename [filename2 [...]] output_filename") + "convert [--object objectdef] [--image-opts] [-U] [-c] [-p] [-q] [-n] = [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapsho= t_id_or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W]= filename [filename2 [...]] output_filename") STEXI -@item convert [--object @var{objectdef}] [--image-opts] [-c] [-p] [-q] [-n= ] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}= ] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}]= [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}]= [-W] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [--object @var{objectdef}] [--image-opts] [-U] [-c] [-p] [-q= ] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output= _fmt}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_= param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename= } [@var{filename2} [...]] @var{output_filename} ETEXI =20 DEF("dd", img_dd, - "dd [--image-opts] [-f fmt] [-O output_fmt] [bs=3Dblock_size] [count= =3Dblocks] [skip=3Dblocks] if=3Dinput of=3Doutput") + "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [bs=3Dblock_size] [co= unt=3Dblocks] [skip=3Dblocks] if=3Dinput of=3Doutput") STEXI -@item dd [--image-opts] [-f @var{fmt}] [-O @var{output_fmt}] [bs=3D@var{bl= ock_size}] [count=3D@var{blocks}] [skip=3D@var{blocks}] if=3D@var{input} of= =3D@var{output} +@item dd [--image-opts] [-U] [-f @var{fmt}] [-O @var{output_fmt}] [bs=3D@v= ar{block_size}] [count=3D@var{blocks}] [skip=3D@var{blocks}] if=3D@var{inpu= t} of=3D@var{output} ETEXI =20 DEF("info", img_info, - "info [--object objectdef] [--image-opts] [-f fmt] [--output=3Dofmt] [= --backing-chain] filename") + "info [--object objectdef] [--image-opts] [-f fmt] [--output=3Dofmt] [= --backing-chain] [-U] filename") STEXI -@item info [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--out= put=3D@var{ofmt}] [--backing-chain] @var{filename} +@item info [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--out= put=3D@var{ofmt}] [--backing-chain] [-U] @var{filename} ETEXI =20 DEF("map", img_map, - "map [--object objectdef] [--image-opts] [-f fmt] [--output=3Dofmt] fi= lename") + "map [--object objectdef] [--image-opts] [-f fmt] [--output=3Dofmt] [-= U] filename") STEXI -@item map [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--outp= ut=3D@var{ofmt}] @var{filename} +@item map [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--outp= ut=3D@var{ofmt}] [-U] @var{filename} ETEXI =20 DEF("snapshot", img_snapshot, - "snapshot [--object objectdef] [--image-opts] [-q] [-l | -a snapshot |= -c snapshot | -d snapshot] filename") + "snapshot [--object objectdef] [--image-opts] [-U] [-q] [-l | -a snaps= hot | -c snapshot | -d snapshot] filename") STEXI -@item snapshot [--object @var{objectdef}] [--image-opts] [-q] [-l | -a @va= r{snapshot} | -c @var{snapshot} | -d @var{snapshot}] @var{filename} +@item snapshot [--object @var{objectdef}] [--image-opts] [-U] [-q] [-l | -= a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot}] @var{filename} ETEXI =20 DEF("rebase", img_rebase, - "rebase [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [= -T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filename") + "rebase [--object objectdef] [--image-opts] [-U] [-q] [-f fmt] [-t cac= he] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] filename") STEXI -@item rebase [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}]= [-t @var{cache}] [-T @var{src_cache}] [-p] [-u] -b @var{backing_file} [-F = @var{backing_fmt}] @var{filename} +@item rebase [--object @var{objectdef}] [--image-opts] [-U] [-q] [-f @var{= fmt}] [-t @var{cache}] [-T @var{src_cache}] [-p] [-u] -b @var{backing_file}= [-F @var{backing_fmt}] @var{filename} ETEXI =20 DEF("resize", img_resize, --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14945136439321000.9158588001466; Thu, 11 May 2017 07:40:43 -0700 (PDT) Received: from localhost ([::1]:48549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pGk-00086X-Es for importer@patchew.org; Thu, 11 May 2017 10:40:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9o-0001PM-SJ for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9n-0006mh-Sz for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36256) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9j-0006gG-Ny; Thu, 11 May 2017 10:33:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3F617F3E1; Thu, 11 May 2017 14:33:26 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5B5D88B24; Thu, 11 May 2017 14:33:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B3F617F3E1 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B3F617F3E1 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:09 +0200 Message-Id: <1494513181-7900-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 14:33:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/58] qemu-io: Add --force-share option 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Add --force-share/-U to program options and -U to open subcommand. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- qemu-io.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index ed0e2dc..34fa8a1 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -20,6 +20,7 @@ #include "qemu/readline.h" #include "qemu/log.h" #include "qapi/qmp/qstring.h" +#include "qapi/qmp/qbool.h" #include "qom/object_interfaces.h" #include "sysemu/block-backend.h" #include "block/block_int.h" @@ -53,7 +54,8 @@ static const cmdinfo_t close_cmd =3D { .oneline =3D "close the current open file", }; =20 -static int openfile(char *name, int flags, bool writethrough, QDict *opts) +static int openfile(char *name, int flags, bool writethrough, bool force_s= hare, + QDict *opts) { Error *local_err =3D NULL; BlockDriverState *bs; @@ -64,6 +66,18 @@ static int openfile(char *name, int flags, bool writethr= ough, QDict *opts) return 1; } =20 + if (force_share) { + if (!opts) { + opts =3D qdict_new(); + } + if (qdict_haskey(opts, BDRV_OPT_FORCE_SHARE) + && !qdict_get_bool(opts, BDRV_OPT_FORCE_SHARE)) { + error_report("-U conflicts with image options"); + QDECREF(opts); + return 1; + } + qdict_put(opts, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true)); + } qemuio_blk =3D blk_new_open(name, NULL, opts, flags, &local_err); if (!qemuio_blk) { error_reportf_err(local_err, "can't open%s%s: ", @@ -108,6 +122,7 @@ static void open_help(void) " -r, -- open file read-only\n" " -s, -- use snapshot file\n" " -n, -- disable host cache, short for -t none\n" +" -U, -- force shared permissions\n" " -k, -- use kernel AIO implementation (on Linux only)\n" " -t, -- use the given cache mode for the image\n" " -d, -- use the given discard mode for the image\n" @@ -124,7 +139,7 @@ static const cmdinfo_t open_cmd =3D { .argmin =3D 1, .argmax =3D -1, .flags =3D CMD_NOFILE_OK, - .args =3D "[-rsnk] [-t cache] [-d discard] [-o options] [path]", + .args =3D "[-rsnkU] [-t cache] [-d discard] [-o options] [path]", .oneline =3D "open the file specified by path", .help =3D open_help, }; @@ -147,8 +162,9 @@ static int open_f(BlockBackend *blk, int argc, char **a= rgv) int c; QemuOpts *qopts; QDict *opts; + bool force_share =3D false; =20 - while ((c =3D getopt(argc, argv, "snro:kt:d:")) !=3D -1) { + while ((c =3D getopt(argc, argv, "snro:kt:d:U")) !=3D -1) { switch (c) { case 's': flags |=3D BDRV_O_SNAPSHOT; @@ -188,6 +204,9 @@ static int open_f(BlockBackend *blk, int argc, char **a= rgv) return 0; } break; + case 'U': + force_share =3D true; + break; default: qemu_opts_reset(&empty_opts); return qemuio_command_usage(&open_cmd); @@ -211,9 +230,9 @@ static int open_f(BlockBackend *blk, int argc, char **a= rgv) qemu_opts_reset(&empty_opts); =20 if (optind =3D=3D argc - 1) { - return openfile(argv[optind], flags, writethrough, opts); + return openfile(argv[optind], flags, writethrough, force_share, op= ts); } else if (optind =3D=3D argc) { - return openfile(NULL, flags, writethrough, opts); + return openfile(NULL, flags, writethrough, force_share, opts); } else { QDECREF(opts); return qemuio_command_usage(&open_cmd); @@ -257,6 +276,7 @@ static void usage(const char *name) " -T, --trace [[enable=3D]][,events=3D][,file=3D]\n" " specify tracing options\n" " see qemu-img(1) man page for full description\n" +" -U, --force-share force shared permissions\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n" "\n" @@ -436,7 +456,7 @@ static QemuOptsList file_opts =3D { int main(int argc, char **argv) { int readonly =3D 0; - const char *sopt =3D "hVc:d:f:rsnmkt:T:"; + const char *sopt =3D "hVc:d:f:rsnmkt:T:U"; const struct option lopt[] =3D { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, @@ -452,6 +472,7 @@ int main(int argc, char **argv) { "trace", required_argument, NULL, 'T' }, { "object", required_argument, NULL, OPTION_OBJECT }, { "image-opts", no_argument, NULL, OPTION_IMAGE_OPTS }, + { "force-share", no_argument, 0, 'U'}, { NULL, 0, NULL, 0 } }; int c; @@ -462,6 +483,7 @@ int main(int argc, char **argv) QDict *opts =3D NULL; const char *format =3D NULL; char *trace_file =3D NULL; + bool force_share =3D false; =20 #ifdef CONFIG_POSIX signal(SIGPIPE, SIG_IGN); @@ -524,6 +546,9 @@ int main(int argc, char **argv) case 'h': usage(progname); exit(0); + case 'U': + force_share =3D true; + break; case OPTION_OBJECT: { QemuOpts *qopts; qopts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -595,7 +620,7 @@ int main(int argc, char **argv) exit(1); } opts =3D qemu_opts_to_qdict(qopts, NULL); - if (openfile(NULL, flags, writethrough, opts)) { + if (openfile(NULL, flags, writethrough, force_share, opts)) { exit(1); } } else { @@ -603,7 +628,8 @@ int main(int argc, char **argv) opts =3D qdict_new(); qdict_put_str(opts, "driver", format); } - if (openfile(argv[optind], flags, writethrough, opts)) { + if (openfile(argv[optind], flags, writethrough, + force_share, opts)) { exit(1); } } --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513514011429.6894271244978; Thu, 11 May 2017 07:38:34 -0700 (PDT) Received: from localhost ([::1]:48529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pEe-0006Bj-Nm for importer@patchew.org; Thu, 11 May 2017 10:38:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9r-0001SI-TL for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9q-0006p5-Sx for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9l-0006i7-7J; Thu, 11 May 2017 10:33:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1735A448D60; Thu, 11 May 2017 14:33:28 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEA0C88B24; Thu, 11 May 2017 14:33:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1735A448D60 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1735A448D60 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:10 +0200 Message-Id: <1494513181-7900-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 11 May 2017 14:33:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/58] iotests: 030: Prepare for image locking 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 qemu-img and qemu-io commands when guest is running need "-U" option, add it. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/030 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 0d472d5..e00c11b 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -63,8 +63,8 @@ class TestSingleDrive(iotests.QMPTestCase): def test_stream_intermediate(self): self.assert_no_active_block_jobs() =20 - self.assertNotEqual(qemu_io('-f', 'raw', '-c', 'map', backing_img), - qemu_io('-f', iotests.imgfmt, '-c', 'map', mid= _img), + self.assertNotEqual(qemu_io('-f', 'raw', '-rU', '-c', 'map', backi= ng_img), + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'ma= p', mid_img), 'image file map matches backing file before st= reaming') =20 result =3D self.vm.qmp('block-stream', device=3D'mid', job_id=3D's= tream-mid') @@ -114,7 +114,7 @@ class TestSingleDrive(iotests.QMPTestCase): self.assert_no_active_block_jobs() =20 # The image map is empty before the operation - empty_map =3D qemu_io('-f', iotests.imgfmt, '-c', 'map', test_img) + empty_map =3D qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'map', te= st_img) =20 # This is a no-op: no data should ever be copied from the base ima= ge result =3D self.vm.qmp('block-stream', device=3D'drive0', base=3Dm= id_img) @@ -197,8 +197,8 @@ class TestParallelOps(iotests.QMPTestCase): =20 # Check that the maps don't match before the streaming operations for i in range(2, self.num_imgs, 2): - self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map',= self.imgs[i]), - qemu_io('-f', iotests.imgfmt, '-c', 'map',= self.imgs[i-1]), + self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c',= 'map', self.imgs[i]), + qemu_io('-f', iotests.imgfmt, '-rU', '-c',= 'map', self.imgs[i-1]), 'image file map matches backing file befor= e streaming') =20 # Create all streaming jobs @@ -351,8 +351,8 @@ class TestParallelOps(iotests.QMPTestCase): def test_stream_base_node_name(self): self.assert_no_active_block_jobs() =20 - self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', sel= f.imgs[4]), - qemu_io('-f', iotests.imgfmt, '-c', 'map', sel= f.imgs[3]), + self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'ma= p', self.imgs[4]), + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'ma= p', self.imgs[3]), 'image file map matches backing file before st= reaming') =20 # Error: the base node does not exist @@ -422,8 +422,8 @@ class TestQuorum(iotests.QMPTestCase): if not iotests.supports_quorum(): return =20 - self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', sel= f.children[0]), - qemu_io('-f', iotests.imgfmt, '-c', 'map', sel= f.backing[0]), + self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'ma= p', self.children[0]), + qemu_io('-f', iotests.imgfmt, '-rU', '-c', 'ma= p', self.backing[0]), 'image file map matches backing file before st= reaming') =20 self.assert_no_active_block_jobs() --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513479927313.8749278190347; Thu, 11 May 2017 07:37:59 -0700 (PDT) Received: from localhost ([::1]:48525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pE5-0005WY-9w for importer@patchew.org; Thu, 11 May 2017 10:37:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9p-0001Pe-6E for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9o-0006n1-Fc for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29385) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9m-0006kW-8P; Thu, 11 May 2017 10:33:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45A4A7AE93; Thu, 11 May 2017 14:33:29 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 575418A8CB; Thu, 11 May 2017 14:33:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 45A4A7AE93 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 45A4A7AE93 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:11 +0200 Message-Id: <1494513181-7900-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 14:33:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/58] iotests: 046: Prepare for image locking 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 The qemu-img info command is executed while VM is running, add -U option to avoid the image locking error. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/046 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 index e528b67..f2ebecf 100755 --- a/tests/qemu-iotests/046 +++ b/tests/qemu-iotests/046 @@ -192,7 +192,7 @@ echo "=3D=3D Verify image content =3D=3D" =20 function verify_io() { - if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep "compat: 0.10" > /d= ev/null); then + if ($QEMU_IMG info -U -f "$IMGFMT" "$TEST_IMG" | grep "compat: 0.10" >= /dev/null); then # For v2 images, discarded clusters are read from the backing file # Keep the variable empty so that the backing file value can be us= ed as # the default below --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513634833164.98867678476313; Thu, 11 May 2017 07:40:34 -0700 (PDT) Received: from localhost ([::1]:48547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pGa-0007u3-9a for importer@patchew.org; Thu, 11 May 2017 10:40:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9r-0001RK-0I for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9p-0006oX-VV for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9n-0006lv-FM; Thu, 11 May 2017 10:33:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 71820C059741; Thu, 11 May 2017 14:33:30 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85B1D88B24; Thu, 11 May 2017 14:33:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 71820C059741 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 71820C059741 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:12 +0200 Message-Id: <1494513181-7900-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 11 May 2017 14:33:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/58] iotests: 055: Don't attach the target image already for drive-backup 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Double attach is not a valid usage of the target image, drive-backup will open the blockdev itself so skip the add_drive call in this case. Signed-off-by: Fam Zheng Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- tests/qemu-iotests/055 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index aafcd24..ba4da65 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -458,17 +458,18 @@ class TestDriveCompression(iotests.QMPTestCase): except OSError: pass =20 - def do_prepare_drives(self, fmt, args): + def do_prepare_drives(self, fmt, args, attach_target): self.vm =3D iotests.VM().add_drive(test_img) =20 qemu_img('create', '-f', fmt, blockdev_target_img, str(TestDriveCompression.image_len), *args) - self.vm.add_drive(blockdev_target_img, format=3Dfmt, interface=3D"= none") + if attach_target: + self.vm.add_drive(blockdev_target_img, format=3Dfmt, interface= =3D"none") =20 self.vm.launch() =20 - def do_test_compress_complete(self, cmd, format, **args): - self.do_prepare_drives(format['type'], format['args']) + def do_test_compress_complete(self, cmd, format, attach_target, **args= ): + self.do_prepare_drives(format['type'], format['args'], attach_targ= et) =20 self.assert_no_active_block_jobs() =20 @@ -484,15 +485,16 @@ class TestDriveCompression(iotests.QMPTestCase): =20 def test_complete_compress_drive_backup(self): for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_complete('drive-backup', format, + self.do_test_compress_complete('drive-backup', format, False, target=3Dblockdev_target_img, m= ode=3D'existing') =20 def test_complete_compress_blockdev_backup(self): for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_complete('blockdev-backup', format, targ= et=3D'drive1') + self.do_test_compress_complete('blockdev-backup', format, True, + target=3D'drive1') =20 - def do_test_compress_cancel(self, cmd, format, **args): - self.do_prepare_drives(format['type'], format['args']) + def do_test_compress_cancel(self, cmd, format, attach_target, **args): + self.do_prepare_drives(format['type'], format['args'], attach_targ= et) =20 self.assert_no_active_block_jobs() =20 @@ -506,15 +508,16 @@ class TestDriveCompression(iotests.QMPTestCase): =20 def test_compress_cancel_drive_backup(self): for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_cancel('drive-backup', format, + self.do_test_compress_cancel('drive-backup', format, False, target=3Dblockdev_target_img, mod= e=3D'existing') =20 def test_compress_cancel_blockdev_backup(self): for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_cancel('blockdev-backup', format, target= =3D'drive1') + self.do_test_compress_cancel('blockdev-backup', format, True, + target=3D'drive1') =20 - def do_test_compress_pause(self, cmd, format, **args): - self.do_prepare_drives(format['type'], format['args']) + def do_test_compress_pause(self, cmd, format, attach_target, **args): + self.do_prepare_drives(format['type'], format['args'], attach_targ= et) =20 self.assert_no_active_block_jobs() =20 @@ -546,12 +549,13 @@ class TestDriveCompression(iotests.QMPTestCase): =20 def test_compress_pause_drive_backup(self): for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_pause('drive-backup', format, + self.do_test_compress_pause('drive-backup', format, False, target=3Dblockdev_target_img, mode= =3D'existing') =20 def test_compress_pause_blockdev_backup(self): for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_pause('blockdev-backup', format, target= =3D'drive1') + self.do_test_compress_pause('blockdev-backup', format, True, + target=3D'drive1') =20 if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['raw', 'qcow2']) --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513796649873.289943463051; Thu, 11 May 2017 07:43:16 -0700 (PDT) Received: from localhost ([::1]:48559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pJB-0002Fv-PN for importer@patchew.org; Thu, 11 May 2017 10:43:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9x-0001ZL-0w for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9w-0006tf-2n for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9q-0006og-Nz; Thu, 11 May 2017 10:33:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5A9B3D94F; Thu, 11 May 2017 14:33:33 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3D0988B24; Thu, 11 May 2017 14:33:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A5A9B3D94F Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A5A9B3D94F From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:13 +0200 Message-Id: <1494513181-7900-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 14:33:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/58] iotests: 085: Avoid image locking conflict 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 In the case where we test the expected error when a blockdev-snapshot target already has a backing image, the backing chain is opened multiple times. This will be a problem when we use image locking, so use a different backing file that is not already open. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/085 | 33 +++++++++++++++++++-------------- tests/qemu-iotests/085.out | 3 ++- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 index c53e97f..b97adcd 100755 --- a/tests/qemu-iotests/085 +++ b/tests/qemu-iotests/085 @@ -45,7 +45,7 @@ _cleanup() rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" done - rm -f "${TEST_IMG}.1" "${TEST_IMG}.2" + rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base" =20 } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -87,24 +87,26 @@ function create_group_snapshot() } =20 # ${1}: unique identifier for the snapshot filename -# ${2}: true: open backing images; false: don't open them (default) +# ${2}: extra_params to the blockdev-add command +# ${3}: filename +function do_blockdev_add() +{ + cmd=3D"{ 'execute': 'blockdev-add', 'arguments': + { 'driver': 'qcow2', 'node-name': 'snap_${1}', ${2} + 'file': + { 'driver': 'file', 'filename': '${3}', + 'node-name': 'file_${1}' } } }" + _send_qemu_cmd $h "${cmd}" "return" +} + +# ${1}: unique identifier for the snapshot filename function add_snapshot_image() { - if [ "${2}" =3D "true" ]; then - extra_params=3D"" - else - extra_params=3D"'backing': '', " - fi base_image=3D"${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" snapshot_file=3D"${TEST_DIR}/${1}-${snapshot_virt0}" _make_test_img -b "${base_image}" "$size" mv "${TEST_IMG}" "${snapshot_file}" - cmd=3D"{ 'execute': 'blockdev-add', 'arguments': - { 'driver': 'qcow2', 'node-name': 'snap_${1}', ${extra_params} - 'file': - { 'driver': 'file', 'filename': '${snapshot_file}', - 'node-name': 'file_${1}' } } }" - _send_qemu_cmd $h "${cmd}" "return" + do_blockdev_add "$1" "'backing': '', " "${snapshot_file}" } =20 # ${1}: unique identifier for the snapshot filename @@ -222,7 +224,10 @@ echo =3D=3D=3D Invalid command - snapshot node has a b= acking image =3D=3D=3D echo =20 SNAPSHOTS=3D$((${SNAPSHOTS}+1)) -add_snapshot_image ${SNAPSHOTS} true + +TEST_IMG=3D"$TEST_IMG.base" _make_test_img "$size" +_make_test_img -b "${TEST_IMG}.base" "$size" +do_blockdev_add ${SNAPSHOTS} "" "${TEST_IMG}" blockdev_snapshot ${SNAPSHOTS} error =20 echo diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 182acb4..a5d4cc3 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -78,7 +78,8 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D13421= 7728 backing_file=3DTEST_DIR/ =20 =3D=3D=3D Invalid command - snapshot node has a backing image =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 backing_file= =3DTEST_DIR/12-snapshot-v0.IMGFMT +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134217728 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 backing_file= =3DTEST_DIR/t.IMGFMT.base {"return": {}} {"error": {"class": "GenericError", "desc": "The snapshot already has a ba= cking image"}} =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513949595470.5485091631924; Thu, 11 May 2017 07:45:49 -0700 (PDT) Received: from localhost ([::1]:48582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pLg-0004Wu-Ag for importer@patchew.org; Thu, 11 May 2017 10:45:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9x-0001bU-Qs for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9x-0006uO-1F for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9r-0006pO-Rk; Thu, 11 May 2017 10:33:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D15357A487; Thu, 11 May 2017 14:33:34 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id E172C88B24; Thu, 11 May 2017 14:33:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D15357A487 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D15357A487 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:14 +0200 Message-Id: <1494513181-7900-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 14:33:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/58] iotests: 087: Don't attach test image twice 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 The test scenario doesn't require the same image, instead it focuses on the duplicated node-name, so use null-co to avoid locking conflict. Reviewed-by: Max Reitz Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/087 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index 9de57dd..6d52f7d 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -82,8 +82,7 @@ run_qemu -drive driver=3D$IMGFMT,id=3Ddisk,node-name=3Dte= st-node,file=3D"$TEST_IMG" < Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513741877466.39624525909255; Thu, 11 May 2017 07:42:21 -0700 (PDT) Received: from localhost ([::1]:48557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pIJ-0000ze-BT for importer@patchew.org; Thu, 11 May 2017 10:42:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8p9x-0001bT-Qh for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9x-0006uV-2K for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9t-0006qn-9P; Thu, 11 May 2017 10:33:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4EE48C04B929; Thu, 11 May 2017 14:33:36 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A3C988B24; Thu, 11 May 2017 14:33:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4EE48C04B929 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4EE48C04B929 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:15 +0200 Message-Id: <1494513181-7900-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 14:33:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/58] iotests: 091: Quit QEMU before checking image 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- tests/qemu-iotests/091 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 index 32bbd56..10ac4a8 100755 --- a/tests/qemu-iotests/091 +++ b/tests/qemu-iotests/091 @@ -95,7 +95,9 @@ echo "vm2: qemu process running successfully" echo "vm2: flush io, and quit" _send_qemu_cmd $h2 'qemu-io disk flush' "(qemu)" _send_qemu_cmd $h2 'quit' "" +_send_qemu_cmd $h1 'quit' "" =20 +wait echo "Check image pattern" ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filte= r_qemu_io =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514414323615.2823128650615; Thu, 11 May 2017 07:53:34 -0700 (PDT) Received: from localhost ([::1]:48618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pT5-0003F9-OO for importer@patchew.org; Thu, 11 May 2017 10:53:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pA2-0001gw-C1 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8p9z-0006wN-Td for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9u-0006rO-Hb; Thu, 11 May 2017 10:33:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B56EC04B955; Thu, 11 May 2017 14:33:37 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F1207A407; Thu, 11 May 2017 14:33:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7B56EC04B955 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7B56EC04B955 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:16 +0200 Message-Id: <1494513181-7900-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 14:33:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/58] iotests: 172: Use separate images for multiple devices 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 To avoid image lock failures. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/172 | 55 +++++++++++++++++++++++++-----------------= ---- tests/qemu-iotests/172.out | 50 +++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/tests/qemu-iotests/172 b/tests/qemu-iotests/172 index 1b7d3a1..826d6fe 100755 --- a/tests/qemu-iotests/172 +++ b/tests/qemu-iotests/172 @@ -30,6 +30,8 @@ status=3D1 # failure is the default! _cleanup() { _cleanup_test_img + rm -f "$TEST_IMG.2" + rm -f "$TEST_IMG.3" } trap "_cleanup; exit \$status" 0 1 2 3 15 =20 @@ -86,6 +88,9 @@ size=3D720k =20 _make_test_img $size =20 +TEST_IMG=3D"$TEST_IMG.2" _make_test_img $size +TEST_IMG=3D"$TEST_IMG.3" _make_test_img $size + # Default drive semantics: # # By default you get a single empty floppy drive. You can override it with @@ -105,7 +110,7 @@ echo =3D=3D=3D Using -fda/-fdb options =3D=3D=3D =20 check_floppy_qtree -fda "$TEST_IMG" check_floppy_qtree -fdb "$TEST_IMG" -check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG" +check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG.2" =20 =20 echo @@ -114,7 +119,7 @@ echo =3D=3D=3D Using -drive options =3D=3D=3D =20 check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG",index=3D1 -check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dflopp= y,file=3D"$TEST_IMG",index=3D1 +check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dflopp= y,file=3D"$TEST_IMG.2",index=3D1 =20 echo echo @@ -122,7 +127,7 @@ echo =3D=3D=3D Using -drive if=3Dnone and -global =3D= =3D=3D =20 check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -global isa-fdc.dri= veA=3Dnone0 check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -global isa-fdc.dri= veB=3Dnone0 -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -global isa-fdc.driveA=3Dnone0 -global isa-fdc.driveB= =3Dnone1 =20 echo @@ -131,7 +136,7 @@ echo =3D=3D=3D Using -drive if=3Dnone and -device =3D= =3D=3D =20 check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -device floppy,driv= e=3Dnone0 check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -device floppy,driv= e=3Dnone0,unit=3D1 -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -device floppy,drive=3Dnone0 -device floppy,drive=3Dnon= e1,unit=3D1 =20 echo @@ -139,58 +144,58 @@ echo echo =3D=3D=3D Mixing -fdX and -global =3D=3D=3D =20 # Working -check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -g= lobal isa-fdc.driveB=3Dnone0 -check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -g= lobal isa-fdc.driveA=3Dnone0 +check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -global isa-fdc.driveB=3Dnone0 +check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -global isa-fdc.driveA=3Dnone0 =20 # Conflicting (-fdX wins) -check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -g= lobal isa-fdc.driveA=3Dnone0 -check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -g= lobal isa-fdc.driveB=3Dnone0 +check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -global isa-fdc.driveA=3Dnone0 +check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -global isa-fdc.driveB=3Dnone0 =20 echo echo echo =3D=3D=3D Mixing -fdX and -device =3D=3D=3D =20 # Working -check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -d= evice floppy,drive=3Dnone0 -check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -d= evice floppy,drive=3Dnone0,unit=3D1 +check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -device floppy,drive=3Dnone0 +check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -device floppy,drive=3Dnone0,unit=3D1 =20 -check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -d= evice floppy,drive=3Dnone0 -check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -d= evice floppy,drive=3Dnone0,unit=3D0 +check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -device floppy,drive=3Dnone0 +check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -device floppy,drive=3Dnone0,unit=3D0 =20 # Conflicting -check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -d= evice floppy,drive=3Dnone0,unit=3D0 -check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG" -d= evice floppy,drive=3Dnone0,unit=3D1 +check_floppy_qtree -fda "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -device floppy,drive=3Dnone0,unit=3D0 +check_floppy_qtree -fdb "$TEST_IMG" -drive if=3Dnone,file=3D"$TEST_IMG.2" = -device floppy,drive=3Dnone0,unit=3D1 =20 echo echo echo =3D=3D=3D Mixing -drive and -device =3D=3D=3D =20 # Working -check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dnone,= file=3D"$TEST_IMG" -device floppy,drive=3Dnone0 -check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dnone,= file=3D"$TEST_IMG" -device floppy,drive=3Dnone0,unit=3D1 +check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dnone,= file=3D"$TEST_IMG.2" -device floppy,drive=3Dnone0 +check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dnone,= file=3D"$TEST_IMG.2" -device floppy,drive=3Dnone0,unit=3D1 =20 # Conflicting -check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dnone,= file=3D"$TEST_IMG" -device floppy,drive=3Dnone0,unit=3D0 +check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" -drive if=3Dnone,= file=3D"$TEST_IMG.2" -device floppy,drive=3Dnone0,unit=3D0 =20 echo echo echo =3D=3D=3D Mixing -global and -device =3D=3D=3D =20 # Working -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dn= one1 -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dn= one1,unit=3D1 =20 -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dn= one1 -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dn= one1,unit=3D0 =20 # Conflicting -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dn= one1,unit=3D0 -check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG" \ +check_floppy_qtree -drive if=3Dnone,file=3D"$TEST_IMG" -drive if=3Dnone,fi= le=3D"$TEST_IMG.2" \ -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dn= one1,unit=3D1 =20 echo @@ -199,8 +204,8 @@ echo =3D=3D=3D Too many floppy drives =3D=3D=3D =20 # Working check_floppy_qtree -drive if=3Dfloppy,file=3D"$TEST_IMG" \ - -drive if=3Dnone,file=3D"$TEST_IMG" \ - -drive if=3Dnone,file=3D"$TEST_IMG" \ + -drive if=3Dnone,file=3D"$TEST_IMG.2" \ + -drive if=3Dnone,file=3D"$TEST_IMG.3" \ -global isa-fdc.driveB=3Dnone0 \ -device floppy,drive=3Dnone1 =20 diff --git a/tests/qemu-iotests/172.out b/tests/qemu-iotests/172.out index 54b5329..2732966 100644 --- a/tests/qemu-iotests/172.out +++ b/tests/qemu-iotests/172.out @@ -1,5 +1,7 @@ QA output created by 172 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D737280 +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=3DIMGFMT size=3D737280 +Formatting 'TEST_DIR/t.IMGFMT.3', fmt=3DIMGFMT size=3D737280 =20 =20 =3D=3D=3D Default =3D=3D=3D @@ -99,7 +101,7 @@ Testing: -fdb TEST_DIR/t.qcow2 share-rw =3D false drive-type =3D "288" =20 -Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2 +Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -205,7 +207,7 @@ Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2,ind= ex=3D1 share-rw =3D false drive-type =3D "288" =20 -Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dfloppy,fil= e=3DTEST_DIR/t.qcow2,index=3D1 +Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dfloppy,fil= e=3DTEST_DIR/t.qcow2.2,index=3D1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -300,7 +302,7 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -glob= al isa-fdc.driveB=3Dnone0 share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa-fdc.driveA=3Dnone0 -global isa-fdc.driveB=3Dno= ne1 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveA=3Dnone0 -global isa-fdc.driveB=3D= none1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -395,7 +397,7 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -devi= ce floppy,drive=3Dnone0,unit=3D1 share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -device floppy,drive=3Dnone0 -device floppy,drive=3Dnone1,= unit=3D1 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -device floppy,drive=3Dnone0 -device floppy,drive=3Dnone= 1,unit=3D1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -436,7 +438,7 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -driv= e if=3Dnone,file=3DTEST_DIR/t.qco =20 =3D=3D=3D Mixing -fdX and -global =3D=3D=3D =20 -Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -g= lobal isa-fdc.driveB=3Dnone0 +Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -global isa-fdc.driveB=3Dnone0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -474,7 +476,7 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa- share-rw =3D false drive-type =3D "144" =20 -Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -g= lobal isa-fdc.driveA=3Dnone0 +Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -global isa-fdc.driveA=3Dnone0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -512,7 +514,7 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa- share-rw =3D false drive-type =3D "144" =20 -Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -g= lobal isa-fdc.driveA=3Dnone0 +Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -global isa-fdc.driveA=3Dnone0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -539,7 +541,7 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa- share-rw =3D false drive-type =3D "144" =20 -Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -g= lobal isa-fdc.driveB=3Dnone0 +Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -global isa-fdc.driveB=3Dnone0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -569,7 +571,7 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa- =20 =3D=3D=3D Mixing -fdX and -device =3D=3D=3D =20 -Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -d= evice floppy,drive=3Dnone0 +Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -607,7 +609,7 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -device flop share-rw =3D false drive-type =3D "144" =20 -Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -d= evice floppy,drive=3Dnone0,unit=3D1 +Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0,unit=3D1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -645,7 +647,7 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -device flop share-rw =3D false drive-type =3D "144" =20 -Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -d= evice floppy,drive=3Dnone0 +Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -683,7 +685,7 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -device flop share-rw =3D false drive-type =3D "144" =20 -Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -d= evice floppy,drive=3Dnone0,unit=3D0 +Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0,unit=3D0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -721,18 +723,18 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2 -device flop share-rw =3D false drive-type =3D "144" =20 -Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -d= evice floppy,drive=3Dnone0,unit=3D0 +Testing: -fda TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0,unit=3D0 QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Floppy unit 0 is in use QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Device initialization fa= iled. =20 -Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -d= evice floppy,drive=3Dnone0,unit=3D1 +Testing: -fdb TEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.2 = -device floppy,drive=3Dnone0,unit=3D1 QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D1: Floppy unit 1 is in use QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D1: Device initialization fa= iled. =20 =20 =3D=3D=3D Mixing -drive and -device =3D=3D=3D =20 -Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2 -device floppy,drive=3Dnone0 +Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2.2 -device floppy,drive=3Dnone0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -770,7 +772,7 @@ Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -dr= ive if=3Dnone,file=3DTEST_DIR/t.q share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2 -device floppy,drive=3Dnone0,unit=3D1 +Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2.2 -device floppy,drive=3Dnone0,unit=3D1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -808,14 +810,14 @@ Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -= drive if=3Dnone,file=3DTEST_DIR/t.q share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2 -device floppy,drive=3Dnone0,unit=3D0 +Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2.2 -device floppy,drive=3Dnone0,unit=3D0 QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Floppy unit 0 is in use QEMU_PROG: -device floppy,drive=3Dnone0,unit=3D0: Device initialization fa= iled. =20 =20 =3D=3D=3D Mixing -global and -device =3D=3D=3D =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dnone1 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dno= ne1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -853,7 +855,7 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -driv= e if=3Dnone,file=3DTEST_DIR/t.qco share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dnone= 1,unit=3D1 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dno= ne1,unit=3D1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -891,7 +893,7 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -driv= e if=3Dnone,file=3DTEST_DIR/t.qco share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dnone1 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dno= ne1 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -929,7 +931,7 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -driv= e if=3Dnone,file=3DTEST_DIR/t.qco share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dnone= 1,unit=3D0 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dno= ne1,unit=3D0 =20 dev: isa-fdc, id "" iobase =3D 1008 (0x3f0) @@ -967,18 +969,18 @@ Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -dr= ive if=3Dnone,file=3DTEST_DIR/t.qco share-rw =3D false drive-type =3D "144" =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dnone= 1,unit=3D0 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveA=3Dnone0 -device floppy,drive=3Dno= ne1,unit=3D0 QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D0: Floppy unit 0 is in use QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D0: Device initialization fa= iled. =20 -Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2 -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dnone= 1,unit=3D1 +Testing: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3D= TEST_DIR/t.qcow2.2 -global isa-fdc.driveB=3Dnone0 -device floppy,drive=3Dno= ne1,unit=3D1 QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D1: Floppy unit 1 is in use QEMU_PROG: -device floppy,drive=3Dnone1,unit=3D1: Device initialization fa= iled. =20 =20 =3D=3D=3D Too many floppy drives =3D=3D=3D =20 -Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2 -global isa-fd= c.driveB=3Dnone0 -device floppy,drive=3Dnone1 +Testing: -drive if=3Dfloppy,file=3DTEST_DIR/t.qcow2 -drive if=3Dnone,file= =3DTEST_DIR/t.qcow2.2 -drive if=3Dnone,file=3DTEST_DIR/t.qcow2.3 -global is= a-fdc.driveB=3Dnone0 -device floppy,drive=3Dnone1 QEMU_PROG: -device floppy,drive=3Dnone1: Can't create floppy unit 2, bus s= upports only 2 units QEMU_PROG: -device floppy,drive=3Dnone1: Device initialization failed. =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513980248177.62326605898386; Thu, 11 May 2017 07:46:20 -0700 (PDT) Received: from localhost ([::1]:48585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pMA-0004vI-Vc for importer@patchew.org; Thu, 11 May 2017 10:46:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pA5-0001k2-4X for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pA1-0006xA-Iu for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36530) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9v-0006sI-NN; Thu, 11 May 2017 10:33:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE3D77F3F5; Thu, 11 May 2017 14:33:38 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCDB37A407; Thu, 11 May 2017 14:33:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE3D77F3F5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AE3D77F3F5 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:17 +0200 Message-Id: <1494513181-7900-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 14:33:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/58] tests: Use null-co:// instead of /dev/null as the dummy image 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- tests/drive_del-test.c | 2 +- tests/nvme-test.c | 2 +- tests/usb-hcd-uhci-test.c | 2 +- tests/usb-hcd-xhci-test.c | 2 +- tests/virtio-blk-test.c | 2 +- tests/virtio-scsi-test.c | 5 +++-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index 121b9c9..2175139 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -92,7 +92,7 @@ static void test_after_failed_device_add(void) static void test_drive_del_device_del(void) { /* Start with a drive used by a device that unplugs instantaneously */ - qtest_start("-drive if=3Dnone,id=3Ddrive0,file=3D/dev/null,format=3Dra= w" + qtest_start("-drive if=3Dnone,id=3Ddrive0,file=3Dnull-co://,format=3Dr= aw" " -device virtio-scsi-pci" " -device scsi-hd,drive=3Ddrive0,id=3Ddev0"); =20 diff --git a/tests/nvme-test.c b/tests/nvme-test.c index c8bece4..7674a44 100644 --- a/tests/nvme-test.c +++ b/tests/nvme-test.c @@ -22,7 +22,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); qtest_add_func("/nvme/nop", nop); =20 - qtest_start("-drive id=3Ddrv0,if=3Dnone,file=3D/dev/null,format=3Draw " + qtest_start("-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://,format=3Draw= " "-device nvme,drive=3Ddrv0,serial=3Dfoo"); ret =3D g_test_run(); =20 diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index f25bae5..5b500fe 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -79,7 +79,7 @@ int main(int argc, char **argv) { const char *arch =3D qtest_get_arch(); const char *cmd =3D "-device piix3-usb-uhci,id=3Duhci,addr=3D1d.0" - " -drive id=3Ddrive0,if=3Dnone,file=3D/dev/null,form= at=3Draw" + " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://,for= mat=3Draw" " -device usb-tablet,bus=3Duhci.0,port=3D1"; int ret; =20 diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 22513e9..031764d 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -89,7 +89,7 @@ int main(int argc, char **argv) qtest_add_func("/xhci/pci/hotplug/usb-uas", test_usb_uas_hotplug); =20 qtest_start("-device nec-usb-xhci,id=3Dxhci" - " -drive id=3Ddrive0,if=3Dnone,file=3D/dev/null,format=3Dr= aw"); + " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://,format=3D= raw"); ret =3D g_test_run(); qtest_end(); =20 diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 1eee95d..fd2078c 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -63,7 +63,7 @@ static QOSState *pci_test_start(void) const char *arch =3D qtest_get_arch(); char *tmp_path; const char *cmd =3D "-drive if=3Dnone,id=3Ddrive0,file=3D%s,format=3Dr= aw " - "-drive if=3Dnone,id=3Ddrive1,file=3D/dev/null,forma= t=3Draw " + "-drive if=3Dnone,id=3Ddrive1,file=3Dnull-co://,form= at=3Draw " "-device virtio-blk-pci,id=3Ddrv0,drive=3Ddrive0," "addr=3D%x.%x"; =20 diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 0eabd56..8b0f77a 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -35,7 +35,7 @@ typedef struct { static QOSState *qvirtio_scsi_start(const char *extra_opts) { const char *arch =3D qtest_get_arch(); - const char *cmd =3D "-drive id=3Ddrv0,if=3Dnone,file=3D/dev/null,forma= t=3Draw " + const char *cmd =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://,form= at=3Draw " "-device virtio-scsi-pci,id=3Dvs0 " "-device scsi-hd,bus=3Dvs0.0,drive=3Ddrv0 %s"; =20 @@ -195,7 +195,8 @@ static void hotplug(void) QDict *response; QOSState *qs; =20 - qs =3D qvirtio_scsi_start("-drive id=3Ddrv1,if=3Dnone,file=3D/dev/null= ,format=3Draw"); + qs =3D qvirtio_scsi_start( + "-drive id=3Ddrv1,if=3Dnone,file=3Dnull-co://,format=3Draw"); response =3D qmp("{\"execute\": \"device_add\"," " \"arguments\": {" " \"driver\": \"scsi-hd\"," --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514112299681.8348777720473; Thu, 11 May 2017 07:48:32 -0700 (PDT) Received: from localhost ([::1]:48594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pOH-0006jD-C7 for importer@patchew.org; Thu, 11 May 2017 10:48:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pA5-0001k1-4W for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pA4-0006zn-3d for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9x-0006u5-1E; Thu, 11 May 2017 10:33:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04394C059756; Thu, 11 May 2017 14:33:40 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAA057A407; Thu, 11 May 2017 14:33:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 04394C059756 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 04394C059756 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:18 +0200 Message-Id: <1494513181-7900-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 11 May 2017 14:33:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/58] file-posix: Add 'locking' option 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Making this option available even before implementing it will let converting tests easier: in coming patches they can specify the option already when necessary, before we actually write code to lock the images. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/file-posix.c | 5 +++++ qapi/block-core.json | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 19c48a0..d13e99c 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -392,6 +392,11 @@ static QemuOptsList raw_runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "host AIO implementation (threads, native)", }, + { + .name =3D "locking", + .type =3D QEMU_OPT_STRING, + .help =3D "file locking mode (on/off/auto, default: auto)", + }, { /* end of list */ } }, }; diff --git a/qapi/block-core.json b/qapi/block-core.json index 30d5952..52e3ecd 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2127,11 +2127,15 @@ # # @filename: path to the image file # @aio: AIO backend (default: threads) (since: 2.8) +# @locking: whether to enable file locking. If set to 'auto', only ena= ble +# when Open File Descriptor (OFD) locking API is available +# (default: auto, since 2.10) # # Since: 2.9 ## { 'struct': 'BlockdevOptionsFile', 'data': { 'filename': 'str', + '*locking': 'OnOffAuto', '*aio': 'BlockdevAioOptions' } } =20 ## --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149451381134893.73503149343469; Thu, 11 May 2017 07:43:31 -0700 (PDT) Received: from localhost ([::1]:48562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pJQ-0002T9-Rh for importer@patchew.org; Thu, 11 May 2017 10:43:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pA1-0001fc-2E for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pA0-0006wT-6L for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53620) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9y-0006v0-6G; Thu, 11 May 2017 10:33:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 320EF61D36; Thu, 11 May 2017 14:33:41 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44E207A407; Thu, 11 May 2017 14:33:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 320EF61D36 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 320EF61D36 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:19 +0200 Message-Id: <1494513181-7900-17-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:33:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 16/58] file-win32: Error out if locking=on 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 We share the same set of QAPI options with file-posix, but locking is not supported here. So error out if it is specified as 'on' for now. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/file-win32.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/file-win32.c b/block/file-win32.c index d1eb0a1..1a35dba 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -344,6 +344,11 @@ static int raw_open(BlockDriverState *bs, QDict *optio= ns, int flags, goto fail; } =20 + if (qdict_get_try_bool(options, "locking", false)) { + error_setg(errp, "locking=3Don is not supported on Windows"); + goto fail; + } + filename =3D qemu_opt_get(opts, "filename"); =20 use_aio =3D get_aio_option(opts, flags, &local_err); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513958819828.3254407334903; Thu, 11 May 2017 07:45:58 -0700 (PDT) Received: from localhost ([::1]:48583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pLn-0004cc-CS for importer@patchew.org; Thu, 11 May 2017 10:45:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pA5-0001jx-3v for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pA1-0006x3-DK for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40850) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8p9z-0006vy-8E; Thu, 11 May 2017 10:33:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C2DBE183F; Thu, 11 May 2017 14:33:42 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 728417A407; Thu, 11 May 2017 14:33:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C2DBE183F Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3C2DBE183F From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:20 +0200 Message-Id: <1494513181-7900-18-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 14:33:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 17/58] tests: Disable image lock in test-replication 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 The COLO block replication architecture requires one disk to be shared between primary and secondary, in the test both processes use posix file protocol (instead of over NBD) so it is affected by image locking. Disable the lock. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/test-replication.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test-replication.c b/tests/test-replication.c index 3016c6f..cebeb79 100644 --- a/tests/test-replication.c +++ b/tests/test-replication.c @@ -179,7 +179,8 @@ static BlockBackend *start_primary(void) char *cmdline; =20 cmdline =3D g_strdup_printf("driver=3Dreplication,mode=3Dprimary,node-= name=3Dxxx," - "file.driver=3Dqcow2,file.file.filename=3D%s" + "file.driver=3Dqcow2,file.file.filename=3D%s= ," + "file.file.locking=3Doff" , p_local_disk); opts =3D qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false); g_free(cmdline); @@ -310,7 +311,9 @@ static BlockBackend *start_secondary(void) Error *local_err =3D NULL; =20 /* add s_local_disk and forge S_LOCAL_DISK_ID */ - cmdline =3D g_strdup_printf("file.filename=3D%s,driver=3Dqcow2", s_loc= al_disk); + cmdline =3D g_strdup_printf("file.filename=3D%s,driver=3Dqcow2," + "file.locking=3Doff", + s_local_disk); opts =3D qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false); g_free(cmdline); =20 @@ -331,8 +334,10 @@ static BlockBackend *start_secondary(void) /* add S_(ACTIVE/HIDDEN)_DISK and forge S_ID */ cmdline =3D g_strdup_printf("driver=3Dreplication,mode=3Dsecondary,top= -id=3D%s," "file.driver=3Dqcow2,file.file.filename=3D%s= ," + "file.file.locking=3Doff," "file.backing.driver=3Dqcow2," "file.backing.file.filename=3D%s," + "file.backing.file.locking=3Doff," "file.backing.backing=3D%s" , S_ID, s_active_disk, s_hidden_disk , S_LOCAL_DISK_ID); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514136272749.0796789797164; Thu, 11 May 2017 07:48:56 -0700 (PDT) Received: from localhost ([::1]:48596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pOf-000731-QG for importer@patchew.org; Thu, 11 May 2017 10:48:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pA8-0001p7-Qc for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pA7-00073e-US for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA0-0006wK-GQ; Thu, 11 May 2017 10:33:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78EC5A090E; Thu, 11 May 2017 14:33:43 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C0647A407; Thu, 11 May 2017 14:33:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 78EC5A090E Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 78EC5A090E From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:21 +0200 Message-Id: <1494513181-7900-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:33:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 18/58] block: Reuse bs as backing hd for drive-backup sync=none 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Opening the backing image for the second time is bad, especially here when it is also in use as the active image as the source. The drive-backup job itself doesn't read from target->backing for COW, instead it gets data from the write notifier, so it's not a big problem. However, exporting the target to NBD etc. won't work, because of the likely stale metadata cache. Use BDRV_O_NO_BACKING in this case and manually set up the backing BdrvChild. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- blockdev.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 0b38c3d..0d3773b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3151,6 +3151,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, Error *local_err =3D NULL; int flags; int64_t size; + bool set_backing_hd =3D false; =20 if (!backup->has_speed) { backup->speed =3D 0; @@ -3201,6 +3202,8 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, } if (backup->sync =3D=3D MIRROR_SYNC_MODE_NONE) { source =3D bs; + flags |=3D BDRV_O_NO_BACKING; + set_backing_hd =3D true; } =20 size =3D bdrv_getlength(bs); @@ -3227,7 +3230,9 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, } =20 if (backup->format) { - options =3D qdict_new(); + if (!options) { + options =3D qdict_new(); + } qdict_put_str(options, "driver", backup->format); } =20 @@ -3238,6 +3243,14 @@ static BlockJob *do_drive_backup(DriveBackup *backup= , BlockJobTxn *txn, =20 bdrv_set_aio_context(target_bs, aio_context); =20 + if (set_backing_hd) { + bdrv_set_backing_hd(target_bs, source, &local_err); + if (local_err) { + bdrv_unref(target_bs); + goto out; + } + } + if (backup->has_bitmap) { bmap =3D bdrv_find_dirty_bitmap(bs, backup->bitmap); if (!bmap) { --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514263556109.56729510842911; Thu, 11 May 2017 07:51:03 -0700 (PDT) Received: from localhost ([::1]:48609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pQg-0000i5-2k for importer@patchew.org; Thu, 11 May 2017 10:50:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pA7-0001ne-94 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pA6-00072L-EH for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA1-0006wm-Hq; Thu, 11 May 2017 10:33:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8892A7F4C0; Thu, 11 May 2017 14:33:44 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id B96A67A407; Thu, 11 May 2017 14:33:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8892A7F4C0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8892A7F4C0 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:22 +0200 Message-Id: <1494513181-7900-20-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 11 May 2017 14:33:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 19/58] osdep: Add qemu_lock_fd and qemu_unlock_fd 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 They are wrappers of POSIX fcntl "file private locking", with a convenient "try lock" wrapper implemented with F_OFD_GETLK. Signed-off-by: Fam Zheng Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- include/qemu/osdep.h | 3 +++ util/osdep.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 122ff06..1c9f5e2 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -341,6 +341,9 @@ int qemu_close(int fd); #ifndef _WIN32 int qemu_dup(int fd); #endif +int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive); +int qemu_unlock_fd(int fd, int64_t start, int64_t len); +int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive); =20 #if defined(__HAIKU__) && defined(__i386__) #define FMT_pid "%ld" diff --git a/util/osdep.c b/util/osdep.c index 06fb1cf..3de4a18 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -140,6 +140,54 @@ static int qemu_parse_fdset(const char *param) { return qemu_parse_fd(param); } + +static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type) +{ +#ifdef F_OFD_SETLK + int ret; + struct flock fl =3D { + .l_whence =3D SEEK_SET, + .l_start =3D start, + .l_len =3D len, + .l_type =3D fl_type, + }; + ret =3D fcntl(fd, F_OFD_SETLK, &fl); + return ret =3D=3D -1 ? -errno : 0; +#else + return -ENOTSUP; +#endif +} + +int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive) +{ + return qemu_lock_fcntl(fd, start, len, exclusive ? F_WRLCK : F_RDLCK); +} + +int qemu_unlock_fd(int fd, int64_t start, int64_t len) +{ + return qemu_lock_fcntl(fd, start, len, F_UNLCK); +} + +int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive) +{ +#ifdef F_OFD_SETLK + int ret; + struct flock fl =3D { + .l_whence =3D SEEK_SET, + .l_start =3D start, + .l_len =3D len, + .l_type =3D exclusive ? F_WRLCK : F_RDLCK, + }; + ret =3D fcntl(fd, F_OFD_GETLK, &fl); + if (ret =3D=3D -1) { + return -errno; + } else { + return fl.l_type =3D=3D F_UNLCK ? 0 : -EAGAIN; + } +#else + return -ENOTSUP; +#endif +} #endif =20 /* --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149451414137183.03785552399506; Thu, 11 May 2017 07:49:01 -0700 (PDT) Received: from localhost ([::1]:48597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pOm-00078t-1E for importer@patchew.org; Thu, 11 May 2017 10:49:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAC-0001uw-2W for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pA6-00072S-I9 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37602) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA2-0006xe-P1; Thu, 11 May 2017 10:33:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B97E27F7A7; Thu, 11 May 2017 14:33:45 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id C88C57A407; Thu, 11 May 2017 14:33:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B97E27F7A7 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B97E27F7A7 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:23 +0200 Message-Id: <1494513181-7900-21-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 14:33:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 20/58] osdep: Fall back to posix lock when OFD lock is unavailable 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- util/osdep.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/util/osdep.c b/util/osdep.c index 3de4a18..a2863c8 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -38,6 +38,14 @@ extern int madvise(caddr_t, size_t, int); #include "qemu/error-report.h" #include "monitor/monitor.h" =20 +#ifdef F_OFD_SETLK +#define QEMU_SETLK F_OFD_SETLK +#define QEMU_GETLK F_OFD_GETLK +#else +#define QEMU_SETLK F_SETLK +#define QEMU_GETLK F_GETLK +#endif + static bool fips_enabled =3D false; =20 static const char *hw_version =3D QEMU_HW_VERSION; @@ -143,7 +151,6 @@ static int qemu_parse_fdset(const char *param) =20 static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type) { -#ifdef F_OFD_SETLK int ret; struct flock fl =3D { .l_whence =3D SEEK_SET, @@ -151,11 +158,8 @@ static int qemu_lock_fcntl(int fd, int64_t start, int6= 4_t len, int fl_type) .l_len =3D len, .l_type =3D fl_type, }; - ret =3D fcntl(fd, F_OFD_SETLK, &fl); + ret =3D fcntl(fd, QEMU_SETLK, &fl); return ret =3D=3D -1 ? -errno : 0; -#else - return -ENOTSUP; -#endif } =20 int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive) @@ -170,7 +174,6 @@ int qemu_unlock_fd(int fd, int64_t start, int64_t len) =20 int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive) { -#ifdef F_OFD_SETLK int ret; struct flock fl =3D { .l_whence =3D SEEK_SET, @@ -178,15 +181,12 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t = len, bool exclusive) .l_len =3D len, .l_type =3D exclusive ? F_WRLCK : F_RDLCK, }; - ret =3D fcntl(fd, F_OFD_GETLK, &fl); + ret =3D fcntl(fd, QEMU_GETLK, &fl); if (ret =3D=3D -1) { return -errno; } else { return fl.l_type =3D=3D F_UNLCK ? 0 : -EAGAIN; } -#else - return -ENOTSUP; -#endif } #endif =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514571555881.5027183762137; Thu, 11 May 2017 07:56:11 -0700 (PDT) Received: from localhost ([::1]:48635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pVh-0005bp-W8 for importer@patchew.org; Thu, 11 May 2017 10:56:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAF-0001ya-1m for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAB-00076u-Nt for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39620) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA3-0006yE-S3; Thu, 11 May 2017 10:33:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5533448D8D; Thu, 11 May 2017 14:33:46 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 026C97A407; Thu, 11 May 2017 14:33:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5533448D8D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5533448D8D From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:24 +0200 Message-Id: <1494513181-7900-22-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 11 May 2017 14:33:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 21/58] file-posix: Add image locking to perm operations 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 This extends the permission bits of op blocker API to external using Linux OFD locks. Each permission in @perm and @shared_perm is represented by a locked byte in the image file. Requesting a permission in @perm is translated to a shared lock of the corresponding byte; rejecting to share the same permission is translated to a shared lock of a separate byte. With that, we use 2x number of bytes of distinct permission types. virtlockd in libvirt locks the first byte, so we do locking from a higher offset. Suggested-by: Kevin Wolf Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/file-posix.c | 276 +++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 275 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index d13e99c..a09055b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -129,12 +129,23 @@ do { \ =20 #define MAX_BLOCKSIZE 4096 =20 +/* Posix file locking bytes. Libvirt takes byte 0, we start from higher by= tes, + * leaving a few more bytes for its future use. */ +#define RAW_LOCK_PERM_BASE 100 +#define RAW_LOCK_SHARED_BASE 200 + typedef struct BDRVRawState { int fd; + int lock_fd; + bool use_lock; int type; int open_flags; size_t buf_align; =20 + /* The current permissions. */ + uint64_t perm; + uint64_t shared_perm; + #ifdef CONFIG_XFS bool is_xfs:1; #endif @@ -411,6 +422,7 @@ static int raw_open_common(BlockDriverState *bs, QDict = *options, BlockdevAioOptions aio, aio_default; int fd, ret; struct stat st; + OnOffAuto locking; =20 opts =3D qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); @@ -440,6 +452,37 @@ static int raw_open_common(BlockDriverState *bs, QDict= *options, } s->use_linux_aio =3D (aio =3D=3D BLOCKDEV_AIO_OPTIONS_NATIVE); =20 + locking =3D qapi_enum_parse(OnOffAuto_lookup, qemu_opt_get(opts, "lock= ing"), + ON_OFF_AUTO__MAX, ON_OFF_AUTO_AUTO, &local_e= rr); + if (local_err) { + error_propagate(errp, local_err); + ret =3D -EINVAL; + goto fail; + } + switch (locking) { + case ON_OFF_AUTO_ON: + s->use_lock =3D true; +#ifndef F_OFD_SETLK + fprintf(stderr, + "File lock requested but OFD locking syscall is unavailabl= e, " + "falling back to POSIX file locks.\n" + "Due to the implementation, locks can be lost unexpectedly= .\n"); +#endif + break; + case ON_OFF_AUTO_OFF: + s->use_lock =3D false; + break; + case ON_OFF_AUTO_AUTO: +#ifdef F_OFD_SETLK + s->use_lock =3D true; +#else + s->use_lock =3D false; +#endif + break; + default: + abort(); + } + s->open_flags =3D open_flags; raw_parse_flags(bdrv_flags, &s->open_flags); =20 @@ -455,6 +498,21 @@ static int raw_open_common(BlockDriverState *bs, QDict= *options, } s->fd =3D fd; =20 + s->lock_fd =3D -1; + if (s->use_lock) { + fd =3D qemu_open(filename, s->open_flags); + if (fd < 0) { + ret =3D -errno; + error_setg_errno(errp, errno, "Could not open '%s' for locking= ", + filename); + qemu_close(s->fd); + goto fail; + } + s->lock_fd =3D fd; + } + s->perm =3D 0; + s->shared_perm =3D BLK_PERM_ALL; + #ifdef CONFIG_LINUX_AIO /* Currently Linux does AIO only for files opened with O_DIRECT */ if (s->use_linux_aio && !(s->open_flags & O_DIRECT)) { @@ -542,6 +600,161 @@ static int raw_open(BlockDriverState *bs, QDict *opti= ons, int flags, return raw_open_common(bs, options, flags, 0, errp); } =20 +typedef enum { + RAW_PL_PREPARE, + RAW_PL_COMMIT, + RAW_PL_ABORT, +} RawPermLockOp; + +#define PERM_FOREACH(i) \ + for ((i) =3D 0; (1ULL << (i)) <=3D BLK_PERM_ALL; i++) + +/* Lock bytes indicated by @perm_lock_bits and @shared_perm_lock_bits in t= he + * file; if @unlock =3D=3D true, also unlock the unneeded bytes. + * @shared_perm_lock_bits is the mask of all permissions that are NOT shar= ed. + */ +static int raw_apply_lock_bytes(BDRVRawState *s, + uint64_t perm_lock_bits, + uint64_t shared_perm_lock_bits, + bool unlock, Error **errp) +{ + int ret; + int i; + + PERM_FOREACH(i) { + int off =3D RAW_LOCK_PERM_BASE + i; + if (perm_lock_bits & (1ULL << i)) { + ret =3D qemu_lock_fd(s->lock_fd, off, 1, false); + if (ret) { + error_setg(errp, "Failed to lock byte %d", off); + return ret; + } + } else if (unlock) { + ret =3D qemu_unlock_fd(s->lock_fd, off, 1); + if (ret) { + error_setg(errp, "Failed to unlock byte %d", off); + return ret; + } + } + } + PERM_FOREACH(i) { + int off =3D RAW_LOCK_SHARED_BASE + i; + if (shared_perm_lock_bits & (1ULL << i)) { + ret =3D qemu_lock_fd(s->lock_fd, off, 1, false); + if (ret) { + error_setg(errp, "Failed to lock byte %d", off); + return ret; + } + } else if (unlock) { + ret =3D qemu_unlock_fd(s->lock_fd, off, 1); + if (ret) { + error_setg(errp, "Failed to unlock byte %d", off); + return ret; + } + } + } + return 0; +} + +/* Check "unshared" bytes implied by @perm and ~@shared_perm in the file. = */ +static int raw_check_lock_bytes(BDRVRawState *s, + uint64_t perm, uint64_t shared_perm, + Error **errp) +{ + int ret; + int i; + + PERM_FOREACH(i) { + int off =3D RAW_LOCK_SHARED_BASE + i; + uint64_t p =3D 1ULL << i; + if (perm & p) { + ret =3D qemu_lock_fd_test(s->lock_fd, off, 1, true); + if (ret) { + char *perm_name =3D bdrv_perm_names(p); + error_setg(errp, + "Failed to get \"%s\" lock", + perm_name); + g_free(perm_name); + error_append_hint(errp, + "Is another process using the image?\n"); + return ret; + } + } + } + PERM_FOREACH(i) { + int off =3D RAW_LOCK_PERM_BASE + i; + uint64_t p =3D 1ULL << i; + if (!(shared_perm & p)) { + ret =3D qemu_lock_fd_test(s->lock_fd, off, 1, true); + if (ret) { + char *perm_name =3D bdrv_perm_names(p); + error_setg(errp, + "Failed to get shared \"%s\" lock", + perm_name); + g_free(perm_name); + error_append_hint(errp, + "Is another process using the image?\n"); + return ret; + } + } + } + return 0; +} + +static int raw_handle_perm_lock(BlockDriverState *bs, + RawPermLockOp op, + uint64_t new_perm, uint64_t new_shared, + Error **errp) +{ + BDRVRawState *s =3D bs->opaque; + int ret =3D 0; + Error *local_err =3D NULL; + + if (!s->use_lock) { + return 0; + } + + if (bdrv_get_flags(bs) & BDRV_O_INACTIVE) { + return 0; + } + + assert(s->lock_fd > 0); + + switch (op) { + case RAW_PL_PREPARE: + ret =3D raw_apply_lock_bytes(s, s->perm | new_perm, + ~s->shared_perm | ~new_shared, + false, errp); + if (!ret) { + ret =3D raw_check_lock_bytes(s, new_perm, new_shared, errp); + if (!ret) { + return 0; + } + } + op =3D RAW_PL_ABORT; + /* fall through to unlock bytes. */ + case RAW_PL_ABORT: + raw_apply_lock_bytes(s, s->perm, ~s->shared_perm, true, &local_err= ); + if (local_err) { + /* Theoretically the above call only unlocks bytes and it cann= ot + * fail. Something weird happened, report it. + */ + error_report_err(local_err); + } + break; + case RAW_PL_COMMIT: + raw_apply_lock_bytes(s, new_perm, ~new_shared, true, &local_err); + if (local_err) { + /* Theoretically the above call only unlocks bytes and it cann= ot + * fail. Something weird happened, report it. + */ + error_report_err(local_err); + } + break; + } + return ret; +} + static int raw_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { @@ -1410,6 +1623,10 @@ static void raw_close(BlockDriverState *bs) qemu_close(s->fd); s->fd =3D -1; } + if (s->lock_fd >=3D 0) { + qemu_close(s->lock_fd); + s->lock_fd =3D -1; + } } =20 static int raw_truncate(BlockDriverState *bs, int64_t offset, Error **errp) @@ -1954,6 +2171,54 @@ static QemuOptsList raw_create_opts =3D { } }; =20 +static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t sh= ared, + Error **errp) +{ + return raw_handle_perm_lock(bs, RAW_PL_PREPARE, perm, shared, errp); +} + +static void raw_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t sha= red) +{ + BDRVRawState *s =3D bs->opaque; + raw_handle_perm_lock(bs, RAW_PL_COMMIT, perm, shared, NULL); + s->perm =3D perm; + s->shared_perm =3D shared; +} + +static void raw_abort_perm_update(BlockDriverState *bs) +{ + raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL); +} + +static int raw_inactivate(BlockDriverState *bs) +{ + int ret; + uint64_t perm =3D 0; + uint64_t shared =3D BLK_PERM_ALL; + + ret =3D raw_handle_perm_lock(bs, RAW_PL_PREPARE, perm, shared, NULL); + if (ret) { + return ret; + } + raw_handle_perm_lock(bs, RAW_PL_COMMIT, perm, shared, NULL); + return 0; +} + + +static void raw_invalidate_cache(BlockDriverState *bs, Error **errp) +{ + BDRVRawState *s =3D bs->opaque; + int ret; + + assert(!(bdrv_get_flags(bs) & BDRV_O_INACTIVE)); + ret =3D raw_handle_perm_lock(bs, RAW_PL_PREPARE, s->perm, s->shared_pe= rm, + errp); + if (ret) { + return; + } + raw_handle_perm_lock(bs, RAW_PL_COMMIT, s->perm, s->shared_perm, NULL); +} + BlockDriver bdrv_file =3D { .format_name =3D "file", .protocol_name =3D "file", @@ -1984,7 +2249,11 @@ BlockDriver bdrv_file =3D { .bdrv_get_info =3D raw_get_info, .bdrv_get_allocated_file_size =3D raw_get_allocated_file_size, - + .bdrv_inactivate =3D raw_inactivate, + .bdrv_invalidate_cache =3D raw_invalidate_cache, + .bdrv_check_perm =3D raw_check_perm, + .bdrv_set_perm =3D raw_set_perm, + .bdrv_abort_perm_update =3D raw_abort_perm_update, .create_opts =3D &raw_create_opts, }; =20 @@ -2443,6 +2712,11 @@ static BlockDriver bdrv_host_device =3D { .bdrv_get_info =3D raw_get_info, .bdrv_get_allocated_file_size =3D raw_get_allocated_file_size, + .bdrv_inactivate =3D raw_inactivate, + .bdrv_invalidate_cache =3D raw_invalidate_cache, + .bdrv_check_perm =3D raw_check_perm, + .bdrv_set_perm =3D raw_set_perm, + .bdrv_abort_perm_update =3D raw_abort_perm_update, .bdrv_probe_blocksizes =3D hdev_probe_blocksizes, .bdrv_probe_geometry =3D hdev_probe_geometry, =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514436449502.88232581425245; Thu, 11 May 2017 07:53:56 -0700 (PDT) Received: from localhost ([::1]:48620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pTU-0003ag-VV for importer@patchew.org; Thu, 11 May 2017 10:53:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAD-0001vI-H0 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAA-00075O-Ns for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34531) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA4-000708-RX; Thu, 11 May 2017 10:33:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB777C04B93B; Thu, 11 May 2017 14:33:47 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CCF27A407; Thu, 11 May 2017 14:33:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CB777C04B93B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CB777C04B93B From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:25 +0200 Message-Id: <1494513181-7900-23-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 14:33:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 22/58] qemu-iotests: Add test case 153 for image locking 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/153 | 233 +++++++++++++++++++++++++++ tests/qemu-iotests/153.out | 390 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/group | 1 + 3 files changed, 624 insertions(+) create mode 100755 tests/qemu-iotests/153 create mode 100644 tests/qemu-iotests/153.out diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 new file mode 100755 index 0000000..0b45d78 --- /dev/null +++ b/tests/qemu-iotests/153 @@ -0,0 +1,233 @@ +#!/bin/bash +# +# Test image locking +# +# Copyright 2016, 2017 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=3Dfamz@redhat.com + +seq=3D"$(basename $0)" +echo "QA output created by $seq" + +here=3D"$PWD" +tmp=3D/tmp/$$ +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f "${TEST_IMG}.base" + rm -f "${TEST_IMG}.convert" + rm -f "${TEST_IMG}.a" + rm -f "${TEST_IMG}.b" + rm -f "${TEST_IMG}.lnk" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +size=3D32M + +_check_ofd() +{ + _make_test_img $size >/dev/null + if $QEMU_IMG_PROG info --image-opts "driver=3Dfile,locking=3Don,filena= me=3D$TEST_IMG" 2>&1 | + grep -q 'falling back to POSIX file'; then + return 1 + else + return 0 + fi +} + +_check_ofd || _notrun "OFD lock not available" + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +_run_cmd() +{ + echo + (echo "$@"; "$@" 2>&1 1>/dev/null) | _filter_testdir +} + +function _do_run_qemu() +{ + ( + if ! test -t 0; then + while read cmd; do + echo $cmd + done + fi + echo quit + ) | $QEMU -nographic -monitor stdio -serial none "$@" 1>/dev/null +} + +function _run_qemu_with_images() +{ + _do_run_qemu \ + $(for i in $@; do echo "-drive if=3Dnone,file=3D$i"; done) 2>&1 \ + | _filter_testdir | _filter_qemu +} + +echo "=3D=3D readonly=3Doff,force-share=3Don should be rejected =3D=3D" +_run_qemu_with_images null-co://,readonly=3Doff,force-share=3Don + +for opts1 in "" "read-only=3Don" "read-only=3Don,force-share=3Don"; do + echo + echo "=3D=3D Creating base image =3D=3D" + TEST_IMG=3D"${TEST_IMG}.base" _make_test_img $size + + echo + echo "=3D=3D Creating test image =3D=3D" + $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" -b ${TEST_IMG}.base | _filte= r_img_create + + echo + echo "=3D=3D Launching QEMU, opts: '$opts1' =3D=3D" + _launch_qemu -drive file=3D"${TEST_IMG}",if=3Dnone,$opts1 + h=3D$QEMU_HANDLE + + for opts2 in "" "read-only=3Don" "read-only=3Don,force-share=3Don"; do + echo + echo "=3D=3D Launching another QEMU, opts: '$opts2' =3D=3D" + echo "quit" | \ + $QEMU -nographic -monitor stdio \ + -drive file=3D"${TEST_IMG}",if=3Dnone,$opts2 2>&1 1>/dev/null = | \ + _filter_testdir | _filter_qemu + done + + for L in "" "-U"; do + + echo + echo "=3D=3D Running utility commands $L =3D=3D" + _run_cmd $QEMU_IO $L -c "read 0 512" "${TEST_IMG}" + _run_cmd $QEMU_IO $L -r -c "read 0 512" "${TEST_IMG}" + _run_cmd $QEMU_IO -c "open $L ${TEST_IMG}" -c "read 0 512" + _run_cmd $QEMU_IO -c "open -r $L ${TEST_IMG}" -c "read 0 512" + _run_cmd $QEMU_IMG info $L "${TEST_IMG}" + _run_cmd $QEMU_IMG check $L "${TEST_IMG}" + _run_cmd $QEMU_IMG compare $L "${TEST_IMG}" "${TEST_IMG}" + _run_cmd $QEMU_IMG map $L "${TEST_IMG}" + _run_cmd $QEMU_IMG amend -o "" $L "${TEST_IMG}" + _run_cmd $QEMU_IMG commit $L "${TEST_IMG}" + _run_cmd $QEMU_IMG resize $L "${TEST_IMG}" $size + _run_cmd $QEMU_IMG rebase $L "${TEST_IMG}" -b "${TEST_IMG}.ba= se" + _run_cmd $QEMU_IMG snapshot -l $L "${TEST_IMG}" + _run_cmd $QEMU_IMG convert $L "${TEST_IMG}" "${TEST_IMG}.conve= rt" + _run_cmd $QEMU_IMG dd $L if=3D"${TEST_IMG}" of=3D"${TEST_= IMG}.convert" bs=3D512 count=3D1 + _run_cmd $QEMU_IMG bench $L -c 1 "${TEST_IMG}" + _run_cmd $QEMU_IMG bench $L -w -c 1 "${TEST_IMG}" + done + _send_qemu_cmd $h "{ 'execute': 'quit', }" "" + echo + echo "Round done" + _cleanup_qemu +done + +for opt1 in $test_opts; do + for opt2 in $test_opts; do + echo + echo "=3D=3D Two devices with the same image ($opt1 - $opt2) =3D= =3D" + _run_qemu_with_images "${TEST_IMG},$opt1" "${TEST_IMG},$opt2" + done +done + +echo "=3D=3D Creating ${TEST_IMG}.[abc] =3D=3D" | _filter_testdir +( + $QEMU_IMG create -f qcow2 "${TEST_IMG}.a" -b "${TEST_IMG}" + $QEMU_IMG create -f qcow2 "${TEST_IMG}.b" -b "${TEST_IMG}" + $QEMU_IMG create -f qcow2 "${TEST_IMG}.c" -b "${TEST_IMG}.b" +) | _filter_img_create + +echo +echo "=3D=3D Two devices sharing the same file in backing chain =3D=3D" +_run_qemu_with_images "${TEST_IMG}.a" "${TEST_IMG}.b" +_run_qemu_with_images "${TEST_IMG}.a" "${TEST_IMG}.c" + +echo +echo "=3D=3D Backing image also as an active device =3D=3D" +_run_qemu_with_images "${TEST_IMG}.a" "${TEST_IMG}" + +echo +echo "=3D=3D Backing image also as an active device (ro) =3D=3D" +_run_qemu_with_images "${TEST_IMG}.a" "${TEST_IMG},readonly=3Don" + +echo +echo "=3D=3D Symbolic link =3D=3D" +rm -f "${TEST_IMG}.lnk" &>/dev/null +ln -s ${TEST_IMG} "${TEST_IMG}.lnk" || echo "Failed to create link" +_run_qemu_with_images "${TEST_IMG}.lnk" "${TEST_IMG}" + +echo +echo "=3D=3D Closing an image should unlock it =3D=3D" +_launch_qemu + +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'qmp_capabilities' }" \ + 'return' + +echo "Adding drive" +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_add 0 if=3Dnone,id=3Dd0,file= =3D${TEST_IMG}' } }" \ + "" + +_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512' + +echo "Closing drive" +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_del d0' } }" \ + "" + +_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512' + +echo "Adding two and closing one" +for d in d0 d1; do + _send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_add 0 if=3Dnone,id=3D$d,f= ile=3D${TEST_IMG},readonly=3Don' } }" \ + "" +done + +_run_cmd $QEMU_IMG info "${TEST_IMG}" + +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_del d0' } }" \ + "" + +_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512' + +echo "Closing the other" +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': { 'command-line': 'drive_del d1' } }" \ + "" + +_run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512' + +_cleanup_qemu + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out new file mode 100644 index 0000000..5ba0b63 --- /dev/null +++ b/tests/qemu-iotests/153.out @@ -0,0 +1,390 @@ +QA output created by 153 +=3D=3D readonly=3Doff,force-share=3Don should be rejected =3D=3D +QEMU_PROG: -drive if=3Dnone,file=3Dnull-co://,readonly=3Doff,force-share= =3Don: force-share=3Don can only be used with read-only images + +=3D=3D Creating base image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D33554432 + +=3D=3D Creating test image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 backing_file= =3DTEST_DIR/t.IMGFMT.base + +=3D=3D Launching QEMU, opts: '' =3D=3D + +=3D=3D Launching another QEMU, opts: '' =3D=3D +QEMU_PROG: -drive file=3DTEST_DIR/t.qcow2,if=3Dnone,: Failed to get "write= " lock +Is another process using the image? + +=3D=3D Launching another QEMU, opts: 'read-only=3Don' =3D=3D +QEMU_PROG: -drive file=3DTEST_DIR/t.qcow2,if=3Dnone,read-only=3Don: Failed= to get shared "write" lock +Is another process using the image? + +=3D=3D Launching another QEMU, opts: 'read-only=3Don,force-share=3Don' =3D= =3D + +=3D=3D Running utility commands =3D=3D + +_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: Failed to get "write" lock +Is another process using the image? + +_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock +Is another process using the image? + +_qemu_io_wrapper -c open TEST_DIR/t.qcow2 -c read 0 512 +can't open device TEST_DIR/t.qcow2: Failed to get "write" lock +Is another process using the image? + +_qemu_io_wrapper -c open -r TEST_DIR/t.qcow2 -c read 0 512 +can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock +Is another process using the image? + +_qemu_img_wrapper info TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper check TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper map TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper amend -o TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper commit TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper dd if=3DTEST_DIR/t.qcow2 of=3DTEST_DIR/t.qcow2.convert b= s=3D512 count=3D1 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" = lock +Is another process using the image? + +_qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +=3D=3D Running utility commands -U =3D=3D + +_qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: force-share=3Don can only be used with= read-only images + +_qemu_io_wrapper -U -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -c open -U TEST_DIR/t.qcow2 -c read 0 512 +can't open device TEST_DIR/t.qcow2: force-share=3Don can only be used with= read-only images + +_qemu_io_wrapper -c open -r -U TEST_DIR/t.qcow2 -c read 0 512 + +_qemu_img_wrapper info -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper check -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -o -U TEST_DIR/t.qcow2 +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper commit -U TEST_DIR/t.qcow2 +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +_qemu_img_wrapper dd -U if=3DTEST_DIR/t.qcow2 of=3DTEST_DIR/t.qcow2.conver= t bs=3D512 count=3D1 + +_qemu_img_wrapper bench -U -c 1 TEST_DIR/t.qcow2 + +_qemu_img_wrapper bench -U -w -c 1 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': force-share=3Don can only be = used with read-only images + +Round done + +=3D=3D Creating base image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D33554432 + +=3D=3D Creating test image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 backing_file= =3DTEST_DIR/t.IMGFMT.base + +=3D=3D Launching QEMU, opts: 'read-only=3Don' =3D=3D + +=3D=3D Launching another QEMU, opts: '' =3D=3D +QEMU_PROG: -drive file=3DTEST_DIR/t.qcow2,if=3Dnone,: Failed to get "write= " lock +Is another process using the image? + +=3D=3D Launching another QEMU, opts: 'read-only=3Don' =3D=3D + +=3D=3D Launching another QEMU, opts: 'read-only=3Don,force-share=3Don' =3D= =3D + +=3D=3D Running utility commands =3D=3D + +_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: Failed to get "write" lock +Is another process using the image? + +_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -c open TEST_DIR/t.qcow2 -c read 0 512 +can't open device TEST_DIR/t.qcow2: Failed to get "write" lock +Is another process using the image? + +_qemu_io_wrapper -c open -r TEST_DIR/t.qcow2 -c read 0 512 + +_qemu_img_wrapper info TEST_DIR/t.qcow2 + +_qemu_img_wrapper check TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -o TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper commit TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +_qemu_img_wrapper dd if=3DTEST_DIR/t.qcow2 of=3DTEST_DIR/t.qcow2.convert b= s=3D512 count=3D1 + +_qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2 + +_qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +=3D=3D Running utility commands -U =3D=3D + +_qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: force-share=3Don can only be used with= read-only images + +_qemu_io_wrapper -U -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -c open -U TEST_DIR/t.qcow2 -c read 0 512 +can't open device TEST_DIR/t.qcow2: force-share=3Don can only be used with= read-only images + +_qemu_io_wrapper -c open -r -U TEST_DIR/t.qcow2 -c read 0 512 + +_qemu_img_wrapper info -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper check -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -o -U TEST_DIR/t.qcow2 +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper commit -U TEST_DIR/t.qcow2 +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base +qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock +Is another process using the image? + +_qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +_qemu_img_wrapper dd -U if=3DTEST_DIR/t.qcow2 of=3DTEST_DIR/t.qcow2.conver= t bs=3D512 count=3D1 + +_qemu_img_wrapper bench -U -c 1 TEST_DIR/t.qcow2 + +_qemu_img_wrapper bench -U -w -c 1 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': force-share=3Don can only be = used with read-only images + +Round done + +=3D=3D Creating base image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D33554432 + +=3D=3D Creating test image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 backing_file= =3DTEST_DIR/t.IMGFMT.base + +=3D=3D Launching QEMU, opts: 'read-only=3Don,force-share=3Don' =3D=3D + +=3D=3D Launching another QEMU, opts: '' =3D=3D + +=3D=3D Launching another QEMU, opts: 'read-only=3Don' =3D=3D + +=3D=3D Launching another QEMU, opts: 'read-only=3Don,force-share=3Don' =3D= =3D + +=3D=3D Running utility commands =3D=3D + +_qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -c open TEST_DIR/t.qcow2 -c read 0 512 + +_qemu_io_wrapper -c open -r TEST_DIR/t.qcow2 -c read 0 512 + +_qemu_img_wrapper info TEST_DIR/t.qcow2 + +_qemu_img_wrapper check TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -o TEST_DIR/t.qcow2 + +_qemu_img_wrapper commit TEST_DIR/t.qcow2 + +_qemu_img_wrapper resize TEST_DIR/t.qcow2 32M + +_qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base + +_qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +_qemu_img_wrapper dd if=3DTEST_DIR/t.qcow2 of=3DTEST_DIR/t.qcow2.convert b= s=3D512 count=3D1 + +_qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2 + +_qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2 + +=3D=3D Running utility commands -U =3D=3D + +_qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2 +can't open device TEST_DIR/t.qcow2: force-share=3Don can only be used with= read-only images + +_qemu_io_wrapper -U -r -c read 0 512 TEST_DIR/t.qcow2 + +_qemu_io_wrapper -c open -U TEST_DIR/t.qcow2 -c read 0 512 +can't open device TEST_DIR/t.qcow2: force-share=3Don can only be used with= read-only images + +_qemu_io_wrapper -c open -r -U TEST_DIR/t.qcow2 -c read 0 512 + +_qemu_img_wrapper info -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper check -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper compare -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2 + +_qemu_img_wrapper map -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper amend -o -U TEST_DIR/t.qcow2 +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper commit -U TEST_DIR/t.qcow2 +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper resize -U TEST_DIR/t.qcow2 32M +qemu-img: unrecognized option '-U' +Try 'qemu-img --help' for more information + +_qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base + +_qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2 + +_qemu_img_wrapper convert -U TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert + +_qemu_img_wrapper dd -U if=3DTEST_DIR/t.qcow2 of=3DTEST_DIR/t.qcow2.conver= t bs=3D512 count=3D1 + +_qemu_img_wrapper bench -U -c 1 TEST_DIR/t.qcow2 + +_qemu_img_wrapper bench -U -w -c 1 TEST_DIR/t.qcow2 +qemu-img: Could not open 'TEST_DIR/t.qcow2': force-share=3Don can only be = used with read-only images + +Round done +=3D=3D Creating TEST_DIR/t.qcow2.[abc] =3D=3D +Formatting 'TEST_DIR/t.IMGFMT.a', fmt=3DIMGFMT size=3D33554432 backing_fil= e=3DTEST_DIR/t.IMGFMT +Formatting 'TEST_DIR/t.IMGFMT.b', fmt=3DIMGFMT size=3D33554432 backing_fil= e=3DTEST_DIR/t.IMGFMT +Formatting 'TEST_DIR/t.IMGFMT.c', fmt=3DIMGFMT size=3D33554432 backing_fil= e=3DTEST_DIR/t.IMGFMT.b + +=3D=3D Two devices sharing the same file in backing chain =3D=3D + +=3D=3D Backing image also as an active device =3D=3D +QEMU_PROG: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2: Failed to get "write"= lock +Is another process using the image? + +=3D=3D Backing image also as an active device (ro) =3D=3D + +=3D=3D Symbolic link =3D=3D +QEMU_PROG: -drive if=3Dnone,file=3DTEST_DIR/t.qcow2: Failed to get "write"= lock +Is another process using the image? + +=3D=3D Closing an image should unlock it =3D=3D +{"return": {}} +Adding drive + +_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 +can't open device TEST_DIR/t.qcow2: Failed to get "write" lock +Is another process using the image? +Closing drive + +_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 +Adding two and closing one + +_qemu_img_wrapper info TEST_DIR/t.qcow2 + +_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 +can't open device TEST_DIR/t.qcow2: Failed to get "write" lock +Is another process using the image? +Closing the other + +_qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 893962d..c8ae60e 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -154,6 +154,7 @@ 149 rw auto sudo 150 rw auto quick 152 rw auto quick +153 rw auto quick 154 rw auto backing quick 155 rw auto 156 rw auto quick --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514286763936.7745883424645; Thu, 11 May 2017 07:51:26 -0700 (PDT) Received: from localhost ([::1]:48611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pR7-00016k-3W for importer@patchew.org; Thu, 11 May 2017 10:51:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAB-0001tr-Ll for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAA-00075F-Fb for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA7-00072s-NW; Thu, 11 May 2017 10:33:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1F44C83D; Thu, 11 May 2017 14:33:50 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18B947A407; Thu, 11 May 2017 14:33:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B1F44C83D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B1F44C83D From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:26 +0200 Message-Id: <1494513181-7900-24-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 14:33:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 23/58] tests: Add POSIX image locking test case 182 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/182 | 68 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/182.out | 8 ++++++ tests/qemu-iotests/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/qemu-iotests/182 create mode 100644 tests/qemu-iotests/182.out diff --git a/tests/qemu-iotests/182 b/tests/qemu-iotests/182 new file mode 100755 index 0000000..7ecbb22 --- /dev/null +++ b/tests/qemu-iotests/182 @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Test image locking for POSIX locks +# +# Copyright 2017 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=3Dfamz@redhat.com + +seq=3D"$(basename $0)" +echo "QA output created by $seq" + +here=3D"$PWD" +tmp=3D/tmp/$$ +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +size=3D32M + +_make_test_img $size + +echo "Starting QEMU" +_launch_qemu -drive file=3D$TEST_IMG,if=3Dnone,id=3Ddrive0,file.locking=3D= on \ + -device virtio-blk-pci,drive=3Ddrive0 + +echo +echo "Starting a second QEMU using the same image should fail" +echo 'quit' | $QEMU -monitor stdio \ + -drive file=3D$TEST_IMG,if=3Dnone,id=3Ddrive0,file.locking=3Don \ + -device virtio-blk-pci,drive=3Ddrive0 2>&1 | _filter_testdir 2>&1 | + _filter_qemu | + sed -e '/falling back to POSIX file/d' \ + -e '/locks can be lost unexpectedly/d' + +_cleanup_qemu + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out new file mode 100644 index 0000000..23a4dbf --- /dev/null +++ b/tests/qemu-iotests/182.out @@ -0,0 +1,8 @@ +QA output created by 182 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 +Starting QEMU + +Starting a second QEMU using the same image should fail +QEMU_PROG: -drive file=3DTEST_DIR/t.qcow2,if=3Dnone,id=3Ddrive0,file.locki= ng=3Don: Failed to get "write" lock +Is another process using the image? +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index c8ae60e..a4549d8 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -171,3 +171,4 @@ 175 auto quick 176 rw auto backing 181 rw auto migration +182 rw auto quick --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514288433140.5477522410995; Thu, 11 May 2017 07:51:28 -0700 (PDT) Received: from localhost ([::1]:48612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pR9-00018d-6R for importer@patchew.org; Thu, 11 May 2017 10:51:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAF-0001yP-0P for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAB-00075g-2S for qemu-devel@nongnu.org; Thu, 11 May 2017 10:33:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA8-00073v-SO; Thu, 11 May 2017 10:33:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD069C04B929; Thu, 11 May 2017 14:33:51 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id F21D87A407; Thu, 11 May 2017 14:33:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DD069C04B929 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DD069C04B929 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:27 +0200 Message-Id: <1494513181-7900-25-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 14:33:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 24/58] qcow2: Fix preallocation size formula 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Max Reitz When calculating the number of reftable entries, we should actually use the number of refblocks and not (wrongly[1]) re-calculate it. [1] "Wrongly" means: Dividing the number of clusters by the number of entries per refblock and rounding down instead of up. Reported-by: Eric Blake Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/qcow2.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 1c26977..8caf800 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2139,7 +2139,7 @@ static int qcow2_create2(const char *filename, int64_= t total_size, * too, as long as the bulk is allocated here). Therefore, using * floating point arithmetic is fine. */ int64_t meta_size =3D 0; - uint64_t nreftablee, nrefblocke, nl1e, nl2e; + uint64_t nreftablee, nrefblocke, nl1e, nl2e, refblock_count; int64_t aligned_total_size =3D align_offset(total_size, cluster_si= ze); int refblock_bits, refblock_size; /* refcount entry size in bytes */ @@ -2182,11 +2182,12 @@ static int qcow2_create2(const char *filename, int6= 4_t total_size, nrefblocke =3D (aligned_total_size + meta_size + cluster_size) / (cluster_size - rces - rces * sizeof(uint64_t) / cluster_size); - meta_size +=3D DIV_ROUND_UP(nrefblocke, refblock_size) * cluster_s= ize; + refblock_count =3D DIV_ROUND_UP(nrefblocke, refblock_size); + meta_size +=3D refblock_count * cluster_size; =20 /* total size of refcount tables */ - nreftablee =3D nrefblocke / refblock_size; - nreftablee =3D align_offset(nreftablee, cluster_size / sizeof(uint= 64_t)); + nreftablee =3D align_offset(refblock_count, + cluster_size / sizeof(uint64_t)); meta_size +=3D nreftablee * sizeof(uint64_t); =20 qemu_opt_set_number(opts, BLOCK_OPT_SIZE, --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514579705984.4918258477694; Thu, 11 May 2017 07:56:19 -0700 (PDT) Received: from localhost ([::1]:48637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pVq-0005m7-9S for importer@patchew.org; Thu, 11 May 2017 10:56:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAG-00023m-F7 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAF-0007A0-76 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53932) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pA9-00074J-Uk; Thu, 11 May 2017 10:33:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E87DA624CC; Thu, 11 May 2017 14:33:52 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A5157A407; Thu, 11 May 2017 14:33:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E87DA624CC Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E87DA624CC From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:28 +0200 Message-Id: <1494513181-7900-26-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:33:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 25/58] qcow2: Reuse preallocated zero clusters 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Max Reitz Instead of just freeing preallocated zero clusters and completely allocating them from scratch, reuse them. We cannot do this in handle_copied(), however, since this is a COW operation. Therefore, we have to add the new logic to handle_alloc() and simply return the existing offset if it exists. The only catch is that we have to convince qcow2_alloc_cluster_link_l2() not to free the old clusters (because we have reused them). Reported-by: Eric Blake Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 80 +++++++++++++++++++++++++++++++++++------------= ---- block/qcow2.h | 3 ++ 2 files changed, 59 insertions(+), 24 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 100398c..fb91fd8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -309,14 +309,20 @@ static int count_contiguous_clusters(int nb_clusters,= int cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; + int first_cluster_type; uint64_t mask =3D stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED; uint64_t first_entry =3D be64_to_cpu(l2_table[0]); uint64_t offset =3D first_entry & mask; =20 - if (!offset) + if (!offset) { return 0; + } =20 - assert(qcow2_get_cluster_type(first_entry) =3D=3D QCOW2_CLUSTER_NORMAL= ); + /* must be allocated */ + first_cluster_type =3D qcow2_get_cluster_type(first_entry); + assert(first_cluster_type =3D=3D QCOW2_CLUSTER_NORMAL || + (first_cluster_type =3D=3D QCOW2_CLUSTER_ZERO && + (first_entry & L2E_OFFSET_MASK) !=3D 0)); =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t l2_entry =3D be64_to_cpu(l2_table[i]) & mask; @@ -835,7 +841,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, Q= CowL2Meta *m) * Don't discard clusters that reach a refcount of 0 (e.g. compressed * clusters), the next write will reuse them anyway. */ - if (j !=3D 0) { + if (!m->keep_old_clusters && j !=3D 0) { for (i =3D 0; i < j; i++) { qcow2_free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1, QCOW2_DISCARD_NEVER); @@ -1132,8 +1138,9 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, uint64_t entry; uint64_t nb_clusters; int ret; + bool keep_old_clusters =3D false; =20 - uint64_t alloc_cluster_offset; + uint64_t alloc_cluster_offset =3D 0; =20 trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_of= fset, *bytes); @@ -1170,31 +1177,54 @@ static int handle_alloc(BlockDriverState *bs, uint6= 4_t guest_offset, * wrong with our code. */ assert(nb_clusters > 0); =20 - qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + if (qcow2_get_cluster_type(entry) =3D=3D QCOW2_CLUSTER_ZERO && + (entry & L2E_OFFSET_MASK) !=3D 0 && (entry & QCOW_OFLAG_COPIED) && + (!*host_offset || + start_of_cluster(s, *host_offset) =3D=3D (entry & L2E_OFFSET_MASK= ))) + { + /* Try to reuse preallocated zero clusters; contiguous normal clus= ters + * would be fine, too, but count_cow_clusters() above has limited + * nb_clusters already to a range of COW clusters */ + int preallocated_nb_clusters =3D + count_contiguous_clusters(nb_clusters, s->cluster_size, + &l2_table[l2_index], QCOW_OFLAG_COPI= ED); + assert(preallocated_nb_clusters > 0); =20 - /* Allocate, if necessary at a given offset in the image file */ - alloc_cluster_offset =3D start_of_cluster(s, *host_offset); - ret =3D do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offse= t, - &nb_clusters); - if (ret < 0) { - goto fail; - } + nb_clusters =3D preallocated_nb_clusters; + alloc_cluster_offset =3D entry & L2E_OFFSET_MASK; =20 - /* Can't extend contiguous allocation */ - if (nb_clusters =3D=3D 0) { - *bytes =3D 0; - return 0; + /* We want to reuse these clusters, so qcow2_alloc_cluster_link_l2= () + * should not free them. */ + keep_old_clusters =3D true; } =20 - /* !*host_offset would overwrite the image header and is reserved for = "no - * host offset preferred". If 0 was a valid host offset, it'd trigger = the - * following overlap check; do that now to avoid having an invalid val= ue in - * *host_offset. */ + qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); + if (!alloc_cluster_offset) { - ret =3D qcow2_pre_write_overlap_check(bs, 0, alloc_cluster_offset, - nb_clusters * s->cluster_size); - assert(ret < 0); - goto fail; + /* Allocate, if necessary at a given offset in the image file */ + alloc_cluster_offset =3D start_of_cluster(s, *host_offset); + ret =3D do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_o= ffset, + &nb_clusters); + if (ret < 0) { + goto fail; + } + + /* Can't extend contiguous allocation */ + if (nb_clusters =3D=3D 0) { + *bytes =3D 0; + return 0; + } + + /* !*host_offset would overwrite the image header and is reserved = for + * "no host offset preferred". If 0 was a valid host offset, it'd + * trigger the following overlap check; do that now to avoid havin= g an + * invalid value in *host_offset. */ + if (!alloc_cluster_offset) { + ret =3D qcow2_pre_write_overlap_check(bs, 0, alloc_cluster_off= set, + nb_clusters * s->cluster_s= ize); + assert(ret < 0); + goto fail; + } } =20 /* @@ -1225,6 +1255,8 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, .offset =3D start_of_cluster(s, guest_offset), .nb_clusters =3D nb_clusters, =20 + .keep_old_clusters =3D keep_old_clusters, + .cow_start =3D { .offset =3D 0, .nb_bytes =3D offset_into_cluster(s, guest_offset), diff --git a/block/qcow2.h b/block/qcow2.h index f8aeb08..8731f24 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -322,6 +322,9 @@ typedef struct QCowL2Meta /** Number of newly allocated clusters */ int nb_clusters; =20 + /** Do not free the old clusters */ + bool keep_old_clusters; + /** * Requests that overlap with this allocation and wait to be restarted * when the allocating request has completed. --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514433946974.415179502534; Thu, 11 May 2017 07:53:53 -0700 (PDT) Received: from localhost ([::1]:48621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pTU-0003aq-F2 for importer@patchew.org; Thu, 11 May 2017 10:53:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAH-00025W-0X for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAG-0007Az-9a for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAB-00075K-70; Thu, 11 May 2017 10:33:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38B6780C2C; Thu, 11 May 2017 14:33:54 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34AC87A407; Thu, 11 May 2017 14:33:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 38B6780C2C Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 38B6780C2C From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:29 +0200 Message-Id: <1494513181-7900-27-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 11 May 2017 14:33:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 26/58] qcow2: Discard preallocated zero clusters 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Max Reitz In discard_single_l2(), we completely discard normal clusters instead of simply turning them into preallocated zero clusters. That means we should probably do the same with such preallocated zero clusters: Discard them instead of keeping them allocated. Reported-by: Eric Blake Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index fb91fd8..31077d8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1511,7 +1511,8 @@ static int discard_single_l2(BlockDriverState *bs, ui= nt64_t offset, break; =20 case QCOW2_CLUSTER_ZERO: - if (!full_discard) { + /* Preallocated zero clusters should be discarded in any c= ase */ + if (!full_discard && (old_l2_entry & L2E_OFFSET_MASK) =3D= =3D 0) { continue; } break; --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514578706621.7072751115942; Thu, 11 May 2017 07:56:18 -0700 (PDT) Received: from localhost ([::1]:48636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pVn-0005ii-W4 for importer@patchew.org; Thu, 11 May 2017 10:56:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAI-00029N-4S for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAG-0007Bv-NS for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAC-000776-Cd; Thu, 11 May 2017 10:33:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64BA080C0C; Thu, 11 May 2017 14:33:55 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 790E47A407; Thu, 11 May 2017 14:33:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 64BA080C0C Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 64BA080C0C From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:30 +0200 Message-Id: <1494513181-7900-28-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 11 May 2017 14:33:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 27/58] iotests: Extend test 066 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Max Reitz 066 was supposed to be a test "for discarding preallocated zero clusters", but it did so incompletely: While it did check the image file's integrity after the operation, it did not confirm that the clusters are indeed freed. This patch adds this test. In addition, new cases for writing to preallocated zero clusters are added. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/066 | 128 +++++++++++++++++++++++++++++++++++++++++= +++- tests/qemu-iotests/066.out | 46 ++++++++++++++++ 2 files changed, 173 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 index c2116a3..8638217 100755 --- a/tests/qemu-iotests/066 +++ b/tests/qemu-iotests/066 @@ -1,6 +1,6 @@ #!/bin/bash # -# Test case for discarding preallocated zero clusters in qcow2 +# Test case for preallocated zero clusters in qcow2 # # Copyright (C) 2013 Red Hat, Inc. # @@ -55,8 +55,134 @@ _make_test_img $IMG_SIZE $QEMU_IO -c "write 0 256k" -c "write -z 0 256k" -c "write 64M 512" \ -c "discard 0 $IMG_SIZE" -c "read -P 0 0 $IMG_SIZE" "$TEST_IMG" \ | _filter_qemu_io + # Check the image (there shouldn't be any leaks) _check_test_img +# Map the image (we want all clusters to be gone) +$QEMU_IMG map "$TEST_IMG" + +_cleanup_test_img + + +echo +echo '=3D=3D=3D Writing to preallocated zero clusters =3D=3D=3D' +echo + +_make_test_img $IMG_SIZE + +# Create data clusters (not aligned to an L2 table) +$QEMU_IO -c 'write -P 42 1M 256k' "$TEST_IMG" | _filter_qemu_io +orig_map=3D$($QEMU_IMG map --output=3Djson "$TEST_IMG") + +# Convert the data clusters to preallocated zero clusters +$QEMU_IO -c 'write -z 1M 256k' "$TEST_IMG" | _filter_qemu_io + +# Now write to them (with a COW needed for the head and tail) +$QEMU_IO -c "write -P 23 $(((1024 + 32) * 1024)) 192k" "$TEST_IMG" \ + | _filter_qemu_io + +# Check metadata correctness +_check_test_img + +# Check data correctness +$QEMU_IO -c "read -P 0 $(( 1024 * 1024)) 32k" \ + -c "read -P 23 $(((1024 + 32) * 1024)) 192k" \ + -c "read -P 0 $(((1024 + 32 + 192) * 1024)) 32k" \ + "$TEST_IMG" \ + | _filter_qemu_io + +# Check that we have actually reused the original area +new_map=3D$($QEMU_IMG map --output=3Djson "$TEST_IMG") +if [ "$new_map" =3D "$orig_map" ]; then + echo 'Successfully reused original clusters.' +else + echo 'Failed to reuse original clusters.' + echo 'Original map:' + echo "$orig_map" + echo 'New map:' + echo "$new_map" +fi + +_cleanup_test_img + + +echo +echo '=3D=3D=3D Writing to a snapshotted preallocated zero cluster =3D=3D= =3D' +echo + +_make_test_img 64k + +# Create a preallocated zero cluster +$QEMU_IO -c 'write -P 42 0 64k' -c 'write -z 0 64k' "$TEST_IMG" \ + | _filter_qemu_io + +# Snapshot it +$QEMU_IMG snapshot -c foo "$TEST_IMG" + +# Write to the cluster +$QEMU_IO -c 'write -P 23 0 64k' "$TEST_IMG" | _filter_qemu_io + +# Check metadata correctness +_check_test_img + +# Check data correctness +$QEMU_IO -c 'read -P 23 0 64k' "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG snapshot -a foo "$TEST_IMG" +$QEMU_IO -c 'read -P 0 0 64k' "$TEST_IMG" | _filter_qemu_io + +_cleanup_test_img + + +echo +echo '=3D=3D=3D Consecutive write to a preallocated zero cluster =3D=3D=3D' +echo + +_make_test_img 192k + +# Create three normal clusters +$QEMU_IO -c 'write -P 42 0 192k' "$TEST_IMG" | _filter_qemu_io +orig_map=3D$($QEMU_IMG map --output=3Djson "$TEST_IMG") + +# Make the middle cluster a preallocated zero cluster +$QEMU_IO -c 'write -z 64k 64k' "$TEST_IMG" | _filter_qemu_io + +# Try to overwrite everything: This should reuse the whole range. To test = that +# this only issues a single continuous write request, use blkdebug. +$QEMU_IO -c 'write -P 42 0 192k' \ + "json:{ + 'driver': '$IMGFMT', + 'file': { + 'driver': 'blkdebug', + 'image.filename': '$TEST_IMG', + 'set-state': [{ + 'event': 'write_aio', + 'new_state': 2 + }], + 'inject-error': [{ + 'event': 'write_aio', + 'state': 2 + }] + } + }" \ + | _filter_qemu_io + +# Check metadata correctness +_check_test_img + +# Check that we have actually reused the original area +new_map=3D$($QEMU_IMG map --output=3Djson "$TEST_IMG") +if [ "$new_map" =3D "$orig_map" ]; then + echo 'Successfully reused original clusters.' +else + echo 'Failed to reuse original clusters.' + echo 'Original map:' + echo "$orig_map" + echo 'New map:' + echo "$new_map" +fi + +_cleanup_test_img + =20 # success, all done echo "*** done" diff --git a/tests/qemu-iotests/066.out b/tests/qemu-iotests/066.out index 7c1f31a..3d9da9b 100644 --- a/tests/qemu-iotests/066.out +++ b/tests/qemu-iotests/066.out @@ -14,4 +14,50 @@ discard 67109376/67109376 bytes at offset 0 read 67109376/67109376 bytes at offset 0 64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. +Offset Length Mapped to File + +=3D=3D=3D Writing to preallocated zero clusters =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67109376 +wrote 262144/262144 bytes at offset 1048576 +256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 262144/262144 bytes at offset 1048576 +256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 196608/196608 bytes at offset 1081344 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +No errors were found on the image. +read 32768/32768 bytes at offset 1048576 +32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 196608/196608 bytes at offset 1081344 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 32768/32768 bytes at offset 1277952 +32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Successfully reused original clusters. + +=3D=3D=3D Writing to a snapshotted preallocated zero cluster =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D65536 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +No errors were found on the image. +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Consecutive write to a preallocated zero cluster =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D196608 +wrote 196608/196608 bytes at offset 0 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 196608/196608 bytes at offset 0 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +No errors were found on the image. +Successfully reused original clusters. *** done --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494513718176491.10415860847434; Thu, 11 May 2017 07:41:58 -0700 (PDT) Received: from localhost ([::1]:48554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pHu-0000er-FC for importer@patchew.org; Thu, 11 May 2017 10:41:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAK-0002Be-IO for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAJ-0007EY-Jp for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAG-0007An-Pk; Thu, 11 May 2017 10:34:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C83679D414; Thu, 11 May 2017 14:33:59 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id A67C47A407; Thu, 11 May 2017 14:33:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C83679D414 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C83679D414 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:31 +0200 Message-Id: <1494513181-7900-29-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:33:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 28/58] migration: Unify block node activation error handling 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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" Migration code activates all block driver nodes on the destination when the migration completes. It does so by calling bdrv_invalidate_cache_all() and blk_resume_after_migration(). There is one code path for precopy and one for postcopy migration, resulting in four function calls, which used to have three different failure modes. This patch unifies the behaviour so that failure to activate all block nodes is non-fatal, but the error message is logged and the VM isn't automatically started. 'cont' will retry activating the block nodes. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- migration/migration.c | 16 +++++----------- migration/savevm.c | 12 +++++------- qmp.c | 18 +++++++++--------- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 799952c..04af719 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -338,20 +338,14 @@ static void process_incoming_migration_bh(void *opaqu= e) Error *local_err =3D NULL; MigrationIncomingState *mis =3D opaque; =20 - /* Make sure all file formats flush their mutable metadata */ + /* Make sure all file formats flush their mutable metadata. + * If we get an error here, just don't restart the VM yet. */ bdrv_invalidate_cache_all(&local_err); - if (local_err) { - migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_FAILED); - error_report_err(local_err); - migrate_decompress_threads_join(); - exit(EXIT_FAILURE); + if (!local_err) { + blk_resume_after_migration(&local_err); } - - /* If we get an error here, just don't restart the VM yet. */ - blk_resume_after_migration(&local_err); if (local_err) { - error_free(local_err); + error_report_err(local_err); local_err =3D NULL; autostart =3D false; } diff --git a/migration/savevm.c b/migration/savevm.c index 352a8f2..3ca8d11 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1612,16 +1612,14 @@ static void loadvm_postcopy_handle_run_bh(void *opa= que) =20 qemu_announce_self(); =20 - /* Make sure all file formats flush their mutable metadata */ + /* Make sure all file formats flush their mutable metadata. + * If we get an error here, just don't restart the VM yet. */ bdrv_invalidate_cache_all(&local_err); - if (local_err) { - error_report_err(local_err); + if (!local_err) { + blk_resume_after_migration(&local_err); } - - /* If we get an error here, just don't restart the VM yet. */ - blk_resume_after_migration(&local_err); if (local_err) { - error_free(local_err); + error_report_err(local_err); local_err =3D NULL; autostart =3D false; } diff --git a/qmp.c b/qmp.c index ab74cd7..25b5050 100644 --- a/qmp.c +++ b/qmp.c @@ -196,15 +196,15 @@ void qmp_cont(Error **errp) } =20 /* Continuing after completed migration. Images have been inactivated = to - * allow the destination to take control. Need to get control back now= . */ - if (runstate_check(RUN_STATE_FINISH_MIGRATE) || - runstate_check(RUN_STATE_POSTMIGRATE)) - { - bdrv_invalidate_cache_all(&local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + * allow the destination to take control. Need to get control back now. + * + * If there are no inactive block nodes (e.g. because the VM was just + * paused rather than completing a migration), bdrv_inactivate_all() s= imply + * doesn't do anything. */ + bdrv_invalidate_cache_all(&local_err); + if (local_err) { + error_propagate(errp, local_err); + return; } =20 blk_resume_after_migration(&local_err); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514727261438.4143216077763; Thu, 11 May 2017 07:58:47 -0700 (PDT) Received: from localhost ([::1]:48652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pYC-0007t8-TF for importer@patchew.org; Thu, 11 May 2017 10:58:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAR-0002Kf-Qt for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAQ-0007RU-Mx for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAL-0007HY-ET; Thu, 11 May 2017 10:34:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5833D85541; Thu, 11 May 2017 14:34:04 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14A657A407; Thu, 11 May 2017 14:33:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5833D85541 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5833D85541 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:32 +0200 Message-Id: <1494513181-7900-30-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 14:34:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 29/58] block: New BdrvChildRole.activate() for blk_resume_after_migration() 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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" Instead of manually calling blk_resume_after_migration() in migration code after doing bdrv_invalidate_cache_all(), integrate the BlockBackend activation with cache invalidation into a single function. This is achieved with a new callback in BdrvChildRole that is called by bdrv_invalidate_cache_all(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 12 +++++++++- block/block-backend.c | 56 +++++++++++++++++++++++--------------------= ---- include/block/block.h | 2 -- include/block/block_int.h | 5 +++++ migration/migration.c | 3 --- migration/savevm.c | 3 --- qmp.c | 6 ----- 7 files changed, 44 insertions(+), 43 deletions(-) diff --git a/block.c b/block.c index 1e00e31..c8e6de2 100644 --- a/block.c +++ b/block.c @@ -3949,7 +3949,7 @@ void bdrv_init_with_whitelist(void) =20 void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) { - BdrvChild *child; + BdrvChild *child, *parent; Error *local_err =3D NULL; int ret; =20 @@ -3985,6 +3985,16 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Err= or **errp) error_setg_errno(errp, -ret, "Could not refresh total sector count= "); return; } + + QLIST_FOREACH(parent, &bs->parents, next_parent) { + if (parent->role->activate) { + parent->role->activate(parent, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + } } =20 void bdrv_invalidate_cache_all(Error **errp) diff --git a/block/block-backend.c b/block/block-backend.c index f5bf13e..a7ce72b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -130,6 +130,32 @@ static const char *blk_root_get_name(BdrvChild *child) return blk_name(child->opaque); } =20 +/* + * Notifies the user of the BlockBackend that migration has completed. qdev + * devices can tighten their permissions in response (specifically revoke + * shared write permissions that we needed for storage migration). + * + * If an error is returned, the VM cannot be allowed to be resumed. + */ +static void blk_root_activate(BdrvChild *child, Error **errp) +{ + BlockBackend *blk =3D child->opaque; + Error *local_err =3D NULL; + + if (!blk->disable_perm) { + return; + } + + blk->disable_perm =3D false; + + blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err); + if (local_err) { + error_propagate(errp, local_err); + blk->disable_perm =3D true; + return; + } +} + static const BdrvChildRole child_root =3D { .inherit_options =3D blk_root_inherit_options, =20 @@ -140,6 +166,8 @@ static const BdrvChildRole child_root =3D { =20 .drained_begin =3D blk_root_drained_begin, .drained_end =3D blk_root_drained_end, + + .activate =3D blk_root_activate, }; =20 /* @@ -601,34 +629,6 @@ void blk_get_perm(BlockBackend *blk, uint64_t *perm, u= int64_t *shared_perm) *shared_perm =3D blk->shared_perm; } =20 -/* - * Notifies the user of all BlockBackends that migration has completed. qd= ev - * devices can tighten their permissions in response (specifically revoke - * shared write permissions that we needed for storage migration). - * - * If an error is returned, the VM cannot be allowed to be resumed. - */ -void blk_resume_after_migration(Error **errp) -{ - BlockBackend *blk; - Error *local_err =3D NULL; - - for (blk =3D blk_all_next(NULL); blk; blk =3D blk_all_next(blk)) { - if (!blk->disable_perm) { - continue; - } - - blk->disable_perm =3D false; - - blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err); - if (local_err) { - error_propagate(errp, local_err); - blk->disable_perm =3D true; - return; - } - } -} - static int blk_do_attach_dev(BlockBackend *blk, void *dev) { if (blk->dev) { diff --git a/include/block/block.h b/include/block/block.h index 877fbb0..80d51d8 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -369,8 +369,6 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error = **errp); void bdrv_invalidate_cache_all(Error **errp); int bdrv_inactivate_all(void); =20 -void blk_resume_after_migration(Error **errp); - /* Ensure contents are flushed to disk. */ int bdrv_flush(BlockDriverState *bs); int coroutine_fn bdrv_co_flush(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 1b4d08e..5637925 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -473,6 +473,11 @@ struct BdrvChildRole { void (*drained_begin)(BdrvChild *child); void (*drained_end)(BdrvChild *child); =20 + /* Notifies the parent that the child has been activated (e.g. when + * migration is completing) and it can start requesting permissions and + * doing I/O on it. */ + void (*activate)(BdrvChild *child, Error **errp); + void (*attach)(BdrvChild *child); void (*detach)(BdrvChild *child); }; diff --git a/migration/migration.c b/migration/migration.c index 04af719..a5ade23 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -341,9 +341,6 @@ static void process_incoming_migration_bh(void *opaque) /* Make sure all file formats flush their mutable metadata. * If we get an error here, just don't restart the VM yet. */ bdrv_invalidate_cache_all(&local_err); - if (!local_err) { - blk_resume_after_migration(&local_err); - } if (local_err) { error_report_err(local_err); local_err =3D NULL; diff --git a/migration/savevm.c b/migration/savevm.c index 3ca8d11..7f66d58 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1615,9 +1615,6 @@ static void loadvm_postcopy_handle_run_bh(void *opaqu= e) /* Make sure all file formats flush their mutable metadata. * If we get an error here, just don't restart the VM yet. */ bdrv_invalidate_cache_all(&local_err); - if (!local_err) { - blk_resume_after_migration(&local_err); - } if (local_err) { error_report_err(local_err); local_err =3D NULL; diff --git a/qmp.c b/qmp.c index 25b5050..f656940 100644 --- a/qmp.c +++ b/qmp.c @@ -207,12 +207,6 @@ void qmp_cont(Error **errp) return; } =20 - blk_resume_after_migration(&local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - if (runstate_check(RUN_STATE_INMIGRATE)) { autostart =3D 1; } else { --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514878985156.02136301611574; Thu, 11 May 2017 08:01:18 -0700 (PDT) Received: from localhost ([::1]:48670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pad-0001ws-D9 for importer@patchew.org; Thu, 11 May 2017 11:01:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAZ-0002RM-28 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAT-0007U0-3W for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAQ-0007QH-KC; Thu, 11 May 2017 10:34:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DB523D95E; Thu, 11 May 2017 14:34:09 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEA5A88B3C; Thu, 11 May 2017 14:34:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DB523D95E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9DB523D95E From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:33 +0200 Message-Id: <1494513181-7900-31-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 14:34:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 30/58] block: Drop permissions when migration completes 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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" With image locking, permissions affect other qemu processes as well. We want to be sure that the destination can run, so let's drop permissions on the source when migration completes. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 12 +++++++++++- block/block-backend.c | 25 +++++++++++++++++++++++++ include/block/block_int.h | 7 ++++--- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index c8e6de2..444a52e 100644 --- a/block.c +++ b/block.c @@ -4019,7 +4019,7 @@ void bdrv_invalidate_cache_all(Error **errp) static int bdrv_inactivate_recurse(BlockDriverState *bs, bool setting_flag) { - BdrvChild *child; + BdrvChild *child, *parent; int ret; =20 if (!setting_flag && bs->drv->bdrv_inactivate) { @@ -4038,6 +4038,16 @@ static int bdrv_inactivate_recurse(BlockDriverState = *bs, =20 if (setting_flag) { bs->open_flags |=3D BDRV_O_INACTIVE; + + QLIST_FOREACH(parent, &bs->parents, next_parent) { + if (parent->role->inactivate) { + ret =3D parent->role->inactivate(parent); + if (ret < 0) { + bs->open_flags &=3D ~BDRV_O_INACTIVE; + return ret; + } + } + } } return 0; } diff --git a/block/block-backend.c b/block/block-backend.c index a7ce72b..f3a6008 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -156,6 +156,30 @@ static void blk_root_activate(BdrvChild *child, Error = **errp) } } =20 +static int blk_root_inactivate(BdrvChild *child) +{ + BlockBackend *blk =3D child->opaque; + + if (blk->disable_perm) { + return 0; + } + + /* Only inactivate BlockBackends for guest devices (which are inactive= at + * this point because the VM is stopped) and unattached monitor-owned + * BlockBackends. If there is still any other user like a block job, t= hen + * we simply can't inactivate the image. */ + if (!blk->dev && !blk->name[0]) { + return -EPERM; + } + + blk->disable_perm =3D true; + if (blk->root) { + bdrv_child_try_set_perm(blk->root, 0, BLK_PERM_ALL, &error_abort); + } + + return 0; +} + static const BdrvChildRole child_root =3D { .inherit_options =3D blk_root_inherit_options, =20 @@ -168,6 +192,7 @@ static const BdrvChildRole child_root =3D { .drained_end =3D blk_root_drained_end, =20 .activate =3D blk_root_activate, + .inactivate =3D blk_root_inactivate, }; =20 /* diff --git a/include/block/block_int.h b/include/block/block_int.h index 5637925..5750a44 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -473,10 +473,11 @@ struct BdrvChildRole { void (*drained_begin)(BdrvChild *child); void (*drained_end)(BdrvChild *child); =20 - /* Notifies the parent that the child has been activated (e.g. when - * migration is completing) and it can start requesting permissions and - * doing I/O on it. */ + /* Notifies the parent that the child has been activated/inactivated (= e.g. + * when migration is completing) and it can start/stop requesting + * permissions and doing I/O on it. */ void (*activate)(BdrvChild *child, Error **errp); + int (*inactivate)(BdrvChild *child); =20 void (*attach)(BdrvChild *child); void (*detach)(BdrvChild *child); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515034277960.3915819807735; Thu, 11 May 2017 08:03:54 -0700 (PDT) Received: from localhost ([::1]:48680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pd8-00045f-VN for importer@patchew.org; Thu, 11 May 2017 11:03:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAa-0002T3-Hh for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAZ-0007bG-LY for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47048) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAT-0007Tj-GR; Thu, 11 May 2017 10:34:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6741C804F3; Thu, 11 May 2017 14:34:12 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFC5888B39; Thu, 11 May 2017 14:34:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6741C804F3 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6741C804F3 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:34 +0200 Message-Id: <1494513181-7900-32-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 14:34:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 31/58] block: Inactivate parents before children 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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" The proper order for inactivating block nodes is that first the parents get inactivated and then the children. If we do things in this order, we can assert that we didn't accidentally leave a parent activated when one of its child nodes is inactive. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index 444a52e..170002e 100644 --- a/block.c +++ b/block.c @@ -762,6 +762,13 @@ static void bdrv_child_cb_drained_end(BdrvChild *child) bdrv_drained_end(bs); } =20 +static int bdrv_child_cb_inactivate(BdrvChild *child) +{ + BlockDriverState *bs =3D child->opaque; + assert(bs->open_flags & BDRV_O_INACTIVE); + return 0; +} + /* * Returns the options and flags that a temporary snapshot should get, bas= ed on * the originally requested flags (the originally requested image will have @@ -822,6 +829,7 @@ const BdrvChildRole child_file =3D { .inherit_options =3D bdrv_inherited_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_end =3D bdrv_child_cb_drained_end, + .inactivate =3D bdrv_child_cb_inactivate, }; =20 /* @@ -843,6 +851,7 @@ const BdrvChildRole child_format =3D { .inherit_options =3D bdrv_inherited_fmt_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_end =3D bdrv_child_cb_drained_end, + .inactivate =3D bdrv_child_cb_inactivate, }; =20 static void bdrv_backing_attach(BdrvChild *c) @@ -928,6 +937,7 @@ const BdrvChildRole child_backing =3D { .inherit_options =3D bdrv_backing_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_end =3D bdrv_child_cb_drained_end, + .inactivate =3D bdrv_child_cb_inactivate, }; =20 static int bdrv_open_flags(BlockDriverState *bs, int flags) @@ -4029,13 +4039,6 @@ static int bdrv_inactivate_recurse(BlockDriverState = *bs, } } =20 - QLIST_FOREACH(child, &bs->children, next) { - ret =3D bdrv_inactivate_recurse(child->bs, setting_flag); - if (ret < 0) { - return ret; - } - } - if (setting_flag) { bs->open_flags |=3D BDRV_O_INACTIVE; =20 @@ -4049,6 +4052,14 @@ static int bdrv_inactivate_recurse(BlockDriverState = *bs, } } } + + QLIST_FOREACH(child, &bs->children, next) { + ret =3D bdrv_inactivate_recurse(child->bs, setting_flag); + if (ret < 0) { + return ret; + } + } + return 0; } =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514206783567.2499613559504; Thu, 11 May 2017 07:50:06 -0700 (PDT) Received: from localhost ([::1]:48601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pPo-0008Fe-72 for importer@patchew.org; Thu, 11 May 2017 10:50:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAb-0002U5-Dj for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAa-0007cH-5o for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAU-0007Uj-M1; Thu, 11 May 2017 10:34:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9554B448D69; Thu, 11 May 2017 14:34:13 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id A812D88B39; Thu, 11 May 2017 14:34:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9554B448D69 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9554B448D69 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:35 +0200 Message-Id: <1494513181-7900-33-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 11 May 2017 14:34:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 32/58] block: Fix write/resize permissions for inactive images 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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" Format drivers for inactive nodes don't need write/resize permissions on their bs->file and can share write/resize with another VM (in fact, this is the whole point of keeping images inactive). Represent this fact in the op blocker system, so that image locking does the right thing without special-casing inactive images. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 35 +++++++++++++++++++++++++++++++++-- include/block/block.h | 1 + 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 170002e..50ba264 100644 --- a/block.c +++ b/block.c @@ -192,11 +192,20 @@ void path_combine(char *dest, int dest_size, } } =20 +/* Returns whether the image file is opened as read-only. Note that this c= an + * return false and writing to the image file is still not possible becaus= e the + * image is inactivated. */ bool bdrv_is_read_only(BlockDriverState *bs) { return bs->read_only; } =20 +/* Returns whether the image file can be written to right now */ +bool bdrv_is_writable(BlockDriverState *bs) +{ + return !bdrv_is_read_only(bs) && !(bs->open_flags & BDRV_O_INACTIVE); +} + int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **e= rrp) { /* Do not set read_only if copy_on_read is enabled */ @@ -1510,7 +1519,7 @@ static int bdrv_check_perm(BlockDriverState *bs, uint= 64_t cumulative_perms, =20 /* Write permissions never work with read-only images */ if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) && - bdrv_is_read_only(bs)) + !bdrv_is_writable(bs)) { error_setg(errp, "Block node is read-only"); return -EPERM; @@ -1795,7 +1804,7 @@ void bdrv_format_default_perms(BlockDriverState *bs, = BdrvChild *c, bdrv_filter_default_perms(bs, c, role, perm, shared, &perm, &share= d); =20 /* Format drivers may touch metadata even if the guest doesn't wri= te */ - if (!bdrv_is_read_only(bs)) { + if (bdrv_is_writable(bs)) { perm |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; } =20 @@ -1821,6 +1830,10 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, BLK_PERM_WRITE_UNCHANGED; } =20 + if (bs->open_flags & BDRV_O_INACTIVE) { + shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } + *nperm =3D perm; *nshared =3D shared; } @@ -3960,6 +3973,7 @@ void bdrv_init_with_whitelist(void) void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) { BdrvChild *child, *parent; + uint64_t perm, shared_perm; Error *local_err =3D NULL; int ret; =20 @@ -3996,6 +4010,16 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Err= or **errp) return; } =20 + /* Update permissions, they may differ for inactive nodes */ + bdrv_get_cumulative_perm(bs, &perm, &shared_perm); + ret =3D bdrv_check_perm(bs, perm, shared_perm, NULL, &local_err); + if (ret < 0) { + bs->open_flags |=3D BDRV_O_INACTIVE; + error_propagate(errp, local_err); + return; + } + bdrv_set_perm(bs, perm, shared_perm); + QLIST_FOREACH(parent, &bs->parents, next_parent) { if (parent->role->activate) { parent->role->activate(parent, &local_err); @@ -4040,6 +4064,8 @@ static int bdrv_inactivate_recurse(BlockDriverState *= bs, } =20 if (setting_flag) { + uint64_t perm, shared_perm; + bs->open_flags |=3D BDRV_O_INACTIVE; =20 QLIST_FOREACH(parent, &bs->parents, next_parent) { @@ -4051,6 +4077,11 @@ static int bdrv_inactivate_recurse(BlockDriverState = *bs, } } } + + /* Update permissions, they may differ for inactive nodes */ + bdrv_get_cumulative_perm(bs, &perm, &shared_perm); + bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort); + bdrv_set_perm(bs, perm, shared_perm); } =20 QLIST_FOREACH(child, &bs->children, next) { diff --git a/include/block/block.h b/include/block/block.h index 80d51d8..90932b4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -435,6 +435,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, Bloc= kDriverState *base, int64_t sector_num, int nb_sectors, int *pnum); =20 bool bdrv_is_read_only(BlockDriverState *bs); +bool bdrv_is_writable(BlockDriverState *bs); int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **e= rrp); int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); bool bdrv_is_sg(BlockDriverState *bs); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149451389678083.83980813862672; Thu, 11 May 2017 07:44:56 -0700 (PDT) Received: from localhost ([::1]:48575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pKo-0003gF-KU for importer@patchew.org; Thu, 11 May 2017 10:44:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAb-0002TM-1v for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAZ-0007bZ-UK for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38322) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAW-0007WR-86; Thu, 11 May 2017 10:34:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3AC8B7F7DB; Thu, 11 May 2017 14:34:15 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id D51C27A407; Thu, 11 May 2017 14:34:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3AC8B7F7DB Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3AC8B7F7DB From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:36 +0200 Message-Id: <1494513181-7900-34-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 14:34:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 33/58] file-posix: Remove .bdrv_inactivate/invalidate_cache 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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" Now that the block layer takes care to request a lot less permissions for inactive nodes, the special-casing in file-posix isn't necessary any more. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/file-posix.c | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index a09055b..4354d49 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2190,35 +2190,6 @@ static void raw_abort_perm_update(BlockDriverState *= bs) raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL); } =20 -static int raw_inactivate(BlockDriverState *bs) -{ - int ret; - uint64_t perm =3D 0; - uint64_t shared =3D BLK_PERM_ALL; - - ret =3D raw_handle_perm_lock(bs, RAW_PL_PREPARE, perm, shared, NULL); - if (ret) { - return ret; - } - raw_handle_perm_lock(bs, RAW_PL_COMMIT, perm, shared, NULL); - return 0; -} - - -static void raw_invalidate_cache(BlockDriverState *bs, Error **errp) -{ - BDRVRawState *s =3D bs->opaque; - int ret; - - assert(!(bdrv_get_flags(bs) & BDRV_O_INACTIVE)); - ret =3D raw_handle_perm_lock(bs, RAW_PL_PREPARE, s->perm, s->shared_pe= rm, - errp); - if (ret) { - return; - } - raw_handle_perm_lock(bs, RAW_PL_COMMIT, s->perm, s->shared_perm, NULL); -} - BlockDriver bdrv_file =3D { .format_name =3D "file", .protocol_name =3D "file", @@ -2249,8 +2220,6 @@ BlockDriver bdrv_file =3D { .bdrv_get_info =3D raw_get_info, .bdrv_get_allocated_file_size =3D raw_get_allocated_file_size, - .bdrv_inactivate =3D raw_inactivate, - .bdrv_invalidate_cache =3D raw_invalidate_cache, .bdrv_check_perm =3D raw_check_perm, .bdrv_set_perm =3D raw_set_perm, .bdrv_abort_perm_update =3D raw_abort_perm_update, @@ -2712,8 +2681,6 @@ static BlockDriver bdrv_host_device =3D { .bdrv_get_info =3D raw_get_info, .bdrv_get_allocated_file_size =3D raw_get_allocated_file_size, - .bdrv_inactivate =3D raw_inactivate, - .bdrv_invalidate_cache =3D raw_invalidate_cache, .bdrv_check_perm =3D raw_check_perm, .bdrv_set_perm =3D raw_set_perm, .bdrv_abort_perm_update =3D raw_abort_perm_update, --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514051573474.54942231254233; Thu, 11 May 2017 07:47:31 -0700 (PDT) Received: from localhost ([::1]:48590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pNJ-0005tG-59 for importer@patchew.org; Thu, 11 May 2017 10:47:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAb-0002Tq-6g for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAa-0007bi-0Z for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49526) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAX-0007Xn-H9; Thu, 11 May 2017 10:34:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 841153D954; Thu, 11 May 2017 14:34:16 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 799987A407; Thu, 11 May 2017 14:34:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 841153D954 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 841153D954 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:37 +0200 Message-Id: <1494513181-7900-35-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 14:34:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 34/58] qemu-img: wait for convert coroutines to complete 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Anton Nefedov On error path (like i/o error in one of the coroutines), it's required to - wait for coroutines completion before cleaning the common structures - reenter dependent coroutines so they ever finish Introduced in 2d9187bc65. Cc: qemu-stable@nongnu.org Signed-off-by: Anton Nefedov Reviewed-by: Peter Lieven Signed-off-by: Kevin Wolf --- qemu-img.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 418f061..b506839 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1761,13 +1761,13 @@ static void coroutine_fn convert_co_do_copy(void *o= paque) qemu_co_mutex_lock(&s->lock); if (s->ret !=3D -EINPROGRESS || s->sector_num >=3D s->total_sector= s) { qemu_co_mutex_unlock(&s->lock); - goto out; + break; } n =3D convert_iteration_sectors(s, s->sector_num); if (n < 0) { qemu_co_mutex_unlock(&s->lock); s->ret =3D n; - goto out; + break; } /* save current sector and allocation status to local variables */ sector_num =3D s->sector_num; @@ -1792,7 +1792,6 @@ static void coroutine_fn convert_co_do_copy(void *opa= que) error_report("error while reading sector %" PRId64 ": %s", sector_num, strerror(-ret)); s->ret =3D ret; - goto out; } } else if (!s->min_sparse && status =3D=3D BLK_ZERO) { status =3D BLK_DATA; @@ -1801,22 +1800,20 @@ static void coroutine_fn convert_co_do_copy(void *o= paque) =20 if (s->wr_in_order) { /* keep writes in order */ - while (s->wr_offs !=3D sector_num) { - if (s->ret !=3D -EINPROGRESS) { - goto out; - } + while (s->wr_offs !=3D sector_num && s->ret =3D=3D -EINPROGRES= S) { s->wait_sector_num[index] =3D sector_num; qemu_coroutine_yield(); } s->wait_sector_num[index] =3D -1; } =20 - ret =3D convert_co_write(s, sector_num, n, buf, status); - if (ret < 0) { - error_report("error while writing sector %" PRId64 - ": %s", sector_num, strerror(-ret)); - s->ret =3D ret; - goto out; + if (s->ret =3D=3D -EINPROGRESS) { + ret =3D convert_co_write(s, sector_num, n, buf, status); + if (ret < 0) { + error_report("error while writing sector %" PRId64 + ": %s", sector_num, strerror(-ret)); + s->ret =3D ret; + } } =20 if (s->wr_in_order) { @@ -1837,7 +1834,6 @@ static void coroutine_fn convert_co_do_copy(void *opa= que) } } =20 -out: qemu_vfree(buf); s->co[index] =3D NULL; s->running_coroutines--; @@ -1899,7 +1895,7 @@ static int convert_do_copy(ImgConvertState *s) qemu_coroutine_enter(s->co[i]); } =20 - while (s->ret =3D=3D -EINPROGRESS) { + while (s->running_coroutines) { main_loop_wait(false); } =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514353308837.7989971082443; Thu, 11 May 2017 07:52:33 -0700 (PDT) Received: from localhost ([::1]:48615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pS9-0002Ax-UP for importer@patchew.org; Thu, 11 May 2017 10:52:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAc-0002VA-CS for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAb-0007eu-CW for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49574) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAY-0007Z0-Qf; Thu, 11 May 2017 10:34:19 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C68013D967; Thu, 11 May 2017 14:34:17 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4ED77A407; Thu, 11 May 2017 14:34:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C68013D967 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C68013D967 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:38 +0200 Message-Id: <1494513181-7900-36-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 14:34:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 35/58] nvme: Implement Write Zeroes 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Christoph Hellwig Signed-off-by: Keith Busch [hch: ported over from qemu-nvme.git to mainline] Signed-off-by: Christoph Hellwig Acked-by: Keith Busch Signed-off-by: Kevin Wolf --- hw/block/nvme.c | 26 ++++++++++++++++++++++++++ hw/block/nvme.h | 1 + 2 files changed, 27 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index ae303d4..7428db9 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -227,6 +227,29 @@ static uint16_t nvme_flush(NvmeCtrl *n, NvmeNamespace = *ns, NvmeCmd *cmd, return NVME_NO_COMPLETE; } =20 +static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *= cmd, + NvmeRequest *req) +{ + NvmeRwCmd *rw =3D (NvmeRwCmd *)cmd; + const uint8_t lba_index =3D NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas); + const uint8_t data_shift =3D ns->id_ns.lbaf[lba_index].ds; + uint64_t slba =3D le64_to_cpu(rw->slba); + uint32_t nlb =3D le16_to_cpu(rw->nlb) + 1; + uint64_t aio_slba =3D slba << (data_shift - BDRV_SECTOR_BITS); + uint32_t aio_nlb =3D nlb << (data_shift - BDRV_SECTOR_BITS); + + if (slba + nlb > ns->id_ns.nsze) { + return NVME_LBA_RANGE | NVME_DNR; + } + + req->has_sg =3D false; + block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0, + BLOCK_ACCT_WRITE); + req->aiocb =3D blk_aio_pwrite_zeroes(n->conf.blk, aio_slba, aio_nlb, + BDRV_REQ_MAY_UNMAP, nvme_rw_cb, re= q); + return NVME_NO_COMPLETE; +} + static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req) { @@ -279,6 +302,8 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeCmd *cmd, = NvmeRequest *req) switch (cmd->opcode) { case NVME_CMD_FLUSH: return nvme_flush(n, ns, cmd, req); + case NVME_CMD_WRITE_ZEROS: + return nvme_write_zeros(n, ns, cmd, req); case NVME_CMD_WRITE: case NVME_CMD_READ: return nvme_rw(n, ns, cmd, req); @@ -895,6 +920,7 @@ static int nvme_init(PCIDevice *pci_dev) id->sqes =3D (0x6 << 4) | 0x6; id->cqes =3D (0x4 << 4) | 0x4; id->nn =3D cpu_to_le32(n->num_namespaces); + id->oncs =3D cpu_to_le16(NVME_ONCS_WRITE_ZEROS); id->psd[0].mp =3D cpu_to_le16(0x9c4); id->psd[0].enlat =3D cpu_to_le32(0x10); id->psd[0].exlat =3D cpu_to_le32(0x4); diff --git a/hw/block/nvme.h b/hw/block/nvme.h index 8fb0c10..a0d1564 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -179,6 +179,7 @@ enum NvmeIoCommands { NVME_CMD_READ =3D 0x02, NVME_CMD_WRITE_UNCOR =3D 0x04, NVME_CMD_COMPARE =3D 0x05, + NVME_CMD_WRITE_ZEROS =3D 0x08, NVME_CMD_DSM =3D 0x09, }; =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514801919187.0630987332106; Thu, 11 May 2017 08:00:01 -0700 (PDT) Received: from localhost ([::1]:48656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pZQ-0000qo-IC for importer@patchew.org; Thu, 11 May 2017 11:00:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAd-0002WA-Eg for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAc-0007h1-D5 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54710) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAa-0007ah-1P; Thu, 11 May 2017 10:34:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0142EA08F8; Thu, 11 May 2017 14:34:19 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1326A7A407; Thu, 11 May 2017 14:34:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0142EA08F8 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0142EA08F8 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:39 +0200 Message-Id: <1494513181-7900-37-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:34:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 36/58] blockdev: use drained_begin/end for qmp_block_resize 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: John Snow Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1447551 If one tries to issue a block_resize while a guest is busy accessing the disk, it is possible that qemu may deadlock when invoking aio_poll from both the main loop and the iothread. Replace another instance of bdrv_drain_all that doesn't quite belong. Cc: qemu-stable@nongnu.org Suggested-by: Paolo Bonzini Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- blockdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 0d3773b..c63f4e8 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2923,10 +2923,9 @@ void qmp_block_resize(bool has_device, const char *d= evice, goto out; } =20 - /* complete all in-flight operations before resizing the device */ - bdrv_drain_all(); - + bdrv_drained_begin(bs); ret =3D blk_truncate(blk, size, errp); + bdrv_drained_end(bs); =20 out: blk_unref(blk); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514976111468.6010409044702; Thu, 11 May 2017 08:02:56 -0700 (PDT) Received: from localhost ([::1]:48677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pcE-0003Hf-KG for importer@patchew.org; Thu, 11 May 2017 11:02:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAe-0002Xu-NG for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAd-0007ix-SJ for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37518) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAb-0007cy-8v; Thu, 11 May 2017 10:34:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32D1980E7B; Thu, 11 May 2017 14:34:20 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 418B97A407; Thu, 11 May 2017 14:34:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 32D1980E7B Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 32D1980E7B From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:40 +0200 Message-Id: <1494513181-7900-38-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 14:34:20 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 37/58] qemu-io: Improve alignment checks 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Several copy-and-pasted alignment checks exist in qemu-io, which could use some minor improvements: - Manual comparison against 0x1ff is not as clean as using our alignment macros (QEMU_IS_ALIGNED) from osdep.h. - The error messages aren't quite grammatically correct. Suggested-by: Philippe Mathieu-Daud=C3=A9 Suggested-by: Max Reitz Signed-off-by: Eric Blake Message-id: 20170429191419.30051-2-eblake@redhat.com Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- qemu-io-cmds.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 21af9e6..6a0024b 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -740,13 +740,13 @@ static int read_f(BlockBackend *blk, int argc, char *= *argv) } =20 if (bflag) { - if (offset & 0x1ff) { - printf("offset %" PRId64 " is not sector aligned\n", + if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { + printf("%" PRId64 " is not a sector-aligned value for 'offset'= \n", offset); return 0; } - if (count & 0x1ff) { - printf("count %"PRId64" is not sector aligned\n", + if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) { + printf("%"PRId64" is not a sector-aligned value for 'count'\n", count); return 0; } @@ -1050,14 +1050,14 @@ static int write_f(BlockBackend *blk, int argc, cha= r **argv) } =20 if (bflag || cflag) { - if (offset & 0x1ff) { - printf("offset %" PRId64 " is not sector aligned\n", + if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { + printf("%" PRId64 " is not a sector-aligned value for 'offset'= \n", offset); return 0; } =20 - if (count & 0x1ff) { - printf("count %"PRId64" is not sector aligned\n", + if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) { + printf("%"PRId64" is not a sector-aligned value for 'count'\n", count); return 0; } @@ -1769,8 +1769,8 @@ static int alloc_f(BlockBackend *blk, int argc, char = **argv) if (offset < 0) { print_cvtnum_err(offset, argv[1]); return 0; - } else if (offset & 0x1ff) { - printf("offset %" PRId64 " is not sector aligned\n", + } else if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { + printf("%" PRId64 " is not a sector-aligned value for 'offset'\n", offset); return 0; } --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514493325233.93916959850083; Thu, 11 May 2017 07:54:53 -0700 (PDT) Received: from localhost ([::1]:48625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pUQ-0004RH-Vx for importer@patchew.org; Thu, 11 May 2017 10:54:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAh-0002be-Sd for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAf-0007mF-6C for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAc-0007fy-GD; Thu, 11 May 2017 10:34:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79FA67A487; Thu, 11 May 2017 14:34:21 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71EBF8A8CE; Thu, 11 May 2017 14:34:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79FA67A487 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 79FA67A487 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:41 +0200 Message-Id: <1494513181-7900-39-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 14:34:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 38/58] qemu-io: Switch 'alloc' command to byte-based length 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake For the 'alloc' command, accepting an offset in bytes but a length in sectors, and reporting output in sectors, is confusing. Do everything in bytes, and adjust the expected output accordingly. Signed-off-by: Eric Blake Message-id: 20170429191419.30051-3-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- qemu-io-cmds.c | 30 ++++++++++++++++++------------ tests/qemu-iotests/019.out | 8 ++++---- tests/qemu-iotests/common.pattern | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 6a0024b..1e0ebb4 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1760,7 +1760,7 @@ out: static int alloc_f(BlockBackend *blk, int argc, char **argv) { BlockDriverState *bs =3D blk_bs(blk); - int64_t offset, sector_num, nb_sectors, remaining; + int64_t offset, sector_num, nb_sectors, remaining, count; char s1[64]; int num, ret; int64_t sum_alloc; @@ -1776,18 +1776,24 @@ static int alloc_f(BlockBackend *blk, int argc, cha= r **argv) } =20 if (argc =3D=3D 3) { - nb_sectors =3D cvtnum(argv[2]); - if (nb_sectors < 0) { - print_cvtnum_err(nb_sectors, argv[2]); + count =3D cvtnum(argv[2]); + if (count < 0) { + print_cvtnum_err(count, argv[2]); return 0; - } else if (nb_sectors > INT_MAX) { - printf("length argument cannot exceed %d, given %s\n", - INT_MAX, argv[2]); + } else if (count > INT_MAX * BDRV_SECTOR_SIZE) { + printf("length argument cannot exceed %llu, given %s\n", + INT_MAX * BDRV_SECTOR_SIZE, argv[2]); return 0; } } else { - nb_sectors =3D 1; + count =3D BDRV_SECTOR_SIZE; + } + if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) { + printf("%" PRId64 " is not a sector-aligned value for 'count'\n", + count); + return 0; } + nb_sectors =3D count >> BDRV_SECTOR_BITS; =20 remaining =3D nb_sectors; sum_alloc =3D 0; @@ -1811,8 +1817,8 @@ static int alloc_f(BlockBackend *blk, int argc, char = **argv) =20 cvtstr(offset, s1, sizeof(s1)); =20 - printf("%"PRId64"/%"PRId64" sectors allocated at offset %s\n", - sum_alloc, nb_sectors, s1); + printf("%"PRId64"/%"PRId64" bytes allocated at offset %s\n", + sum_alloc << BDRV_SECTOR_BITS, nb_sectors << BDRV_SECTOR_BITS, = s1); return 0; } =20 @@ -1822,8 +1828,8 @@ static const cmdinfo_t alloc_cmd =3D { .argmin =3D 1, .argmax =3D 2, .cfunc =3D alloc_f, - .args =3D "off [sectors]", - .oneline =3D "checks if a sector is present in the file", + .args =3D "offset [count]", + .oneline =3D "checks if offset is allocated in the file", }; =20 =20 diff --git a/tests/qemu-iotests/019.out b/tests/qemu-iotests/019.out index 0124264..17a7c03 100644 --- a/tests/qemu-iotests/019.out +++ b/tests/qemu-iotests/019.out @@ -542,8 +542,8 @@ Testing conversion with -B TEST_DIR/t.IMGFMT.base =20 Checking if backing clusters are allocated when they shouldn't =20 -0/128 sectors allocated at offset 1 MiB -0/128 sectors allocated at offset 4.001 GiB +0/65536 bytes allocated at offset 1 MiB +0/65536 bytes allocated at offset 4.001 GiB Reading =20 =3D=3D=3D IO: pattern 42 @@ -1086,8 +1086,8 @@ Testing conversion with -o backing_file=3DTEST_DIR/t.= IMGFMT.base =20 Checking if backing clusters are allocated when they shouldn't =20 -0/128 sectors allocated at offset 1 MiB -0/128 sectors allocated at offset 4.001 GiB +0/65536 bytes allocated at offset 1 MiB +0/65536 bytes allocated at offset 4.001 GiB Reading =20 =3D=3D=3D IO: pattern 42 diff --git a/tests/qemu-iotests/common.pattern b/tests/qemu-iotests/common.= pattern index ddfbca1..34f4a8d 100644 --- a/tests/qemu-iotests/common.pattern +++ b/tests/qemu-iotests/common.pattern @@ -18,7 +18,7 @@ =20 function do_is_allocated() { local start=3D$1 - local size=3D$(( $2 / 512)) + local size=3D$2 local step=3D$3 local count=3D$4 =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515206317803.5626156382393; Thu, 11 May 2017 08:06:46 -0700 (PDT) Received: from localhost ([::1]:48702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pfs-0006gK-IE for importer@patchew.org; Thu, 11 May 2017 11:06:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAk-0002en-Nh for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAj-0007sW-Es for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAd-0007iG-Ls; Thu, 11 May 2017 10:34:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7DE97F6AC; Thu, 11 May 2017 14:34:22 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id B629588B3C; Thu, 11 May 2017 14:34:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7DE97F6AC Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A7DE97F6AC From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:42 +0200 Message-Id: <1494513181-7900-40-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 14:34:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 39/58] qemu-io: Switch 'map' output to byte-based reporting 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Mixing byte offset and sector allocation counts is a bit confusing. Also, reporting n/m sectors, where m decreases according to the remaining size of the file, isn't really adding any useful information; and reporting an offset at both the front and end of the line, with large amounts of whitespace, is pointless. Update the output to use byte counts and shorter lines, then adjust the affected tests (./check -qcow2 102, ./check -vpc 146). Note that 'qemu-io map' is MUCH weaker than 'qemu-img map'; the former only shows which regions of the active layer are allocated, without regards to where the allocation comes from or whether the allocated portion is known to read as zero (because it is using the weaker bdrv_is_allocated()); while the latter (especially in --output=3Djson mode) reports more details from bdrv_get_block_status(). Signed-off-by: Eric Blake Message-id: 20170429191419.30051-4-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- qemu-io-cmds.c | 11 ++++++----- tests/qemu-iotests/102.out | 4 ++-- tests/qemu-iotests/146.out | 30 +++++++++++++++--------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 1e0ebb4..4b2278f 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1868,7 +1868,7 @@ static int map_f(BlockBackend *blk, int argc, char **= argv) { int64_t offset; int64_t nb_sectors, total_sectors; - char s1[64]; + char s1[64], s2[64]; int64_t num; int ret; const char *retstr; @@ -1894,10 +1894,11 @@ static int map_f(BlockBackend *blk, int argc, char = **argv) } =20 retstr =3D ret ? " allocated" : "not allocated"; - cvtstr(offset << 9ULL, s1, sizeof(s1)); - printf("[% 24" PRId64 "] % 8" PRId64 "/% 8" PRId64 " sectors %s " - "at offset %s (%d)\n", - offset << 9ULL, num, nb_sectors, retstr, s1, ret); + cvtstr(num << BDRV_SECTOR_BITS, s1, sizeof(s1)); + cvtstr(offset << BDRV_SECTOR_BITS, s2, sizeof(s2)); + printf("%s (0x%" PRIx64 ") bytes %s at offset %s (0x%" PRIx64 ")\n= ", + s1, num << BDRV_SECTOR_BITS, retstr, + s2, offset << BDRV_SECTOR_BITS); =20 offset +=3D num; nb_sectors -=3D num; diff --git a/tests/qemu-iotests/102.out b/tests/qemu-iotests/102.out index eecde16..ccf172a 100644 --- a/tests/qemu-iotests/102.out +++ b/tests/qemu-iotests/102.out @@ -6,7 +6,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D65536 wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image resized. -[ 0] 128/ 128 sectors allocated at offs= et 0 bytes (1) +64 KiB (0x10000) bytes allocated at offset 0 bytes (0x0) Offset Length Mapped to File =20 =3D=3D=3D Testing map on an image file truncated outside of qemu =3D=3D=3D @@ -17,5 +17,5 @@ wrote 65536/65536 bytes at offset 0 Image resized. QEMU X.Y.Z monitor - type 'help' for more information (qemu) qemu-io drv0 map -[ 0] 128/ 128 sectors allocated at offs= et 0 bytes (1) +64 KiB (0x10000) bytes allocated at offset 0 bytes (0x0) *** done diff --git a/tests/qemu-iotests/146.out b/tests/qemu-iotests/146.out index 4f334d8..db6b296 100644 --- a/tests/qemu-iotests/146.out +++ b/tests/qemu-iotests/146.out @@ -2,39 +2,39 @@ QA output created by 146 =20 =3D=3D=3D Testing VPC Autodetect =3D=3D=3D =20 -[ 0] 266334240/ 266334240 sectors not allocated at = offset 0 bytes (0) +126.998 GiB (0x1fbfe04000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing VPC with current_size force =3D=3D=3D =20 -[ 0] 266338304/ 266338304 sectors not allocated at = offset 0 bytes (0) +127 GiB (0x1fc0000000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing VPC with chs force =3D=3D=3D =20 -[ 0] 266334240/ 266334240 sectors not allocated at = offset 0 bytes (0) +126.998 GiB (0x1fbfe04000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing Hyper-V Autodetect =3D=3D=3D =20 -[ 0] 266338304/ 266338304 sectors not allocated at = offset 0 bytes (0) +127 GiB (0x1fc0000000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing Hyper-V with current_size force =3D=3D=3D =20 -[ 0] 266338304/ 266338304 sectors not allocated at = offset 0 bytes (0) +127 GiB (0x1fc0000000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing Hyper-V with chs force =3D=3D=3D =20 -[ 0] 266334240/ 266334240 sectors not allocated at = offset 0 bytes (0) +126.998 GiB (0x1fbfe04000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing d2v Autodetect =3D=3D=3D =20 -[ 0] 514560/ 514560 sectors allocated at offs= et 0 bytes (1) +251.250 MiB (0xfb40000) bytes allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing d2v with current_size force =3D=3D=3D =20 -[ 0] 514560/ 514560 sectors allocated at offs= et 0 bytes (1) +251.250 MiB (0xfb40000) bytes allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing d2v with chs force =3D=3D=3D =20 -[ 0] 514560/ 514560 sectors allocated at offs= et 0 bytes (1) +251.250 MiB (0xfb40000) bytes allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing Image create, default =3D=3D=3D =20 @@ -42,15 +42,15 @@ Formatting 'TEST_DIR/IMGFMT-create-test.IMGFMT', fmt=3D= IMGFMT size=3D4294967296 =20 =3D=3D=3D Read created image, default opts =3D=3D=3D=3D =20 -[ 0] 8389584/ 8389584 sectors not allocated at offs= et 0 bytes (0) +4 GiB (0x10007a000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Read created image, force_size_calc=3Dchs =3D=3D=3D=3D =20 -[ 0] 8389584/ 8389584 sectors not allocated at offs= et 0 bytes (0) +4 GiB (0x10007a000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Read created image, force_size_calc=3Dcurrent_size =3D=3D=3D=3D =20 -[ 0] 8389584/ 8389584 sectors not allocated at offs= et 0 bytes (0) +4 GiB (0x10007a000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Testing Image create, force_size =3D=3D=3D =20 @@ -58,13 +58,13 @@ Formatting 'TEST_DIR/IMGFMT-create-test.IMGFMT', fmt=3D= IMGFMT size=3D4294967296 forc =20 =3D=3D=3D Read created image, default opts =3D=3D=3D=3D =20 -[ 0] 8388608/ 8388608 sectors not allocated at offs= et 0 bytes (0) +4 GiB (0x100000000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Read created image, force_size_calc=3Dchs =3D=3D=3D=3D =20 -[ 0] 8388608/ 8388608 sectors not allocated at offs= et 0 bytes (0) +4 GiB (0x100000000) bytes not allocated at offset 0 bytes (0x0) =20 =3D=3D=3D Read created image, force_size_calc=3Dcurrent_size =3D=3D=3D=3D =20 -[ 0] 8388608/ 8388608 sectors not allocated at offs= et 0 bytes (0) +4 GiB (0x100000000) bytes not allocated at offset 0 bytes (0x0) *** done --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514639156407.9709967521925; Thu, 11 May 2017 07:57:19 -0700 (PDT) Received: from localhost ([::1]:48638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pWm-0006aP-In for importer@patchew.org; Thu, 11 May 2017 10:57:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAj-0002dX-PW for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAj-0007rP-1L for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAe-0007jx-So; Thu, 11 May 2017 10:34:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5BD94ACB3; Thu, 11 May 2017 14:34:23 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7C507A407; Thu, 11 May 2017 14:34:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D5BD94ACB3 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D5BD94ACB3 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:43 +0200 Message-Id: <1494513181-7900-41-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 14:34:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 40/58] blkdebug: Sanity check block layer guarantees 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Commits 04ed95f4 and 1a62d0ac updated the block layer to auto-fragment any I/O to fit within device boundaries. Additionally, when using a minimum alignment of 4k, we want to ensure the block layer does proper read-modify-write rather than requesting I/O on a slice of a sector. Let's enforce that the contract is obeyed when using blkdebug. For now, blkdebug only allows alignment overrides, and just inherits other limits from whatever device it is wrapping, but a future patch will further enhance things. Signed-off-by: Eric Blake Reviewed-by: Kevin Wolf Reviewed-by: Max Reitz Message-id: 20170429191419.30051-5-eblake@redhat.com Signed-off-by: Max Reitz --- block/blkdebug.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index 3c08893..a562e2e 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -429,6 +429,13 @@ blkdebug_co_preadv(BlockDriverState *bs, uint64_t offs= et, uint64_t bytes, BDRVBlkdebugState *s =3D bs->opaque; BlkdebugRule *rule =3D NULL; =20 + /* Sanity check block layer guarantees */ + assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); + assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment)); + if (bs->bl.max_transfer) { + assert(bytes <=3D bs->bl.max_transfer); + } + QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset =3D rule->options.inject.offset; =20 @@ -453,6 +460,13 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t off= set, uint64_t bytes, BDRVBlkdebugState *s =3D bs->opaque; BlkdebugRule *rule =3D NULL; =20 + /* Sanity check block layer guarantees */ + assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); + assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment)); + if (bs->bl.max_transfer) { + assert(bytes <=3D bs->bl.max_transfer); + } + QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset =3D rule->options.inject.offset; =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149451478465913.924308330649183; Thu, 11 May 2017 07:59:44 -0700 (PDT) Received: from localhost ([::1]:48654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pZ6-0000Yp-7s for importer@patchew.org; Thu, 11 May 2017 10:59:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAl-0002fu-OI for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAk-0007tf-F7 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37630) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAi-0007o4-0d; Thu, 11 May 2017 10:34:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E69648AE75; Thu, 11 May 2017 14:34:26 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20B2B7A407; Thu, 11 May 2017 14:34:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E69648AE75 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E69648AE75 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:44 +0200 Message-Id: <1494513181-7900-42-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 14:34:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 41/58] blkdebug: Refactor error injection 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Rather than repeat the logic at each caller of checking if a Rule exists that warrants an error injection, fold that logic into inject_error(); and rename it to rule_check() for legibility. This will help the next patch, which adds two more callers that need to check rules for the potential of injecting errors. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-6-eblake@redhat.com Signed-off-by: Max Reitz --- block/blkdebug.c | 74 +++++++++++++++++++++++++---------------------------= ---- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index a562e2e..554573f 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -403,11 +403,30 @@ out: return ret; } =20 -static int inject_error(BlockDriverState *bs, BlkdebugRule *rule) +static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t byte= s) { BDRVBlkdebugState *s =3D bs->opaque; - int error =3D rule->options.inject.error; - bool immediately =3D rule->options.inject.immediately; + BlkdebugRule *rule =3D NULL; + int error; + bool immediately; + + QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { + uint64_t inject_offset =3D rule->options.inject.offset; + + if (inject_offset =3D=3D -1 || + (bytes && inject_offset >=3D offset && + inject_offset < offset + bytes)) + { + break; + } + } + + if (!rule || !rule->options.inject.error) { + return 0; + } + + immediately =3D rule->options.inject.immediately; + error =3D rule->options.inject.error; =20 if (rule->options.inject.once) { QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next); @@ -426,8 +445,7 @@ static int coroutine_fn blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - BDRVBlkdebugState *s =3D bs->opaque; - BlkdebugRule *rule =3D NULL; + int err; =20 /* Sanity check block layer guarantees */ assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); @@ -436,18 +454,9 @@ blkdebug_co_preadv(BlockDriverState *bs, uint64_t offs= et, uint64_t bytes, assert(bytes <=3D bs->bl.max_transfer); } =20 - QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { - uint64_t inject_offset =3D rule->options.inject.offset; - - if (inject_offset =3D=3D -1 || - (inject_offset >=3D offset && inject_offset < offset + bytes)) - { - break; - } - } - - if (rule && rule->options.inject.error) { - return inject_error(bs, rule); + err =3D rule_check(bs, offset, bytes); + if (err) { + return err; } =20 return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); @@ -457,8 +466,7 @@ static int coroutine_fn blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - BDRVBlkdebugState *s =3D bs->opaque; - BlkdebugRule *rule =3D NULL; + int err; =20 /* Sanity check block layer guarantees */ assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); @@ -467,18 +475,9 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t off= set, uint64_t bytes, assert(bytes <=3D bs->bl.max_transfer); } =20 - QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { - uint64_t inject_offset =3D rule->options.inject.offset; - - if (inject_offset =3D=3D -1 || - (inject_offset >=3D offset && inject_offset < offset + bytes)) - { - break; - } - } - - if (rule && rule->options.inject.error) { - return inject_error(bs, rule); + err =3D rule_check(bs, offset, bytes); + if (err) { + return err; } =20 return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); @@ -486,17 +485,10 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t of= fset, uint64_t bytes, =20 static int blkdebug_co_flush(BlockDriverState *bs) { - BDRVBlkdebugState *s =3D bs->opaque; - BlkdebugRule *rule =3D NULL; - - QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { - if (rule->options.inject.offset =3D=3D -1) { - break; - } - } + int err =3D rule_check(bs, 0, 0); =20 - if (rule && rule->options.inject.error) { - return inject_error(bs, rule); + if (err) { + return err; } =20 return bdrv_co_flush(bs->file->bs); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515348623517.5183274805365; Thu, 11 May 2017 08:09:08 -0700 (PDT) Received: from localhost ([::1]:48714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8piE-0000TF-VX for importer@patchew.org; Thu, 11 May 2017 11:09:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAn-0002hr-CB for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAl-0007vD-WE for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAj-0007pR-31; Thu, 11 May 2017 10:34:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1ABFE2D9FCE; Thu, 11 May 2017 14:34:28 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3094C7A407; Thu, 11 May 2017 14:34:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1ABFE2D9FCE Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1ABFE2D9FCE From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:45 +0200 Message-Id: <1494513181-7900-43-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 14:34:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 42/58] blkdebug: Add pass-through write_zero and discard support 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake In order to test the effects of artificial geometry constraints on operations like write zero or discard, we first need blkdebug to manage these actions. It also allows us to inject errors on those operations, just like we can for read/write/flush. We can also test the contract promised by the block layer; namely, if a device has specified limits on alignment or maximum size, then those limits must be obeyed (for now, the blkdebug driver merely inherits limits from whatever it is wrapping, but the next patch will further enhance it to allow specific limit overrides). This patch intentionally refuses to service requests smaller than the requested alignments; this is because an upcoming patch adds a qemu-iotest to prove that the block layer is correctly handling fragmentation, but the test only works if there is a way to tell the difference at artificial alignment boundaries when blkdebug is using a larger-than-default alignment. If we let the blkdebug layer always defer to the underlying layer, which potentially has a smaller granularity, the iotest will be thwarted. Tested by setting up an NBD server with export 'foo', then invoking: $ ./qemu-io qemu-io> open -o driver=3Dblkdebug blkdebug::nbd://localhost:10809/foo qemu-io> d 0 15M qemu-io> w -z 0 15M Pre-patch, the server never sees the discard (it was silently eaten by the block layer); post-patch it is passed across the wire. Likewise, pre-patch the write is always passed with NBD_WRITE (with 15M of zeroes on the wire), while post-patch it can utilize NBD_WRITE_ZEROES (for less traffic). Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-7-eblake@redhat.com Signed-off-by: Max Reitz --- block/blkdebug.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 74 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index 554573f..b8cc876 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -1,6 +1,7 @@ /* * Block protocol for I/O error injection * + * Copyright (C) 2016-2017 Red Hat, Inc. * Copyright (c) 2010 Kevin Wolf * * Permission is hereby granted, free of charge, to any person obtaining a= copy @@ -382,6 +383,11 @@ static int blkdebug_open(BlockDriverState *bs, QDict *= options, int flags, goto out; } =20 + bs->supported_write_flags =3D BDRV_REQ_FUA & + bs->file->bs->supported_write_flags; + bs->supported_zero_flags =3D (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & + bs->file->bs->supported_zero_flags; + /* Set request alignment */ align =3D qemu_opt_get_size(opts, "align", 0); if (align < INT_MAX && is_power_of_2(align)) { @@ -494,6 +500,72 @@ static int blkdebug_co_flush(BlockDriverState *bs) return bdrv_co_flush(bs->file->bs); } =20 +static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int coun= t, + BdrvRequestFlags flags) +{ + uint32_t align =3D MAX(bs->bl.request_alignment, + bs->bl.pwrite_zeroes_alignment); + int err; + + /* Only pass through requests that are larger than requested + * preferred alignment (so that we test the fallback to writes on + * unaligned portions), and check that the block layer never hands + * us anything unaligned that crosses an alignment boundary. */ + if (count < align) { + assert(QEMU_IS_ALIGNED(offset, align) || + QEMU_IS_ALIGNED(offset + count, align) || + DIV_ROUND_UP(offset, align) =3D=3D + DIV_ROUND_UP(offset + count, align)); + return -ENOTSUP; + } + assert(QEMU_IS_ALIGNED(offset, align)); + assert(QEMU_IS_ALIGNED(count, align)); + if (bs->bl.max_pwrite_zeroes) { + assert(count <=3D bs->bl.max_pwrite_zeroes); + } + + err =3D rule_check(bs, offset, count); + if (err) { + return err; + } + + return bdrv_co_pwrite_zeroes(bs->file, offset, count, flags); +} + +static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs, + int64_t offset, int count) +{ + uint32_t align =3D bs->bl.pdiscard_alignment; + int err; + + /* Only pass through requests that are larger than requested + * minimum alignment, and ensure that unaligned requests do not + * cross optimum discard boundaries. */ + if (count < bs->bl.request_alignment) { + assert(QEMU_IS_ALIGNED(offset, align) || + QEMU_IS_ALIGNED(offset + count, align) || + DIV_ROUND_UP(offset, align) =3D=3D + DIV_ROUND_UP(offset + count, align)); + return -ENOTSUP; + } + assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); + assert(QEMU_IS_ALIGNED(count, bs->bl.request_alignment)); + if (align && count >=3D align) { + assert(QEMU_IS_ALIGNED(offset, align)); + assert(QEMU_IS_ALIGNED(count, align)); + } + if (bs->bl.max_pdiscard) { + assert(count <=3D bs->bl.max_pdiscard); + } + + err =3D rule_check(bs, offset, count); + if (err) { + return err; + } + + return bdrv_co_pdiscard(bs->file->bs, offset, count); +} =20 static void blkdebug_close(BlockDriverState *bs) { @@ -748,6 +820,8 @@ static BlockDriver bdrv_blkdebug =3D { .bdrv_co_preadv =3D blkdebug_co_preadv, .bdrv_co_pwritev =3D blkdebug_co_pwritev, .bdrv_co_flush_to_disk =3D blkdebug_co_flush, + .bdrv_co_pwrite_zeroes =3D blkdebug_co_pwrite_zeroes, + .bdrv_co_pdiscard =3D blkdebug_co_pdiscard, =20 .bdrv_debug_event =3D blkdebug_debug_event, .bdrv_debug_breakpoint =3D blkdebug_debug_breakpoint, --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514948982535.9861228690447; Thu, 11 May 2017 08:02:28 -0700 (PDT) Received: from localhost ([::1]:48675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pbj-0002so-WB for importer@patchew.org; Thu, 11 May 2017 11:02:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAs-0002kv-LW for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAr-00081l-Ou for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47478) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAk-0007sh-9V; Thu, 11 May 2017 10:34:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4914D81127; Thu, 11 May 2017 14:34:29 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CBD47A407; Thu, 11 May 2017 14:34:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4914D81127 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4914D81127 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:46 +0200 Message-Id: <1494513181-7900-44-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 14:34:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 43/58] blkdebug: Simplify override logic 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Rather than store into a local variable, then copy to the struct if the value is valid, then reporting errors otherwise, it is simpler to just store into the struct and report errors if the value is invalid. This however requires that the struct store a 64-bit number, rather than a narrower type. Likewise, setting a sane errno value in ret prior to the sequence of parsing and jumping to out: on error makes it easier for the next patch to add a chain of similar checks. Signed-off-by: Eric Blake Message-id: 20170429191419.30051-8-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/blkdebug.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index b8cc876..29ab7a3 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -38,7 +38,7 @@ typedef struct BDRVBlkdebugState { int state; int new_state; - int align; + uint64_t align; =20 /* For blkdebug_refresh_filename() */ char *config_file; @@ -353,7 +353,6 @@ static int blkdebug_open(BlockDriverState *bs, QDict *o= ptions, int flags, BDRVBlkdebugState *s =3D bs->opaque; QemuOpts *opts; Error *local_err =3D NULL; - uint64_t align; int ret; =20 opts =3D qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); @@ -387,20 +386,17 @@ static int blkdebug_open(BlockDriverState *bs, QDict = *options, int flags, bs->file->bs->supported_write_flags; bs->supported_zero_flags =3D (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & bs->file->bs->supported_zero_flags; + ret =3D -EINVAL; =20 /* Set request alignment */ - align =3D qemu_opt_get_size(opts, "align", 0); - if (align < INT_MAX && is_power_of_2(align)) { - s->align =3D align; - } else if (align) { - error_setg(errp, "Invalid alignment"); - ret =3D -EINVAL; + s->align =3D qemu_opt_get_size(opts, "align", 0); + if (s->align && (s->align >=3D INT_MAX || !is_power_of_2(s->align))) { + error_setg(errp, "Cannot meet constraints with align %" PRIu64, + s->align); goto out; } =20 ret =3D 0; - goto out; - out: if (ret < 0) { g_free(s->config_file); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514746141433.1781014587207; Thu, 11 May 2017 07:59:06 -0700 (PDT) Received: from localhost ([::1]:48653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pYW-0008BN-FW for importer@patchew.org; Thu, 11 May 2017 10:59:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAt-0002lf-5g for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAr-00081e-NW for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAm-0007vA-HF; Thu, 11 May 2017 10:34:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DF8EC04B941; Thu, 11 May 2017 14:34:31 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8969B7A407; Thu, 11 May 2017 14:34:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7DF8EC04B941 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7DF8EC04B941 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:47 +0200 Message-Id: <1494513181-7900-45-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 14:34:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 44/58] blkdebug: Add ability to override unmap geometries 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Make it easier to simulate various unusual hardware setups (for example, recent commits 3482b9b and b8d0a98 affect the Dell Equallogic iSCSI with its 15M preferred and maximum unmap and write zero sizing, or b2f95fe deals with the Linux loopback block device having a max_transfer of 64k), by allowing blkdebug to wrap any other device with further restrictions on various alignments. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-9-eblake@redhat.com Signed-off-by: Max Reitz --- block/blkdebug.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++= +++- qapi/block-core.json | 33 ++++++++++++++++-- 2 files changed, 125 insertions(+), 4 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 29ab7a3..a5196e8 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -39,6 +39,11 @@ typedef struct BDRVBlkdebugState { int state; int new_state; uint64_t align; + uint64_t max_transfer; + uint64_t opt_write_zero; + uint64_t max_write_zero; + uint64_t opt_discard; + uint64_t max_discard; =20 /* For blkdebug_refresh_filename() */ char *config_file; @@ -343,6 +348,31 @@ static QemuOptsList runtime_opts =3D { .type =3D QEMU_OPT_SIZE, .help =3D "Required alignment in bytes", }, + { + .name =3D "max-transfer", + .type =3D QEMU_OPT_SIZE, + .help =3D "Maximum transfer size in bytes", + }, + { + .name =3D "opt-write-zero", + .type =3D QEMU_OPT_SIZE, + .help =3D "Optimum write zero alignment in bytes", + }, + { + .name =3D "max-write-zero", + .type =3D QEMU_OPT_SIZE, + .help =3D "Maximum write zero size in bytes", + }, + { + .name =3D "opt-discard", + .type =3D QEMU_OPT_SIZE, + .help =3D "Optimum discard alignment in bytes", + }, + { + .name =3D "max-discard", + .type =3D QEMU_OPT_SIZE, + .help =3D "Maximum discard size in bytes", + }, { /* end of list */ } }, }; @@ -354,6 +384,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *o= ptions, int flags, QemuOpts *opts; Error *local_err =3D NULL; int ret; + uint64_t align; =20 opts =3D qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); @@ -388,13 +419,61 @@ static int blkdebug_open(BlockDriverState *bs, QDict = *options, int flags, bs->file->bs->supported_zero_flags; ret =3D -EINVAL; =20 - /* Set request alignment */ + /* Set alignment overrides */ s->align =3D qemu_opt_get_size(opts, "align", 0); if (s->align && (s->align >=3D INT_MAX || !is_power_of_2(s->align))) { error_setg(errp, "Cannot meet constraints with align %" PRIu64, s->align); goto out; } + align =3D MAX(s->align, bs->file->bs->bl.request_alignment); + + s->max_transfer =3D qemu_opt_get_size(opts, "max-transfer", 0); + if (s->max_transfer && + (s->max_transfer >=3D INT_MAX || + !QEMU_IS_ALIGNED(s->max_transfer, align))) { + error_setg(errp, "Cannot meet constraints with max-transfer %" PRI= u64, + s->max_transfer); + goto out; + } + + s->opt_write_zero =3D qemu_opt_get_size(opts, "opt-write-zero", 0); + if (s->opt_write_zero && + (s->opt_write_zero >=3D INT_MAX || + !QEMU_IS_ALIGNED(s->opt_write_zero, align))) { + error_setg(errp, "Cannot meet constraints with opt-write-zero %" P= RIu64, + s->opt_write_zero); + goto out; + } + + s->max_write_zero =3D qemu_opt_get_size(opts, "max-write-zero", 0); + if (s->max_write_zero && + (s->max_write_zero >=3D INT_MAX || + !QEMU_IS_ALIGNED(s->max_write_zero, + MAX(s->opt_write_zero, align)))) { + error_setg(errp, "Cannot meet constraints with max-write-zero %" P= RIu64, + s->max_write_zero); + goto out; + } + + s->opt_discard =3D qemu_opt_get_size(opts, "opt-discard", 0); + if (s->opt_discard && + (s->opt_discard >=3D INT_MAX || + !QEMU_IS_ALIGNED(s->opt_discard, align))) { + error_setg(errp, "Cannot meet constraints with opt-discard %" PRIu= 64, + s->opt_discard); + goto out; + } + + s->max_discard =3D qemu_opt_get_size(opts, "max-discard", 0); + if (s->max_discard && + (s->max_discard >=3D INT_MAX || + !QEMU_IS_ALIGNED(s->max_discard, + MAX(s->opt_discard, align)))) { + error_setg(errp, "Cannot meet constraints with max-discard %" PRIu= 64, + s->max_discard); + goto out; + } =20 ret =3D 0; out: @@ -789,6 +868,21 @@ static void blkdebug_refresh_limits(BlockDriverState *= bs, Error **errp) if (s->align) { bs->bl.request_alignment =3D s->align; } + if (s->max_transfer) { + bs->bl.max_transfer =3D s->max_transfer; + } + if (s->opt_write_zero) { + bs->bl.pwrite_zeroes_alignment =3D s->opt_write_zero; + } + if (s->max_write_zero) { + bs->bl.max_pwrite_zeroes =3D s->max_write_zero; + } + if (s->opt_discard) { + bs->bl.pdiscard_alignment =3D s->opt_discard; + } + if (s->max_discard) { + bs->bl.max_pdiscard =3D s->max_discard; + } } =20 static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state, diff --git a/qapi/block-core.json b/qapi/block-core.json index 52e3ecd..6b974b9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2434,8 +2434,33 @@ # # @config: filename of the configuration file # -# @align: required alignment for requests in bytes, -# must be power of 2, or 0 for default +# @align: required alignment for requests in bytes, must be +# positive power of 2, or 0 for default +# +# @max-transfer: maximum size for I/O transfers in bytes, must be +# positive multiple of @align and of the underlying +# file's request alignment (but need not be a power of +# 2), or 0 for default (since 2.10) +# +# @opt-write-zero: preferred alignment for write zero requests in bytes, +# must be positive multiple of @align and of the +# underlying file's request alignment (but need not be a +# power of 2), or 0 for default (since 2.10) +# +# @max-write-zero: maximum size for write zero requests in bytes, must be +# positive multiple of @align, of @opt-write-zero, and of +# the underlying file's request alignment (but need not +# be a power of 2), or 0 for default (since 2.10) +# +# @opt-discard: preferred alignment for discard requests in bytes, must +# be positive multiple of @align and of the underlying +# file's request alignment (but need not be a power of +# 2), or 0 for default (since 2.10) +# +# @max-discard: maximum size for discard requests in bytes, must be +# positive multiple of @align, of @opt-discard, and of +# the underlying file's request alignment (but need not +# be a power of 2), or 0 for default (since 2.10) # # @inject-error: array of error injection descriptions # @@ -2446,7 +2471,9 @@ { 'struct': 'BlockdevOptionsBlkdebug', 'data': { 'image': 'BlockdevRef', '*config': 'str', - '*align': 'int', + '*align': 'int', '*max-transfer': 'int32', + '*opt-write-zero': 'int32', '*max-write-zero': 'int32', + '*opt-discard': 'int32', '*max-discard': 'int32', '*inject-error': ['BlkdebugInjectErrorOptions'], '*set-state': ['BlkdebugSetStateOptions'] } } =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494514910475987.0230562506628; Thu, 11 May 2017 08:01:50 -0700 (PDT) Received: from localhost ([::1]:48674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pb9-0002Nh-5A for importer@patchew.org; Thu, 11 May 2017 11:01:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pB0-0002to-Ux for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAw-00088G-Vy for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAn-0007w6-Jw; Thu, 11 May 2017 10:34:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E81EC059739; Thu, 11 May 2017 14:34:32 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF85A7A407; Thu, 11 May 2017 14:34:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8E81EC059739 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8E81EC059739 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:48 +0200 Message-Id: <1494513181-7900-46-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 11 May 2017 14:34:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 45/58] tests: Add coverage for recent block geometry fixes 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Use blkdebug's new geometry constraints to emulate setups that have needed past regression fixes: write zeroes asserting when running through a loopback block device with max-transfer smaller than cluster size, and discard rounding away portions of requests not aligned to preferred boundaries. Also, add coverage that the block layer is honoring max transfer limits. For now, a single iotest performs all actions, with the idea that we can add future blkdebug constraint test cases in the same file; but it can be split into multiple iotests if we find reason to run one portion of the test in more setups than what are possible in the other. For reference, the final portion of the test (checking whether discard passes as much as possible to the lowest layers of the stack) works as follows: qemu-io: discard 30M at 80000001, passed to blkdebug blkdebug: discard 511 bytes at 80000001, -ENOTSUP (smaller than blkdebug's 512 align) blkdebug: discard 14371328 bytes at 80000512, passed to qcow2 qcow2: discard 739840 bytes at 80000512, -ENOTSUP (smaller than qcow2's 1M align) qcow2: discard 13M bytes at 77M, succeeds blkdebug: discard 15M bytes at 90M, passed to qcow2 qcow2: discard 15M bytes at 90M, succeeds blkdebug: discard 1356800 bytes at 105M, passed to qcow2 qcow2: discard 1M at 105M, succeeds qcow2: discard 308224 bytes at 106M, -ENOTSUP (smaller than qcow2's 1M align) blkdebug: discard 1 byte at 111457280, -ENOTSUP (smaller than blkdebug's 512 align) Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-10-eblake@redhat.com [mreitz: For cooperation with image locking, add -r to the qemu-io invocation which verifies the image content] Signed-off-by: Max Reitz --- tests/qemu-iotests/177 | 114 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/177.out | 49 +++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 164 insertions(+) create mode 100755 tests/qemu-iotests/177 create mode 100644 tests/qemu-iotests/177.out diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177 new file mode 100755 index 0000000..2005c17 --- /dev/null +++ b/tests/qemu-iotests/177 @@ -0,0 +1,114 @@ +#!/bin/bash +# +# Test corner cases with unusual block geometries +# +# Copyright (C) 2016-2017 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=3Deblake@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 +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file + +CLUSTER_SIZE=3D1M +size=3D128M +options=3Ddriver=3Dblkdebug,image.driver=3Dqcow2 + +echo +echo "=3D=3D setting up files =3D=3D" + +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $size +$QEMU_IO -c "write -P 11 0 $size" "$TEST_IMG.base" | _filter_qemu_io +_make_test_img -b "$TEST_IMG.base" +$QEMU_IO -c "write -P 22 0 $size" "$TEST_IMG" | _filter_qemu_io + +# Limited to 64k max-transfer +echo +echo "=3D=3D constrained alignment and max-transfer =3D=3D" +limits=3Dalign=3D4k,max-transfer=3D64k +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "write -P 33 1000 128k" -c "read -P 33 1000 128k" | _filter_qe= mu_io + +echo +echo "=3D=3D write zero with constrained max-transfer =3D=3D" +limits=3Dalign=3D512,max-transfer=3D64k,opt-write-zero=3D$CLUSTER_SIZE +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "write -z 8003584 2093056" | _filter_qemu_io + +# non-power-of-2 write-zero/discard alignments +echo +echo "=3D=3D non-power-of-2 write zeroes limits =3D=3D" + +limits=3Dalign=3D512,opt-write-zero=3D15M,max-write-zero=3D15M,opt-discard= =3D15M,max-discard=3D15M +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "write -z 32M 32M" | _filter_qemu_io + +echo +echo "=3D=3D non-power-of-2 discard limits =3D=3D" + +limits=3Dalign=3D512,opt-write-zero=3D15M,max-write-zero=3D15M,opt-discard= =3D15M,max-discard=3D15M +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "discard 80000001 30M" | _filter_qemu_io + +echo +echo "=3D=3D verify image content =3D=3D" + +function verify_io() +{ + if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | + grep "compat: 0.10" > /dev/null); then + # For v2 images, discarded clusters are read from the backing file + discarded=3D11 + else + # Discarded clusters are zeroed for v3 or later + discarded=3D0 + fi + + echo read -P 22 0 1000 + echo read -P 33 1000 128k + echo read -P 22 132072 7871512 + echo read -P 0 8003584 2093056 + echo read -P 22 10096640 23457792 + echo read -P 0 32M 32M + echo read -P 22 64M 13M + echo read -P $discarded 77M 29M + echo read -P 22 106M 22M +} + +verify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io + +_check_test_img + +# success, all done +echo "*** done" +status=3D0 diff --git a/tests/qemu-iotests/177.out b/tests/qemu-iotests/177.out new file mode 100644 index 0000000..e887542 --- /dev/null +++ b/tests/qemu-iotests/177.out @@ -0,0 +1,49 @@ +QA output created by 177 + +=3D=3D setting up files =3D=3D +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134217728 +wrote 134217728/134217728 bytes at offset 0 +128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 134217728/134217728 bytes at offset 0 +128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D constrained alignment and max-transfer =3D=3D +wrote 131072/131072 bytes at offset 1000 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 1000 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D write zero with constrained max-transfer =3D=3D +wrote 2093056/2093056 bytes at offset 8003584 +1.996 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D non-power-of-2 write zeroes limits =3D=3D +wrote 33554432/33554432 bytes at offset 33554432 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D non-power-of-2 discard limits =3D=3D +discard 31457280/31457280 bytes at offset 80000001 +30 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D verify image content =3D=3D +read 1000/1000 bytes at offset 0 +1000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 1000 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 7871512/7871512 bytes at offset 132072 +7.507 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 2093056/2093056 bytes at offset 8003584 +1.996 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 23457792/23457792 bytes at offset 10096640 +22.371 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 33554432 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 13631488/13631488 bytes at offset 67108864 +13 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 30408704/30408704 bytes at offset 80740352 +29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 23068672/23068672 bytes at offset 111149056 +22 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +No errors were found on the image. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index a4549d8..bb6df8f 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -170,5 +170,6 @@ 174 auto 175 auto quick 176 rw auto backing +177 rw auto quick 181 rw auto migration 182 rw auto quick --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515502908174.24085552922827; Thu, 11 May 2017 08:11:42 -0700 (PDT) Received: from localhost ([::1]:48736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pkh-00030y-8U for importer@patchew.org; Thu, 11 May 2017 11:11:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pB1-0002uF-EI for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAv-00085h-D8 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAo-0007xf-R6; Thu, 11 May 2017 10:34:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5B1A64D94; Thu, 11 May 2017 14:34:33 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF6D37A407; Thu, 11 May 2017 14:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5B1A64D94 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5B1A64D94 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:49 +0200 Message-Id: <1494513181-7900-47-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 14:34:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 46/58] qcow2: Nicer variable names in qcow2_update_snapshot_refcount() 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake In order to keep checkpatch happy when the next patch changes indentation, we first have to shorten some long lines. The easiest approach is to use a new variable in place of 'offset & L2E_OFFSET_MASK', except that 'offset' is the best name for that variable. Change '[old_]offset' to '[old_]entry' to make room. While touching things, also fix checkpatch warnings about unusual 'for' statements. Suggested by Max Reitz Signed-off-by: Eric Blake Message-id: 20170507000552.20847-2-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 4efca7e..db0af2c 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1059,9 +1059,9 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, int64_t l1_table_offset, int l1_size, int addend) { BDRVQcow2State *s =3D bs->opaque; - uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, refcount; + uint64_t *l1_table, *l2_table, l2_offset, entry, l1_size2, refcount; bool l1_allocated =3D false; - int64_t old_offset, old_l2_offset; + int64_t old_entry, old_l2_offset; int i, j, l1_modified =3D 0, nb_csectors; int ret; =20 @@ -1089,15 +1089,16 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - for(i =3D 0;i < l1_size; i++) + for (i =3D 0; i < l1_size; i++) { be64_to_cpus(&l1_table[i]); + } } else { assert(l1_size =3D=3D s->l1_size); l1_table =3D s->l1_table; l1_allocated =3D false; } =20 - for(i =3D 0; i < l1_size; i++) { + for (i =3D 0; i < l1_size; i++) { l2_offset =3D l1_table[i]; if (l2_offset) { old_l2_offset =3D l2_offset; @@ -1117,20 +1118,22 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, goto fail; } =20 - for(j =3D 0; j < s->l2_size; j++) { + for (j =3D 0; j < s->l2_size; j++) { uint64_t cluster_index; + uint64_t offset; =20 - offset =3D be64_to_cpu(l2_table[j]); - old_offset =3D offset; - offset &=3D ~QCOW_OFLAG_COPIED; + entry =3D be64_to_cpu(l2_table[j]); + old_entry =3D entry; + entry &=3D ~QCOW_OFLAG_COPIED; + offset =3D entry & L2E_OFFSET_MASK; =20 - switch (qcow2_get_cluster_type(offset)) { + switch (qcow2_get_cluster_type(entry)) { case QCOW2_CLUSTER_COMPRESSED: - nb_csectors =3D ((offset >> s->csize_shift) & + nb_csectors =3D ((entry >> s->csize_shift) & s->csize_mask) + 1; if (addend !=3D 0) { ret =3D update_refcount(bs, - (offset & s->cluster_offset_mask) & ~511, + (entry & s->cluster_offset_mask) & ~511, nb_csectors * 512, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); if (ret < 0) { @@ -1143,18 +1146,17 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, =20 case QCOW2_CLUSTER_NORMAL: case QCOW2_CLUSTER_ZERO: - if (offset_into_cluster(s, offset & L2E_OFFSET_MAS= K)) { + if (offset_into_cluster(s, offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Dat= a " - "cluster offset %#llx " - "unaligned (L2 offset:= %#" + "cluster offset %#" PR= Ix64 + " unaligned (L2 offset= : %#" PRIx64 ", L2 index: %#= x)", - offset & L2E_OFFSET_MA= SK, - l2_offset, j); + offset, l2_offset, j); ret =3D -EIO; goto fail; } =20 - cluster_index =3D (offset & L2E_OFFSET_MASK) >> s-= >cluster_bits; + cluster_index =3D offset >> s->cluster_bits; if (!cluster_index) { /* unallocated */ refcount =3D 0; @@ -1184,14 +1186,14 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, } =20 if (refcount =3D=3D 1) { - offset |=3D QCOW_OFLAG_COPIED; + entry |=3D QCOW_OFLAG_COPIED; } - if (offset !=3D old_offset) { + if (entry !=3D old_entry) { if (addend > 0) { qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache); } - l2_table[j] =3D cpu_to_be64(offset); + l2_table[j] =3D cpu_to_be64(entry); qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); } --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149451510072184.05894563251024; Thu, 11 May 2017 08:05:00 -0700 (PDT) Received: from localhost ([::1]:48687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8peC-00053K-CT for importer@patchew.org; Thu, 11 May 2017 11:04:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pAv-0002oJ-M8 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pAu-00084x-Mj for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAr-000815-Qf; Thu, 11 May 2017 10:34:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C59A2C04B939; Thu, 11 May 2017 14:34:36 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 119D08A8D3; Thu, 11 May 2017 14:34:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C59A2C04B939 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C59A2C04B939 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:50 +0200 Message-Id: <1494513181-7900-48-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 11 May 2017 14:34:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 47/58] qcow2: Use consistent switch indentation 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Fix a couple of inconsistent indentations, before an upcoming patch further tweaks the switch statements. (best viewed with 'git diff -b'). Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-3-eblake@redhat.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 32 +++++++++---------- block/qcow2-refcount.c | 84 +++++++++++++++++++++++++---------------------= ---- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 31077d8..335a505 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1504,25 +1504,25 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, * but rather fall through to the backing file. */ switch (qcow2_get_cluster_type(old_l2_entry)) { - case QCOW2_CLUSTER_UNALLOCATED: - if (full_discard || !bs->backing) { - continue; - } - break; + case QCOW2_CLUSTER_UNALLOCATED: + if (full_discard || !bs->backing) { + continue; + } + break; =20 - case QCOW2_CLUSTER_ZERO: - /* Preallocated zero clusters should be discarded in any c= ase */ - if (!full_discard && (old_l2_entry & L2E_OFFSET_MASK) =3D= =3D 0) { - continue; - } - break; + case QCOW2_CLUSTER_ZERO: + /* Preallocated zero clusters should be discarded in any case = */ + if (!full_discard && (old_l2_entry & L2E_OFFSET_MASK) =3D=3D 0= ) { + continue; + } + break; =20 - case QCOW2_CLUSTER_NORMAL: - case QCOW2_CLUSTER_COMPRESSED: - break; + case QCOW2_CLUSTER_NORMAL: + case QCOW2_CLUSTER_COMPRESSED: + break; =20 - default: - abort(); + default: + abort(); } =20 /* First remove L2 entries */ diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index db0af2c..908dbe5 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1128,61 +1128,61 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, offset =3D entry & L2E_OFFSET_MASK; =20 switch (qcow2_get_cluster_type(entry)) { - case QCOW2_CLUSTER_COMPRESSED: - nb_csectors =3D ((entry >> s->csize_shift) & - s->csize_mask) + 1; - if (addend !=3D 0) { - ret =3D update_refcount(bs, + case QCOW2_CLUSTER_COMPRESSED: + nb_csectors =3D ((entry >> s->csize_shift) & + s->csize_mask) + 1; + if (addend !=3D 0) { + ret =3D update_refcount(bs, (entry & s->cluster_offset_mask) & ~511, nb_csectors * 512, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); - if (ret < 0) { - goto fail; - } - } - /* compressed clusters are never modified */ - refcount =3D 2; - break; - - case QCOW2_CLUSTER_NORMAL: - case QCOW2_CLUSTER_ZERO: - if (offset_into_cluster(s, offset)) { - qcow2_signal_corruption(bs, true, -1, -1, "Dat= a " - "cluster offset %#" PR= Ix64 - " unaligned (L2 offset= : %#" - PRIx64 ", L2 index: %#= x)", - offset, l2_offset, j); - ret =3D -EIO; + if (ret < 0) { goto fail; } + } + /* compressed clusters are never modified */ + refcount =3D 2; + break; + + case QCOW2_CLUSTER_NORMAL: + case QCOW2_CLUSTER_ZERO: + if (offset_into_cluster(s, offset)) { + qcow2_signal_corruption(bs, true, -1, -1, "Data " + "cluster offset %#" PRIx64 + " unaligned (L2 offset: %#" + PRIx64 ", L2 index: %#x)", + offset, l2_offset, j); + ret =3D -EIO; + goto fail; + } =20 - cluster_index =3D offset >> s->cluster_bits; - if (!cluster_index) { - /* unallocated */ - refcount =3D 0; - break; - } - if (addend !=3D 0) { - ret =3D qcow2_update_cluster_refcount(bs, + cluster_index =3D offset >> s->cluster_bits; + if (!cluster_index) { + /* unallocated */ + refcount =3D 0; + break; + } + if (addend !=3D 0) { + ret =3D qcow2_update_cluster_refcount(bs, cluster_index, abs(addend), addend < 0, QCOW2_DISCARD_SNAPSHOT); - if (ret < 0) { - goto fail; - } - } - - ret =3D qcow2_get_refcount(bs, cluster_index, &ref= count); if (ret < 0) { goto fail; } - break; + } =20 - case QCOW2_CLUSTER_UNALLOCATED: - refcount =3D 0; - break; + ret =3D qcow2_get_refcount(bs, cluster_index, &refcoun= t); + if (ret < 0) { + goto fail; + } + break; + + case QCOW2_CLUSTER_UNALLOCATED: + refcount =3D 0; + break; =20 - default: - abort(); + default: + abort(); } =20 if (refcount =3D=3D 1) { --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515064764318.7068888209835; Thu, 11 May 2017 08:04:24 -0700 (PDT) Received: from localhost ([::1]:48684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pdd-0004ZO-9E for importer@patchew.org; Thu, 11 May 2017 11:04:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pB4-0002wg-JV for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pB3-0008Cc-I5 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pAx-000882-GZ; Thu, 11 May 2017 10:34:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75E2263704; Thu, 11 May 2017 14:34:42 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F3D08A8CF; Thu, 11 May 2017 14:34:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 75E2263704 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 75E2263704 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:51 +0200 Message-Id: <1494513181-7900-49-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:34:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 48/58] block: Update comments on BDRV_BLOCK_* meanings 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake We had some conflicting documentation: a nice 8-way table that described all possible combinations of DATA, ZERO, and OFFSET_VALID, contrasted with text that implied that OFFSET_VALID always meant raw data could be read directly. Furthermore, the text refers a lot to bs->file, even though the interface was updated back in 67a0fd2a to let the driver pass back a specific BDS (not necessarily bs->file). As the 8-way table is the intended semantics, simplify the rest of the text to get rid of the confusion. ALLOCATED is always set by the block layer for convenience (drivers do not have to worry about it). RAW is used only internally, but by more than the raw driver. Document these additional items on the driver callback. Suggested-by: Max Reitz Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-4-eblake@redhat.com Signed-off-by: Max Reitz --- include/block/block.h | 35 +++++++++++++++++++---------------- include/block/block_int.h | 7 +++++++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 90932b4..9b355e9 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -121,29 +121,32 @@ typedef struct HDGeometry { #define BDRV_REQUEST_MAX_BYTES (BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BI= TS) =20 /* - * Allocation status flags - * BDRV_BLOCK_DATA: data is read from a file returned by bdrv_get_block_st= atus. - * BDRV_BLOCK_ZERO: sectors read as zero - * BDRV_BLOCK_OFFSET_VALID: sector stored as raw data in a file returned by - * bdrv_get_block_status. + * Allocation status flags for bdrv_get_block_status() and friends. + * + * Public flags: + * BDRV_BLOCK_DATA: allocation for data at offset is tied to this layer + * BDRV_BLOCK_ZERO: offset reads as zero + * BDRV_BLOCK_OFFSET_VALID: an associated offset exists for accessing raw = data * BDRV_BLOCK_ALLOCATED: the content of the block is determined by this - * layer (as opposed to the backing file) - * BDRV_BLOCK_RAW: used internally to indicate that the request - * was answered by the raw driver and that one - * should look in bs->file directly. + * layer (short for DATA || ZERO), set by block layer * - * If BDRV_BLOCK_OFFSET_VALID is set, bits 9-62 represent the offset in - * bs->file where sector data can be read from as raw data. + * Internal flag: + * BDRV_BLOCK_RAW: used internally to indicate that the request was + * answered by a passthrough driver such as raw and that t= he + * block layer should recompute the answer from bs->file. * - * DATA =3D=3D 0 && ZERO =3D=3D 0 means that data is read from backing_hd = if present. + * If BDRV_BLOCK_OFFSET_VALID is set, bits 9-62 (BDRV_BLOCK_OFFSET_MASK) + * represent the offset in the returned BDS that is allocated for the + * corresponding raw data; however, whether that offset actually contains + * data also depends on BDRV_BLOCK_DATA and BDRV_BLOCK_ZERO, as follows: * * DATA ZERO OFFSET_VALID - * t t t sectors read as zero, bs->file is zero at offset - * t f t sectors read as valid from bs->file at offset - * f t t sectors preallocated, read as zero, bs->file not + * t t t sectors read as zero, returned file is zero at o= ffset + * t f t sectors read as valid from file at offset + * f t t sectors preallocated, read as zero, returned fil= e not * necessarily zero at offset * f f t sectors preallocated but read from backing_hd, - * bs->file contains garbage at offset + * returned file contains garbage at offset * t t f sectors preallocated, read as zero, unknown offs= et * t f f sectors read from unknown file or offset * f t f not allocated or unknown offset, read as zero diff --git a/include/block/block_int.h b/include/block/block_int.h index 5750a44..8d3724c 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -165,6 +165,13 @@ struct BlockDriver { int64_t offset, int count, BdrvRequestFlags flags); int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs, int64_t offset, int count); + + /* + * Building block for bdrv_block_status[_above]. The driver should + * answer only according to the current layer, and should not + * set BDRV_BLOCK_ALLOCATED, but may set BDRV_BLOCK_RAW. See block.h + * for the meaning of _DATA, _ZERO, and _OFFSET_VALID. + */ int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file); --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149451525020770.7358968602498; Thu, 11 May 2017 08:07:30 -0700 (PDT) Received: from localhost ([::1]:48705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pga-0007NC-KQ for importer@patchew.org; Thu, 11 May 2017 11:07:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBC-00034u-Bx for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBB-0008Jy-Ab for qemu-devel@nongnu.org; Thu, 11 May 2017 10:34:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pB5-0008De-Kx; Thu, 11 May 2017 10:34:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D50E80C2D; Thu, 11 May 2017 14:34:50 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id B622C8A8CF; Thu, 11 May 2017 14:34:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9D50E80C2D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9D50E80C2D From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:52 +0200 Message-Id: <1494513181-7900-50-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 11 May 2017 14:34:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 49/58] qcow2: Correctly report status of preallocated zero clusters 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake We were throwing away the preallocation information associated with zero clusters. But we should be matching the well-defined semantics in bdrv_get_block_status(), where (BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID) informs the user which offset is reserved, while still reminding the user that reading from that offset is likely to read garbage. count_contiguous_clusters_by_type() is now used only for unallocated cluster runs, hence it gets renamed and tightened. Making this change lets us see which portions of an image are zero but preallocated, when using qemu-img map --output=3Djson. The --output=3Dhuman side intentionally ignores all zero clusters, whether or not they are preallocated. The fact that there is no change to qemu-iotests './check -qcow2' merely means that we aren't yet testing this aspect of qemu-img; a later patch will add a test. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-5-eblake@redhat.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 335a505..f3bfce6 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -334,16 +334,23 @@ static int count_contiguous_clusters(int nb_clusters,= int cluster_size, return i; } =20 -static int count_contiguous_clusters_by_type(int nb_clusters, - uint64_t *l2_table, - int wanted_type) +/* + * Checks how many consecutive unallocated clusters in a given L2 + * table have the same cluster type. + */ +static int count_contiguous_clusters_unallocated(int nb_clusters, + uint64_t *l2_table, + int wanted_type) { int i; =20 + assert(wanted_type =3D=3D QCOW2_CLUSTER_ZERO || + wanted_type =3D=3D QCOW2_CLUSTER_UNALLOCATED); for (i =3D 0; i < nb_clusters; i++) { - int type =3D qcow2_get_cluster_type(be64_to_cpu(l2_table[i])); + uint64_t entry =3D be64_to_cpu(l2_table[i]); + int type =3D qcow2_get_cluster_type(entry); =20 - if (type !=3D wanted_type) { + if (type !=3D wanted_type || entry & L2E_OFFSET_MASK) { break; } } @@ -565,14 +572,32 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, ret =3D -EIO; goto fail; } - c =3D count_contiguous_clusters_by_type(nb_clusters, &l2_table[l2_= index], - QCOW2_CLUSTER_ZERO); - *cluster_offset =3D 0; + /* Distinguish between pure zero clusters and pre-allocated ones */ + if (*cluster_offset & L2E_OFFSET_MASK) { + c =3D count_contiguous_clusters(nb_clusters, s->cluster_size, + &l2_table[l2_index], QCOW_OFLAG_= ZERO); + *cluster_offset &=3D L2E_OFFSET_MASK; + if (offset_into_cluster(s, *cluster_offset)) { + qcow2_signal_corruption(bs, true, -1, -1, + "Preallocated zero cluster offset = %#" + PRIx64 " unaligned (L2 offset: %#" + PRIx64 ", L2 index: %#x)", + *cluster_offset, l2_offset, l2_ind= ex); + ret =3D -EIO; + goto fail; + } + } else { + c =3D count_contiguous_clusters_unallocated(nb_clusters, + &l2_table[l2_index], + QCOW2_CLUSTER_ZERO); + *cluster_offset =3D 0; + } break; case QCOW2_CLUSTER_UNALLOCATED: /* how many empty clusters ? */ - c =3D count_contiguous_clusters_by_type(nb_clusters, &l2_table[l2_= index], - QCOW2_CLUSTER_UNALLOCATED); + c =3D count_contiguous_clusters_unallocated(nb_clusters, + &l2_table[l2_index], + QCOW2_CLUSTER_UNALLOCATE= D); *cluster_offset =3D 0; break; case QCOW2_CLUSTER_NORMAL: --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515665020591.0140769253043; Thu, 11 May 2017 08:14:25 -0700 (PDT) Received: from localhost ([::1]:48750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pnI-0005hS-Gk for importer@patchew.org; Thu, 11 May 2017 11:14:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBE-00036d-4v for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBD-0008LQ-1e for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37385) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pB9-0008Gz-Hi; Thu, 11 May 2017 10:34:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 817AEA090C; Thu, 11 May 2017 14:34:54 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE0EF8A8CF; Thu, 11 May 2017 14:34:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 817AEA090C Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 817AEA090C From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:53 +0200 Message-Id: <1494513181-7900-51-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:34:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 50/58] qcow2: Name typedef for cluster type 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Although it doesn't add all that much type safety (this is C, after all), it does add a bit of legibility to use the name QCow2ClusterType instead of a plain int. In particular, qcow2_get_cluster_offset() has an overloaded return type; a QCow2ClusterType on success, and -errno on failure; keeping the cluster type in a separate variable makes it slightly easier for the next patch to make further computations based on the type. Suggested-by: Max Reitz Signed-off-by: Eric Blake Message-id: 20170507000552.20847-6-eblake@redhat.com [mreitz: Use the new type in two more places (one of them pulled from the next patch)] Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 21 +++++++++++---------- block/qcow2-refcount.c | 2 +- block/qcow2.h | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index f3bfce6..26f9e0e 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -309,7 +309,7 @@ static int count_contiguous_clusters(int nb_clusters, i= nt cluster_size, uint64_t *l2_table, uint64_t stop_flags) { int i; - int first_cluster_type; + QCow2ClusterType first_cluster_type; uint64_t mask =3D stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED; uint64_t first_entry =3D be64_to_cpu(l2_table[0]); uint64_t offset =3D first_entry & mask; @@ -340,7 +340,7 @@ static int count_contiguous_clusters(int nb_clusters, i= nt cluster_size, */ static int count_contiguous_clusters_unallocated(int nb_clusters, uint64_t *l2_table, - int wanted_type) + QCow2ClusterType wanted_t= ype) { int i; =20 @@ -348,7 +348,7 @@ static int count_contiguous_clusters_unallocated(int nb= _clusters, wanted_type =3D=3D QCOW2_CLUSTER_UNALLOCATED); for (i =3D 0; i < nb_clusters; i++) { uint64_t entry =3D be64_to_cpu(l2_table[i]); - int type =3D qcow2_get_cluster_type(entry); + QCow2ClusterType type =3D qcow2_get_cluster_type(entry); =20 if (type !=3D wanted_type || entry & L2E_OFFSET_MASK) { break; @@ -500,6 +500,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, int l1_bits, c; unsigned int offset_in_cluster; uint64_t bytes_available, bytes_needed, nb_clusters; + QCow2ClusterType type; int ret; =20 offset_in_cluster =3D offset_into_cluster(s, offset); @@ -522,13 +523,13 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, =20 l1_index =3D offset >> l1_bits; if (l1_index >=3D s->l1_size) { - ret =3D QCOW2_CLUSTER_UNALLOCATED; + type =3D QCOW2_CLUSTER_UNALLOCATED; goto out; } =20 l2_offset =3D s->l1_table[l1_index] & L1E_OFFSET_MASK; if (!l2_offset) { - ret =3D QCOW2_CLUSTER_UNALLOCATED; + type =3D QCOW2_CLUSTER_UNALLOCATED; goto out; } =20 @@ -557,8 +558,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint= 64_t offset, * true */ assert(nb_clusters <=3D INT_MAX); =20 - ret =3D qcow2_get_cluster_type(*cluster_offset); - switch (ret) { + type =3D qcow2_get_cluster_type(*cluster_offset); + switch (type) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters can only be processed one by one */ c =3D 1; @@ -633,7 +634,7 @@ out: assert(bytes_available - offset_in_cluster <=3D UINT_MAX); *bytes =3D bytes_available - offset_in_cluster; =20 - return ret; + return type; =20 fail: qcow2_cache_put(bs, s->l2_table_cache, (void **)&l2_table); @@ -891,7 +892,7 @@ static int count_cow_clusters(BDRVQcow2State *s, int nb= _clusters, =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t l2_entry =3D be64_to_cpu(l2_table[l2_index + i]); - int cluster_type =3D qcow2_get_cluster_type(l2_entry); + QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_entry); =20 switch(cluster_type) { case QCOW2_CLUSTER_NORMAL: @@ -1757,7 +1758,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, for (j =3D 0; j < s->l2_size; j++) { uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); int64_t offset =3D l2_entry & L2E_OFFSET_MASK; - int cluster_type =3D qcow2_get_cluster_type(l2_entry); + QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_en= try); bool preallocated =3D offset !=3D 0; =20 if (cluster_type !=3D QCOW2_CLUSTER_ZERO) { diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 908dbe5..e639b34 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1640,7 +1640,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, for (j =3D 0; j < s->l2_size; j++) { uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); uint64_t data_offset =3D l2_entry & L2E_OFFSET_MASK; - int cluster_type =3D qcow2_get_cluster_type(l2_entry); + QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_en= try); =20 if ((cluster_type =3D=3D QCOW2_CLUSTER_NORMAL) || ((cluster_type =3D=3D QCOW2_CLUSTER_ZERO) && (data_offset = !=3D 0))) { diff --git a/block/qcow2.h b/block/qcow2.h index 8731f24..c148bbc 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -349,12 +349,12 @@ typedef struct QCowL2Meta QLIST_ENTRY(QCowL2Meta) next_in_flight; } QCowL2Meta; =20 -enum { +typedef enum QCow2ClusterType { QCOW2_CLUSTER_UNALLOCATED, QCOW2_CLUSTER_NORMAL, QCOW2_CLUSTER_COMPRESSED, QCOW2_CLUSTER_ZERO -}; +} QCow2ClusterType; =20 typedef enum QCow2MetadataOverlap { QCOW2_OL_MAIN_HEADER_BITNR =3D 0, @@ -443,7 +443,7 @@ static inline uint64_t qcow2_max_refcount_clusters(BDRV= Qcow2State *s) return QCOW_MAX_REFTABLE_SIZE >> s->cluster_bits; } =20 -static inline int qcow2_get_cluster_type(uint64_t l2_entry) +static inline QCow2ClusterType qcow2_get_cluster_type(uint64_t l2_entry) { if (l2_entry & QCOW_OFLAG_COMPRESSED) { return QCOW2_CLUSTER_COMPRESSED; --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515231772218.2507646580233; Thu, 11 May 2017 08:07:11 -0700 (PDT) Received: from localhost ([::1]:48704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pgJ-00077u-BL for importer@patchew.org; Thu, 11 May 2017 11:07:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBK-0003DS-Ti for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBJ-0008Qt-3H for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5421) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBD-0008Kg-3M; Thu, 11 May 2017 10:34:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DDDE7EAB8; Thu, 11 May 2017 14:34:58 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id C191F88B3C; Thu, 11 May 2017 14:34:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0DDDE7EAB8 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0DDDE7EAB8 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:54 +0200 Message-Id: <1494513181-7900-52-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 14:34:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 51/58] qcow2: Make distinction between zero cluster types obvious 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Treat plain zero clusters differently from allocated ones, so that we can simplify the logic of checking whether an offset is present. Do this by splitting QCOW2_CLUSTER_ZERO into two new enums, QCOW2_CLUSTER_ZERO_PLAIN and QCOW2_CLUSTER_ZERO_ALLOC. I tried to arrange the enum so that we could use 'ret <=3D QCOW2_CLUSTER_ZERO_PLAIN' for all unallocated types, and 'ret >=3D QCOW2_CLUSTER_ZERO_ALLOC' for allocated types, although I didn't actually end up taking advantage of the layout. In many cases, this leads to simpler code, by properly combining cases (sometimes, both zero types pair together, other times, plain zero is more like unallocated while allocated zero is more like normal). Signed-off-by: Eric Blake Message-id: 20170507000552.20847-7-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 79 ++++++++++++++++++------------------------= ---- block/qcow2-refcount.c | 44 +++++++++++--------------- block/qcow2.c | 9 ++++-- block/qcow2.h | 8 +++-- tests/qemu-iotests/060.out | 6 ++-- 5 files changed, 63 insertions(+), 83 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 26f9e0e..558c239 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -321,8 +321,7 @@ static int count_contiguous_clusters(int nb_clusters, i= nt cluster_size, /* must be allocated */ first_cluster_type =3D qcow2_get_cluster_type(first_entry); assert(first_cluster_type =3D=3D QCOW2_CLUSTER_NORMAL || - (first_cluster_type =3D=3D QCOW2_CLUSTER_ZERO && - (first_entry & L2E_OFFSET_MASK) !=3D 0)); + first_cluster_type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC); =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t l2_entry =3D be64_to_cpu(l2_table[i]) & mask; @@ -344,13 +343,13 @@ static int count_contiguous_clusters_unallocated(int = nb_clusters, { int i; =20 - assert(wanted_type =3D=3D QCOW2_CLUSTER_ZERO || + assert(wanted_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || wanted_type =3D=3D QCOW2_CLUSTER_UNALLOCATED); for (i =3D 0; i < nb_clusters; i++) { uint64_t entry =3D be64_to_cpu(l2_table[i]); QCow2ClusterType type =3D qcow2_get_cluster_type(entry); =20 - if (type !=3D wanted_type || entry & L2E_OFFSET_MASK) { + if (type !=3D wanted_type) { break; } } @@ -559,55 +558,36 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, ui= nt64_t offset, assert(nb_clusters <=3D INT_MAX); =20 type =3D qcow2_get_cluster_type(*cluster_offset); + if (s->qcow_version < 3 && (type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || + type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC)) { + qcow2_signal_corruption(bs, true, -1, -1, "Zero cluster entry foun= d" + " in pre-v3 image (L2 offset: %#" PRIx64 + ", L2 index: %#x)", l2_offset, l2_index); + ret =3D -EIO; + goto fail; + } switch (type) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters can only be processed one by one */ c =3D 1; *cluster_offset &=3D L2E_COMPRESSED_OFFSET_SIZE_MASK; break; - case QCOW2_CLUSTER_ZERO: - if (s->qcow_version < 3) { - qcow2_signal_corruption(bs, true, -1, -1, "Zero cluster entry = found" - " in pre-v3 image (L2 offset: %#" PRIx= 64 - ", L2 index: %#x)", l2_offset, l2_inde= x); - ret =3D -EIO; - goto fail; - } - /* Distinguish between pure zero clusters and pre-allocated ones */ - if (*cluster_offset & L2E_OFFSET_MASK) { - c =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], QCOW_OFLAG_= ZERO); - *cluster_offset &=3D L2E_OFFSET_MASK; - if (offset_into_cluster(s, *cluster_offset)) { - qcow2_signal_corruption(bs, true, -1, -1, - "Preallocated zero cluster offset = %#" - PRIx64 " unaligned (L2 offset: %#" - PRIx64 ", L2 index: %#x)", - *cluster_offset, l2_offset, l2_ind= ex); - ret =3D -EIO; - goto fail; - } - } else { - c =3D count_contiguous_clusters_unallocated(nb_clusters, - &l2_table[l2_index], - QCOW2_CLUSTER_ZERO); - *cluster_offset =3D 0; - } - break; + case QCOW2_CLUSTER_ZERO_PLAIN: case QCOW2_CLUSTER_UNALLOCATED: /* how many empty clusters ? */ c =3D count_contiguous_clusters_unallocated(nb_clusters, - &l2_table[l2_index], - QCOW2_CLUSTER_UNALLOCATE= D); + &l2_table[l2_index], typ= e); *cluster_offset =3D 0; break; + case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: /* how many allocated clusters ? */ c =3D count_contiguous_clusters(nb_clusters, s->cluster_size, - &l2_table[l2_index], QCOW_OFLAG_ZERO); + &l2_table[l2_index], QCOW_OFLAG_ZERO= ); *cluster_offset &=3D L2E_OFFSET_MASK; if (offset_into_cluster(s, *cluster_offset)) { - qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset= %#" + qcow2_signal_corruption(bs, true, -1, -1, + "Cluster allocation offset %#" PRIx64 " unaligned (L2 offset: %#" PRI= x64 ", L2 index: %#x)", *cluster_offset, l2_offset, l2_index); @@ -902,7 +882,8 @@ static int count_cow_clusters(BDRVQcow2State *s, int nb= _clusters, break; case QCOW2_CLUSTER_UNALLOCATED: case QCOW2_CLUSTER_COMPRESSED: - case QCOW2_CLUSTER_ZERO: + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_ZERO_ALLOC: break; default: abort(); @@ -1203,8 +1184,8 @@ static int handle_alloc(BlockDriverState *bs, uint64_= t guest_offset, * wrong with our code. */ assert(nb_clusters > 0); =20 - if (qcow2_get_cluster_type(entry) =3D=3D QCOW2_CLUSTER_ZERO && - (entry & L2E_OFFSET_MASK) !=3D 0 && (entry & QCOW_OFLAG_COPIED) && + if (qcow2_get_cluster_type(entry) =3D=3D QCOW2_CLUSTER_ZERO_ALLOC && + (entry & QCOW_OFLAG_COPIED) && (!*host_offset || start_of_cluster(s, *host_offset) =3D=3D (entry & L2E_OFFSET_MASK= ))) { @@ -1536,13 +1517,13 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, } break; =20 - case QCOW2_CLUSTER_ZERO: - /* Preallocated zero clusters should be discarded in any case = */ - if (!full_discard && (old_l2_entry & L2E_OFFSET_MASK) =3D=3D 0= ) { + case QCOW2_CLUSTER_ZERO_PLAIN: + if (!full_discard) { continue; } break; =20 + case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: case QCOW2_CLUSTER_COMPRESSED: break; @@ -1759,13 +1740,13 @@ static int expand_zero_clusters_in_l1(BlockDriverSt= ate *bs, uint64_t *l1_table, uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); int64_t offset =3D l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_en= try); - bool preallocated =3D offset !=3D 0; =20 - if (cluster_type !=3D QCOW2_CLUSTER_ZERO) { + if (cluster_type !=3D QCOW2_CLUSTER_ZERO_PLAIN && + cluster_type !=3D QCOW2_CLUSTER_ZERO_ALLOC) { continue; } =20 - if (!preallocated) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { if (!bs->backing) { /* not backed; therefore we can simply deallocate the * cluster */ @@ -1800,7 +1781,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, "%#" PRIx64 " unaligned (L2 offset= : %#" PRIx64 ", L2 index: %#x)", offset, l2_offset, j); - if (!preallocated) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } @@ -1810,7 +1791,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, =20 ret =3D qcow2_pre_write_overlap_check(bs, 0, offset, s->cluste= r_size); if (ret < 0) { - if (!preallocated) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } @@ -1819,7 +1800,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, =20 ret =3D bdrv_pwrite_zeroes(bs->file, offset, s->cluster_size, = 0); if (ret < 0) { - if (!preallocated) { + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN) { qcow2_free_clusters(bs, offset, s->cluster_size, QCOW2_DISCARD_ALWAYS); } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index e639b34..7c06061 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1028,18 +1028,17 @@ void qcow2_free_any_clusters(BlockDriverState *bs, = uint64_t l2_entry, } break; case QCOW2_CLUSTER_NORMAL: - case QCOW2_CLUSTER_ZERO: - if (l2_entry & L2E_OFFSET_MASK) { - if (offset_into_cluster(s, l2_entry & L2E_OFFSET_MASK)) { - qcow2_signal_corruption(bs, false, -1, -1, - "Cannot free unaligned cluster %#l= lx", - l2_entry & L2E_OFFSET_MASK); - } else { - qcow2_free_clusters(bs, l2_entry & L2E_OFFSET_MASK, - nb_clusters << s->cluster_bits, type); - } + case QCOW2_CLUSTER_ZERO_ALLOC: + if (offset_into_cluster(s, l2_entry & L2E_OFFSET_MASK)) { + qcow2_signal_corruption(bs, false, -1, -1, + "Cannot free unaligned cluster %#llx", + l2_entry & L2E_OFFSET_MASK); + } else { + qcow2_free_clusters(bs, l2_entry & L2E_OFFSET_MASK, + nb_clusters << s->cluster_bits, type); } break; + case QCOW2_CLUSTER_ZERO_PLAIN: case QCOW2_CLUSTER_UNALLOCATED: break; default: @@ -1145,10 +1144,10 @@ int qcow2_update_snapshot_refcount(BlockDriverState= *bs, break; =20 case QCOW2_CLUSTER_NORMAL: - case QCOW2_CLUSTER_ZERO: + case QCOW2_CLUSTER_ZERO_ALLOC: if (offset_into_cluster(s, offset)) { - qcow2_signal_corruption(bs, true, -1, -1, "Data " - "cluster offset %#" PRIx64 + qcow2_signal_corruption(bs, true, -1, -1, "Cluster= " + "allocation offset %#" PRI= x64 " unaligned (L2 offset: %#" PRIx64 ", L2 index: %#x)", offset, l2_offset, j); @@ -1157,11 +1156,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState = *bs, } =20 cluster_index =3D offset >> s->cluster_bits; - if (!cluster_index) { - /* unallocated */ - refcount =3D 0; - break; - } + assert(cluster_index); if (addend !=3D 0) { ret =3D qcow2_update_cluster_refcount(bs, cluster_index, abs(addend), addend < 0, @@ -1177,6 +1172,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, } break; =20 + case QCOW2_CLUSTER_ZERO_PLAIN: case QCOW2_CLUSTER_UNALLOCATED: refcount =3D 0; break; @@ -1443,12 +1439,7 @@ static int check_refcounts_l2(BlockDriverState *bs, = BdrvCheckResult *res, } break; =20 - case QCOW2_CLUSTER_ZERO: - if ((l2_entry & L2E_OFFSET_MASK) =3D=3D 0) { - break; - } - /* fall through */ - + case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: { uint64_t offset =3D l2_entry & L2E_OFFSET_MASK; @@ -1478,6 +1469,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, break; } =20 + case QCOW2_CLUSTER_ZERO_PLAIN: case QCOW2_CLUSTER_UNALLOCATED: break; =20 @@ -1642,8 +1634,8 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, uint64_t data_offset =3D l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(l2_en= try); =20 - if ((cluster_type =3D=3D QCOW2_CLUSTER_NORMAL) || - ((cluster_type =3D=3D QCOW2_CLUSTER_ZERO) && (data_offset = !=3D 0))) { + if (cluster_type =3D=3D QCOW2_CLUSTER_NORMAL || + cluster_type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC) { ret =3D qcow2_get_refcount(bs, data_offset >> s->cluster_bits, &refcount); diff --git a/block/qcow2.c b/block/qcow2.c index 8caf800..3fa62b0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1385,7 +1385,7 @@ static int64_t coroutine_fn qcow2_co_get_block_status= (BlockDriverState *bs, *file =3D bs->file->bs; status |=3D BDRV_BLOCK_OFFSET_VALID | cluster_offset; } - if (ret =3D=3D QCOW2_CLUSTER_ZERO) { + if (ret =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || ret =3D=3D QCOW2_CLUSTER_ZE= RO_ALLOC) { status |=3D BDRV_BLOCK_ZERO; } else if (ret !=3D QCOW2_CLUSTER_UNALLOCATED) { status |=3D BDRV_BLOCK_DATA; @@ -1482,7 +1482,8 @@ static coroutine_fn int qcow2_co_preadv(BlockDriverSt= ate *bs, uint64_t offset, } break; =20 - case QCOW2_CLUSTER_ZERO: + case QCOW2_CLUSTER_ZERO_PLAIN: + case QCOW2_CLUSTER_ZERO_ALLOC: qemu_iovec_memset(&hd_qiov, 0, 0, cur_bytes); break; =20 @@ -2491,7 +2492,9 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockD= riverState *bs, count =3D s->cluster_size; nr =3D s->cluster_size; ret =3D qcow2_get_cluster_offset(bs, offset, &nr, &off); - if (ret !=3D QCOW2_CLUSTER_UNALLOCATED && ret !=3D QCOW2_CLUSTER_Z= ERO) { + if (ret !=3D QCOW2_CLUSTER_UNALLOCATED && + ret !=3D QCOW2_CLUSTER_ZERO_PLAIN && + ret !=3D QCOW2_CLUSTER_ZERO_ALLOC) { qemu_co_mutex_unlock(&s->lock); return -ENOTSUP; } diff --git a/block/qcow2.h b/block/qcow2.h index c148bbc..810ceb8 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -351,9 +351,10 @@ typedef struct QCowL2Meta =20 typedef enum QCow2ClusterType { QCOW2_CLUSTER_UNALLOCATED, + QCOW2_CLUSTER_ZERO_PLAIN, + QCOW2_CLUSTER_ZERO_ALLOC, QCOW2_CLUSTER_NORMAL, QCOW2_CLUSTER_COMPRESSED, - QCOW2_CLUSTER_ZERO } QCow2ClusterType; =20 typedef enum QCow2MetadataOverlap { @@ -448,7 +449,10 @@ static inline QCow2ClusterType qcow2_get_cluster_type(= uint64_t l2_entry) if (l2_entry & QCOW_OFLAG_COMPRESSED) { return QCOW2_CLUSTER_COMPRESSED; } else if (l2_entry & QCOW_OFLAG_ZERO) { - return QCOW2_CLUSTER_ZERO; + if (l2_entry & L2E_OFFSET_MASK) { + return QCOW2_CLUSTER_ZERO_ALLOC; + } + return QCOW2_CLUSTER_ZERO_PLAIN; } else if (!(l2_entry & L2E_OFFSET_MASK)) { return QCOW2_CLUSTER_UNALLOCATED; } else { diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out index 5d40206..9e8f5b9 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -135,7 +135,7 @@ qemu-img: Error while amending options: Input/output er= ror Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qcow2: Marking image as corrupt: Data cluster offset 0x52a00 unaligned (L2= offset: 0x40000, L2 index: 0); further corruption events will be suppressed +qcow2: Marking image as corrupt: Cluster allocation offset 0x52a00 unalign= ed (L2 offset: 0x40000, L2 index: 0); further corruption events will be sup= pressed read failed: Input/output error =20 =3D=3D=3D Testing unaligned pre-allocated zero cluster =3D=3D=3D @@ -166,7 +166,7 @@ discard 65536/65536 bytes at offset 0 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qcow2: Image is corrupt: Data cluster offset 0x52a00 unaligned (L2 offset:= 0x40000, L2 index: 0); further non-fatal corruption events will be suppres= sed +qcow2: Image is corrupt: Cluster allocation offset 0x52a00 unaligned (L2 o= ffset: 0x40000, L2 index: 0); further non-fatal corruption events will be s= uppressed read failed: Input/output error read failed: Input/output error =20 @@ -176,7 +176,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D671= 08864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) qcow2: Image is corrupt: Cannot free unaligned cluster 0x52a00; further no= n-fatal corruption events will be suppressed -qcow2: Marking image as corrupt: Data cluster offset 0x62a00 unaligned (L2= offset: 0x40000, L2 index: 0x1); further corruption events will be suppres= sed +qcow2: Marking image as corrupt: Cluster allocation offset 0x62a00 unalign= ed (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be s= uppressed discard 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read failed: Input/output error --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515895247443.51841545738966; Thu, 11 May 2017 08:18:15 -0700 (PDT) Received: from localhost ([::1]:48778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pr2-0000i1-Nb for importer@patchew.org; Thu, 11 May 2017 11:18:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBP-0003Kt-ID for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBL-0008TJ-Dn for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38452) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBE-0008Lo-MB; Thu, 11 May 2017 10:35:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D3F77AE85; Thu, 11 May 2017 14:34:59 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DC8C88B24; Thu, 11 May 2017 14:34:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8D3F77AE85 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8D3F77AE85 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:55 +0200 Message-Id: <1494513181-7900-53-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 11 May 2017 14:34:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 52/58] qcow2: Optimize zero_single_l2() to minimize L2 churn 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Similar to discard_single_l2(), we should try to avoid dirtying the L2 cache when the cluster we are changing already has the right characteristics. Note that by the time we get to zero_single_l2(), BDRV_REQ_MAY_UNMAP is a requirement to unallocate a cluster (this is because the block layer clears that flag if discard.* flags during open requested that we never punch holes - see the conversation around commit 170f4b2e, https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg07306.html). Therefore, this patch can only reuse a zero cluster as-is if either unmapping is not requested, or if the zero cluster was not associated with an allocation. Technically, there are some cases where an unallocated cluster already reads as all zeroes (namely, when there is no backing file [easy: check bs->backing], or when the backing file also reads as zeroes [harder: we can't check bdrv_get_block_status since we are already holding the lock]), where the guest would not immediately see a difference if we left that cluster unallocated. But if the user did not request unmapping, leaving an unallocated cluster is wrong; and even if the user DID request unmapping, keeping a cluster unallocated risks a subtle semantic change of guest-visible contents if a backing file is later added, and it is not worth auditing whether all internal uses such as mirror properly avoid an unmap request. Thus, this patch is intentionally limited to just clusters that are already marked as zero. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-8-eblake@redhat.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 558c239..e2c5759 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1601,6 +1601,7 @@ static int zero_single_l2(BlockDriverState *bs, uint6= 4_t offset, int l2_index; int ret; int i; + bool unmap =3D !!(flags & BDRV_REQ_MAY_UNMAP); =20 ret =3D get_cluster_table(bs, offset, &l2_table, &l2_index); if (ret < 0) { @@ -1613,12 +1614,22 @@ static int zero_single_l2(BlockDriverState *bs, uin= t64_t offset, =20 for (i =3D 0; i < nb_clusters; i++) { uint64_t old_offset; + QCow2ClusterType cluster_type; =20 old_offset =3D be64_to_cpu(l2_table[l2_index + i]); =20 - /* Update L2 entries */ + /* + * Minimize L2 changes if the cluster already reads back as + * zeroes with correct allocation. + */ + cluster_type =3D qcow2_get_cluster_type(old_offset); + if (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || + (cluster_type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC && !unmap)) { + continue; + } + qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); - if (old_offset & QCOW_OFLAG_COMPRESSED || flags & BDRV_REQ_MAY_UNM= AP) { + if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { l2_table[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); } else { --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515380764686.6977617202602; Thu, 11 May 2017 08:09:40 -0700 (PDT) Received: from localhost ([::1]:48716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pih-0000wW-0r for importer@patchew.org; Thu, 11 May 2017 11:09:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBO-0003IX-4g for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBM-0008VH-EK for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41956) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBH-0008Ov-P1; Thu, 11 May 2017 10:35:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8035448D79; Thu, 11 May 2017 14:35:02 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCA0888B24; Thu, 11 May 2017 14:34:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A8035448D79 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A8035448D79 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:56 +0200 Message-Id: <1494513181-7900-54-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 11 May 2017 14:35:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 53/58] iotests: Improve _filter_qemu_img_map 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Although _filter_qemu_img_map documents that it scrubs offsets, it was only doing so for human mode. Of the existing tests using the filter (97, 122, 150, 154, 176), two of them are affected, but it does not hurt the validity of the tests to not require particular mappings (another test, 66, uses offsets but intentionally does not pass through _filter_qemu_img_map, because it checks that offsets are unchanged before and after an operation). Another justification for this patch is that it will allow a future patch to utilize 'qemu-img map --output=3Djson' to check the status of preallocated zero clusters without regards to the mapping (since the qcow2 mapping can be very sensitive to the chosen cluster size, when preallocation is not in use). Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-9-eblake@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/122.out | 16 ++++++++-------- tests/qemu-iotests/154.out | 30 +++++++++++++++--------------- tests/qemu-iotests/common.filter | 4 +++- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out index 9317d80..47d8656 100644 --- a/tests/qemu-iotests/122.out +++ b/tests/qemu-iotests/122.out @@ -112,7 +112,7 @@ read 3145728/3145728 bytes at offset 0 3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 63963136/63963136 bytes at offset 3145728 61 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true= , "offset": 327680}] +[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true= , "offset": OFFSET}] =20 convert -c -S 0: read 3145728/3145728 bytes at offset 0 @@ -134,7 +134,7 @@ read 30408704/30408704 bytes at offset 3145728 29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 33554432/33554432 bytes at offset 33554432 32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true= , "offset": 327680}] +[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true= , "offset": OFFSET}] =20 convert -c -S 0 with source backing file: read 3145728/3145728 bytes at offset 0 @@ -152,7 +152,7 @@ read 30408704/30408704 bytes at offset 3145728 29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 33554432/33554432 bytes at offset 33554432 32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true= , "offset": 327680}] +[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true= , "offset": OFFSET}] =20 convert -c -S 0 -B ... read 3145728/3145728 bytes at offset 0 @@ -176,11 +176,11 @@ wrote 1024/1024 bytes at offset 17408 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 convert -S 4k -[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true, "o= ffset": 8192}, +[{ "start": 0, "length": 1024, "depth": 0, "zero": false, "data": true, "o= ffset": OFFSET}, { "start": 1024, "length": 7168, "depth": 0, "zero": true, "data": false}, -{ "start": 8192, "length": 1024, "depth": 0, "zero": false, "data": true, = "offset": 9216}, +{ "start": 8192, "length": 1024, "depth": 0, "zero": false, "data": true, = "offset": OFFSET}, { "start": 9216, "length": 8192, "depth": 0, "zero": true, "data": false}, -{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true,= "offset": 10240}, +{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 18432, "length": 67090432, "depth": 0, "zero": true, "data": fa= lse}] =20 convert -c -S 4k @@ -192,9 +192,9 @@ convert -c -S 4k { "start": 18432, "length": 67090432, "depth": 0, "zero": true, "data": fa= lse}] =20 convert -S 8k -[{ "start": 0, "length": 9216, "depth": 0, "zero": false, "data": true, "o= ffset": 8192}, +[{ "start": 0, "length": 9216, "depth": 0, "zero": false, "data": true, "o= ffset": OFFSET}, { "start": 9216, "length": 8192, "depth": 0, "zero": true, "data": false}, -{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true,= "offset": 17408}, +{ "start": 17408, "length": 1024, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 18432, "length": 67090432, "depth": 0, "zero": true, "data": fa= lse}] =20 convert -c -S 8k diff --git a/tests/qemu-iotests/154.out b/tests/qemu-iotests/154.out index da9eabd..d3b68e7 100644 --- a/tests/qemu-iotests/154.out +++ b/tests/qemu-iotests/154.out @@ -42,9 +42,9 @@ read 1024/1024 bytes at offset 65536 read 2048/2048 bytes at offset 67584 2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [{ "start": 0, "length": 32768, "depth": 1, "zero": true, "data": false}, -{ "start": 32768, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 20480}, +{ "start": 32768, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 36864, "length": 28672, "depth": 1, "zero": true, "data": false= }, -{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 24576}, +{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 69632, "length": 134148096, "depth": 1, "zero": true, "data": f= alse}] =20 =3D=3D backing file contains non-zero data after write_zeroes =3D=3D @@ -69,9 +69,9 @@ read 1024/1024 bytes at offset 44032 read 3072/3072 bytes at offset 40960 3 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [{ "start": 0, "length": 32768, "depth": 1, "zero": true, "data": false}, -{ "start": 32768, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 20480}, +{ "start": 32768, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 36864, "length": 4096, "depth": 1, "zero": true, "data": false}, -{ "start": 40960, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 24576}, +{ "start": 40960, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 45056, "length": 134172672, "depth": 1, "zero": true, "data": f= alse}] =20 =3D=3D write_zeroes covers non-zero data =3D=3D @@ -143,13 +143,13 @@ read 1024/1024 bytes at offset 67584 read 5120/5120 bytes at offset 68608 5 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [{ "start": 0, "length": 32768, "depth": 1, "zero": true, "data": false}, -{ "start": 32768, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 20480}, +{ "start": 32768, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 36864, "length": 4096, "depth": 0, "zero": true, "data": false}, { "start": 40960, "length": 8192, "depth": 1, "zero": true, "data": false}, -{ "start": 49152, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 24576}, +{ "start": 49152, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 53248, "length": 4096, "depth": 0, "zero": true, "data": false}, { "start": 57344, "length": 8192, "depth": 1, "zero": true, "data": false}, -{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 28672}, +{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 69632, "length": 4096, "depth": 0, "zero": true, "data": false}, { "start": 73728, "length": 134144000, "depth": 1, "zero": true, "data": f= alse}] =20 @@ -186,13 +186,13 @@ read 1024/1024 bytes at offset 72704 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [{ "start": 0, "length": 32768, "depth": 1, "zero": true, "data": false}, { "start": 32768, "length": 4096, "depth": 0, "zero": true, "data": false}, -{ "start": 36864, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 20480}, +{ "start": 36864, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 40960, "length": 8192, "depth": 1, "zero": true, "data": false}, { "start": 49152, "length": 4096, "depth": 0, "zero": true, "data": false}, -{ "start": 53248, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 24576}, +{ "start": 53248, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 57344, "length": 8192, "depth": 1, "zero": true, "data": false}, { "start": 65536, "length": 4096, "depth": 0, "zero": true, "data": false}, -{ "start": 69632, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 28672}, +{ "start": 69632, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 73728, "length": 134144000, "depth": 1, "zero": true, "data": f= alse}] =20 =3D=3D spanning two clusters, partially overwriting backing file =3D=3D @@ -212,7 +212,7 @@ read 1024/1024 bytes at offset 5120 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 2048/2048 bytes at offset 6144 2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -[{ "start": 0, "length": 8192, "depth": 0, "zero": false, "data": true, "o= ffset": 20480}, +[{ "start": 0, "length": 8192, "depth": 0, "zero": false, "data": true, "o= ffset": OFFSET}, { "start": 8192, "length": 134209536, "depth": 1, "zero": true, "data": fa= lse}] =20 =3D=3D spanning multiple clusters, non-zero in first cluster =3D=3D @@ -227,7 +227,7 @@ read 2048/2048 bytes at offset 65536 read 10240/10240 bytes at offset 67584 10 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [{ "start": 0, "length": 65536, "depth": 1, "zero": true, "data": false}, -{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 20480}, +{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 69632, "length": 8192, "depth": 0, "zero": true, "data": false}, { "start": 77824, "length": 134139904, "depth": 1, "zero": true, "data": f= alse}] =20 @@ -257,7 +257,7 @@ read 2048/2048 bytes at offset 75776 2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [{ "start": 0, "length": 65536, "depth": 1, "zero": true, "data": false}, { "start": 65536, "length": 8192, "depth": 0, "zero": true, "data": false}, -{ "start": 73728, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 20480}, +{ "start": 73728, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 77824, "length": 134139904, "depth": 1, "zero": true, "data": f= alse}] =20 =3D=3D spanning multiple clusters, partially overwriting backing file =3D= =3D @@ -278,8 +278,8 @@ read 2048/2048 bytes at offset 74752 read 1024/1024 bytes at offset 76800 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [{ "start": 0, "length": 65536, "depth": 1, "zero": true, "data": false}, -{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 20480}, +{ "start": 65536, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 69632, "length": 4096, "depth": 0, "zero": true, "data": false}, -{ "start": 73728, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": 24576}, +{ "start": 73728, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 77824, "length": 134139904, "depth": 1, "zero": true, "data": f= alse}] *** done diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index f58548d..2f595b2 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -152,10 +152,12 @@ _filter_img_info() -e "/log_size: [0-9]\\+/d" } =20 -# filter out offsets and file names from qemu-img map +# filter out offsets and file names from qemu-img map; good for both +# human and json output _filter_qemu_img_map() { sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \ + -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \ -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt } =20 --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515408338286.22658350630786; Thu, 11 May 2017 08:10:08 -0700 (PDT) Received: from localhost ([::1]:48718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pjA-0001XT-RD for importer@patchew.org; Thu, 11 May 2017 11:10:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBV-0003RZ-A1 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBS-0000FG-Te for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54560) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBN-0008VL-2w; Thu, 11 May 2017 10:35:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0338FC05973F; Thu, 11 May 2017 14:35:08 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id E67A68A8E4; Thu, 11 May 2017 14:35:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0338FC05973F Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0338FC05973F From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:57 +0200 Message-Id: <1494513181-7900-55-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 11 May 2017 14:35:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 54/58] iotests: Add test 179 to cover write zeroes with unmap 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake No tests were covering write zeroes with unmap. Additionally, I needed to prove that my previous patches for correct status reporting and write zeroes optimizations actually had an impact. The test works for cluster_size between 8k and 2M (for smaller sizes, it fails because our allocation patterns are not contiguous with small clusters - in part, the largest consecutive allocation we tend to get is often bounded by the size covered by one L2 table). Note that testing for zero clusters is tricky: 'qemu-io map' reports whether data comes from the current layer of the image (useful for sniffing out which regions of the file have QCOW_OFLAG_ZERO) - but doesn't show which clusters have mappings; while 'qemu-img map' sees "zero":true for both unallocated and zero clusters for any qcow2 with no backing layer (so less useful at detecting true zero clusters), but reliably shows mappings. So we have to rely on both queries side-by-side at each point of the test. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-10-eblake@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/179 | 130 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/179.out | 156 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/group | 1 + 3 files changed, 287 insertions(+) create mode 100755 tests/qemu-iotests/179 create mode 100644 tests/qemu-iotests/179.out diff --git a/tests/qemu-iotests/179 b/tests/qemu-iotests/179 new file mode 100755 index 0000000..7bc8db8 --- /dev/null +++ b/tests/qemu-iotests/179 @@ -0,0 +1,130 @@ +#!/bin/bash +# +# Test case for write zeroes with unmap +# +# Copyright (C) 2017 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=3Deblake@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 +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +# v2 images can't mark clusters as zero +_unsupported_imgopts compat=3D0.10 + +echo +echo '=3D=3D=3D Testing write zeroes with unmap =3D=3D=3D' +echo + +TEST_IMG=3D"$TEST_IMG.base" _make_test_img 64M +_make_test_img -b "$TEST_IMG.base" + +# Offsets chosen at or near 2M boundaries so test works at all cluster siz= es +# 8k and larger (smaller clusters fail due to non-contiguous allocations) + +# Aligned writes to unallocated cluster should not allocate mapping, but m= ust +# mark cluster as zero, whether or not unmap was requested +$QEMU_IO -c "write -z -u 2M 2M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z 6M 2M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "map" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG.base" | _filter_qemu_img_map + +# Unaligned writes need not allocate mapping if the cluster already reads +# as zero, but must mark cluster as zero, whether or not unmap was request= ed +$QEMU_IO -c "write -z -u 10485761 2097150" "$TEST_IMG.base" | _filter_qemu= _io +$QEMU_IO -c "write -z 14680065 2097150" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "map" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG.base" | _filter_qemu_img_map + +# Requesting unmap of normal data must deallocate; omitting unmap should +# preserve the mapping +$QEMU_IO -c "write 18M 14M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z -u 20M 2M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z 24M 6M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "map" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG.base" | _filter_qemu_img_map + +# Likewise when writing on already-mapped zero data +$QEMU_IO -c "write -z -u 26M 2M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z 28M 2M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "map" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG.base" | _filter_qemu_img_map + +# Writing on unmapped zeroes does not allocate +$QEMU_IO -c "write -z 32M 8M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z -u 34M 2M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z 36M 2M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "map" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG.base" | _filter_qemu_img_map + +# Writing zero overrides a backing file, regardless of backing cluster type +$QEMU_IO -c "write -z 40M 8M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write 48M 8M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z -u 42M 2M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 44M 2M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z -u 50M 2M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 52M 2M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z -u 58M 2M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z 60M 2M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "map" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Final check that mappings are correct and images are still sane +TEST_IMG=3D"$TEST_IMG.base" _check_test_img +_check_test_img + +echo +echo '=3D=3D=3D Testing cache optimization =3D=3D=3D' +echo + +BLKDBG_TEST_IMG=3D"blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG.base" + +cat > "$TEST_DIR/blkdebug.conf" < Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14945155503179.70079058817339; Thu, 11 May 2017 08:12:30 -0700 (PDT) Received: from localhost ([::1]:48737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8plR-0003gQ-Ik for importer@patchew.org; Thu, 11 May 2017 11:12:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBf-0003ar-MK for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBd-0000O0-1E for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBQ-0000A7-MP; Thu, 11 May 2017 10:35:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7F9E7704; Thu, 11 May 2017 14:35:11 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 413F88A8CD; Thu, 11 May 2017 14:35:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7F9E7704 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A7F9E7704 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:58 +0200 Message-Id: <1494513181-7900-56-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 May 2017 14:35:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 55/58] qcow2: Optimize write zero of unaligned tail cluster 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake We've already improved discards to operate efficiently on the tail of an unaligned qcow2 image; it's time to make a similar improvement to write zeroes. The special case is only valid at the tail cluster of a file, where we must recognize that any sectors beyond the image end would implicitly read as zero, and therefore should not penalize our logic for widening a partial cluster into writing the whole cluster as zero. However, note that for now, the special case of end-of-file is only recognized if there is no backing file, or if the backing file has the same length; that's because when the backing file is shorter than the active layer, we don't have code in place to recognize that reads of a sector unallocated at the top and beyond the backing end-of-file are implicitly zero. It's not much of a real loss, because most people don't use images that aren't cluster-aligned, or where the active layer is a different size than the backing layer (especially where the difference falls within a single cluster). Update test 154 to cover the new scenarios, using two images of intentionally differing length. While at it, fix the test to gracefully skip when run as ./check -qcow2 -o compat=3D0.10 154 since the older format lacks zero clusters already required earlier in the test. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-11-eblake@redhat.com Signed-off-by: Max Reitz --- block/qcow2.c | 7 ++ tests/qemu-iotests/154 | 160 +++++++++++++++++++++++++++++++++++++++++= +++- tests/qemu-iotests/154.out | 128 ++++++++++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 3fa62b0..72b1650 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2451,6 +2451,10 @@ static bool is_zero_sectors(BlockDriverState *bs, in= t64_t start, BlockDriverState *file; int64_t res; =20 + if (start + count > bs->total_sectors) { + count =3D bs->total_sectors - start; + } + if (!count) { return true; } @@ -2469,6 +2473,9 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockD= riverState *bs, uint32_t tail =3D (offset + count) % s->cluster_size; =20 trace_qcow2_pwrite_zeroes_start_req(qemu_coroutine_self(), offset, cou= nt); + if (offset + count =3D=3D bs->total_sectors * BDRV_SECTOR_SIZE) { + tail =3D 0; + } =20 if (head || tail) { int64_t cl_start =3D (offset - head) >> BDRV_SECTOR_BITS; diff --git a/tests/qemu-iotests/154 b/tests/qemu-iotests/154 index 7ca7219..dd8a426 100755 --- a/tests/qemu-iotests/154 +++ b/tests/qemu-iotests/154 @@ -2,7 +2,7 @@ # # qcow2 specific bdrv_pwrite_zeroes tests with backing files (complements = 034) # -# Copyright (C) 2016 Red Hat, Inc. +# Copyright (C) 2016-2017 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 @@ -42,7 +42,10 @@ _supported_proto file _supported_os Linux =20 CLUSTER_SIZE=3D4k -size=3D128M +size=3D$((128 * 1024 * 1024)) + +# This test requires zero clusters, added in v3 images +_unsupported_imgopts compat=3D0.10 =20 echo echo =3D=3D backing file contains zeros =3D=3D @@ -299,6 +302,159 @@ $QEMU_IO -c "read -P 0 75k 1k" "$TEST_IMG" | _filter_= qemu_io =20 $QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map =20 +echo +echo =3D=3D unaligned image tail cluster, no allocation needed =3D=3D + +# With no backing file, write to all or part of unallocated partial cluster +# will mark the cluster as zero, but does not allocate. +# Re-create the image each time to get back to unallocated clusters. + +# Write at the front: sector-wise, the request is: 128m... | 00 -- -- -- +_make_test_img $((size + 2048)) +$QEMU_IO -c "write -z $size 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write at the back: sector-wise, the request is: 128m... | -- -- -- 00 +_make_test_img $((size + 2048)) +$QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write at middle: sector-wise, the request is: 128m... | -- 00 00 -- +_make_test_img $((size + 2048)) +$QEMU_IO -c "write -z $((size + 512)) 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write entire cluster: sector-wise, the request is: 128m... | 00 00 00 00 +_make_test_img $((size + 2048)) +$QEMU_IO -c "write -z $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Repeat with backing file holding unallocated cluster. +# TODO: Note that this forces an allocation, because we aren't yet able to +# quickly detect that reads beyond EOF of the backing file are always zero +CLUSTER_SIZE=3D2048 TEST_IMG=3D"$TEST_IMG.base" _make_test_img $((size + 1= 024)) + +# Write at the front: sector-wise, the request is: +# backing: 128m... | -- -- +# active: 128m... | 00 -- -- -- +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $size 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write at the back: sector-wise, the request is: +# backing: 128m... | -- -- +# active: 128m... | -- -- -- 00 +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write at middle: sector-wise, the request is: +# backing: 128m... | -- -- +# active: 128m... | -- 00 00 -- +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $((size + 512)) 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write entire cluster: sector-wise, the request is: +# backing: 128m... | -- -- +# active: 128m... | 00 00 00 00 +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Repeat with backing file holding zero'd cluster +# TODO: Note that this forces an allocation, because we aren't yet able to +# quickly detect that reads beyond EOF of the backing file are always zero +$QEMU_IO -c "write -z $size 512" "$TEST_IMG.base" | _filter_qemu_io + +# Write at the front: sector-wise, the request is: +# backing: 128m... | 00 00 +# active: 128m... | 00 -- -- -- +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $size 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write at the back: sector-wise, the request is: +# backing: 128m... | 00 00 +# active: 128m... | -- -- -- 00 +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write at middle: sector-wise, the request is: +# backing: 128m... | 00 00 +# active: 128m... | -- 00 00 -- +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $((size + 512)) 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Write entire cluster: sector-wise, the request is: +# backing: 128m... | 00 00 +# active: 128m... | 00 00 00 00 +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -z $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 2048" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# A preallocated cluster maintains its allocation, whether it stays as +# data due to a partial write: +# Convert 128m... | XX XX =3D> ... | XX 00 +_make_test_img $((size + 1024)) +$QEMU_IO -c "write -P 1 $((size)) 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 1 $((size)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# or because it is the entire cluster and can use the zero flag: +# Convert 128m... | XX XX =3D> ... | 00 00 +$QEMU_IO -c "write -z $((size)) 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc $size 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 $size 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +echo +echo =3D=3D unaligned image tail cluster, allocation required =3D=3D + +# Write beyond backing file must COW +# Backing file: 128m... | XX -- +# Active layer: 128m... | -- -- 00 -- +CLUSTER_SIZE=3D512 TEST_IMG=3D"$TEST_IMG.base" _make_test_img $((size + 10= 24)) +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -P 1 $((size)) 512" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z $((size + 1024)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 1 $((size)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 $((size + 512)) 1536" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# Writes at boundaries of (partial) cluster must not lose mid-cluster data +# Backing file: 128m: ... | -- XX +# Active layer: 128m: ... | 00 -- -- 00 +CLUSTER_SIZE=3D512 TEST_IMG=3D"$TEST_IMG.base" _make_test_img $((size + 10= 24)) +_make_test_img -b "$TEST_IMG.base" $((size + 2048)) +$QEMU_IO -c "write -P 1 $((size + 512)) 512" "$TEST_IMG.base" | _filter_qe= mu_io +$QEMU_IO -c "write -z $((size)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 $((size)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 1 $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 $((size + 1024)) 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -z $((size + 1536)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 $((size)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 1 $((size + 512)) 512" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "read -P 0 $((size + 1024)) 1024" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/154.out b/tests/qemu-iotests/154.out index d3b68e7..d8485ee 100644 --- a/tests/qemu-iotests/154.out +++ b/tests/qemu-iotests/154.out @@ -282,4 +282,132 @@ read 1024/1024 bytes at offset 76800 { "start": 69632, "length": 4096, "depth": 0, "zero": true, "data": false}, { "start": 73728, "length": 4096, "depth": 0, "zero": false, "data": true,= "offset": OFFSET}, { "start": 77824, "length": 134139904, "depth": 1, "zero": true, "data": f= alse}] + +=3D=3D unaligned image tail cluster, no allocation needed =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 +wrote 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134219776, "depth": 0, "zero": true, "data": fals= e}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 +wrote 512/512 bytes at offset 134219264 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134219776, "depth": 0, "zero": true, "data": fals= e}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 +wrote 1024/1024 bytes at offset 134218240 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134219776, "depth": 0, "zero": true, "data": fals= e}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 +wrote 2048/2048 bytes at offset 134217728 +2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134219776, "depth": 0, "zero": true, "data": fals= e}] +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134218752 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 512/512 bytes at offset 134219264 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 1024/1024 bytes at offset 134218240 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 2048/2048 bytes at offset 134217728 +2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": true, "data": fa= lse}] +wrote 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 512/512 bytes at offset 134219264 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 1024/1024 bytes at offset 134218240 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 2048/2048 bytes at offset 134217728 +2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": true, "data": fa= lse}] +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134218752 +wrote 1024/1024 bytes at offset 134217728 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 134218240 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 134218240 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +1024/1024 bytes allocated at offset 128 MiB +[{ "start": 0, "length": 134217728, "depth": 0, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 1024, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +wrote 1024/1024 bytes at offset 134217728 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +1024/1024 bytes allocated at offset 128 MiB +read 1024/1024 bytes at offset 134217728 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +[{ "start": 0, "length": 134217728, "depth": 0, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 1024, "depth": 0, "zero": true, "data": fa= lse, "offset": OFFSET}] + +=3D=3D unaligned image tail cluster, allocation required =3D=3D +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134218752 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 134218752 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 1536/1536 bytes at offset 134218240 +1.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134218752 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134219776 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 512/512 bytes at offset 134218240 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 134218240 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 1024/1024 bytes at offset 134218752 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 134219264 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 134217728 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 134218240 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 1024/1024 bytes at offset 134218752 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +[{ "start": 0, "length": 134217728, "depth": 1, "zero": true, "data": fals= e}, +{ "start": 134217728, "length": 2048, "depth": 0, "zero": false, "data": t= rue, "offset": OFFSET}] *** done --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515152071424.7474766455084; Thu, 11 May 2017 08:05:52 -0700 (PDT) Received: from localhost ([::1]:48700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pf1-0005tr-Nf for importer@patchew.org; Thu, 11 May 2017 11:05:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBX-0003Sy-3V for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBW-0000K7-6i for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56484) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBT-0000FK-Hg; Thu, 11 May 2017 10:35:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 747A69D414; Thu, 11 May 2017 14:35:14 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id E819888B24; Thu, 11 May 2017 14:35:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 747A69D414 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 747A69D414 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:32:59 +0200 Message-Id: <1494513181-7900-57-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 14:35:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 56/58] qcow2: Assert that cluster operations are aligned 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake We already audited (in commit 0c1bd469) that qcow2_discard_clusters() is only passed cluster-aligned start values; but we can further tighten the assertion that the only unaligned end value is at EOF. Recent commits have taken advantage of an unaligned tail cluster, for both discard and write zeroes. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-12-eblake@redhat.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index e2c5759..43bde56 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1559,11 +1559,10 @@ int qcow2_discard_clusters(BlockDriverState *bs, ui= nt64_t offset, =20 end_offset =3D offset + (nb_sectors << BDRV_SECTOR_BITS); =20 - /* The caller must cluster-align start; round end down except at EOF */ + /* Caller must pass aligned values, except at image end */ assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); - if (end_offset !=3D bs->total_sectors * BDRV_SECTOR_SIZE) { - end_offset =3D start_of_cluster(s, end_offset); - } + assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || + end_offset =3D=3D bs->total_sectors << BDRV_SECTOR_BITS); =20 nb_clusters =3D size_to_clusters(s, end_offset - offset); =20 @@ -1646,9 +1645,17 @@ int qcow2_zero_clusters(BlockDriverState *bs, uint64= _t offset, int nb_sectors, int flags) { BDRVQcow2State *s =3D bs->opaque; + uint64_t end_offset; uint64_t nb_clusters; int ret; =20 + end_offset =3D offset + (nb_sectors << BDRV_SECTOR_BITS); + + /* Caller must pass aligned values, except at image end */ + assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); + assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || + end_offset =3D=3D bs->total_sectors << BDRV_SECTOR_BITS); + /* The zero flag is only supported by version 3 and newer */ if (s->qcow_version < 3) { return -ENOTSUP; --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494516058892175.25728698166563; Thu, 11 May 2017 08:20:58 -0700 (PDT) Received: from localhost ([::1]:48796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pth-00038y-Ad for importer@patchew.org; Thu, 11 May 2017 11:20:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBe-0003Zh-D1 for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBd-0000Nv-0K for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBV-0000Hi-2a; Thu, 11 May 2017 10:35:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D22583D94F; Thu, 11 May 2017 14:35:15 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA6458A8CD; Thu, 11 May 2017 14:35:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D22583D94F Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D22583D94F From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:33:00 +0200 Message-Id: <1494513181-7900-58-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 11 May 2017 14:35:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 57/58] qcow2: Discard/zero clusters by byte count 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Eric Blake Passing a byte offset, but sector count, when we ultimately want to operate on cluster granularity, is madness. Clean up the external interfaces to take both offset and count as bytes, while still keeping the assertion added previously that the caller must align the values to a cluster. Then rename things to make sure backports don't get confused by changed units: instead of qcow2_discard_clusters() and qcow2_zero_clusters(), we now have qcow2_cluster_discard() and qcow2_cluster_zeroize(). The internal functions still operate on clusters at a time, and return an int for number of cleared clusters; but on an image with 2M clusters, a single L2 table holds 256k entries that each represent a 2M cluster, totalling well over INT_MAX bytes if we ever had a request for that many bytes at once. All our callers currently limit themselves to 32-bit bytes (and therefore fewer clusters), but by making this function 64-bit clean, we have one less place to clean up if we later improve the block layer to support 64-bit bytes through all operations (with the block layer auto-fragmenting on behalf of more-limited drivers), rather than the current state where some interfaces are artificially limited to INT_MAX at a time. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170507000552.20847-13-eblake@redhat.com Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 42 ++++++++++++++++++++++-------------------- block/qcow2-snapshot.c | 7 +++---- block/qcow2.c | 22 +++++++++------------- block/qcow2.h | 9 +++++---- 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 43bde56..347d94b 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1549,34 +1549,36 @@ static int discard_single_l2(BlockDriverState *bs, = uint64_t offset, return nb_clusters; } =20 -int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, - int nb_sectors, enum qcow2_discard_type type, bool full_discard) +int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, + uint64_t bytes, enum qcow2_discard_type type, + bool full_discard) { BDRVQcow2State *s =3D bs->opaque; - uint64_t end_offset; + uint64_t end_offset =3D offset + bytes; uint64_t nb_clusters; + int64_t cleared; int ret; =20 - end_offset =3D offset + (nb_sectors << BDRV_SECTOR_BITS); - /* Caller must pass aligned values, except at image end */ assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || end_offset =3D=3D bs->total_sectors << BDRV_SECTOR_BITS); =20 - nb_clusters =3D size_to_clusters(s, end_offset - offset); + nb_clusters =3D size_to_clusters(s, bytes); =20 s->cache_discards =3D true; =20 /* Each L2 table is handled by its own loop iteration */ while (nb_clusters > 0) { - ret =3D discard_single_l2(bs, offset, nb_clusters, type, full_disc= ard); - if (ret < 0) { + cleared =3D discard_single_l2(bs, offset, nb_clusters, type, + full_discard); + if (cleared < 0) { + ret =3D cleared; goto fail; } =20 - nb_clusters -=3D ret; - offset +=3D (ret * s->cluster_size); + nb_clusters -=3D cleared; + offset +=3D (cleared * s->cluster_size); } =20 ret =3D 0; @@ -1641,16 +1643,15 @@ static int zero_single_l2(BlockDriverState *bs, uin= t64_t offset, return nb_clusters; } =20 -int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sect= ors, - int flags) +int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset, + uint64_t bytes, int flags) { BDRVQcow2State *s =3D bs->opaque; - uint64_t end_offset; + uint64_t end_offset =3D offset + bytes; uint64_t nb_clusters; + int64_t cleared; int ret; =20 - end_offset =3D offset + (nb_sectors << BDRV_SECTOR_BITS); - /* Caller must pass aligned values, except at image end */ assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || @@ -1662,18 +1663,19 @@ int qcow2_zero_clusters(BlockDriverState *bs, uint6= 4_t offset, int nb_sectors, } =20 /* Each L2 table is handled by its own loop iteration */ - nb_clusters =3D size_to_clusters(s, nb_sectors << BDRV_SECTOR_BITS); + nb_clusters =3D size_to_clusters(s, bytes); =20 s->cache_discards =3D true; =20 while (nb_clusters > 0) { - ret =3D zero_single_l2(bs, offset, nb_clusters, flags); - if (ret < 0) { + cleared =3D zero_single_l2(bs, offset, nb_clusters, flags); + if (cleared < 0) { + ret =3D cleared; goto fail; } =20 - nb_clusters -=3D ret; - offset +=3D (ret * s->cluster_size); + nb_clusters -=3D cleared; + offset +=3D (cleared * s->cluster_size); } =20 ret =3D 0; diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 0324243..44243e0 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -440,10 +440,9 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSn= apshotInfo *sn_info) =20 /* The VM state isn't needed any more in the active L1 table; in fact,= it * hurts by causing expensive COW for the next snapshot. */ - qcow2_discard_clusters(bs, qcow2_vm_state_offset(s), - align_offset(sn->vm_state_size, s->cluster_size) - >> BDRV_SECTOR_BITS, - QCOW2_DISCARD_NEVER, false); + qcow2_cluster_discard(bs, qcow2_vm_state_offset(s), + align_offset(sn->vm_state_size, s->cluster_size), + QCOW2_DISCARD_NEVER, false); =20 #ifdef DEBUG_ALLOC { diff --git a/block/qcow2.c b/block/qcow2.c index 72b1650..a8d61f0 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2512,7 +2512,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockD= riverState *bs, trace_qcow2_pwrite_zeroes(qemu_coroutine_self(), offset, count); =20 /* Whatever is left can use real zero clusters */ - ret =3D qcow2_zero_clusters(bs, offset, count >> BDRV_SECTOR_BITS, fla= gs); + ret =3D qcow2_cluster_zeroize(bs, offset, count, flags); qemu_co_mutex_unlock(&s->lock); =20 return ret; @@ -2535,8 +2535,8 @@ static coroutine_fn int qcow2_co_pdiscard(BlockDriver= State *bs, } =20 qemu_co_mutex_lock(&s->lock); - ret =3D qcow2_discard_clusters(bs, offset, count >> BDRV_SECTOR_BITS, - QCOW2_DISCARD_REQUEST, false); + ret =3D qcow2_cluster_discard(bs, offset, count, QCOW2_DISCARD_REQUEST, + false); qemu_co_mutex_unlock(&s->lock); return ret; } @@ -2843,9 +2843,8 @@ fail: static int qcow2_make_empty(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; - uint64_t start_sector; - int sector_step =3D (QEMU_ALIGN_DOWN(INT_MAX, s->cluster_size) / - BDRV_SECTOR_SIZE); + uint64_t offset, end_offset; + int step =3D QEMU_ALIGN_DOWN(INT_MAX, s->cluster_size); int l1_clusters, ret =3D 0; =20 l1_clusters =3D DIV_ROUND_UP(s->l1_size, s->cluster_size / sizeof(uint= 64_t)); @@ -2862,18 +2861,15 @@ static int qcow2_make_empty(BlockDriverState *bs) =20 /* This fallback code simply discards every active cluster; this is sl= ow, * but works in all cases */ - for (start_sector =3D 0; start_sector < bs->total_sectors; - start_sector +=3D sector_step) - { + end_offset =3D bs->total_sectors * BDRV_SECTOR_SIZE; + for (offset =3D 0; offset < end_offset; offset +=3D step) { /* As this function is generally used after committing an external * snapshot, QCOW2_DISCARD_SNAPSHOT seems appropriate. Also, the * default action for this kind of discard is to pass the discard, * which will ideally result in an actually smaller image file, as * is probably desired. */ - ret =3D qcow2_discard_clusters(bs, start_sector * BDRV_SECTOR_SIZE, - MIN(sector_step, - bs->total_sectors - start_sector), - QCOW2_DISCARD_SNAPSHOT, true); + ret =3D qcow2_cluster_discard(bs, offset, MIN(step, end_offset - o= ffset), + QCOW2_DISCARD_SNAPSHOT, true); if (ret < 0) { break; } diff --git a/block/qcow2.h b/block/qcow2.h index 810ceb8..1801dc3 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -551,10 +551,11 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockD= riverState *bs, int compressed_size); =20 int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m); -int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, - int nb_sectors, enum qcow2_discard_type type, bool full_discard); -int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sect= ors, - int flags); +int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, + uint64_t bytes, enum qcow2_discard_type type, + bool full_discard); +int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset, + uint64_t bytes, int flags); =20 int qcow2_expand_zero_clusters(BlockDriverState *bs, BlockDriverAmendStatusCB *status_cb, --=20 1.8.3.1 From nobody Tue Apr 30 04:53:17 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494515299772633.0446063014437; Thu, 11 May 2017 08:08:19 -0700 (PDT) Received: from localhost ([::1]:48707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8phO-000871-Dm for importer@patchew.org; Thu, 11 May 2017 11:08:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8pBh-0003cw-Qe for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8pBh-0000QJ-2R for qemu-devel@nongnu.org; Thu, 11 May 2017 10:35:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40104) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8pBY-0000LS-OE; Thu, 11 May 2017 10:35:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B02EB7D4F3; Thu, 11 May 2017 14:35:19 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DD0C8A8DD; Thu, 11 May 2017 14:35:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B02EB7D4F3 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B02EB7D4F3 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 11 May 2017 16:33:01 +0200 Message-Id: <1494513181-7900-59-git-send-email-kwolf@redhat.com> In-Reply-To: <1494513181-7900-1-git-send-email-kwolf@redhat.com> References: <1494513181-7900-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 11 May 2017 14:35:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 58/58] MAINTAINERS: Add qemu-progress to the block layer 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: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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: Max Reitz util/qemu-progress.c is currently unmaintained. The only user of its functionality is qemu-img, so it effectively is part of the block layer. Suggested-by: Fam Zheng Signed-off-by: Max Reitz Message-id: 20170428165517.30341-1-mreitz@redhat.com Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8224be0..145be0f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1170,6 +1170,7 @@ F: include/block/ F: qemu-img* F: qemu-io* F: tests/qemu-iotests/ +F: util/qemu-progress.c T: git git://repo.or.cz/qemu/kevin.git block =20 Block I/O path --=20 1.8.3.1