From nobody Sat May 4 14:43:33 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 1492674879031427.2933374780282; Thu, 20 Apr 2017 00:54:39 -0700 (PDT) Received: from localhost ([::1]:52098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16vE-0008C9-Vc for importer@patchew.org; Thu, 20 Apr 2017 03:54:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16ta-0006rU-4Y for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16tZ-0003F1-Ax for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:52:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52696) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tX-0003Dn-47; Thu, 20 Apr 2017 03:52:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 049D2C054925; Thu, 20 Apr 2017 07:52:50 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5355C183D6; Thu, 20 Apr 2017 07:52:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 049D2C054925 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 049D2C054925 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:18 +0800 Message-Id: <20170420075237.18219-2-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 20 Apr 2017 07:52: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 v13 01/20] block: Introduce BDRV_O_UNSAFE_READ 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 , 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 flag clears out the "consistent read" permission that blk_new_open requests. Signed-off-by: Fam Zheng Reviewed-by: Eric Blake --- block/block-backend.c | 2 +- include/block/block.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 7405024..b4ba182 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -200,7 +200,7 @@ BlockBackend *blk_new_open(const char *filename, const = char *reference, * caller of blk_new_open() doesn't make use of the permissions, but t= hey * shouldn't hurt either. We can still share everything here because t= he * guest devices will add their own blockers if they can't share. */ - perm =3D BLK_PERM_CONSISTENT_READ; + perm =3D flags & BDRV_O_UNSAFE_READ ? 0 : BLK_PERM_CONSISTENT_READ; if (flags & BDRV_O_RDWR) { perm |=3D BLK_PERM_WRITE; } diff --git a/include/block/block.h b/include/block/block.h index 5ddc0cf..a4917d7 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -98,6 +98,7 @@ typedef struct HDGeometry { select an appropriate protocol drive= r, ignoring the format layer */ #define BDRV_O_NO_IO 0x10000 /* don't initialize for I/O */ +#define BDRV_O_UNSAFE_READ 0x20000 /* don't require consistent read */ =20 #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH) =20 --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492675017154772.484761274471; Thu, 20 Apr 2017 00:56:57 -0700 (PDT) Received: from localhost ([::1]:52116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16xT-0001nM-2S for importer@patchew.org; Thu, 20 Apr 2017 03:56:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16tc-0006tb-Oy for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16tb-0003Fx-T1 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:52:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tZ-0003Eq-SY; Thu, 20 Apr 2017 03:52:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC2BC8051F; Thu, 20 Apr 2017 07:52:52 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98997183D6; Thu, 20 Apr 2017 07:52:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BC2BC8051F 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 BC2BC8051F From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:19 +0800 Message-Id: <20170420075237.18219-3-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Apr 2017 07:52:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 02/20] block: Drop consistent read perm if opened unsafe 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 , 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 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 1fbbb8d..f5182d8 100644 --- a/block.c +++ b/block.c @@ -1722,9 +1722,15 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, } =20 /* bs->file always needs to be consistent because of the metadata.= We - * can never allow other users to resize or write to it. */ - perm |=3D BLK_PERM_CONSISTENT_READ; - shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + * cannot allow other users to resize or write to it unless the ca= ller + * explicitly expects unsafe readings. */ + if (!(bdrv_get_flags(bs) & BDRV_O_UNSAFE_READ)) { + perm |=3D BLK_PERM_CONSISTENT_READ; + shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + } else { + perm &=3D ~BLK_PERM_CONSISTENT_READ; + shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } } else { /* We want consistent read from backing files if the parent needs = it. * No other operations are performed on backing files. */ --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492674889023708.7935518166178; Thu, 20 Apr 2017 00:54:49 -0700 (PDT) Received: from localhost ([::1]:52099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16vP-0008KQ-5z for importer@patchew.org; Thu, 20 Apr 2017 03:54:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16tj-0006ys-OA for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16ti-0003IS-L3 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53070) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tc-0003G3-TO; Thu, 20 Apr 2017 03:52:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC50767AE7; Thu, 20 Apr 2017 07:52:55 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6439D18B36; Thu, 20 Apr 2017 07:52:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CC50767AE7 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 CC50767AE7 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:20 +0800 Message-Id: <20170420075237.18219-4-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Apr 2017 07:52:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 03/20] block: Don't require BLK_PERM_CONSISTENT_READ when unsafe open 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 , 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index f5182d8..ac0527a 100644 --- a/block.c +++ b/block.c @@ -2372,7 +2372,9 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, goto fail; } if (file_bs !=3D NULL) { - file =3D blk_new(BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL); + file =3D blk_new(flags & BDRV_O_UNSAFE_READ ? + 0 : BLK_PERM_CONSISTENT_READ, + BLK_PERM_ALL); blk_insert_bs(file, file_bs, &local_err); bdrv_unref(file_bs); if (local_err) { --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492674904613476.915020556306; Thu, 20 Apr 2017 00:55:04 -0700 (PDT) Received: from localhost ([::1]:52100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16vf-000071-1M for importer@patchew.org; Thu, 20 Apr 2017 03:55:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16to-000739-Fr for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16tl-0003Jm-UA for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tg-0003HE-86; Thu, 20 Apr 2017 03:53:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A1154AEBE; Thu, 20 Apr 2017 07:52:59 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 890E2183D6; Thu, 20 Apr 2017 07:52:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1A1154AEBE 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 1A1154AEBE From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:21 +0800 Message-Id: <20170420075237.18219-5-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 20 Apr 2017 07:52:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 04/20] qemu-img: Add --unsafe-read 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 , 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.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++----------= ---- 1 file changed, 114 insertions(+), 34 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index b220cf7..b9dcd3e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -283,12 +283,15 @@ 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 unsafe) { QDict *options; Error *local_err =3D NULL; BlockBackend *blk; options =3D qemu_opts_to_qdict(opts, NULL); + if (unsafe) { + flags |=3D BDRV_O_UNSAFE_READ; + } blk =3D blk_new_open(NULL, NULL, options, flags, &local_err); if (!blk) { error_reportf_err(local_err, "Could not open '%s': ", optstr); @@ -305,7 +308,7 @@ 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 uns= afe) { BlockBackend *blk; Error *local_err =3D NULL; @@ -316,6 +319,9 @@ static BlockBackend *img_open_file(const char *filename, qdict_put(options, "driver", qstring_from_str(fmt)); } =20 + if (unsafe) { + flags |=3D BDRV_O_UNSAFE_READ; + } 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 +340,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 unsafe) { BlockBackend *blk; if (image_opts) { @@ -348,9 +354,9 @@ 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, = unsafe); } else { - blk =3D img_open_file(filename, fmt, flags, writethrough, quiet); + blk =3D img_open_file(filename, fmt, flags, writethrough, quiet, u= nsafe); } return blk; } @@ -650,6 +656,7 @@ static int img_check(int argc, char **argv) ImageCheck *check; bool quiet =3D false; bool image_opts =3D false; + bool unsafe_read =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -664,9 +671,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}, + {"unsafe-read", 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 +713,9 @@ static int img_check(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -744,7 +755,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, + unsafe_read); if (!blk) { return 1; } @@ -864,6 +876,7 @@ static int img_commit(int argc, char **argv) CommonBlockJobCBInfo cbi; bool image_opts =3D false; AioContext *aio_context; + bool unsafe_read =3D false; =20 fmt =3D NULL; cache =3D BDRV_DEFAULT_CACHE; @@ -873,9 +886,10 @@ static int img_commit(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:ht:b:dpq", + c =3D getopt_long(argc, argv, ":f:ht:b:dpqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -910,6 +924,9 @@ static int img_commit(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -947,7 +964,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, + unsafe_read); if (!blk) { return 1; } @@ -1206,6 +1224,7 @@ static int img_compare(int argc, char **argv) int c, pnum; uint64_t progress_base; bool image_opts =3D false; + bool unsafe_read =3D false; =20 cache =3D BDRV_DEFAULT_CACHE; for (;;) { @@ -1213,9 +1232,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}, + {"unsafe-read", 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 +1268,9 @@ static int img_compare(int argc, char **argv) case 's': strict =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -1293,13 +1316,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, + unsafe_read); 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, + unsafe_read); if (!blk2) { ret =3D 2; goto out2; @@ -1941,6 +1966,7 @@ static int img_convert(int argc, char **argv) bool image_opts =3D false; bool wr_in_order =3D true; long num_coroutines =3D 8; + bool unsafe_read =3D false; =20 fmt =3D NULL; out_fmt =3D "raw"; @@ -1954,9 +1980,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}, + {"unsafe-read", 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; @@ -2065,6 +2092,9 @@ static int img_convert(int argc, char **argv) case 'W': wr_in_order =3D false; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: opts =3D qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); @@ -2132,7 +2162,8 @@ static int img_convert(int argc, char **argv) total_sectors =3D 0; for (bs_i =3D 0; bs_i < bs_n; bs_i++) { blk[bs_i] =3D img_open(image_opts, argv[optind + bs_i], - fmt, src_flags, src_writethrough, quiet); + fmt, src_flags, src_writethrough, quiet, + unsafe_read); if (!blk[bs_i]) { ret =3D -1; goto out; @@ -2277,7 +2308,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... */ - out_blk =3D img_open_file(out_filename, out_fmt, flags, writethrough, = quiet); + out_blk =3D img_open_file(out_filename, out_fmt, flags, writethrough, = quiet, + unsafe_read); if (!out_blk) { ret =3D -1; goto out; @@ -2448,7 +2480,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 unsafe) { ImageInfoList *head =3D NULL; ImageInfoList **last =3D &head; @@ -2471,7 +2503,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, + unsafe); if (!blk) { goto err; } @@ -2523,6 +2556,7 @@ static int img_info(int argc, char **argv) const char *filename, *fmt, *output; ImageInfoList *list; bool image_opts =3D false; + bool unsafe_read =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -2535,9 +2569,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}, + {"unsafe-read", 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; @@ -2555,6 +2590,9 @@ static int img_info(int argc, char **argv) case 'f': fmt =3D optarg; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OUTPUT: output =3D optarg; break; @@ -2594,7 +2632,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, + unsafe_read); if (!list) { return 1; } @@ -2740,6 +2779,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 unsafe_read =3D false; =20 fmt =3D NULL; output =3D NULL; @@ -2751,9 +2791,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}, + {"unsafe-read", 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; @@ -2771,6 +2812,9 @@ static int img_map(int argc, char **argv) case 'f': fmt =3D optarg; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OUTPUT: output =3D optarg; break; @@ -2807,7 +2851,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, unsafe_re= ad); if (!blk) { return 1; } @@ -2870,6 +2914,7 @@ static int img_snapshot(int argc, char **argv) bool quiet =3D false; Error *err =3D NULL; bool image_opts =3D false; + bool unsafe_read =3D false; =20 bdrv_oflags =3D BDRV_O_RDWR; /* Parse commandline parameters */ @@ -2878,9 +2923,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}, + {"unsafe-read", 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; @@ -2930,6 +2976,9 @@ static int img_snapshot(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -2956,7 +3005,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, + unsafe_read); if (!blk) { return 1; } @@ -3020,6 +3070,7 @@ static int img_rebase(int argc, char **argv) int c, flags, src_flags, ret; bool writethrough, src_writethrough; int unsafe =3D 0; + bool unsafe_read =3D 0; int progress =3D 0; bool quiet =3D false; Error *local_err =3D NULL; @@ -3036,9 +3087,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}, + {"unsafe-read", 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; @@ -3088,6 +3140,9 @@ static int img_rebase(int argc, char **argv) case OPTION_IMAGE_OPTS: image_opts =3D true; break; + case 'U': + unsafe_read =3D true; + break; } } =20 @@ -3136,7 +3191,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, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -3161,6 +3217,9 @@ static int img_rebase(int argc, char **argv) qdict_put(options, "driver", qstring_from_str(bs->backing_form= at)); } =20 + if (unsafe_read) { + src_flags |=3D BDRV_O_UNSAFE_READ; + } 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); @@ -3376,6 +3435,7 @@ static int img_resize(int argc, char **argv) bool quiet =3D false; BlockBackend *blk =3D NULL; QemuOpts *param; + bool unsafe_read =3D true; =20 static QemuOptsList resize_options =3D { .name =3D "resize_options", @@ -3408,9 +3468,10 @@ static int img_resize(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":f:hq", + c =3D getopt_long(argc, argv, ":f:hqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -3431,6 +3492,9 @@ static int img_resize(int argc, char **argv) case 'q': quiet =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *opts; opts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -3483,7 +3547,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, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -3544,6 +3609,7 @@ static int img_amend(int argc, char **argv) BlockBackend *blk =3D NULL; BlockDriverState *bs =3D NULL; bool image_opts =3D false; + bool unsafe_read =3D false; =20 cache =3D BDRV_DEFAULT_CACHE; for (;;) { @@ -3551,9 +3617,10 @@ static int img_amend(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"unsafe-read", no_argument, 0, 'U'}, {0, 0, 0, 0} }; - c =3D getopt_long(argc, argv, ":ho:f:t:pq", + c =3D getopt_long(argc, argv, ":ho:f:t:pqU", long_options, NULL); if (c =3D=3D -1) { break; @@ -3646,7 +3713,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, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -3814,6 +3882,7 @@ static int img_bench(int argc, char **argv) bool writethrough =3D false; struct timeval t1, t2; int i; + bool unsafe_read =3D false; =20 for (;;) { static const struct option long_options[] =3D { @@ -3822,9 +3891,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}, + {"unsafe-read", 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; } @@ -3918,6 +3988,9 @@ static int img_bench(int argc, char **argv) flags |=3D BDRV_O_RDWR; is_write =3D true; break; + case 'U': + unsafe_read =3D true; + break; case OPTION_PATTERN: { unsigned long res; @@ -3965,7 +4038,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, + unsafe_read); if (!blk) { ret =3D -1; goto out; @@ -4132,6 +4206,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 unsafe_read =3D false; struct DdInfo dd =3D { .flags =3D 0, .count =3D 0, @@ -4160,10 +4235,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}, + { "unsafe-read", 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; } @@ -4183,6 +4259,9 @@ static int img_dd(int argc, char **argv) case 'h': help(); break; + case 'U': + unsafe_read =3D true; + break; case OPTION_IMAGE_OPTS: image_opts =3D true; break; @@ -4227,7 +4306,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, + unsafe_read); =20 if (!blk1) { ret =3D -1; @@ -4295,7 +4375,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, unsafe_read); =20 if (!blk2) { ret =3D -1; --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492675036281634.9578173531291; Thu, 20 Apr 2017 00:57:16 -0700 (PDT) Received: from localhost ([::1]:52118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16xm-00025I-G4 for importer@patchew.org; Thu, 20 Apr 2017 03:57:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16ts-00076E-0N for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16tm-0003KL-VF for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35356) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tj-0003IP-7a; Thu, 20 Apr 2017 03:53:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16038C04BD3C; Thu, 20 Apr 2017 07:53:02 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id B39BA183D6; Thu, 20 Apr 2017 07:52:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 16038C04BD3C 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 16038C04BD3C From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:22 +0800 Message-Id: <20170420075237.18219-6-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 20 Apr 2017 07:53:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 05/20] qemu-img: Update documentation for --unsafe-read 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 , 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 | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 8ac7822..da76b8e 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] [--unsafe-read] 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] [--unsafe-read] @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] [--unsafe-read] 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}] [--unsafe-r= ead] @var{filename} ETEXI =20 DEF("create", img_create, @@ -28,62 +28,62 @@ STEXI ETEXI =20 DEF("commit", img_commit, - "commit [-q] [--object objectdef] [--image-opts] [-f fmt] [-t cache] [= -b base] [-d] [-p] filename") + "commit [-q] [--object objectdef] [--image-opts] [-f fmt] [-t cache] [= -b base] [-d] [-p] [--unsafe-read] filename") STEXI -@item commit [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}]= [-t @var{cache}] [-b @var{base}] [-d] [-p] @var{filename} +@item commit [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}]= [-t @var{cache}] [-b @var{base}] [-d] [-p] [--unsafe-read] @var{filename} 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] [--unsafe-read] 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] [--unsafe-read] @var{filena= me1} @var{filename2} 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] [-o options] [-s snapshot_id_= or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] file= name [filename2 [...]] output_filename") + "convert [--object objectdef] [--image-opts] [-c] [-p] [-q] [-n] [-f f= mt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_id_= or_name] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] [--u= nsafe-read] 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}= ] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param= }] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@v= ar{filename2} [...]] @var{output_filename} +@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}= ] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param= }] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] [--unsafe-read] @v= ar{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] [--unsafe-read] [-f fmt] [-O output_fmt] [bs=3Dbloc= k_size] [count=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] [--unsafe-read] [-f @var{fmt}] [-O @var{output_fmt= }] [bs=3D@var{block_size}] [count=3D@var{blocks}] [skip=3D@var{blocks}] if= =3D@var{input} 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] [--unsafe-read] 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] [--unsafe-read] @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] [-= -unsafe-read] 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}] [--unsafe-read] @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] [--unsafe-read] [-q] [-l= | -a snapshot | -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] [--unsafe-read] [= -q] [-l | -a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot}] @var{f= ilename} 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] [--unsafe-read] [-q] [-f f= mt] [-t cache] [-T src_cache] [-p] [-u] -b backing_file [-F backing_fmt] fi= lename") 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] [--unsafe-read] [-q= ] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-p] [-u] -b @var{ba= cking_file} [-F @var{backing_fmt}] @var{filename} ETEXI =20 DEF("resize", img_resize, - "resize [--object objectdef] [--image-opts] [-q] filename [+ | -]size") + "resize [--object objectdef] [--image-opts] [--unsafe-read] [-q] filen= ame [+ | -]size") STEXI -@item resize [--object @var{objectdef}] [--image-opts] [-q] @var{filename}= [+ | -]@var{size} +@item resize [--object @var{objectdef}] [--image-opts] [--unsafe-read] [-q= ] @var{filename} [+ | -]@var{size} ETEXI =20 DEF("amend", img_amend, - "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cach= e] -o options filename") + "amend [--object objectdef] [--image-opts] [--unsafe-read] [-p] [-q] [= -f fmt] [-t cache] -o options filename") STEXI -@item amend [--object @var{objectdef}] [--image-opts] [-p] [-q] [-f @var{f= mt}] [-t @var{cache}] -o @var{options} @var{filename} +@item amend [--object @var{objectdef}] [--image-opts] [--unsafe-read] [-p]= [-q] [-f @var{fmt}] [-t @var{cache}] -o @var{options} @var{filename} @end table ETEXI --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492675165009544.3299315751724; Thu, 20 Apr 2017 00:59:25 -0700 (PDT) Received: from localhost ([::1]:52132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16zr-00047q-Aj for importer@patchew.org; Thu, 20 Apr 2017 03:59:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16tt-00078B-N6 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16ts-0003Nl-39 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60488) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tm-0003Jc-5x; Thu, 20 Apr 2017 03:53:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 187C83D97C; Thu, 20 Apr 2017 07:53:05 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB1C2183D6; Thu, 20 Apr 2017 07:53:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 187C83D97C 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 187C83D97C From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:23 +0800 Message-Id: <20170420075237.18219-7-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 20 Apr 2017 07:53:05 +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 v13 06/20] qemu-io: Add --unsafe-read 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 , 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-io.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index 427cbae..e7e032c 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -53,7 +53,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 unsafe_= read, + QDict *opts) { Error *local_err =3D NULL; BlockDriverState *bs; @@ -64,6 +65,9 @@ static int openfile(char *name, int flags, bool writethro= ugh, QDict *opts) return 1; } =20 + if (unsafe_read) { + flags |=3D BDRV_O_UNSAFE_READ; + } 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 +112,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, -- allow unsafe reads when another process is writing\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 +129,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 +152,9 @@ static int open_f(BlockBackend *blk, int argc, char **a= rgv) int c; QemuOpts *qopts; QDict *opts; + bool unsafe_read =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 +194,9 @@ static int open_f(BlockBackend *blk, int argc, char **a= rgv) return 0; } break; + case 'U': + unsafe_read =3D true; + break; default: qemu_opts_reset(&empty_opts); return qemuio_command_usage(&open_cmd); @@ -211,9 +220,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, unsafe_read, op= ts); } else if (optind =3D=3D argc) { - return openfile(NULL, flags, writethrough, opts); + return openfile(NULL, flags, writethrough, unsafe_read, opts); } else { QDECREF(opts); return qemuio_command_usage(&open_cmd); @@ -257,6 +266,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, --unsafe-read allow unsafe reads when another process is writing= \n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n" "\n" @@ -436,7 +446,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 +462,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 }, + { "unsafe-read", no_argument, 0, 'U'}, { NULL, 0, NULL, 0 } }; int c; @@ -462,6 +473,7 @@ int main(int argc, char **argv) QDict *opts =3D NULL; const char *format =3D NULL; char *trace_file =3D NULL; + bool unsafe_read =3D false; =20 #ifdef CONFIG_POSIX signal(SIGPIPE, SIG_IGN); @@ -524,6 +536,9 @@ int main(int argc, char **argv) case 'h': usage(progname); exit(0); + case 'U': + unsafe_read =3D true; + break; case OPTION_OBJECT: { QemuOpts *qopts; qopts =3D qemu_opts_parse_noisily(&qemu_object_opts, @@ -595,7 +610,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, unsafe_read, opts)) { exit(1); } } else { @@ -603,7 +618,7 @@ 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, unsafe_read, o= pts)) { exit(1); } } --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492675156333339.4249481212016; Thu, 20 Apr 2017 00:59:16 -0700 (PDT) Received: from localhost ([::1]:52131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16zi-00040s-Qy for importer@patchew.org; Thu, 20 Apr 2017 03:59:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16tv-00079z-DI for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16tu-0003PP-4O for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tp-0003LM-04; Thu, 20 Apr 2017 03:53:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E37BA4ACB6; Thu, 20 Apr 2017 07:53:07 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id A459582616; Thu, 20 Apr 2017 07:53:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E37BA4ACB6 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 E37BA4ACB6 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:24 +0800 Message-Id: <20170420075237.18219-8-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 20 Apr 2017 07:53:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 07/20] 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 , 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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 0d472d5..5f1dce8 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) @@ -125,7 +125,7 @@ class TestSingleDrive(iotests.QMPTestCase): self.assert_no_active_block_jobs() self.vm.shutdown() =20 - self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', test_i= mg), + self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', '-r', = test_img), empty_map, 'image file map changed after a no-op') =20 def test_stream_partial(self): @@ -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, '-U', '-c', = 'map', self.imgs[i]), + qemu_io('-f', iotests.imgfmt, '-U', '-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, '-U', '-c', 'map= ', self.imgs[4]), + qemu_io('-f', iotests.imgfmt, '-U', '-c', 'map= ', 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, '-U', '-c', 'map= ', self.children[0]), + qemu_io('-f', iotests.imgfmt, '-U', '-c', 'map= ', self.backing[0]), 'image file map matches backing file before st= reaming') =20 self.assert_no_active_block_jobs() @@ -436,8 +436,8 @@ class TestQuorum(iotests.QMPTestCase): self.assert_no_active_block_jobs() self.vm.shutdown() =20 - self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map', self.c= hildren[0]), - qemu_io('-f', iotests.imgfmt, '-c', 'map', self.b= acking[0]), + self.assertEqual(qemu_io('-f', iotests.imgfmt, '-U', '-c', 'map', = self.children[0]), + qemu_io('-f', iotests.imgfmt, '-U', '-c', 'map', = self.backing[0]), 'image file map does not match backing file after= streaming') =20 class TestSmallerBackingFile(iotests.QMPTestCase): --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492675026189341.616720088811; Thu, 20 Apr 2017 00:57:06 -0700 (PDT) Received: from localhost ([::1]:52117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16xc-0001wL-Jt for importer@patchew.org; Thu, 20 Apr 2017 03:57:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16tv-0007AX-MV for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16tu-0003Q1-Tr for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53010) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16ts-0003NQ-9W; Thu, 20 Apr 2017 03:53:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25B81C1CA42A; Thu, 20 Apr 2017 07:53:11 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76C4982616; Thu, 20 Apr 2017 07:53:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 25B81C1CA42A 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 25B81C1CA42A From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:25 +0800 Message-Id: <20170420075237.18219-9-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 20 Apr 2017 07:53:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 08/20] 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 , 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 Sat May 4 14:43:33 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 1492675289984642.920399683323; Thu, 20 Apr 2017 01:01:29 -0700 (PDT) Received: from localhost ([::1]:52152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d171s-0005pF-G6 for importer@patchew.org; Thu, 20 Apr 2017 04:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16u3-0007IR-05 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16ty-0003SR-4N for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60094) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16tv-0003Pu-BQ; Thu, 20 Apr 2017 03:53:15 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 421A231F3F8; Thu, 20 Apr 2017 07:53:14 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACD9982616; Thu, 20 Apr 2017 07:53:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 421A231F3F8 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 421A231F3F8 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:26 +0800 Message-Id: <20170420075237.18219-10-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Apr 2017 07:53:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 09/20] 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 , 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 Sat May 4 14:43:33 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 1492675421469822.9952429260353; Thu, 20 Apr 2017 01:03:41 -0700 (PDT) Received: from localhost ([::1]:52166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1740-0007XK-20 for importer@patchew.org; Thu, 20 Apr 2017 04:03:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16u5-0007Kg-BC for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16u4-0003Vq-BB for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9737) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16ty-0003ST-PD; Thu, 20 Apr 2017 03:53:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A82638C0CC; Thu, 20 Apr 2017 07:53:17 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD80B82616; Thu, 20 Apr 2017 07:53:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A82638C0CC 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 A82638C0CC From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:27 +0800 Message-Id: <20170420075237.18219-11-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 20 Apr 2017 07:53: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 v13 10/20] 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 , 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 | 34 ++++++++++++++++++++-------------- tests/qemu-iotests/085.out | 3 ++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085 index c53e97f..cc6efd8 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,11 @@ 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 + +_make_test_img "$size" +mv "${TEST_IMG}" "${TEST_IMG}.base" +_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..65b0f68 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', 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 Sat May 4 14:43:33 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 149267527586042.196251118503596; Thu, 20 Apr 2017 01:01:15 -0700 (PDT) Received: from localhost ([::1]:52148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d171e-0005ct-DM for importer@patchew.org; Thu, 20 Apr 2017 04:01:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16u5-0007KQ-46 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16u4-0003Vi-5R for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42042) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16u1-0003Tr-Fr; Thu, 20 Apr 2017 03:53:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63AC890E64; Thu, 20 Apr 2017 07:53:20 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40BCC183D6; Thu, 20 Apr 2017 07:53:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 63AC890E64 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 63AC890E64 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:28 +0800 Message-Id: <20170420075237.18219-12-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Apr 2017 07:53:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 11/20] 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 , 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 1492675561678340.1773554203812; Thu, 20 Apr 2017 01:06:01 -0700 (PDT) Received: from localhost ([::1]:52182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d176F-0000uU-QH for importer@patchew.org; Thu, 20 Apr 2017 04:05:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16u7-0007Ni-By for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16u6-0003Wt-Jw for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46110) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16u4-0003Vc-IG; Thu, 20 Apr 2017 03:53:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A5626330D; Thu, 20 Apr 2017 07:53:23 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21E87183D6; Thu, 20 Apr 2017 07:53:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A5626330D 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 7A5626330D From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:29 +0800 Message-Id: <20170420075237.18219-13-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 20 Apr 2017 07:53:23 +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 v13 12/20] 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 , 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 Sat May 4 14:43:33 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 149267521833686.99082470639462; Thu, 20 Apr 2017 01:00:18 -0700 (PDT) Received: from localhost ([::1]:52136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d170i-0004q3-LL for importer@patchew.org; Thu, 20 Apr 2017 04:00:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16uI-0007Y9-Hh for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16uG-0003Zx-30 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16u8-0003XB-3K; Thu, 20 Apr 2017 03:53:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0A0B7F7B7; Thu, 20 Apr 2017 07:53:26 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E42282616; Thu, 20 Apr 2017 07:53:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F0A0B7F7B7 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 F0A0B7F7B7 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:30 +0800 Message-Id: <20170420075237.18219-14-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 20 Apr 2017 07:53:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 13/20] 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 , 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 Sat May 4 14:43:33 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 1492675711497918.5382475504799; Thu, 20 Apr 2017 01:08:31 -0700 (PDT) Received: from localhost ([::1]:52199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d178f-00034q-Mz for importer@patchew.org; Thu, 20 Apr 2017 04:08:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16uI-0007Y8-Hh for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16uH-0003at-ER for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58624) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16uD-0003ZB-Tt; Thu, 20 Apr 2017 03:53:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C491B81241; Thu, 20 Apr 2017 07:53:32 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0C5D18B36; Thu, 20 Apr 2017 07:53:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C491B81241 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 C491B81241 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:31 +0800 Message-Id: <20170420075237.18219-15-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 20 Apr 2017 07:53:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 14/20] 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 , 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 | 4 ++-- 6 files changed, 7 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..5e2ff14 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,7 @@ 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 Sat May 4 14:43:33 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 1492675345653959.595690191904; Thu, 20 Apr 2017 01:02:25 -0700 (PDT) Received: from localhost ([::1]:52158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d172m-0006Wf-22 for importer@patchew.org; Thu, 20 Apr 2017 04:02:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16uJ-0007ai-QM for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16uI-0003cd-Tk for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16uG-0003a2-OI; Thu, 20 Apr 2017 03:53:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2F732EF181; Thu, 20 Apr 2017 07:53:35 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F45A183D6; Thu, 20 Apr 2017 07:53:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A2F732EF181 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 A2F732EF181 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:32 +0800 Message-Id: <20170420075237.18219-16-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Apr 2017 07:53:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 15/20] 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 , 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 +++++ 1 file changed, 5 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 0c48968..24ea3ff 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -394,6 +394,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_BOOL, + .help =3D "lock the file", + }, { /* end of list */ } }, }; --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492675068732587.5379983750095; Thu, 20 Apr 2017 00:57:48 -0700 (PDT) Received: from localhost ([::1]:52119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16yI-0002dX-Vh for importer@patchew.org; Thu, 20 Apr 2017 03:57:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16uR-0007iE-5u for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16uQ-0003g3-55 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16uJ-0003cj-MU; Thu, 20 Apr 2017 03:53:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E70164DBD; Thu, 20 Apr 2017 07:53:38 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48650183D6; Thu, 20 Apr 2017 07:53:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8E70164DBD 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 8E70164DBD From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:33 +0800 Message-Id: <20170420075237.18219-17-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 20 Apr 2017 07:53:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v13 16/20] 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 , 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 fac2da3..e1c4235 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 Sat May 4 14:43:33 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 1492675419911586.7663118068126; Thu, 20 Apr 2017 01:03:39 -0700 (PDT) Received: from localhost ([::1]:52163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d173u-0007S4-El for importer@patchew.org; Thu, 20 Apr 2017 04:03:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16uR-0007j4-SA for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16uR-0003gP-5h for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60960) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16uM-0003eE-OC; Thu, 20 Apr 2017 03:53:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97DE964DA1; Thu, 20 Apr 2017 07:53:41 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 274F618B36; Thu, 20 Apr 2017 07:53:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 97DE964DA1 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 97DE964DA1 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:34 +0800 Message-Id: <20170420075237.18219-18-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 20 Apr 2017 07:53: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 v13 17/20] block: Workaround drive-backup sync=none 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 , 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 --- blockdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blockdev.c b/blockdev.c index 4927914..5831b95 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3223,6 +3223,9 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, } } if (backup->sync =3D=3D MIRROR_SYNC_MODE_NONE) { + /* FIXME: block layer should really open target with BDRV_O_NO_BAC= KING + * and reuse source's backing chain, if they share one. */ + flags |=3D BDRV_O_UNSAFE_READ; source =3D bs; } =20 --=20 2.9.3 From nobody Sat May 4 14:43:33 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 1492675478012142.12314427749538; Thu, 20 Apr 2017 01:04:38 -0700 (PDT) Received: from localhost ([::1]:52169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d174t-0008EO-UY for importer@patchew.org; Thu, 20 Apr 2017 04:04:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16uT-0007le-U2 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16uS-0003h7-MV for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16uP-0003fB-Lw; Thu, 20 Apr 2017 03:53:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D74D7E9F6; Thu, 20 Apr 2017 07:53:44 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37AA318B36; Thu, 20 Apr 2017 07:53:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8D74D7E9F6 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 8D74D7E9F6 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:35 +0800 Message-Id: <20170420075237.18219-19-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Apr 2017 07:53: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 v13 18/20] 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 , 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 Sat May 4 14:43:33 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 1492675566156134.79588628551494; Thu, 20 Apr 2017 01:06:06 -0700 (PDT) Received: from localhost ([::1]:52183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d176K-0000yL-08 for importer@patchew.org; Thu, 20 Apr 2017 04:06:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16ud-0007uz-IV for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:54:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16ua-0003rT-Uo for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:53:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16uS-0003gr-I7; Thu, 20 Apr 2017 03:53:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73B21C04BD3C; Thu, 20 Apr 2017 07:53:47 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FC8F18B36; Thu, 20 Apr 2017 07:53:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73B21C04BD3C 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 73B21C04BD3C From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:36 +0800 Message-Id: <20170420075237.18219-20-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 20 Apr 2017 07:53: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 v13 19/20] file-posix: Add image locking in 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 , 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" virtlockd in libvirt locks the first byte, so we start looking at the file bytes from 0x10. The complication is in the transactional interface. To make the reopen logic managable, and allow better reuse, the code is internally organized with a table from old mode to the new one. Signed-off-by: Fam Zheng --- block/file-posix.c | 744 +++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 741 insertions(+), 3 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 24ea3ff..b85ac9c 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -131,8 +131,54 @@ do { \ =20 #define MAX_BLOCKSIZE 4096 =20 +/* Posix file locking bytes. Libvirt takes byte 0, we start from byte 0x10, + * leaving a few more bytes for its future use. */ +#define RAW_LOCK_BYTE_MIN 0x10 +#define RAW_LOCK_BYTE_NO_OTHER_WRITER 0x10 +#define RAW_LOCK_BYTE_WRITE 0x11 +#ifdef F_OFD_SETLK +#define RAW_LOCK_SUPPORTED 1 +#else +#define RAW_LOCK_SUPPORTED 0 +#endif + +/* + ** reader that can tolerate writers: Don't do anything + * + ** reader that can't tolerate writers: Take shared lock on byte 0x10. Test + * byte 0x11 is unlocked. + * + ** shared writer: Take shared lock on byte 0x11. Test byte 0x10 is unlock= ed. + * + ** exclusive writer: Take exclusive locks on both bytes. + */ + +typedef enum { + /* Read only and accept other writers. */ + RAW_L_READ_SHARE_RW, + /* Read only and try to forbid other writers. */ + RAW_L_READ, + /* Read/write and accept other writers. */ + RAW_L_WRITE_SHARE_RW, + /* Read/write and try to forbid other writers. */ + RAW_L_WRITE, +} BDRVRawLockMode; + +typedef struct BDRVRawLockUpdateState { + /* A dup of @fd used for acquiring lock. */ + int image_fd; + int lock_fd; + int open_flags; + BDRVRawLockMode new_lock; + bool use_lock; +} BDRVRawLockUpdateState; + typedef struct BDRVRawState { int fd; + /* A dup of @fd to make manipulating lock easier, especially during re= open, + * where this will accept BDRVRawReopenState.lock_fd. */ + int lock_fd; + bool use_lock; int type; int open_flags; size_t buf_align; @@ -147,6 +193,11 @@ typedef struct BDRVRawState { bool page_cache_inconsistent:1; bool has_fallocate; bool needs_alignment; + /* The current lock mode we are in. Note that in incoming migration th= is is + * the "desired" mode to be applied at bdrv_invalidate_cache. */ + BDRVRawLockMode cur_lock_mode; + /* Used by raw_check_perm/raw_set_perm. */ + BDRVRawLockUpdateState *lock_update; } BDRVRawState; =20 typedef struct BDRVRawReopenState { @@ -369,6 +420,64 @@ static void raw_parse_flags(int bdrv_flags, int *open_= flags) } } =20 +static int raw_lock_fd(int fd, BDRVRawLockMode mode, Error **errp) +{ + int ret; + assert(fd >=3D 0); + assert(RAW_LOCK_SUPPORTED); + switch (mode) { + case RAW_L_READ_SHARE_RW: + ret =3D qemu_unlock_fd(fd, RAW_LOCK_BYTE_MIN, 2); + if (ret) { + error_setg_errno(errp, -ret, "Failed to unlock fd"); + goto fail; + } + break; + case RAW_L_READ: + ret =3D qemu_lock_fd(fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1, false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock share byte"); + goto fail; + } + ret =3D qemu_lock_fd_test(fd, RAW_LOCK_BYTE_WRITE, 1, true); + if (ret) { + error_setg_errno(errp, -ret, "Write byte lock is taken"); + goto fail; + } + break; + case RAW_L_WRITE_SHARE_RW: + ret =3D qemu_lock_fd(fd, RAW_LOCK_BYTE_WRITE, 1, true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock write byte exclus= ively"); + goto fail; + } + ret =3D qemu_lock_fd(fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to downgrade lock write b= yte"); + goto fail; + } + ret =3D qemu_lock_fd_test(fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1, tr= ue); + if (ret) { + error_setg_errno(errp, -ret, "Share byte lock is taken"); + goto fail; + } + break; + case RAW_L_WRITE: + ret =3D qemu_lock_fd(fd, RAW_LOCK_BYTE_MIN, 2, true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock image"); + goto fail; + } + break; + default: + abort(); + } + return 0; +fail: + qemu_unlock_fd(fd, RAW_LOCK_BYTE_MIN, 2); + return ret; +} + static void raw_parse_filename(const char *filename, QDict *options, Error **errp) { @@ -403,6 +512,23 @@ static QemuOptsList raw_runtime_opts =3D { }, }; =20 +static BDRVRawLockMode raw_get_lock_mode(bool write, bool shared) +{ + if (write) { + if (shared) { + return RAW_L_WRITE_SHARE_RW; + } else { + return RAW_L_WRITE; + } + } else { + if (shared) { + return RAW_L_READ_SHARE_RW; + } else { + return RAW_L_READ; + } + } +} + static int raw_open_common(BlockDriverState *bs, QDict *options, int bdrv_flags, int open_flags, Error **errp) { @@ -442,10 +568,13 @@ static int raw_open_common(BlockDriverState *bs, QDic= t *options, } s->use_linux_aio =3D (aio =3D=3D BLOCKDEV_AIO_OPTIONS_NATIVE); =20 + s->use_lock =3D qemu_opt_get_bool(opts, "locking", true); + s->open_flags =3D open_flags; raw_parse_flags(bdrv_flags, &s->open_flags); =20 s->fd =3D -1; + s->lock_fd =3D -1; fd =3D qemu_open(filename, s->open_flags, 0644); if (fd < 0) { ret =3D -errno; @@ -544,6 +673,509 @@ static int raw_open(BlockDriverState *bs, QDict *opti= ons, int flags, return raw_open_common(bs, options, flags, 0, errp); } =20 +typedef enum { + RAW_LT_PREPARE, + RAW_LT_COMMIT, + RAW_LT_ABORT +} RawLockTransOp; + +typedef int (*RawLockTransFunc)(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp); + +static int raw_lt_nop(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + assert(old_lock =3D=3D new_lock || new_lock =3D=3D RAW_L_READ_SHARE_RW= ); + return 0; +} + +static int raw_lt_from_unlock(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + assert(old_lock !=3D new_lock); + assert(old_lock =3D=3D RAW_L_READ_SHARE_RW); + switch (op) { + case RAW_LT_PREPARE: + return raw_lock_fd(new_lock_fd, new_lock, errp); + case RAW_LT_COMMIT: + break; + case RAW_LT_ABORT: + break; + } + + return 0; +} + +static int raw_lt_read_to_write_share(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + int ret =3D 0; + + assert(old_lock =3D=3D RAW_L_READ); + assert(new_lock =3D=3D RAW_L_WRITE_SHARE_RW); + + /* + * lock byte "no other writer" lock byte "write" + * old S 0 + * new 0 S + * + * (0 =3D unlocked; S =3D shared; X =3D exclusive.) + */ + switch (op) { + case RAW_LT_PREPARE: + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_WRITE, 1, true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock new fd (write byt= e)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock new fd (share byt= e)"); + break; + } + ret =3D qemu_unlock_fd(old_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER,= 1); + if (ret) { + error_setg_errno(errp, -ret, "Failed to unlock old fd (share b= yte)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to upgrade new fd (share = byte)"); + break; + } + ret =3D qemu_unlock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER,= 1); + if (ret) { + /* This is very unlikely, but catch it anyway. */ + error_setg_errno(errp, -ret, "Failed to unlock new fd (share b= yte)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to downgrade new fd (writ= e byte)"); + break; + } + break; + case RAW_LT_COMMIT: + break; + case RAW_LT_ABORT: + ret =3D qemu_lock_fd(old_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (ret) { + /* As unlikely as above unlock failure, but report it anyway. = */ + error_report("Failed to restore lock on old fd (share byte)"); + } + break; + } + return ret; +} + +static int raw_lt_read_to_write(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + int ret =3D 0; + + assert(old_lock =3D=3D RAW_L_READ); + assert(new_lock =3D=3D RAW_L_WRITE); + /* + * lock byte "no other writer" lock byte "write" + * old S 0 + * new X X + * + * (0 =3D unlocked; S =3D shared; X =3D exclusive.) + */ + switch (op) { + case RAW_LT_PREPARE: + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_WRITE, 1, true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock new fd (write byt= e)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock new fd (share byt= e)"); + break; + } + ret =3D qemu_unlock_fd(old_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER,= 1); + if (ret) { + error_setg_errno(errp, -ret, "Failed to unlock old fd (share b= yte)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to upgrade new fd (share = byte)"); + break; + } + break; + case RAW_LT_COMMIT: + break; + case RAW_LT_ABORT: + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to downgrade new fd (shar= e byte)"); + break; + } + ret =3D qemu_lock_fd(old_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (ret) { + error_report("Failed to restore lock on old fd (share byte)"); + } + break; + } + return ret; +} + +static int raw_lt_write_share_to_read(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + int ret =3D 0; + + assert(old_lock =3D=3D RAW_L_WRITE_SHARE_RW); + assert(new_lock =3D=3D RAW_L_READ); + /* + * lock byte "no other writer" lock byte "write" + * old 0 S + * new S 0 + * + * (0 =3D unlocked; S =3D shared; X =3D exclusive.) + */ + switch (op) { + case RAW_LT_PREPARE: + /* Make sure there are no other writers. */ + ret =3D qemu_lock_fd(old_lock_fd, RAW_LOCK_BYTE_WRITE, 1, true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock old fd (write byt= e)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (!ret) { + break; + } + error_setg_errno(errp, -ret, "Failed to lock new fd (share byte)"); + /* fall through */ + case RAW_LT_ABORT: + ret =3D qemu_lock_fd(old_lock_fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_report("Failed to downgrade old fd (write byte)"); + } + break; + case RAW_LT_COMMIT: + break; + } + return ret; +} + +static int raw_lt_write_share_to_write(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + int ret =3D 0; + + assert(old_lock =3D=3D RAW_L_WRITE_SHARE_RW); + assert(new_lock =3D=3D RAW_L_WRITE); + /* + * lock byte "no other writer" lock byte "write" + * old 0 S + * new X X + * + * (0 =3D unlocked; S =3D shared; X =3D exclusive.) + */ + switch (op) { + case RAW_LT_PREPARE: + /* Make sure there are no other writers. */ + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock new fd (share byt= e)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock new fd (write byt= e)"); + break; + } + ret =3D qemu_unlock_fd(old_lock_fd, RAW_LOCK_BYTE_WRITE, 1); + if (ret) { + error_setg_errno(errp, -ret, "Failed to unlock old fd (write b= yte)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_WRITE, 1, true); + if (ret) { + error_setg_errno(errp, -ret, "Failed to upgrade new fd (write = byte)"); + break; + } + break; + case RAW_LT_COMMIT: + break; + case RAW_LT_ABORT: + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to downgrade new fd (writ= e byte)"); + break; + } + ret =3D qemu_lock_fd(old_lock_fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to restore old fd (write = byte)"); + break; + } + break; + } + return ret; +} + +static int raw_lt_write_to_read(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + int ret =3D 0; + + assert(old_lock =3D=3D RAW_L_WRITE); + assert(new_lock =3D=3D RAW_L_READ); + /* + * lock byte "no other writer" lock byte "write" + * old X X + * new S 0 + * + * (0 =3D unlocked; S =3D shared; X =3D exclusive.) + */ + switch (op) { + case RAW_LT_PREPARE: + break; + case RAW_LT_COMMIT: + ret =3D qemu_lock_fd(old_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to downgrade old fd (shar= e byte)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_NO_OTHER_WRITER, 1= , false); + if (ret) { + error_setg_errno(errp, -ret, "Failed to lock new fd (share byt= e)"); + break; + } + break; + case RAW_LT_ABORT: + break; + } + return ret; +} + +static int raw_lt_write_to_write_share(RawLockTransOp op, + int old_lock_fd, int new_lock_fd, + BDRVRawLockMode old_lock, + BDRVRawLockMode new_lock, + Error **errp) +{ + int ret =3D 0; + + assert(old_lock =3D=3D RAW_L_WRITE); + assert(new_lock =3D=3D RAW_L_WRITE_SHARE_RW); + /* + * lock byte "no other writer" lock byte "write" + * old X X + * new 0 S + * + * (0 =3D unlocked; S =3D shared; X =3D exclusive.) + */ + switch (op) { + case RAW_LT_PREPARE: + break; + case RAW_LT_COMMIT: + ret =3D qemu_lock_fd(old_lock_fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_report("Failed to downgrade old fd (share byte)"); + break; + } + ret =3D qemu_lock_fd(new_lock_fd, RAW_LOCK_BYTE_WRITE, 1, false); + if (ret) { + error_report("Failed to lock new fd (write byte)"); + } + break; + case RAW_LT_ABORT: + break; + } + return ret; +} + +/** + * Transactionally moving between possible locking states is tricky and mu= st be + * done carefully. That is mostly because downgrading an exclusive lock to + * shared or unlocked is not guaranteed to be revertible. As a result, in = such + * cases we have to defer the downgrading to "commit", given that no rever= t will + * happen after that point, and that downgrading a lock should never fail. + * + * On the other hand, upgrading a lock (e.g. from unlocked or shared to + * exclusive lock) must happen in "prepare" because it may fail. + * + * Manage the operation matrix with this state transition table to make + * fulfilling above conditions easier. + */ +static const struct RawLockTransOp { + BDRVRawLockMode old_lock; + BDRVRawLockMode new_lock; + RawLockTransFunc func; + bool need_lock_fd; + bool close_old_lock_fd; +} raw_lock_trans_ops[] =3D { + + {RAW_L_READ_SHARE_RW, RAW_L_READ_SHARE_RW, raw_lt_nop, = false, false}, + {RAW_L_READ_SHARE_RW, RAW_L_READ, raw_lt_from_unlock, = true}, + {RAW_L_READ_SHARE_RW, RAW_L_WRITE_SHARE_RW, raw_lt_from_unlock, = true}, + {RAW_L_READ_SHARE_RW, RAW_L_WRITE, raw_lt_from_unlock, = true}, + + {RAW_L_READ, RAW_L_READ_SHARE_RW, raw_lt_nop, = false, true}, + {RAW_L_READ, RAW_L_READ, raw_lt_nop, = false, false}, + {RAW_L_READ, RAW_L_WRITE_SHARE_RW, raw_lt_read_to_write_shar= e, true}, + {RAW_L_READ, RAW_L_WRITE, raw_lt_read_to_write, = true}, + + {RAW_L_WRITE_SHARE_RW, RAW_L_READ_SHARE_RW, raw_lt_nop, = false, true}, + {RAW_L_WRITE_SHARE_RW, RAW_L_READ, raw_lt_write_share_to_rea= d, true}, + {RAW_L_WRITE_SHARE_RW, RAW_L_WRITE_SHARE_RW, raw_lt_nop, = false, false}, + {RAW_L_WRITE_SHARE_RW, RAW_L_WRITE, raw_lt_write_share_to_wri= te, true}, + + {RAW_L_WRITE, RAW_L_READ_SHARE_RW, raw_lt_nop, = false, true}, + {RAW_L_WRITE, RAW_L_READ, raw_lt_write_to_read, = true}, + {RAW_L_WRITE, RAW_L_WRITE_SHARE_RW, raw_lt_write_to_write_sha= re, true}, + {RAW_L_WRITE, RAW_L_WRITE, raw_lt_nop, = false, false}, +}; + +static int raw_handle_lock_update(BlockDriverState *bs, + RawLockTransOp op, + Error **errp) +{ + BDRVRawState *s =3D bs->opaque; + BDRVRawLockMode old_lock, new_lock; + const struct RawLockTransOp *rec; + int ret =3D 0; + Error *local_err =3D NULL; + BDRVRawLockUpdateState *lu =3D s->lock_update; + int lock_fd; + + if (!RAW_LOCK_SUPPORTED) { + return 0; + } + + if (bdrv_get_flags(bs) & BDRV_O_INACTIVE) { + /* leave the work to bdrv_invalidate_cache. */ + return 0; + } + + if (op =3D=3D RAW_LT_PREPARE) { + lock_fd =3D qemu_open(bs->filename, lu->open_flags); + if (lock_fd =3D=3D -1) { + if (errno =3D=3D ENOENT) { + /* The file is gone, probably BDRV_O_SNAPSHOT? Skip lockin= g. */ + lu->use_lock =3D false; + } else { + /* other errors handled later. */ + } + } + } + + old_lock =3D s->cur_lock_mode; + new_lock =3D lu->use_lock ? lu->new_lock : RAW_L_READ_SHARE_RW; + for (rec =3D &raw_lock_trans_ops[0]; + rec < &raw_lock_trans_ops[ARRAY_SIZE(raw_lock_trans_ops)]; + rec++) { + if (rec->old_lock =3D=3D old_lock && rec->new_lock =3D=3D new_lock= ) { + break; + } + } + assert(rec !=3D &raw_lock_trans_ops[ARRAY_SIZE(raw_lock_trans_ops)]); + + assert(old_lock =3D=3D RAW_L_READ_SHARE_RW || s->lock_fd >=3D 0); + + DPRINTF("handle lock %p old lock %d new lock %d op %d func %p\n", bs, + old_lock, new_lock, op, rec->func); + switch (op) { + case RAW_LT_PREPARE: + if (rec->need_lock_fd) { + if (lock_fd >=3D 0) { + lu->lock_fd =3D lock_fd; + } else { + error_setg(errp, "Failed to initialize lock fd"); + } + } else { + if (lock_fd >=3D 0) { + qemu_close(lock_fd); + lock_fd =3D -1; + } + } + ret =3D rec->func(op, s->lock_fd, lu->lock_fd, old_lock, new_lock,= errp); + if (!ret) { + break; + } + /* Only succeeded preparation will be reverted by block layer, we + * need to clean up this failure manually. */ + op =3D RAW_LT_ABORT; + /* fall through */ + case RAW_LT_ABORT: + rec->func(op, s->lock_fd, lu->lock_fd, old_lock, new_lock, &local_= err); + if (local_err) { + error_report_err(local_err); + } + if (lu->lock_fd >=3D 0) { + qemu_close(lu->lock_fd); + lu->lock_fd =3D -1; + } + goto cleanup; + case RAW_LT_COMMIT: + rec->func(op, s->lock_fd, lu->lock_fd, old_lock, new_lock, &error_= abort); + if ((rec->need_lock_fd || rec->close_old_lock_fd) && s->lock_fd >= =3D 0) { + raw_lock_fd(s->lock_fd, RAW_L_READ_SHARE_RW, NULL); + qemu_close(s->lock_fd); + s->lock_fd =3D -1; + } + if (rec->need_lock_fd) { + s->lock_fd =3D lu->lock_fd; + } + assert(s->lock_fd >=3D 0 || new_lock =3D=3D RAW_L_READ_SHARE_RW); + s->cur_lock_mode =3D new_lock; + s->use_lock =3D lu->use_lock; + goto cleanup; + } + return ret; +cleanup: + g_free(s->lock_update); + s->lock_update =3D NULL; + return ret; +} + +static void raw_init_lock_update(BlockDriverState *bs, + int image_fd, + bool write, bool shared, + bool use_lock) +{ + BDRVRawState *s =3D bs->opaque; + + assert(!s->lock_update); + s->lock_update =3D g_new0(BDRVRawLockUpdateState, 1); + *s->lock_update =3D (BDRVRawLockUpdateState) { + .image_fd =3D image_fd, + .new_lock =3D raw_get_lock_mode(write, shared), + .use_lock =3D use_lock, + .open_flags =3D (s->open_flags & ~(O_RDWR | O_RDONLY)) | + (write ? O_RDWR : O_RDONLY), + }; +} + static int raw_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { @@ -551,6 +1183,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, BDRVRawReopenState *rs; int ret =3D 0; Error *local_err =3D NULL; + bool shared; =20 assert(state !=3D NULL); assert(state->bs !=3D NULL); @@ -615,13 +1248,27 @@ static int raw_reopen_prepare(BDRVReopenState *state, if (rs->fd !=3D -1) { raw_probe_alignment(state->bs, rs->fd, &local_err); if (local_err) { - qemu_close(rs->fd); - rs->fd =3D -1; error_propagate(errp, local_err); ret =3D -EINVAL; + goto fail; } } + shared =3D s->cur_lock_mode =3D=3D RAW_L_READ_SHARE_RW || + s->cur_lock_mode =3D=3D RAW_L_WRITE_SHARE_RW; + /* Shared perm doesn't change during reopen. */ + raw_init_lock_update(state->bs, rs->fd, state->flags & BDRV_O_RDWR, sh= ared, + s->use_lock); =20 + qdict_del(state->options, "locking"); + ret =3D raw_handle_lock_update(state->bs, RAW_LT_PREPARE, errp); + if (ret) { + goto fail; + } + + return 0; +fail: + qemu_close(rs->fd); + rs->fd =3D -1; return ret; } =20 @@ -632,6 +1279,8 @@ static void raw_reopen_commit(BDRVReopenState *state) =20 s->open_flags =3D rs->open_flags; =20 + raw_handle_lock_update(state->bs, RAW_LT_COMMIT, &error_abort); + qemu_close(s->fd); s->fd =3D rs->fd; =20 @@ -649,6 +1298,8 @@ static void raw_reopen_abort(BDRVReopenState *state) return; } =20 + raw_handle_lock_update(state->bs, RAW_LT_ABORT, &error_abort); + if (rs->fd >=3D 0) { qemu_close(rs->fd); rs->fd =3D -1; @@ -1412,6 +2063,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) @@ -1949,6 +2604,85 @@ static QemuOptsList raw_create_opts =3D { } }; =20 +static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t sh= ared, + Error **errp) +{ + bool is_shared; + BDRVRawState *s =3D bs->opaque; + + if (!RAW_LOCK_SUPPORTED) { + return 0; + } + if (s->lock_update) { + /* Override the previously stashed update. */ + g_free(s->lock_update); + s->lock_update =3D NULL; + } + is_shared =3D !(perm & BLK_PERM_CONSISTENT_READ) && (shared & BLK_PERM= _WRITE); + DPRINTF("raw check perm %p rw %d shared %d\n", + bs, perm & BLK_PERM_WRITE ? 1 : 0, + is_shared); + raw_init_lock_update(bs, s->fd, + perm & BLK_PERM_WRITE, is_shared, s->use_lock); + + return raw_handle_lock_update(bs, RAW_LT_PREPARE, errp); +} + +static void raw_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t sha= red) +{ + BDRVRawState *s =3D bs->opaque; + + if (!RAW_LOCK_SUPPORTED) { + return; + } + assert(s->lock_update); + + raw_handle_lock_update(bs, RAW_LT_COMMIT, NULL); +} + +static void raw_abort_perm_update(BlockDriverState *bs) +{ + BDRVRawState *s =3D bs->opaque; + + if (!RAW_LOCK_SUPPORTED) { + return; + } + if (!s->lock_update) { + return; + } + raw_handle_lock_update(bs, RAW_LT_ABORT, NULL); +} + +static int raw_inactivate(BlockDriverState *bs) +{ + BDRVRawState *s =3D bs->opaque; + int r =3D 0; + + if (RAW_LOCK_SUPPORTED && s->cur_lock_mode !=3D RAW_L_READ_SHARE_RW) { + r =3D raw_lock_fd(s->lock_fd, RAW_L_READ_SHARE_RW, NULL); + } + return r; +} + +static void raw_invalidate_cache(BlockDriverState *bs, Error **errp) +{ + int r; + BDRVRawState *s =3D bs->opaque; + + if (!RAW_LOCK_SUPPORTED) { + return; + } + if (s->lock_update) { + /* Apply the pending lock update from perm or reopen. */ + r =3D raw_handle_lock_update(bs, RAW_LT_PREPARE, errp); + if (r) { + return; + } + raw_handle_lock_update(bs, RAW_LT_COMMIT, errp); + assert(!s->lock_update); + } +} + BlockDriver bdrv_file =3D { .format_name =3D "file", .protocol_name =3D "file", @@ -1979,7 +2713,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 --=20 2.9.3 From nobody Sat May 4 14:43:33 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 149267563060859.266400583804966; Thu, 20 Apr 2017 01:07:10 -0700 (PDT) Received: from localhost ([::1]:52185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d177M-0001nr-DF for importer@patchew.org; Thu, 20 Apr 2017 04:07:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d16ue-0007wA-Ey for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:54:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d16uc-0003tj-HF for qemu-devel@nongnu.org; Thu, 20 Apr 2017 03:54:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32970) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d16uV-0003jC-Mo; Thu, 20 Apr 2017 03:53:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97ACD3DBCC; Thu, 20 Apr 2017 07:53:50 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1021818B36; Thu, 20 Apr 2017 07:53:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 97ACD3DBCC 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 97ACD3DBCC From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 15:52:37 +0800 Message-Id: <20170420075237.18219-21-famz@redhat.com> In-Reply-To: <20170420075237.18219-1-famz@redhat.com> References: <20170420075237.18219-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 20 Apr 2017 07:53: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 v13 20/20] tests: Add test-image-lock 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 , 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/Makefile.include | 2 + tests/test-image-lock.c | 259 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 261 insertions(+) create mode 100644 tests/test-image-lock.c diff --git a/tests/Makefile.include b/tests/Makefile.include index f3de81f..20e3093 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -58,6 +58,7 @@ check-unit-y +=3D tests/test-hbitmap$(EXESUF) gcov-files-test-hbitmap-y =3D blockjob.c check-unit-y +=3D tests/test-blockjob$(EXESUF) check-unit-y +=3D tests/test-blockjob-txn$(EXESUF) +check-unit-y +=3D tests/test-image-lock$(EXESUF) check-unit-y +=3D tests/test-x86-cpuid$(EXESUF) # all code tested by test-x86-cpuid is inside topology.h gcov-files-test-x86-cpuid-y =3D @@ -545,6 +546,7 @@ tests/test-aio-multithread$(EXESUF): tests/test-aio-mul= tithread.o $(test-block-o tests/test-throttle$(EXESUF): tests/test-throttle.o $(test-block-obj-y) tests/test-blockjob$(EXESUF): tests/test-blockjob.o $(test-block-obj-y) $(= test-util-obj-y) tests/test-blockjob-txn$(EXESUF): tests/test-blockjob-txn.o $(test-block-o= bj-y) $(test-util-obj-y) +tests/test-image-lock$(EXESUF): tests/test-image-lock.o $(test-block-obj-y= ) $(libqos-obj-y) tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj= -y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) diff --git a/tests/test-image-lock.c b/tests/test-image-lock.c new file mode 100644 index 0000000..a118e89 --- /dev/null +++ b/tests/test-image-lock.c @@ -0,0 +1,259 @@ +/* + * Image lock tests + * + * Copyright 2016 Red Hat, Inc. + * + * Authors: + * Fam Zheng + * + * This work is licensed under the terms of the GNU LGPL, version 2 or lat= er. + * See the COPYING.LIB file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qstring.h" +#include "sysemu/block-backend.h" + +#define DEBUG_IMAGE_LOCK_TEST 0 +#define DPRINTF(...) do { \ + if (DEBUG_IMAGE_LOCK_TEST) { \ + printf(__VA_ARGS__); \ + } \ + } while (0) + +#define TEST_IMAGE_SIZE 4096 +static char test_image[] =3D "/tmp/qtest.XXXXXX"; +static int test_image_fd; + +static BlockBackend *open_test_image(const char *format, + int flags, bool disable_lock, Error *= *errp) +{ + QDict *opts =3D qdict_new(); + + qdict_set_default_str(opts, "driver", format); + qdict_set_default_str(opts, "file.driver", "file"); + qdict_set_default_str(opts, "file.filename", test_image); + qdict_set_default_str(opts, "file.locking", disable_lock ? "off" : "on= "); + + return blk_new_open(NULL, NULL, opts, flags, errp); +} + +#define RW true +#define RO false +#define SHARE true +#define EXCLU false + +static struct CompatData { + bool write_1; + bool share_1; + bool write_2; + bool share_2; + bool compatible; +} compat_data[] =3D { + /* Write 1, Share 1, Write 2, Share 2, Compatible. */ + { RO, SHARE, RO, SHARE, true, }, + { RO, SHARE, RO, EXCLU, true, }, + { RO, SHARE, RW, SHARE, true, }, + { RO, SHARE, RW, EXCLU, true, }, + + { RO, EXCLU, RO, EXCLU, true, }, + { RO, EXCLU, RW, SHARE, false, }, + { RO, EXCLU, RW, EXCLU, false, }, + + { RW, SHARE, RW, SHARE, false, }, + { RW, SHARE, RW, EXCLU, false, }, + + { RW, EXCLU, RW, EXCLU, false, }, +}; + +static void dprint_flags(int flags) +{ + DPRINTF(" %8x", flags); + if (flags & BDRV_O_RDWR) { + DPRINTF(" RW"); + } else { + DPRINTF(" RO"); + } + if (flags & BDRV_O_UNSAFE_READ) { + DPRINTF(" SHARE"); + } else { + DPRINTF(" EXCLU"); + } + DPRINTF("\n"); +} + +/* Test one combination scenario. + * + * @flags1: The flags of the first blk. + * @flags2: The flags of the second blk. + * @disable1: The value for raw-posix disable-lock option of the first blk. + * @disable2: The value for raw-posix disable-lock option of the second bl= k. + * @from_reopen: Whether or not the first blk should get flags1 from a reo= pen. + * @initial: The source flags from which the blk1 is reopened, only + * effective if @from_reopen is true. + */ +static void do_test_compat_one(const char *format, + int flags1, int flags2, + bool disable1, bool disable2, + bool from_reopen, int initial_readonly, + bool compatible) +{ + int ret; + BlockBackend *blk1, *blk2; + int initial_flags =3D flags1; + Error *local_err =3D NULL; + + DPRINTF("\n=3D=3D=3D\ndo test compat one\n"); + DPRINTF("flags1:"); + dprint_flags(flags1); + DPRINTF("flags2:"); + dprint_flags(flags2); + DPRINTF("disable %d %d\n", disable1, disable2); + DPRINTF("from reopen %d, initial readonly: %d\n", from_reopen, initial= _readonly); + DPRINTF("compatible %d\n", compatible); + if (!from_reopen) { + blk1 =3D open_test_image(format, flags1, disable1, &local_err); + if (local_err) { + abort(); + } + } else { + if (initial_readonly) { + initial_flags &=3D ~BDRV_O_RDWR; + } else { + initial_flags |=3D BDRV_O_RDWR; + } + if ((initial_flags & BDRV_O_RDWR) !=3D (flags1 & BDRV_O_RDWR)) { + flags1 |=3D BDRV_O_ALLOW_RDWR; + initial_flags |=3D BDRV_O_ALLOW_RDWR; + } + DPRINTF("initial flags: "); + dprint_flags(initial_flags); + blk1 =3D open_test_image(format, initial_flags, disable1, &error_a= bort); + BlockReopenQueue *rq =3D NULL; + + rq =3D bdrv_reopen_queue(rq, blk_bs(blk1), NULL, flags1); + ret =3D bdrv_reopen_multiple(blk_get_aio_context(blk1), rq, &error= _abort); + g_assert_cmpint(ret, =3D=3D, 0); + } + g_assert_nonnull(blk1); + blk2 =3D open_test_image(format, flags2, disable2, &local_err); + if (compatible) { + g_assert_nonnull(blk2); + } else { + g_assert_null(blk2); + } + blk_unref(blk2); + if (from_reopen && initial_flags !=3D flags1) { + BlockReopenQueue *rq =3D NULL; + + rq =3D bdrv_reopen_queue(rq, blk_bs(blk1), NULL, initial_flags); + ret =3D bdrv_reopen_multiple(blk_get_aio_context(blk1), rq, &error= _abort); + g_assert_cmpint(ret, =3D=3D, 0); + } + blk_unref(blk1); +} + +static void do_test_compat(const char *format, + bool test_disable, bool from_reopen, + int initial_readonly) +{ + int i; + int flags1, flags2; + + for (i =3D 0; i < ARRAY_SIZE(compat_data); i++) { + struct CompatData *data =3D &compat_data[i]; + bool compat =3D data->compatible; + + flags1 =3D (data->write_1 ? BDRV_O_RDWR : 0) | + (data->share_1 ? BDRV_O_UNSAFE_READ : 0); + flags2 =3D (data->write_2 ? BDRV_O_RDWR : 0) | + (data->share_2 ? BDRV_O_UNSAFE_READ : 0); + if (!test_disable) { + do_test_compat_one(format, + flags1, flags2, false, false, + from_reopen, initial_readonly, compat); + + do_test_compat_one(format, + flags2, flags1, false, false, + from_reopen, initial_readonly, compat); + } else { + compat =3D true; + do_test_compat_one(format, + flags1, flags2, true, false, + from_reopen, initial_readonly, compat); + do_test_compat_one(format, + flags1, flags2, false, true, + from_reopen, initial_readonly, compat); + do_test_compat_one(format, + flags2, flags1, true, false, + from_reopen, initial_readonly, compat); + do_test_compat_one(format, + flags2, flags1, false, true, + from_reopen, initial_readonly, compat); + do_test_compat_one(format, + flags1, flags2, true, true, + from_reopen, initial_readonly, compat); + } + } +} + +static void test_compat(void) +{ + bdrv_img_create(test_image, "qcow2", NULL, NULL, NULL, TEST_IMAGE_SIZE, + BDRV_O_RDWR, &error_fatal, true); + do_test_compat("qcow2", false, false, false); +} + +static void test_compat_after_reopen(void) +{ + bdrv_img_create(test_image, "qcow2", NULL, NULL, NULL, TEST_IMAGE_SIZE, + BDRV_O_RDWR, &error_fatal, true); + do_test_compat("qcow2", false, true, false); + do_test_compat("qcow2", false, true, true); +} + +static void test_disable(void) +{ + bdrv_img_create(test_image, "qcow2", NULL, NULL, NULL, TEST_IMAGE_SIZE, + BDRV_O_RDWR, &error_fatal, true); + do_test_compat("qcow2", true, false, 0); + do_test_compat("qcow2", true, true, false); + do_test_compat("qcow2", true, true, true); +} + +static void test_0bytefile(void) +{ + int ret; + + ret =3D ftruncate(test_image_fd, 0); + g_assert_cmpint(ret, =3D=3D, 0); + do_test_compat("raw", false, false, 0); +} + +int main(int argc, char **argv) +{ +#ifndef F_OFD_SETLK + return 0; +#endif + int r; + test_image_fd =3D mkstemp(test_image); + g_assert(test_image_fd >=3D 0); + + qemu_init_main_loop(&error_fatal); + bdrv_init(); + + g_test_init(&argc, &argv, NULL); + g_test_add_func("/image-lock/compat", test_compat); + g_test_add_func("/image-lock/compat_after_reopen", test_compat_after_r= eopen); + g_test_add_func("/image-lock/disable", test_disable); + g_test_add_func("/image-lock/compat_0bytefile", test_0bytefile); + aio_context_acquire(qemu_get_aio_context()); + r =3D g_test_run(); + aio_context_release(qemu_get_aio_context()); + close(test_image_fd); + unlink(test_image); + return r; +} --=20 2.9.3