From nobody Fri Mar 29 00:36:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502460488520166.68195518129437; Fri, 11 Aug 2017 07:08:08 -0700 (PDT) Received: from localhost ([::1]:43157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAbd-0002PC-K3 for importer@patchew.org; Fri, 11 Aug 2017 10:08:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAZc-00016B-Sf for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgAZX-0002NG-Cu for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60000) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgAZU-0002LH-Ur; Fri, 11 Aug 2017 10:05:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D71A615A195; Fri, 11 Aug 2017 14:05:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80C8FD7676; Fri, 11 Aug 2017 14:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D71A615A195 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Aug 2017 16:05:30 +0200 Message-Id: <20170811140536.2792-2-kwolf@redhat.com> In-Reply-To: <20170811140536.2792-1-kwolf@redhat.com> References: <20170811140536.2792-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 11 Aug 2017 14:05:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/7] tests/multiboot: Fix whitespace failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Commit b43671f8 accidentally broke run_test.sh within tests/multiboot; due to a subtle change in whitespace. These two commands produce theh same output (at least, for sane $IFS of space-tab-newline): echo -e "...$@..." echo -e "...$*..." But that's only because echo inserts spaces between multiple arguments (the $@ case), while the $* form gives a single argument to echo with the spaces already present. But when converting to printf %b, there are no automatic spaces between multiple arguments, so we HAVE to use $*. It doesn't help that run_test.sh isn't part of 'make check'. Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/multiboot/run_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/multiboot/run_test.sh b/tests/multiboot/run_test.sh index c8f3da8f37..0278148b43 100755 --- a/tests/multiboot/run_test.sh +++ b/tests/multiboot/run_test.sh @@ -26,7 +26,7 @@ run_qemu() { local kernel=3D$1 shift =20 - printf %b "\n\n=3D=3D=3D Running test case: $kernel $@ =3D=3D=3D\n\n" = >> test.log + printf %b "\n\n=3D=3D=3D Running test case: $kernel $* =3D=3D=3D\n\n" = >> test.log =20 $QEMU \ -kernel $kernel \ --=20 2.13.4 From nobody Fri Mar 29 00:36:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502460547125306.56666867826675; Fri, 11 Aug 2017 07:09:07 -0700 (PDT) Received: from localhost ([::1]:43160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAcY-0003Gw-R9 for importer@patchew.org; Fri, 11 Aug 2017 10:09:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAZe-00017u-Sc for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgAZc-0002WO-JN for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48566) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgAZW-0002MU-SL; Fri, 11 Aug 2017 10:05:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D15F4B17E; Fri, 11 Aug 2017 14:05:53 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D8AB97DE5; Fri, 11 Aug 2017 14:05:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D15F4B17E 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Aug 2017 16:05:31 +0200 Message-Id: <20170811140536.2792-3-kwolf@redhat.com> In-Reply-To: <20170811140536.2792-1-kwolf@redhat.com> References: <20170811140536.2792-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 11 Aug 2017 14:05:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/7] vpc: Check failure of bdrv_getlength() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Eric Blake vpc_open() was checking for bdrv_getlength() failure in one, but not the other, location. Reported-by: Markus Armbruster Signed-off-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Jeff Cody Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- block/vpc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/vpc.c b/block/vpc.c index 574879ba7c..82911ebead 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -219,6 +219,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, uint64_t pagetable_size; int disk_type =3D VHD_DYNAMIC; int ret; + int64_t bs_size; =20 bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); @@ -411,7 +412,13 @@ static int vpc_open(BlockDriverState *bs, QDict *optio= ns, int flags, } } =20 - if (s->free_data_block_offset > bdrv_getlength(bs->file->bs)) { + bs_size =3D bdrv_getlength(bs->file->bs); + if (bs_size < 0) { + error_setg_errno(errp, -bs_size, "Unable to learn image size"); + ret =3D bs_size; + goto fail; + } + if (s->free_data_block_offset > bs_size) { error_setg(errp, "block-vpc: free_data_block_offset points aft= er " "the end of file. The image has been truncate= d."); ret =3D -EINVAL; --=20 2.13.4 From nobody Fri Mar 29 00:36:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502460520418786.6736996968259; Fri, 11 Aug 2017 07:08:40 -0700 (PDT) Received: from localhost ([::1]:43159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAcB-0002ot-0W for importer@patchew.org; Fri, 11 Aug 2017 10:08:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAZm-0001E0-QU for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgAZk-0002kg-Ek for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgAZZ-0002Oq-Ne; Fri, 11 Aug 2017 10:05:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A11D39B38; Fri, 11 Aug 2017 14:05:56 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2832696DE5; Fri, 11 Aug 2017 14:05:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A11D39B38 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Aug 2017 16:05:32 +0200 Message-Id: <20170811140536.2792-4-kwolf@redhat.com> In-Reply-To: <20170811140536.2792-1-kwolf@redhat.com> References: <20170811140536.2792-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 11 Aug 2017 14:05:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/7] qcow2: Drop debugging dump_refcounts() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Eric Blake It's been #if 0'd since its introduction in 2006, commit 585f8587. We can revive dead code if we need it, but in the meantime, it has bit-rotted (for example, not checking for failure in bdrv_getlength()). Signed-off-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Jeff Cody Reviewed-by: Kevin Wolf Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- block/qcow2.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index d7c600b5a2..99407403ea 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3798,27 +3798,6 @@ static ImageInfoSpecific *qcow2_get_specific_info(Bl= ockDriverState *bs) return spec_info; } =20 -#if 0 -static void dump_refcounts(BlockDriverState *bs) -{ - BDRVQcow2State *s =3D bs->opaque; - int64_t nb_clusters, k, k1, size; - int refcount; - - size =3D bdrv_getlength(bs->file->bs); - nb_clusters =3D size_to_clusters(s, size); - for(k =3D 0; k < nb_clusters;) { - k1 =3D k; - refcount =3D get_refcount(bs, k); - k++; - while (k < nb_clusters && get_refcount(bs, k) =3D=3D refcount) - k++; - printf("%" PRId64 ": refcount=3D%d nb=3D%" PRId64 "\n", k, refcoun= t, - k - k1); - } -} -#endif - static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos) { --=20 2.13.4 From nobody Fri Mar 29 00:36:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502460670124177.39573827517313; Fri, 11 Aug 2017 07:11:10 -0700 (PDT) Received: from localhost ([::1]:43199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAea-0005HJ-Ts for importer@patchew.org; Fri, 11 Aug 2017 10:11:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAZk-0001BY-Ij for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgAZe-0002ZX-Vd for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgAZb-0002S9-3o; Fri, 11 Aug 2017 10:05:59 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11F82C04A5AE; Fri, 11 Aug 2017 14:05:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF58B91B2E; Fri, 11 Aug 2017 14:05:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11F82C04A5AE 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Aug 2017 16:05:33 +0200 Message-Id: <20170811140536.2792-5-kwolf@redhat.com> In-Reply-To: <20170811140536.2792-1-kwolf@redhat.com> References: <20170811140536.2792-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 11 Aug 2017 14:05:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/7] qcow2: Check failure of bdrv_getlength() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Eric Blake qcow2_co_pwritev_compressed() should not call bdrv_truncate() if determining the size failed. Reported-by: Markus Armbruster Signed-off-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Jeff Cody Reviewed-by: Kevin Wolf Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- block/qcow2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index 99407403ea..40ba26c111 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3282,12 +3282,15 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, u= int64_t offset, z_stream strm; int ret, out_len; uint8_t *buf, *out_buf; - uint64_t cluster_offset; + int64_t cluster_offset; =20 if (bytes =3D=3D 0) { /* align end of file to a sector boundary to ease reading with sector based I/Os */ cluster_offset =3D bdrv_getlength(bs->file->bs); + if (cluster_offset < 0) { + return cluster_offset; + } return bdrv_truncate(bs->file, cluster_offset, PREALLOC_MODE_OFF, = NULL); } =20 --=20 2.13.4 From nobody Fri Mar 29 00:36:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502460662481127.46875435672246; Fri, 11 Aug 2017 07:11:02 -0700 (PDT) Received: from localhost ([::1]:43198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAeT-0005AU-4G for importer@patchew.org; Fri, 11 Aug 2017 10:11:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAZk-0001BA-3B for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgAZi-0002gQ-Sg for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60392) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgAZc-0002Vv-I8; Fri, 11 Aug 2017 10:06:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F9E5A1F63; Fri, 11 Aug 2017 14:05:59 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AFFC91B2E; Fri, 11 Aug 2017 14:05:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F9E5A1F63 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Aug 2017 16:05:34 +0200 Message-Id: <20170811140536.2792-6-kwolf@redhat.com> In-Reply-To: <20170811140536.2792-1-kwolf@redhat.com> References: <20170811140536.2792-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 11 Aug 2017 14:05:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/7] osdep: Add runtime OFD lock detection X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng Build time check of OFD lock is not sufficient and can cause image open errors when the runtime environment doesn't support it. Add a helper function to probe it at runtime, additionally. Also provide a qemu_has_ofd_lock() for callers to check the status. Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- include/qemu/osdep.h | 1 + util/osdep.c | 66 ++++++++++++++++++++++++++++++++++++++++++++----= ---- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 3b74f6fcb2..6855b94bbf 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -357,6 +357,7 @@ int qemu_dup(int fd); 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); +bool qemu_has_ofd_lock(void); =20 #if defined(__HAIKU__) && defined(__i386__) #define FMT_pid "%ld" diff --git a/util/osdep.c b/util/osdep.c index a2863c8e53..a479fedc4a 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -38,14 +38,6 @@ extern int madvise(caddr_t, size_t, int); #include "qemu/error-report.h" #include "monitor/monitor.h" =20 -#ifdef F_OFD_SETLK -#define QEMU_SETLK F_OFD_SETLK -#define QEMU_GETLK F_OFD_GETLK -#else -#define QEMU_SETLK F_SETLK -#define QEMU_GETLK F_GETLK -#endif - static bool fips_enabled =3D false; =20 static const char *hw_version =3D QEMU_HW_VERSION; @@ -82,6 +74,10 @@ int qemu_madvise(void *addr, size_t len, int advice) } =20 #ifndef _WIN32 + +static int fcntl_op_setlk =3D -1; +static int fcntl_op_getlk =3D -1; + /* * Dups an fd and sets the flags */ @@ -149,6 +145,54 @@ static int qemu_parse_fdset(const char *param) return qemu_parse_fd(param); } =20 +static void qemu_probe_lock_ops(void) +{ + if (fcntl_op_setlk =3D=3D -1) { +#ifdef F_OFD_SETLK + int fd; + int ret; + struct flock fl =3D { + .l_whence =3D SEEK_SET, + .l_start =3D 0, + .l_len =3D 0, + .l_type =3D F_WRLCK, + }; + + fd =3D open("/dev/null", O_RDWR); + if (fd < 0) { + fprintf(stderr, + "Failed to open /dev/null for OFD lock probing: %s\n", + strerror(errno)); + fcntl_op_setlk =3D F_SETLK; + fcntl_op_getlk =3D F_GETLK; + return; + } + ret =3D fcntl(fd, F_OFD_GETLK, &fl); + close(fd); + if (!ret) { + fcntl_op_setlk =3D F_OFD_SETLK; + fcntl_op_getlk =3D F_OFD_GETLK; + } else { + fcntl_op_setlk =3D F_SETLK; + fcntl_op_getlk =3D F_GETLK; + } +#else + fcntl_op_setlk =3D F_SETLK; + fcntl_op_getlk =3D F_GETLK; +#endif + } +} + +bool qemu_has_ofd_lock(void) +{ + qemu_probe_lock_ops(); +#ifdef F_OFD_SETLK + return fcntl_op_setlk =3D=3D F_OFD_SETLK; +#else + return false; +#endif +} + static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type) { int ret; @@ -158,7 +202,8 @@ static int qemu_lock_fcntl(int fd, int64_t start, int64= _t len, int fl_type) .l_len =3D len, .l_type =3D fl_type, }; - ret =3D fcntl(fd, QEMU_SETLK, &fl); + qemu_probe_lock_ops(); + ret =3D fcntl(fd, fcntl_op_setlk, &fl); return ret =3D=3D -1 ? -errno : 0; } =20 @@ -181,7 +226,8 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t le= n, bool exclusive) .l_len =3D len, .l_type =3D exclusive ? F_WRLCK : F_RDLCK, }; - ret =3D fcntl(fd, QEMU_GETLK, &fl); + qemu_probe_lock_ops(); + ret =3D fcntl(fd, fcntl_op_getlk, &fl); if (ret =3D=3D -1) { return -errno; } else { --=20 2.13.4 From nobody Fri Mar 29 00:36:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150246081964414.313475816747655; Fri, 11 Aug 2017 07:13:39 -0700 (PDT) Received: from localhost ([::1]:43476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAh0-0007ws-2e for importer@patchew.org; Fri, 11 Aug 2017 10:13:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAZo-0001Ef-N3 for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgAZk-0002kr-FL for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgAZe-0002YB-3X; Fri, 11 Aug 2017 10:06:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D3C424CD65; Fri, 11 Aug 2017 14:06:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9BDF96DF5; Fri, 11 Aug 2017 14:05:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D3C424CD65 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Aug 2017 16:05:35 +0200 Message-Id: <20170811140536.2792-7-kwolf@redhat.com> In-Reply-To: <20170811140536.2792-1-kwolf@redhat.com> References: <20170811140536.2792-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 11 Aug 2017 14:06:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/7] file-posix: Do runtime check for ofd lock API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Fam Zheng It is reported that on Windows Subsystem for Linux, ofd operations fail with -EINVAL. In other words, QEMU binary built with system headers that exports F_OFD_SETLK doesn't necessarily run in an environment that actually supports it: $ qemu-system-aarch64 ... -drive file=3Dtest.vhdx,if=3Dnone,id=3Dhd0 \ -device virtio-blk-pci,drive=3Dhd0 qemu-system-aarch64: -drive file=3Dtest.vhdx,if=3Dnone,id=3Dhd0: Failed to = unlock byte 100 qemu-system-aarch64: -drive file=3Dtest.vhdx,if=3Dnone,id=3Dhd0: Failed to = unlock byte 100 qemu-system-aarch64: -drive file=3Dtest.vhdx,if=3Dnone,id=3Dhd0: Failed to = lock byte 100 As a matter of fact this is not WSL specific. It can happen when running a QEMU compiled against a newer glibc on an older kernel, such as in a containerized environment. Let's do a runtime check to cope with that. Reported-by: Andrew Baumann Reviewed-by: Eric Blake Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/file-posix.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index f4de022ae0..cb3bfce147 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -457,22 +457,19 @@ static int raw_open_common(BlockDriverState *bs, QDic= t *options, switch (locking) { case ON_OFF_AUTO_ON: s->use_lock =3D true; -#ifndef F_OFD_SETLK - fprintf(stderr, - "File lock requested but OFD locking syscall is unavailabl= e, " - "falling back to POSIX file locks.\n" - "Due to the implementation, locks can be lost unexpectedly= .\n"); -#endif + if (!qemu_has_ofd_lock()) { + fprintf(stderr, + "File lock requested but OFD locking syscall is " + "unavailable, falling back to POSIX file locks.\n" + "Due to the implementation, locks can be lost " + "unexpectedly.\n"); + } break; case ON_OFF_AUTO_OFF: s->use_lock =3D false; break; case ON_OFF_AUTO_AUTO: -#ifdef F_OFD_SETLK - s->use_lock =3D true; -#else - s->use_lock =3D false; -#endif + s->use_lock =3D qemu_has_ofd_lock(); break; default: abort(); --=20 2.13.4 From nobody Fri Mar 29 00:36:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502460697152514.115597218331; Fri, 11 Aug 2017 07:11:37 -0700 (PDT) Received: from localhost ([::1]:43256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAf1-0005lZ-Oo for importer@patchew.org; Fri, 11 Aug 2017 10:11:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgAZv-0001Lg-Fi for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgAZs-00033i-Rl for qemu-devel@nongnu.org; Fri, 11 Aug 2017 10:06:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60620) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dgAZf-0002Zs-MR; Fri, 11 Aug 2017 10:06:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A26E3154E27; Fri, 11 Aug 2017 14:06:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 677DB96DE5; Fri, 11 Aug 2017 14:06:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A26E3154E27 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 11 Aug 2017 16:05:36 +0200 Message-Id: <20170811140536.2792-8-kwolf@redhat.com> In-Reply-To: <20170811140536.2792-1-kwolf@redhat.com> References: <20170811140536.2792-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 11 Aug 2017 14:06:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/7] qemu-iotests: fix 185 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 185 can sometimes produce wrong output like this: 185 2s ... - output mismatch (see 185.out.bad) --- /work/src/qemu/master/tests/qemu-iotests/185.out 2017-07-14 \ 15:14:29.520343805 +0300 +++ 185.out.bad 2017-08-07 16:51:02.231922900 +0300 @@ -37,7 +37,7 @@ {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, \ "event": "SHUTDOWN", "data": {"guest": false}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, \ "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", \ "len": 4194304, "offset": 4194304, "speed": 65536, "type": \ "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, \ "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", \ "len": 0, "offset": 0, "speed": 65536, "type": "mirror"}} =3D=3D=3D Start backup job and exit qemu =3D=3D=3D Failures: 185 Failed 1 of 1 tests This is because, under heavy load, the quit can happen before the first iteration of the mirror request has occurred. To make sure we've had time to iterate, let's just add a sleep for 0.5 seconds before quitting. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/185 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185 index 0eda371f27..f5b47e4c1a 100755 --- a/tests/qemu-iotests/185 +++ b/tests/qemu-iotests/185 @@ -156,6 +156,10 @@ _send_qemu_cmd $h \ 'speed': 65536 } }" \ "return" =20 +# If we don't sleep here 'quit' command may be handled before +# the first mirror iteration is done +sleep 0.5 + _send_qemu_cmd $h "{ 'execute': 'quit' }" "return" wait=3D1 _cleanup_qemu =20 --=20 2.13.4