From nobody Mon Apr 29 12:19:16 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 1502201220979475.9004661476912; Tue, 8 Aug 2017 07:07:00 -0700 (PDT) Received: from localhost ([::1]:42784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df59v-0006tf-Dm for importer@patchew.org; Tue, 08 Aug 2017 10:06:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52H-0000AO-66 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52B-00020R-1a for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:05 -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 1df51x-0001ty-KD; Tue, 08 Aug 2017 09:58:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77B5C8553D; Tue, 8 Aug 2017 13:58:44 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AC8E5C8BB; Tue, 8 Aug 2017 13:58:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 77B5C8553D 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:21 +0200 Message-Id: <20170808135838.11525-2-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 08 Aug 2017 13:58:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/18] qemu-iotests/109: Fix lock race condition 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 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: Cleber Rosa A race condition is currently present between the clean up attempt of the QEMU process and the execution of qemu-img. The actual (bad) output is: -Warning: Image size mismatch! -Images are identical. +qemu-img: Could not open '/tests/qemu-iotests/scratch/t.raw': = Failed to get "consistent read" lock +Is another process using the image? A KILL signal is sent to the QEMU process, but qemu-img may begin to run before the QEMU process is really gone. qemu-img will then attempt to open the TEST_IMG file before it can secure a lock on it. This attempts a more graceful shutdown, and waits for the QEMU process to exit. Signed-off-by: Cleber Rosa Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- tests/qemu-iotests/109 | 3 ++- tests/qemu-iotests/109.out | 56 ++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109 index 3b496a3918..d70b574d88 100755 --- a/tests/qemu-iotests/109 +++ b/tests/qemu-iotests/109 @@ -67,7 +67,8 @@ function run_qemu() _send_qemu_cmd $QEMU_HANDLE '' "BLOCK_JOB_COMPLETED" fi _send_qemu_cmd $QEMU_HANDLE '{"execute":"query-block-jobs"}' "return" - _cleanup_qemu + _send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return" + wait=3D1 _cleanup_qemu } =20 for fmt in qcow qcow2 qed vdi vmdk vpc; do diff --git a/tests/qemu-iotests/109.out b/tests/qemu-iotests/109.out index dc02f9eefa..c189e2833d 100644 --- a/tests/qemu-iotests/109.out +++ b/tests/qemu-iotests/109.out @@ -12,12 +12,17 @@ Specify the 'raw' format explicitly to remove the restr= ictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": 0,= "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 1024, "offset": 1024,= "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 102= 4, "offset": 1024, "paused": false, "speed": 0, "ready": true, "type": "mir= ror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1= 024, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -33,12 +38,17 @@ Specify the 'raw' format explicitly to remove the restr= ictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": 51= 2, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 197120, "offset": 197= 120, "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 197= 120, "offset": 197120, "paused": false, "speed": 0, "ready": true, "type": = "mirror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 197120, "offset":= 197120, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -54,12 +64,17 @@ Specify the 'raw' format explicitly to remove the restr= ictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": 26= 2144, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 327680, "offset": 327= 680, "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 327= 680, "offset": 327680, "paused": false, "speed": 0, "ready": true, "type": = "mirror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset":= 327680, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -75,12 +90,17 @@ Specify the 'raw' format explicitly to remove the restr= ictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": 0,= "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 1024, "offset": 1024,= "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 102= 4, "offset": 1024, "paused": false, "speed": 0, "ready": true, "type": "mir= ror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1= 024, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -96,12 +116,17 @@ Specify the 'raw' format explicitly to remove the rest= rictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": 0,= "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 65536, "offset": 6553= 6, "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 655= 36, "offset": 65536, "paused": false, "speed": 0, "ready": true, "type": "m= irror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": = 65536, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -117,12 +142,17 @@ Specify the 'raw' format explicitly to remove the res= trictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": 0,= "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 2560, "offset": 2560,= "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 256= 0, "offset": 2560, "paused": false, "speed": 0, "ready": true, "type": "mir= ror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2= 560, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -137,12 +167,17 @@ Specify the 'raw' format explicitly to remove the res= trictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": OF= FSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 2560, "offset": 2560,= "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 256= 0, "offset": 2560, "paused": false, "speed": 0, "ready": true, "type": "mir= ror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2= 560, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -157,12 +192,17 @@ Specify the 'raw' format explicitly to remove the res= trictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": OF= FSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 31457280, "offset": 3= 1457280, "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 314= 57280, "offset": 31457280, "paused": false, "speed": 0, "ready": true, "typ= e": "mirror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 31457280, "offset= ": 31457280, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -177,12 +217,17 @@ Specify the 'raw' format explicitly to remove the res= trictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": OF= FSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 327680, "offset": 327= 680, "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 327= 680, "offset": 327680, "paused": false, "speed": 0, "ready": true, "type": = "mirror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset":= 327680, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -197,12 +242,17 @@ Specify the 'raw' format explicitly to remove the res= trictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_ERROR", "data": {"device": "src", "operation": "write", "actio= n": "report"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": LEN, "offset": OF= FSET, "speed": 0, "type": "mirror", "error": "Operation not permitted"}} {"return": []} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 2048, "offset": 2048,= "speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 204= 8, "offset": 2048, "paused": false, "speed": 0, "ready": true, "type": "mir= ror"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2048, "offset": 2= 048, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. =20 @@ -216,12 +266,18 @@ Specify the 'raw' format explicitly to remove the res= trictions. {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 512, "offset": 512, "= speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 512= , "offset": 512, "paused": false, "speed": 0, "ready": true, "type": "mirro= r"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 51= 2, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. {"return": {}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "src", "len": 512, "offset": 512, "= speed": 0, "type": "mirror"}} {"return": [{"io-status": "ok", "device": "src", "busy": false, "len": 512= , "offset": 512, "paused": false, "speed": 0, "ready": true, "type": "mirro= r"}]} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 51= 2, "speed": 0, "type": "mirror"}} Warning: Image size mismatch! Images are identical. *** done --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 15022008900771006.4304401740961; Tue, 8 Aug 2017 07:01:30 -0700 (PDT) Received: from localhost ([::1]:42752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df54a-0002Fb-KN for importer@patchew.org; Tue, 08 Aug 2017 10:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52E-00007m-ES for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df529-0001zh-KL for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df51y-0001uQ-Vh; Tue, 08 Aug 2017 09:58:47 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8E62C047B60; Tue, 8 Aug 2017 13:58:45 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEC335C549; Tue, 8 Aug 2017 13:58:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B8E62C047B60 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:22 +0200 Message-Id: <20170808135838.11525-3-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Aug 2017 13:58:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/18] quorum: Set sectors-count to 0 when reporting a flush error 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 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: Alberto Garcia The QUORUM_REPORT_BAD event has fields to report the sector in which the error was detected and the number of affected sectors starting from that one. This is important for read and write errors, but not for flush errors. For flush errors the current code reports the total size of the disk image. That is however not useful information in this case. Moreover, the bdrv_getlength() call can fail, and there's no good way of handling that failure. Since we're reporting useless information and we cannot even guarantee to do it in a consistent way, this patch changes the code to report 0 instead in all cases. Reported-by: Markus Armbruster Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/quorum.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 55ba916655..d04da4f430 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -785,8 +785,7 @@ static coroutine_fn int quorum_co_flush(BlockDriverStat= e *bs) for (i =3D 0; i < s->num_children; i++) { result =3D bdrv_co_flush(s->children[i]->bs); if (result) { - quorum_report_bad(QUORUM_OP_TYPE_FLUSH, 0, - bdrv_getlength(s->children[i]->bs), + quorum_report_bad(QUORUM_OP_TYPE_FLUSH, 0, 0, s->children[i]->bs->node_name, result); result_value.l =3D result; quorum_count_vote(&error_votes, &result_value, i); --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201056657169.3558774106964; Tue, 8 Aug 2017 07:04:16 -0700 (PDT) Received: from localhost ([::1]:42767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df57H-0004WC-9A for importer@patchew.org; Tue, 08 Aug 2017 10:04:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52G-00009F-3L for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52B-00020W-2U for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32099) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df520-0001uw-3H; Tue, 08 Aug 2017 09:58:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFDEDA795; Tue, 8 Aug 2017 13:58:46 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05F5C5C8BB; Tue, 8 Aug 2017 13:58:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EFDEDA795 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:23 +0200 Message-Id: <20170808135838.11525-4-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 Aug 2017 13:58: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] [PULL 03/18] block/vhdx: check error return 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 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: Jeff Cody Calls to bdrv_getlength() were not checking for error. In vhdx.c, this can lead to truncating an image file, so it is a definite bug. In vhdx-log.c, the path for improper behavior is less clear, but it is best to check in any case. Some minor code movement of the log_guid intialization, as well. Reported-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Jeff Cody Signed-off-by: Kevin Wolf --- block/vhdx-log.c | 23 ++++++++++++++++++----- block/vhdx.c | 9 ++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 01278f3fc9..2e26fd46a5 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -491,6 +491,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHD= XState *s, uint32_t cnt, sectors_read; uint64_t new_file_size; void *data =3D NULL; + int64_t file_length; VHDXLogDescEntries *desc_entries =3D NULL; VHDXLogEntryHeader hdr_tmp =3D { 0 }; =20 @@ -510,10 +511,15 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVV= HDXState *s, if (ret < 0) { goto exit; } + file_length =3D bdrv_getlength(bs->file->bs); + if (file_length < 0) { + ret =3D file_length; + goto exit; + } /* if the log shows a FlushedFileOffset larger than our current fi= le * size, then that means the file has been truncated / corrupted, = and * we must refused to open it / use it */ - if (hdr_tmp.flushed_file_offset > bdrv_getlength(bs->file->bs)) { + if (hdr_tmp.flushed_file_offset > file_length) { ret =3D -EINVAL; goto exit; } @@ -543,7 +549,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHD= XState *s, goto exit; } } - if (bdrv_getlength(bs->file->bs) < desc_entries->hdr.last_file_off= set) { + if (file_length < desc_entries->hdr.last_file_offset) { new_file_size =3D desc_entries->hdr.last_file_offset; if (new_file_size % (1024*1024)) { /* round up to nearest 1MB boundary */ @@ -851,6 +857,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHD= XState *s, uint32_t partial_sectors =3D 0; uint32_t bytes_written =3D 0; uint64_t file_offset; + int64_t file_length; VHDXHeader *header; VHDXLogEntryHeader new_hdr; VHDXLogDescriptor *new_desc =3D NULL; @@ -904,6 +911,12 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVH= DXState *s, =20 sectors +=3D partial_sectors; =20 + file_length =3D bdrv_getlength(bs->file->bs); + if (file_length < 0) { + ret =3D file_length; + goto exit; + } + /* sectors is now how many sectors the data itself takes, not * including the header and descriptor metadata */ =20 @@ -913,11 +926,11 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVV= HDXState *s, .sequence_number =3D s->log.sequence, .descriptor_count =3D sectors, .reserved =3D 0, - .flushed_file_offset =3D bdrv_getlength(bs->file->bs), - .last_file_offset =3D bdrv_getlength(bs->file->bs), + .flushed_file_offset =3D file_length, + .last_file_offset =3D file_length, + .log_guid =3D header->log_guid, }; =20 - new_hdr.log_guid =3D header->log_guid; =20 desc_sectors =3D vhdx_compute_desc_sectors(new_hdr.descriptor_count); =20 diff --git a/block/vhdx.c b/block/vhdx.c index a9cecd2773..37224b8858 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1166,7 +1166,14 @@ exit: static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, uint64_t *new_offset) { - *new_offset =3D bdrv_getlength(bs->file->bs); + int64_t current_len; + + current_len =3D bdrv_getlength(bs->file->bs); + if (current_len < 0) { + return current_len; + } + + *new_offset =3D current_len; =20 /* per the spec, the address for a block is in units of 1MB */ *new_offset =3D ROUND_UP(*new_offset, 1024 * 1024); --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 150220089017015.336296933337508; Tue, 8 Aug 2017 07:01:30 -0700 (PDT) Received: from localhost ([::1]:42751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df54a-0002F6-0z for importer@patchew.org; Tue, 08 Aug 2017 10:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52G-00009X-97 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52B-00020l-GS for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50530) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df521-0001vU-Ac; Tue, 08 Aug 2017 09:58:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 365C98125F; Tue, 8 Aug 2017 13:58:48 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DFE95C8BB; Tue, 8 Aug 2017 13:58:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 365C98125F 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:24 +0200 Message-Id: <20170808135838.11525-5-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 08 Aug 2017 13:58:48 +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 04/18] block/vhdx: check for offset overflow to bdrv_truncate() 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 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: Jeff Cody VHDX uses uint64_t types for most offsets, following the VHDX spec. However, bdrv_truncate() takes an int64_t value for the truncating offset. Check for overflow before calling bdrv_truncate(). While we are here, replace the bit shifting with QEMU_ALIGN_UP as well. N.B.: For a compliant image this is not an issue, as the maximum VHDX image size is defined per the spec to be 64TB. Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Jeff Cody Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Kevin Wolf --- block/vhdx-log.c | 6 +++++- block/vhdx.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 2e26fd46a5..95972230f0 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -553,7 +553,11 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVH= DXState *s, new_file_size =3D desc_entries->hdr.last_file_offset; if (new_file_size % (1024*1024)) { /* round up to nearest 1MB boundary */ - new_file_size =3D ((new_file_size >> 20) + 1) << 20; + new_file_size =3D QEMU_ALIGN_UP(new_file_size, MiB); + if (new_file_size > INT64_MAX) { + ret =3D -EINVAL; + goto exit; + } bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF, = NULL); } } diff --git a/block/vhdx.c b/block/vhdx.c index 37224b8858..7ae4589879 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1177,6 +1177,9 @@ static int vhdx_allocate_block(BlockDriverState *bs, = BDRVVHDXState *s, =20 /* per the spec, the address for a block is in units of 1MB */ *new_offset =3D ROUND_UP(*new_offset, 1024 * 1024); + if (*new_offset > INT64_MAX) { + return -EINVAL; + } =20 return bdrv_truncate(bs->file, *new_offset + s->block_size, PREALLOC_MODE_OFF, NULL); --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201024531103.96265252664205; Tue, 8 Aug 2017 07:03:44 -0700 (PDT) Received: from localhost ([::1]:42765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df56l-00046q-84 for importer@patchew.org; Tue, 08 Aug 2017 10:03:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52H-0000BG-QQ for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52C-00022u-Sa for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46330) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df522-0001vy-NQ; Tue, 08 Aug 2017 09:58:50 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DD5C356F2; Tue, 8 Aug 2017 13:58:49 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76DCF5C549; Tue, 8 Aug 2017 13:58:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DD5C356F2 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: Tue, 8 Aug 2017 15:58:25 +0200 Message-Id: <20170808135838.11525-6-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 08 Aug 2017 13:58:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/18] block/vhdx: check error return of bdrv_flush() 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 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: Jeff Cody Reported-by: Kevin Wolf Signed-off-by: Jeff Cody Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/vhdx-log.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 95972230f0..a27dc059cd 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -565,7 +565,10 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVH= DXState *s, desc_entries =3D NULL; } =20 - bdrv_flush(bs); + ret =3D bdrv_flush(bs); + if (ret < 0) { + goto exit; + } /* once the log is fully flushed, indicate that we have an empty log * now. This also sets the log guid to 0, to indicate an empty log */ vhdx_log_reset(bs, s); @@ -1039,7 +1042,11 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, B= DRVVHDXState *s, =20 /* Make sure data written (new and/or changed blocks) is stable * on disk, before creating log entry */ - bdrv_flush(bs); + ret =3D bdrv_flush(bs); + if (ret < 0) { + goto exit; + } + ret =3D vhdx_log_write(bs, s, data, length, offset); if (ret < 0) { goto exit; @@ -1047,7 +1054,11 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, B= DRVVHDXState *s, logs.log =3D s->log; =20 /* Make sure log is stable on disk */ - bdrv_flush(bs); + ret =3D bdrv_flush(bs); + if (ret < 0) { + goto exit; + } + ret =3D vhdx_log_flush(bs, s, &logs); if (ret < 0) { goto exit; --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201181153942.4905553623408; Tue, 8 Aug 2017 07:06:21 -0700 (PDT) Received: from localhost ([::1]:42781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df59H-0006Qx-95 for importer@patchew.org; Tue, 08 Aug 2017 10:06:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52I-0000CA-PH for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52E-00025c-5U for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28492) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df523-0001wI-U0; Tue, 08 Aug 2017 09:58:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CCD097AE85; Tue, 8 Aug 2017 13:58:50 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE33A5C8BB; Tue, 8 Aug 2017 13:58:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CCD097AE85 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:26 +0200 Message-Id: <20170808135838.11525-7-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 08 Aug 2017 13:58:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/18] block/vhdx: check error return of bdrv_truncate() 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 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: Jeff Cody Signed-off-by: Jeff Cody Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/vhdx-log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index a27dc059cd..14b724ef7b 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -558,7 +558,11 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVH= DXState *s, ret =3D -EINVAL; goto exit; } - bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF, = NULL); + ret =3D bdrv_truncate(bs->file, new_file_size, PREALLOC_MO= DE_OFF, + NULL); + if (ret < 0) { + goto exit; + } } } qemu_vfree(desc_entries); --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201329410241.9870833819365; Tue, 8 Aug 2017 07:08:49 -0700 (PDT) Received: from localhost ([::1]:42798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5Bg-0000Ge-5n for importer@patchew.org; Tue, 08 Aug 2017 10:08:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52K-0000Dj-8N for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52F-00027A-BK for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58328) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df525-0001x0-AM; Tue, 08 Aug 2017 09:58:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F746C049D5C; Tue, 8 Aug 2017 13:58:52 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A5465C8BB; Tue, 8 Aug 2017 13:58:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F746C049D5C 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:27 +0200 Message-Id: <20170808135838.11525-8-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Aug 2017 13:58: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 07/18] block: drop bdrv_set_key from BlockDriver 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 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: Paolo Bonzini This is not used anymore since c01c214b69 ("block: remove all encryption handling APIs", 2017-07-11). Signed-off-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index d4f4ea7584..7571c0aaaf 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -127,7 +127,6 @@ struct BlockDriver { Error **errp); void (*bdrv_close)(BlockDriverState *bs); int (*bdrv_create)(const char *filename, QemuOpts *opts, Error **errp); - int (*bdrv_set_key)(BlockDriverState *bs, const char *key); int (*bdrv_make_empty)(BlockDriverState *bs); =20 void (*bdrv_refresh_filename)(BlockDriverState *bs, QDict *options); --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201372382469.1668663017563; Tue, 8 Aug 2017 07:09:32 -0700 (PDT) Received: from localhost ([::1]:42803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5CN-0000nq-3W for importer@patchew.org; Tue, 08 Aug 2017 10:09:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52M-0000GT-Ng for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52H-00028S-D5 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df526-0001xr-TE; Tue, 08 Aug 2017 09:58:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3B3B13A5D; Tue, 8 Aug 2017 13:58:53 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 804FE5C8BB; Tue, 8 Aug 2017 13:58:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B3B3B13A5D 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:28 +0200 Message-Id: <20170808135838.11525-9-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 Aug 2017 13:58:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/18] block/null: Remove 'filename' option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org 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 option was only added to allow 'null-co://' and 'null-aio://' as filenames, its value never served any actual purpose and was ignored. Nevertheless it was accepted as '-drive driver=3Dnull,filename=3Dfoo'. The correct way to enable the protocol prefixes (and that without adding a useless -drive option) is implementing .bdrv_parse_filename. This is what this patch does. Technically, this is an incompatible change, but the null block driver is only used for benchmarking, testing and debugging, and an option without effect isn't likely to be used by anyone anyway, so no bad effects are to be expected. Reported-by: Markus Armbruster Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Stefan Hajnoczi --- block/null.c | 31 ++++++++++++++++++++++++++----- tests/qemu-iotests/136 | 2 +- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/block/null.c b/block/null.c index 876f90965b..dd9c13f9ba 100644 --- a/block/null.c +++ b/block/null.c @@ -30,11 +30,6 @@ static QemuOptsList runtime_opts =3D { .head =3D QTAILQ_HEAD_INITIALIZER(runtime_opts.head), .desc =3D { { - .name =3D "filename", - .type =3D QEMU_OPT_STRING, - .help =3D "", - }, - { .name =3D BLOCK_OPT_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "size of the null block", @@ -54,6 +49,30 @@ static QemuOptsList runtime_opts =3D { }, }; =20 +static void null_co_parse_filename(const char *filename, QDict *options, + Error **errp) +{ + /* This functions only exists so that a null-co:// filename is accepted + * with the null-co driver. */ + if (strcmp(filename, "null-co://")) { + error_setg(errp, "The only allowed filename for this driver is " + "'null-co://'"); + return; + } +} + +static void null_aio_parse_filename(const char *filename, QDict *options, + Error **errp) +{ + /* This functions only exists so that a null-aio:// filename is accept= ed + * with the null-aio driver. */ + if (strcmp(filename, "null-aio://")) { + error_setg(errp, "The only allowed filename for this driver is " + "'null-aio://'"); + return; + } +} + static int null_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -242,6 +261,7 @@ static BlockDriver bdrv_null_co =3D { .instance_size =3D sizeof(BDRVNullState), =20 .bdrv_file_open =3D null_file_open, + .bdrv_parse_filename =3D null_co_parse_filename, .bdrv_close =3D null_close, .bdrv_getlength =3D null_getlength, =20 @@ -261,6 +281,7 @@ static BlockDriver bdrv_null_aio =3D { .instance_size =3D sizeof(BDRVNullState), =20 .bdrv_file_open =3D null_file_open, + .bdrv_parse_filename =3D null_aio_parse_filename, .bdrv_close =3D null_close, .bdrv_getlength =3D null_getlength, =20 diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136 index 635b977552..4b994897af 100644 --- a/tests/qemu-iotests/136 +++ b/tests/qemu-iotests/136 @@ -75,7 +75,7 @@ sector =3D "%d" drive_args.append("stats-account-failed=3D%s" % (self.account_failed and "on" or "off")) self.create_blkdebug_file() - self.vm =3D iotests.VM().add_drive('blkdebug:%s:%s ' % + self.vm =3D iotests.VM().add_drive('blkdebug:%s:%s' % (blkdebug_file, self.test_img), ','.join(drive_args)) self.vm.launch() --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201101798141.27729879469837; Tue, 8 Aug 2017 07:05:01 -0700 (PDT) Received: from localhost ([::1]:42768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df580-000536-Hx for importer@patchew.org; Tue, 08 Aug 2017 10:05:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52N-0000HP-FK for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52I-00029G-Qc for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46526) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df528-0001ye-DY; Tue, 08 Aug 2017 09:58:56 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A3F1356EC; Tue, 8 Aug 2017 13:58:55 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEDD35C549; Tue, 8 Aug 2017 13:58:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4A3F1356EC 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: Tue, 8 Aug 2017 15:58:29 +0200 Message-Id: <20170808135838.11525-10-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 08 Aug 2017 13:58:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/18] vmdk: Fix error handling/reporting of vmdk_check 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 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 Errors from the callees must be captured and propagated to our caller, ensure this for both find_extent() and bdrv_getlength(). Reported-by: Markus Armbruster Signed-off-by: Fam Zheng Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/vmdk.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 0fc97391a6..c665bcc977 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2236,6 +2236,7 @@ static int vmdk_check(BlockDriverState *bs, BdrvCheck= Result *result, fprintf(stderr, "ERROR: could not find extent for sector %" PRId64 "\n= ", sector_num); + ret =3D -EINVAL; break; } ret =3D get_cluster_offset(bs, extent, NULL, @@ -2247,19 +2248,28 @@ static int vmdk_check(BlockDriverState *bs, BdrvChe= ckResult *result, PRId64 "\n", sector_num); break; } - if (ret =3D=3D VMDK_OK && - cluster_offset >=3D bdrv_getlength(extent->file->bs)) - { - fprintf(stderr, - "ERROR: cluster offset for sector %" - PRId64 " points after EOF\n", sector_num); - break; + if (ret =3D=3D VMDK_OK) { + int64_t extent_len =3D bdrv_getlength(extent->file->bs); + if (extent_len < 0) { + fprintf(stderr, + "ERROR: could not get extent file length for secto= r %" + PRId64 "\n", sector_num); + ret =3D extent_len; + break; + } + if (cluster_offset >=3D extent_len) { + fprintf(stderr, + "ERROR: cluster offset for sector %" + PRId64 " points after EOF\n", sector_num); + ret =3D -EINVAL; + break; + } } sector_num +=3D extent->cluster_sectors; } =20 result->corruptions++; - return 0; + return ret; } =20 static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201537485639.2738216658199; Tue, 8 Aug 2017 07:12:17 -0700 (PDT) Received: from localhost ([::1]:42821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5F2-0003Vg-3v for importer@patchew.org; Tue, 08 Aug 2017 10:12:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52R-0000Lc-04 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52L-0002B2-9e for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39564) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df529-0001zX-Qz; Tue, 08 Aug 2017 09:58:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AEEF64A6E1; Tue, 8 Aug 2017 13:58:56 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B1E45C8BB; Tue, 8 Aug 2017 13:58:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AEEF64A6E1 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: Tue, 8 Aug 2017 15:58:30 +0200 Message-Id: <20170808135838.11525-11-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 08 Aug 2017 13:58:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/18] block: respect error code from bdrv_getlength in handle_aiocb_write_zeroes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org 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: "Denis V. Lunev" Original idea beyond the code in question was the following: we have failed to write zeroes with fallocate(FALLOC_FL_ZERO_RANGE) as the simplest approach and via fallocate(FALLOC_FL_PUNCH_HOLE)/fallocate(0). We have the only chance now: if the request comes beyond end of the file. Thus we should calculate file length and respect the error code from that op. Signed-off-by: Denis V. Lunev CC: Markus Armbruster CC: Kevin Wolf CC: Max Reitz CC: Stefan Hajnoczi Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/file-posix.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index cfbb236f6f..f4de022ae0 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1339,6 +1339,9 @@ static ssize_t handle_aiocb_write_zeroes(RawPosixAIOD= ata *aiocb) #if defined(CONFIG_FALLOCATE) || defined(CONFIG_XFS) BDRVRawState *s =3D aiocb->bs->opaque; #endif +#ifdef CONFIG_FALLOCATE + int64_t len; +#endif =20 if (aiocb->aio_type & QEMU_AIO_BLKDEV) { return handle_aiocb_write_zeroes_block(aiocb); @@ -1381,7 +1384,10 @@ static ssize_t handle_aiocb_write_zeroes(RawPosixAIO= Data *aiocb) #endif =20 #ifdef CONFIG_FALLOCATE - if (s->has_fallocate && aiocb->aio_offset >=3D bdrv_getlength(aiocb->b= s)) { + /* Last resort: we are trying to extend the file with zeroed data. This + * can be done via fallocate(fd, 0) */ + len =3D bdrv_getlength(aiocb->bs); + if (s->has_fallocate && len >=3D 0 && aiocb->aio_offset >=3D len) { int ret =3D do_fallocate(s->fd, 0, aiocb->aio_offset, aiocb->aio_n= bytes); if (ret =3D=3D 0 || ret !=3D -ENOTSUP) { return ret; --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201500977550.792417115785; Tue, 8 Aug 2017 07:11:40 -0700 (PDT) Received: from localhost ([::1]:42818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5ER-0002zC-Da for importer@patchew.org; Tue, 08 Aug 2017 10:11:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52R-0000Ld-1h for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52L-0002BA-Ee for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7921) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52B-00020I-31; Tue, 08 Aug 2017 09:58:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F209AC047B76; Tue, 8 Aug 2017 13:58:57 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF76E5C8BB; Tue, 8 Aug 2017 13:58:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F209AC047B76 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:31 +0200 Message-Id: <20170808135838.11525-12-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Aug 2017 13:58:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/18] parallels: respect error code of bdrv_getlength() in allocate_clusters() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org 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: "Denis V. Lunev" If we can not get the file length, the state of BDS is broken completely. Return error to the caller. Signed-off-by: Denis V. Lunev CC: Markus Armbruster CC: Kevin Wolf CC: Max Reitz CC: Stefan Hajnoczi Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/parallels.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 5bbdfabb7a..6794e53c0b 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -192,7 +192,7 @@ static int64_t allocate_clusters(BlockDriverState *bs, = int64_t sector_num, int nb_sectors, int *pnum) { BDRVParallelsState *s =3D bs->opaque; - int64_t pos, space, idx, to_allocate, i; + int64_t pos, space, idx, to_allocate, i, len; =20 pos =3D block_status(s, sector_num, nb_sectors, pnum); if (pos > 0) { @@ -214,7 +214,11 @@ static int64_t allocate_clusters(BlockDriverState *bs,= int64_t sector_num, assert(idx < s->bat_size && idx + to_allocate <=3D s->bat_size); =20 space =3D to_allocate * s->tracks; - if (s->data_end + space > bdrv_getlength(bs->file->bs) >> BDRV_SECTOR_= BITS) { + len =3D bdrv_getlength(bs->file->bs); + if (len < 0) { + return len; + } + if (s->data_end + space > (len >> BDRV_SECTOR_BITS)) { int ret; space +=3D s->prealloc_size; if (s->prealloc_mode =3D=3D PRL_PREALLOC_MODE_FALLOCATE) { --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201254074962.7989490710584; Tue, 8 Aug 2017 07:07:34 -0700 (PDT) Received: from localhost ([::1]:42788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5AS-0007Vr-P8 for importer@patchew.org; Tue, 08 Aug 2017 10:07:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52S-0000MQ-3H for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52M-0002DU-VO for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37873) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52C-00020v-BC; Tue, 08 Aug 2017 09:59:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FF40356E1; Tue, 8 Aug 2017 13:58:59 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C3575C549; Tue, 8 Aug 2017 13:58:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3FF40356E1 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: Tue, 8 Aug 2017 15:58:32 +0200 Message-Id: <20170808135838.11525-13-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 08 Aug 2017 13:58: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 12/18] parallels: drop check that bdrv_truncate() is working 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 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: "Denis V. Lunev" This would be actually strange and error prone. If truncate() nowadays will fail, there is something fatally wrong. Let's check for that during the actual work. The only fallback case is when the file is not zero initialized. In this case we should switch to preallocation via fallocate(). Signed-off-by: Denis V. Lunev CC: Markus Armbruster CC: Kevin Wolf CC: Max Reitz CC: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/parallels.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6794e53c0b..e1e06d23cc 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -703,9 +703,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, goto fail_options; } =20 - if (!(flags & BDRV_O_RESIZE) || !bdrv_has_zero_init(bs->file->bs) || - bdrv_truncate(bs->file, bdrv_getlength(bs->file->bs), - PREALLOC_MODE_OFF, NULL) !=3D 0) { + if (!bdrv_has_zero_init(bs->file->bs)) { s->prealloc_mode =3D PRL_PREALLOC_MODE_FALLOCATE; } =20 --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201658485154.57888802243792; Tue, 8 Aug 2017 07:14:18 -0700 (PDT) Received: from localhost ([::1]:42829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5Gz-0005CS-4L for importer@patchew.org; Tue, 08 Aug 2017 10:14:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52S-0000MV-9P for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52N-0002EP-I3 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58670) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52D-00022y-HI; Tue, 08 Aug 2017 09:59:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70768C049D5C; Tue, 8 Aug 2017 13:59:00 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 801C35C549; Tue, 8 Aug 2017 13:58:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 70768C049D5C 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:33 +0200 Message-Id: <20170808135838.11525-14-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Aug 2017 13:59:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/18] block: Fix order in bdrv_replace_child() 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 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" Commit 8ee03995 refactored the code incorrectly and broke the release of permissions on the old BDS. Instead of changing the permissions to the new required values after removing the old BDS from the list of children, it only re-obtains the permissions it already had. Change the order of operations so that the old BDS is removed again before calculating the new required permissions. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: John Snow --- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index ce9cce7b3c..ab908cdc50 100644 --- a/block.c +++ b/block.c @@ -1933,6 +1933,8 @@ static void bdrv_replace_child(BdrvChild *child, Bloc= kDriverState *new_bs) BlockDriverState *old_bs =3D child->bs; uint64_t perm, shared_perm; =20 + bdrv_replace_child_noperm(child, new_bs); + if (old_bs) { /* Update permissions for old node. This is guaranteed to succeed * because we're just taking a parent away, so we're loosening @@ -1942,8 +1944,6 @@ static void bdrv_replace_child(BdrvChild *child, Bloc= kDriverState *new_bs) bdrv_set_perm(old_bs, perm, shared_perm); } =20 - bdrv_replace_child_noperm(child, new_bs); - if (new_bs) { bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm); bdrv_set_perm(new_bs, perm, shared_perm); --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502200879812505.1508175731658; Tue, 8 Aug 2017 07:01:19 -0700 (PDT) Received: from localhost ([::1]:42750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df54Q-000240-GJ for importer@patchew.org; Tue, 08 Aug 2017 10:01:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52U-0000Ow-F2 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52P-0002FP-Hl for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58778) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52E-00025g-T4; Tue, 08 Aug 2017 09:59:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C42E3C049D5C; Tue, 8 Aug 2017 13:59:01 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id B76FF5C549; Tue, 8 Aug 2017 13:59:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C42E3C049D5C 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:34 +0200 Message-Id: <20170808135838.11525-15-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Aug 2017 13:59: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 14/18] block: Allow reopen rw without BDRV_O_ALLOW_RDWR 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 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" BDRV_O_ALLOW_RDWR is a flag that tells whether qemu can internally reopen a node read-write temporarily because the user requested read-write for the top-level image, but qemu decided that read-only is enough for this node (a backing file). bdrv_reopen() is different, it is also used for cases where the user changed their mind and wants to update the options. There is no reason to forbid making a node read-write in that case. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: John Snow --- include/block/block.h | 3 ++- block.c | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 34770bb33a..ab80195378 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -436,7 +436,8 @@ int bdrv_is_allocated_above(BlockDriverState *top, Bloc= kDriverState *base, =20 bool bdrv_is_read_only(BlockDriverState *bs); bool bdrv_is_writable(BlockDriverState *bs); -int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **e= rrp); +int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, + bool ignore_allow_rdw, Error **errp); int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); bool bdrv_is_sg(BlockDriverState *bs); bool bdrv_is_inserted(BlockDriverState *bs); diff --git a/block.c b/block.c index ab908cdc50..2711c3dd3b 100644 --- a/block.c +++ b/block.c @@ -246,7 +246,8 @@ bool bdrv_is_writable(BlockDriverState *bs) return !bdrv_is_read_only(bs) && !(bs->open_flags & BDRV_O_INACTIVE); } =20 -int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **e= rrp) +int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, + bool ignore_allow_rdw, Error **errp) { /* Do not set read_only if copy_on_read is enabled */ if (bs->copy_on_read && read_only) { @@ -256,7 +257,9 @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool r= ead_only, Error **errp) } =20 /* Do not clear read_only if it is prohibited */ - if (!read_only && !(bs->open_flags & BDRV_O_ALLOW_RDWR)) { + if (!read_only && !(bs->open_flags & BDRV_O_ALLOW_RDWR) && + !ignore_allow_rdw) + { error_setg(errp, "Node '%s' is read only", bdrv_get_device_or_node_name(bs)); return -EPERM; @@ -269,7 +272,7 @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_= only, Error **errp) { int ret =3D 0; =20 - ret =3D bdrv_can_set_read_only(bs, read_only, errp); + ret =3D bdrv_can_set_read_only(bs, read_only, false, errp); if (ret < 0) { return ret; } @@ -2907,7 +2910,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state= , BlockReopenQueue *queue, * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RD= WR is * not set, or if the BDS still has copy_on_read enabled */ read_only =3D !(reopen_state->flags & BDRV_O_RDWR); - ret =3D bdrv_can_set_read_only(reopen_state->bs, read_only, &local_err= ); + ret =3D bdrv_can_set_read_only(reopen_state->bs, read_only, true, &loc= al_err); if (local_err) { error_propagate(errp, local_err); goto error; --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201408227832.715812007604; Tue, 8 Aug 2017 07:10:08 -0700 (PDT) Received: from localhost ([::1]:42806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5Cw-0001Qo-Rv for importer@patchew.org; Tue, 08 Aug 2017 10:10:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52W-0000RP-K4 for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52R-0002HI-TP for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52H-000287-K4; Tue, 08 Aug 2017 09:59:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 69BBEC0587DD; Tue, 8 Aug 2017 13:59:04 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 140A65C8BB; Tue, 8 Aug 2017 13:59:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 69BBEC0587DD 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: Tue, 8 Aug 2017 15:58:35 +0200 Message-Id: <20170808135838.11525-16-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 08 Aug 2017 13:59:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/18] block: Set BDRV_O_ALLOW_RDWR during rw reopen 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 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" Reopening an image should be consistent with opening it, so we should set BDRV_O_ALLOW_RDWR for any image that is reopened read-write like in bdrv_open_inherit(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: John Snow --- block.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 2711c3dd3b..3615a6809e 100644 --- a/block.c +++ b/block.c @@ -2729,8 +2729,11 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Blo= ckReopenQueue *bs_queue, bdrv_join_options(bs, options, old_options); QDECREF(old_options); =20 - /* bdrv_open() masks this flag out */ + /* bdrv_open_inherit() sets and clears some additional flags internall= y */ flags &=3D ~BDRV_O_PROTOCOL; + if (flags & BDRV_O_RDWR) { + flags |=3D BDRV_O_ALLOW_RDWR; + } =20 QLIST_FOREACH(child, &bs->children, next) { QDict *new_child_options; --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 150220179695282.76470984307048; Tue, 8 Aug 2017 07:16:36 -0700 (PDT) Received: from localhost ([::1]:42850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5JD-0007Zg-8K for importer@patchew.org; Tue, 08 Aug 2017 10:16:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52Z-0000Us-7x for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52U-0002It-FN for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39828) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52J-00029Z-Qn; Tue, 08 Aug 2017 09:59:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B309ADB93B; Tue, 8 Aug 2017 13:59:06 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9BB958858; Tue, 8 Aug 2017 13:59:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B309ADB93B 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: Tue, 8 Aug 2017 15:58:36 +0200 Message-Id: <20170808135838.11525-17-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 08 Aug 2017 13:59:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 16/18] qemu-io: Allow reopen read-write 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 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 allows qemu-iotests to test the switch between read-only and read-write mode for block devices. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: John Snow --- qemu-io-cmds.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 3eb42c6728..2811a89099 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1920,6 +1920,7 @@ static void reopen_help(void) " 'reopen -o lazy-refcounts=3Don' - activates lazy refcount writeback on a= qcow2 image\n" "\n" " -r, -- Reopen the image read-only\n" +" -w, -- Reopen the image read-write\n" " -c, -- Change the cache mode to the given value\n" " -o, -- Changes block driver options (cf. 'open' command)\n" "\n"); @@ -1942,7 +1943,7 @@ static const cmdinfo_t reopen_cmd =3D { .argmin =3D 0, .argmax =3D -1, .cfunc =3D reopen_f, - .args =3D "[-r] [-c cache] [-o options]", + .args =3D "[(-r|-w)] [-c cache] [-o options]", .oneline =3D "reopens an image with new options", .help =3D reopen_help, }; @@ -1955,11 +1956,12 @@ static int reopen_f(BlockBackend *blk, int argc, ch= ar **argv) int c; int flags =3D bs->open_flags; bool writethrough =3D !blk_enable_write_cache(blk); + bool has_rw_option =3D false; =20 BlockReopenQueue *brq; Error *local_err =3D NULL; =20 - while ((c =3D getopt(argc, argv, "c:o:r")) !=3D -1) { + while ((c =3D getopt(argc, argv, "c:o:rw")) !=3D -1) { switch (c) { case 'c': if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) { @@ -1974,7 +1976,20 @@ static int reopen_f(BlockBackend *blk, int argc, cha= r **argv) } break; case 'r': + if (has_rw_option) { + error_report("Only one -r/-w option may be given"); + return 0; + } flags &=3D ~BDRV_O_RDWR; + has_rw_option =3D true; + break; + case 'w': + if (has_rw_option) { + error_report("Only one -r/-w option may be given"); + return 0; + } + flags |=3D BDRV_O_RDWR; + has_rw_option =3D true; break; default: qemu_opts_reset(&reopen_opts); --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201048359144.59005127457533; Tue, 8 Aug 2017 07:04:08 -0700 (PDT) Received: from localhost ([::1]:42766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df579-0004Ok-5e for importer@patchew.org; Tue, 08 Aug 2017 10:04:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52c-0000Yd-Nl for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52X-0002Kc-Oh for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52M-0002Bs-Hk; Tue, 08 Aug 2017 09:59:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E8064E33A; Tue, 8 Aug 2017 13:59:09 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2FC55C8BB; Tue, 8 Aug 2017 13:59:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5E8064E33A 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: Tue, 8 Aug 2017 15:58:37 +0200 Message-Id: <20170808135838.11525-18-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 08 Aug 2017 13:59:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 17/18] qemu-iotests: Test reopen between read-only and read-write 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 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 serves as a regression test for the bugs that were just fixed for bdrv_reopen() between read-only and read-write mode. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: John Snow --- tests/qemu-iotests/187 | 69 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/187.out | 18 ++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 88 insertions(+) create mode 100755 tests/qemu-iotests/187 create mode 100644 tests/qemu-iotests/187.out diff --git a/tests/qemu-iotests/187 b/tests/qemu-iotests/187 new file mode 100755 index 0000000000..7bb783363c --- /dev/null +++ b/tests/qemu-iotests/187 @@ -0,0 +1,69 @@ +#!/bin/bash +# +# Test switching between read-only and read-write +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dkwolf@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +here=3D`pwd` +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f "$TEST_IMG.2" + rm -f "$TEST_IMG.3" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +size=3D64M +_make_test_img $size + +echo +echo "Start from read-only" +echo + +$QEMU_IO -r -c 'write 0 64k' $TEST_IMG | _filter_qemu_io +$QEMU_IO -r -c 'reopen -w' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io +$QEMU_IO -r -c 'reopen -w' -c 'reopen -r' -c 'write 0 64k' $TEST_IMG | _fi= lter_qemu_io + +echo +echo "Start from read-write" +echo + +$QEMU_IO -c 'write 0 64k' $TEST_IMG | _filter_qemu_io +$QEMU_IO -c 'reopen -r' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io +$QEMU_IO -c 'reopen -r' -c 'reopen -w' -c 'write 0 64k' $TEST_IMG | _filte= r_qemu_io + + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/187.out b/tests/qemu-iotests/187.out new file mode 100644 index 0000000000..68fb944cd5 --- /dev/null +++ b/tests/qemu-iotests/187.out @@ -0,0 +1,18 @@ +QA output created by 187 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 + +Start from read-only + +Block node is read-only +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Block node is read-only + +Start from read-write + +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +write failed: Operation not permitted +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 823811076d..1848077932 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -182,6 +182,7 @@ 183 rw auto migration 185 rw auto 186 rw auto +187 rw auto 188 rw auto quick 189 rw auto 190 rw auto quick --=20 2.13.4 From nobody Mon Apr 29 12:19:16 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 1502201824132180.1377167652846; Tue, 8 Aug 2017 07:17:04 -0700 (PDT) Received: from localhost ([::1]:42853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df5Je-0007z1-SC for importer@patchew.org; Tue, 08 Aug 2017 10:17:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1df52d-0000ZH-GE for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1df52Y-0002Ko-GS for qemu-devel@nongnu.org; Tue, 08 Aug 2017 09:59:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59260) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1df52O-0002E6-3I; Tue, 08 Aug 2017 09:59:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03798C047B7B; Tue, 8 Aug 2017 13:59:11 +0000 (UTC) Received: from dhcp-200-186.str.redhat.com (dhcp-200-186.str.redhat.com [10.33.200.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07EC5C8BB; Tue, 8 Aug 2017 13:59:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 03798C047B7B 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 8 Aug 2017 15:58:38 +0200 Message-Id: <20170808135838.11525-19-kwolf@redhat.com> In-Reply-To: <20170808135838.11525-1-kwolf@redhat.com> References: <20170808135838.11525-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Aug 2017 13:59:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 18/18] block/nfs: fix mutex assertion in nfs_file_close() 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 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: Jeff Cody Commit c096358e747e88fc7364e40e3c354ee0bb683960 introduced assertion checks for when qemu_mutex() functions are called without the corresponding qemu_mutex_init() having initialized the mutex. This uncovered a latent bug in qemu's nfs driver - in nfs_client_close(), the NFSClient structure is overwritten with zeros, prior to the mutex being destroyed. Go ahead and destroy the mutex in nfs_client_close(), and change where we call qemu_mutex_init() so that it is correctly balanced. There are also a couple of memory leaks obscured by the memset, so this fixes those as well. Finally, we should be able to get rid of the memset(), as it isn't necessary. Cc: qemu-stable@nongnu.org Signed-off-by: Jeff Cody Reviewed-by: Peter Lieven Reviewed-by: Stefan Hajnoczi Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- block/nfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/nfs.c b/block/nfs.c index d8db419957..bec16b72a6 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -433,19 +433,23 @@ static void nfs_client_close(NFSClient *client) if (client->context) { if (client->fh) { nfs_close(client->context, client->fh); + client->fh =3D NULL; } aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context= ), false, NULL, NULL, NULL, NULL); nfs_destroy_context(client->context); + client->context =3D NULL; } - memset(client, 0, sizeof(NFSClient)); + g_free(client->path); + qemu_mutex_destroy(&client->mutex); + qapi_free_NFSServer(client->server); + client->server =3D NULL; } =20 static void nfs_file_close(BlockDriverState *bs) { NFSClient *client =3D bs->opaque; nfs_client_close(client); - qemu_mutex_destroy(&client->mutex); } =20 static NFSServer *nfs_config(QDict *options, Error **errp) @@ -498,6 +502,7 @@ static int64_t nfs_client_open(NFSClient *client, QDict= *options, struct stat st; char *file =3D NULL, *strp =3D NULL; =20 + qemu_mutex_init(&client->mutex); opts =3D qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { @@ -660,7 +665,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *o= ptions, int flags, if (ret < 0) { return ret; } - qemu_mutex_init(&client->mutex); + bs->total_sectors =3D ret; ret =3D 0; return ret; --=20 2.13.4