From nobody Sun Apr 28 23:09:38 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 1493743138613644.8466742146014; Tue, 2 May 2017 09:38:58 -0700 (PDT) Received: from localhost ([::1]:60103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5apE-0005Tq-4l for importer@patchew.org; Tue, 02 May 2017 12:38:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5amh-0003Io-MA for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5amh-0007uS-1w for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57808) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5amc-0007n6-O4; Tue, 02 May 2017 12:36: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 9FD153416E1; Tue, 2 May 2017 16:36:13 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 153BC18408; Tue, 2 May 2017 16:36:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FD153416E1 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9FD153416E1 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:36 +0800 Message-Id: <20170502163558.7611-2-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 01/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It can be used outside of block.c for making user friendly messages. Signed-off-by: Fam Zheng --- block.c | 2 +- include/block/block.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 6c6bb3e..d8fcad9 100644 --- a/block.c +++ b/block.c @@ -1588,7 +1588,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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743090956987.8848445654902; Tue, 2 May 2017 09:38:10 -0700 (PDT) Received: from localhost ([::1]:60101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aoS-0004oc-C1 for importer@patchew.org; Tue, 02 May 2017 12:38:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5amk-0003Kj-Cn for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5amj-0007xl-G8 for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41842) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5amg-0007tF-H6; Tue, 02 May 2017 12:36:18 -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 668A211C81F; Tue, 2 May 2017 16:36:17 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3189678000; Tue, 2 May 2017 16:36:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 668A211C81F 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 668A211C81F From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:37 +0800 Message-Id: <20170502163558.7611-3-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 02/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- 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 d8fcad9..710ba04 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"); @@ -1152,6 +1154,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 */ } }, }; @@ -1191,6 +1198,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 87fb747..1cf29a1 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743247651321.4985108256765; Tue, 2 May 2017 09:40:47 -0700 (PDT) Received: from localhost ([::1]:60124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5ar0-00079n-4N for importer@patchew.org; Tue, 02 May 2017 12:40:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5amq-0003Pp-Gg for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5amp-00084a-Kf for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56108) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5aml-0007yt-10; Tue, 02 May 2017 12:36: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 ED9A324C298; Tue, 2 May 2017 16:36:21 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id D80E177CA1; Tue, 2 May 2017 16:36:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED9A324C298 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED9A324C298 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:38 +0800 Message-Id: <20170502163558.7611-4-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 03/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- block.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/block.c b/block.c index 710ba04..70ca7b4 100644 --- a/block.c +++ b/block.c @@ -1467,6 +1467,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 @@ -1511,9 +1527,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) { @@ -1573,9 +1589,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); } } @@ -1910,8 +1926,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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743275008446.78818562456354; Tue, 2 May 2017 09:41:15 -0700 (PDT) Received: from localhost ([::1]:60125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5arQ-0007T9-EL for importer@patchew.org; Tue, 02 May 2017 12:41:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5an5-0003b6-1p for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5an2-0008K6-Nz for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52964) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5amw-0008AQ-HG; Tue, 02 May 2017 12:36: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 5E31914F14F; Tue, 2 May 2017 16:36:33 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 777A477CA1; Tue, 2 May 2017 16:36:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5E31914F14F 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5E31914F14F From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:39 +0800 Message-Id: <20170502163558.7611-5-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 04/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This will force the opened images to allow sharing all permissions with oth= er programs. Signed-off-by: Fam Zheng --- qemu-img.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 118 insertions(+), 36 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index c719636..f981b57 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(options, "driver", qstring_from_str(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(options, "driver", qstring_from_str(bs->backing_form= at)); } =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,13 @@ 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(options, "driver", qstring_from_str(out_basefmt)= ); - } else { - options =3D NULL; + } + if (force_share) { + qdict_put(options, BDRV_OPT_FORCE_SHARE, + qbool_from_bool(true)); } =20 blk_new_backing =3D blk_new_open(out_baseimg, NULL, @@ -3419,7 +3487,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 +3642,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 +3811,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 +3820,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 +3917,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 +3967,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 +4135,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 +4164,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 +4188,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 +4235,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 +4304,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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743411451484.5162861074391; Tue, 2 May 2017 09:43:31 -0700 (PDT) Received: from localhost ([::1]:60144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5atb-0001Sn-EW for importer@patchew.org; Tue, 02 May 2017 12:43:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5an4-0003aZ-Gf for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5an3-0008KL-4i for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42116) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5amz-0008F8-Ox; Tue, 02 May 2017 12:36: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 98B88A1DAE; Tue, 2 May 2017 16:36:36 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECE6D18408; Tue, 2 May 2017 16:36:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 98B88A1DAE 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 98B88A1DAE From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:40 +0800 Message-Id: <20170502163558.7611-6-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 05/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743243718604.0058141896675; Tue, 2 May 2017 09:40:43 -0700 (PDT) Received: from localhost ([::1]:60122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aqv-00074s-Bu for importer@patchew.org; Tue, 02 May 2017 12:40:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anA-0003gL-DB for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5an7-0008Ot-7T for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5an4-0008L0-AC; Tue, 02 May 2017 12:36: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 35DB7A6437; Tue, 2 May 2017 16:36:41 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2015587C80; Tue, 2 May 2017 16:36:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 35DB7A6437 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 35DB7A6437 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:41 +0800 Message-Id: <20170502163558.7611-7-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 06/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add --force-share/-U to program options and -U to open subcommand. Signed-off-by: Fam Zheng --- qemu-io.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index 427cbae..cf4b876 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(opts, "driver", qstring_from_str(format)); } - if (openfile(argv[optind], flags, writethrough, opts)) { + if (openfile(argv[optind], flags, writethrough, + force_share, opts)) { exit(1); } } --=20 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743306144925.7656388122297; Tue, 2 May 2017 09:41:46 -0700 (PDT) Received: from localhost ([::1]:60126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aru-0007s8-Qg for importer@patchew.org; Tue, 02 May 2017 12:41:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anC-0003iL-Ic for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anB-0008US-MA for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54700) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5an7-0008OM-DO; Tue, 02 May 2017 12:36: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 4786BC24A5E8; Tue, 2 May 2017 16:36:44 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF293173A8; Tue, 2 May 2017 16:36:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4786BC24A5E8 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4786BC24A5E8 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:42 +0800 Message-Id: <20170502163558.7611-8-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 07/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qemu-img and qemu-io commands when guest is running need "-U" option, add it. Signed-off-by: Fam Zheng --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743564844117.18802896827594; Tue, 2 May 2017 09:46:04 -0700 (PDT) Received: from localhost ([::1]:60166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aw7-0003e8-FH for importer@patchew.org; Tue, 02 May 2017 12:46:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anD-0003j6-BA for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anC-0008VH-I2 for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anA-0008RD-FG; Tue, 02 May 2017 12:36: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 591B4C0B03AA; Tue, 2 May 2017 16:36:47 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEF1C18408; Tue, 2 May 2017 16:36:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 591B4C0B03AA 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 591B4C0B03AA From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:43 +0800 Message-Id: <20170502163558.7611-9-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36:47 +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] [PATCH v17 08/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743453445763.1581719692654; Tue, 2 May 2017 09:44:13 -0700 (PDT) Received: from localhost ([::1]:60148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5auK-000244-10 for importer@patchew.org; Tue, 02 May 2017 12:44:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anJ-0003ol-Gy for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anG-00007N-BB for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anD-0008Vh-Ha; Tue, 02 May 2017 12:36: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 6B16CC1E9CF0; Tue, 2 May 2017 16:36:50 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1C0E18408; Tue, 2 May 2017 16:36:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B16CC1E9CF0 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6B16CC1E9CF0 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:44 +0800 Message-Id: <20170502163558.7611-10-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 09/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743734534563.0499505190874; Tue, 2 May 2017 09:48:54 -0700 (PDT) Received: from localhost ([::1]:60182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5ayp-0005pd-9R for importer@patchew.org; Tue, 02 May 2017 12:48:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anL-0003qX-OY for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anK-0000Df-QN for qemu-devel@nongnu.org; Tue, 02 May 2017 12:36:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59824) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anG-00006H-5O; Tue, 02 May 2017 12:36: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 0134E132691; Tue, 2 May 2017 16:36:53 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE0A0173A8; Tue, 2 May 2017 16:36:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0134E132691 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0134E132691 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:45 +0800 Message-Id: <20170502163558.7611-11-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36: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] [PATCH v17 10/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743604395461.8947981964583; Tue, 2 May 2017 09:46:44 -0700 (PDT) Received: from localhost ([::1]:60168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5awj-00048y-K0 for importer@patchew.org; Tue, 02 May 2017 12:46:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anM-0003rB-DS for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anL-0000Eh-Ia for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anJ-0000AS-69; Tue, 02 May 2017 12:36:57 -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 106AB144962; Tue, 2 May 2017 16:36:56 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 972E0173A8; Tue, 2 May 2017 16:36:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 106AB144962 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 106AB144962 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:46 +0800 Message-Id: <20170502163558.7611-12-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:36:56 +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] [PATCH v17 11/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 1493743410448928.420903765527; Tue, 2 May 2017 09:43:30 -0700 (PDT) Received: from localhost ([::1]:60145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5atd-0001Ua-6a for importer@patchew.org; Tue, 02 May 2017 12:43:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anT-0003ya-52 for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anP-0000Kn-TB for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59548) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anN-0000Ge-Pz; Tue, 02 May 2017 12:37:01 -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 B2D29C1FF731; Tue, 2 May 2017 16:37:00 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 905A11862F; Tue, 2 May 2017 16:36:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B2D29C1FF731 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B2D29C1FF731 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:47 +0800 Message-Id: <20170502163558.7611-13-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37:00 +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] [PATCH v17 12/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng Reviewed-by: Max Reitz --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743452478563.8190940736769; Tue, 2 May 2017 09:44:12 -0700 (PDT) Received: from localhost ([::1]:60147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5auI-00022J-Nj for importer@patchew.org; Tue, 02 May 2017 12:44:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anf-0004C0-VJ for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5and-0000Ze-KE for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33992) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anX-0000Rs-FW; Tue, 02 May 2017 12:37:11 -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 576642A3E73; Tue, 2 May 2017 16:37:10 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49ACA18408; Tue, 2 May 2017 16:37:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 576642A3E73 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 576642A3E73 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:48 +0800 Message-Id: <20170502163558.7611-14-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37:10 +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] [PATCH v17 13/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To avoid image lock failures. Signed-off-by: Fam Zheng --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743605029233.6335095169227; Tue, 2 May 2017 09:46:45 -0700 (PDT) Received: from localhost ([::1]:60169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5awk-00049f-GG for importer@patchew.org; Tue, 02 May 2017 12:46:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anh-0004Dl-Ip for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5ang-0000eE-8m for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5and-0000XX-Ao; Tue, 02 May 2017 12:37: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 21E351C27FA; Tue, 2 May 2017 16:37:16 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFBC818408; Tue, 2 May 2017 16:37:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21E351C27FA 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 21E351C27FA From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:49 +0800 Message-Id: <20170502163558.7611-15-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 14/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng Reviewed-by: Max Reitz --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743925758478.48639783549413; Tue, 2 May 2017 09:52:05 -0700 (PDT) Received: from localhost ([::1]:60203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5b1t-0000WC-As for importer@patchew.org; Tue, 02 May 2017 12:52:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5ann-0004O9-Lz for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anm-0000kh-RP for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59848) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5ani-0000fU-9I; Tue, 02 May 2017 12:37: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 2778EC1D3505; Tue, 2 May 2017 16:37:21 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9543173A8; Tue, 2 May 2017 16:37:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2778EC1D3505 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2778EC1D3505 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:50 +0800 Message-Id: <20170502163558.7611-16-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 15/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 1941fb6..261563d 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 1cf29a1..29d3040 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743773316397.9087586970851; Tue, 2 May 2017 09:49:33 -0700 (PDT) Received: from localhost ([::1]:60185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5azT-0006cX-R8 for importer@patchew.org; Tue, 02 May 2017 12:49:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5ano-0004P5-Bu for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5ann-0000lQ-Li for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34110) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anl-0000ia-AJ; Tue, 02 May 2017 12:37: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 39B41120F8; Tue, 2 May 2017 16:37:24 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7D08173A8; Tue, 2 May 2017 16:37:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 39B41120F8 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 39B41120F8 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:51 +0800 Message-Id: <20170502163558.7611-17-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 16/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- block/file-win32.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/file-win32.c b/block/file-win32.c index 7872e00..534021b 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493744070597469.17024253248667; Tue, 2 May 2017 09:54:30 -0700 (PDT) Received: from localhost ([::1]:60222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5b4G-0002WA-Q2 for importer@patchew.org; Tue, 02 May 2017 12:54:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anv-0004aq-C8 for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5ans-0000q6-6W for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anq-0000n6-1T; Tue, 02 May 2017 12:37: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 E647C11C827; Tue, 2 May 2017 16:37:28 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6A5D173A8; Tue, 2 May 2017 16:37:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E647C11C827 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E647C11C827 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:52 +0800 Message-Id: <20170502163558.7611-18-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 17/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493744183263193.61873214695277; Tue, 2 May 2017 09:56:23 -0700 (PDT) Received: from localhost ([::1]:60237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5b66-0003sn-0D for importer@patchew.org; Tue, 02 May 2017 12:56:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5anx-0004et-VZ for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5anx-0000uW-3z for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34760) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5anu-0000rk-Pa; Tue, 02 May 2017 12:37: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 9EB9B277CFB; Tue, 2 May 2017 16:37:33 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8934378000; Tue, 2 May 2017 16:37:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9EB9B277CFB 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9EB9B277CFB From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:53 +0800 Message-Id: <20170502163558.7611-19-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 18/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- blockdev.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 4d8cded..654a880 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3155,6 +3155,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; @@ -3205,6 +3206,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); @@ -3231,7 +3234,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(options, "driver", qstring_from_str(backup->format)); } =20 @@ -3242,6 +3247,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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743642330137.2327526652855; Tue, 2 May 2017 09:47:22 -0700 (PDT) Received: from localhost ([::1]:60171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5axM-0004aZ-1D for importer@patchew.org; Tue, 02 May 2017 12:47:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5ao7-0004qA-V5 for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5ao7-00015w-1c for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34700) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5ao1-0000yL-Nt; Tue, 02 May 2017 12:37: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 9A1A62A3E73; Tue, 2 May 2017 16:37:40 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29D0E77FFE; Tue, 2 May 2017 16:37:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9A1A62A3E73 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9A1A62A3E73 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:54 +0800 Message-Id: <20170502163558.7611-20-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 19/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493743942327167.20643871885557; Tue, 2 May 2017 09:52:22 -0700 (PDT) Received: from localhost ([::1]:60206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5b2C-0000l4-VB for importer@patchew.org; Tue, 02 May 2017 12:52:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aoB-0004t1-4X for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5aoA-00018v-9j for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5ao4-00012y-RO; Tue, 02 May 2017 12:37: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 A5BDC120E6; Tue, 2 May 2017 16:37:43 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 354041862F; Tue, 2 May 2017 16:37:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A5BDC120E6 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A5BDC120E6 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:55 +0800 Message-Id: <20170502163558.7611-21-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 20/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 1493744304445244.77302007260107; Tue, 2 May 2017 09:58:24 -0700 (PDT) Received: from localhost ([::1]:60254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5b83-0005WT-4X for importer@patchew.org; Tue, 02 May 2017 12:58:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aoE-0004w8-Dz for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5aoB-0001AT-O3 for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43356) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5ao7-000163-Sr; Tue, 02 May 2017 12:37: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 B9070108806; Tue, 2 May 2017 16:37:46 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D46E18408; Tue, 2 May 2017 16:37:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B9070108806 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B9070108806 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:56 +0800 Message-Id: <20170502163558.7611-22-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 21/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This 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 --- 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 261563d..f1f924b 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 149374449610216.70456298784609; Tue, 2 May 2017 10:01:36 -0700 (PDT) Received: from localhost ([::1]:60277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5bB8-0007mJ-Kv for importer@patchew.org; Tue, 02 May 2017 13:01:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aoK-00052L-MI for qemu-devel@nongnu.org; Tue, 02 May 2017 12:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5aoH-0001HK-LG for qemu-devel@nongnu.org; Tue, 02 May 2017 12:38:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53796) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5aoB-00019F-8x; Tue, 02 May 2017 12:37: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 2230A11B067; Tue, 2 May 2017 16:37:50 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EC2777C9B; Tue, 2 May 2017 16:37:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2230A11B067 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2230A11B067 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:57 +0800 Message-Id: <20170502163558.7611-23-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 22/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- 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 2.9.3 From nobody Sun Apr 28 23:09:38 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 149374380760075.96661908107205; Tue, 2 May 2017 09:50:07 -0700 (PDT) Received: from localhost ([::1]:60187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5b02-0007AF-7h for importer@patchew.org; Tue, 02 May 2017 12:50:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5aoI-00050F-IE for qemu-devel@nongnu.org; Tue, 02 May 2017 12:38:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5aoH-0001GB-78 for qemu-devel@nongnu.org; Tue, 02 May 2017 12:37:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5aoE-0001C5-AW; Tue, 02 May 2017 12:37: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 32F1411C5E6; Tue, 2 May 2017 16:37:53 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8EA81862F; Tue, 2 May 2017 16:37:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 32F1411C5E6 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=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 32F1411C5E6 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 May 2017 00:35:58 +0800 Message-Id: <20170502163558.7611-24-famz@redhat.com> In-Reply-To: <20170502163558.7611-1-famz@redhat.com> References: <20170502163558.7611-1-famz@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]); Tue, 02 May 2017 16:37: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] [PATCH v17 23/23] 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: Kevin Wolf , famz@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- tests/qemu-iotests/182 | 73 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/182.out | 8 +++++ tests/qemu-iotests/group | 1 + 3 files changed, 82 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..ddc2f18 --- /dev/null +++ b/tests/qemu-iotests/182 @@ -0,0 +1,73 @@ +#!/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 + +_run_cmd() +{ + echo + (echo "$@"; "$@" 1>/dev/null) >&2 | _filter_testdir +} + +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 | + 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..b4b8f77 --- /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-system-x86_64: -drive file=3DTEST_DIR/t.qcow2,if=3Dnone,id=3Ddrive0,f= ile.locking=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 2.9.3