From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547153; cv=none; d=zohomail.com; s=zohoarc; b=Er5glvuBJqYVf7KdBxO4fC/QVPN/C0cIpbLvi9d3dgANP5hPZix2NB40fwjdO1PiKxeCmartvO95TTVvTIkP6V+pwAd7uK9+11/RyMjUJOfthbUTE3CUopYafd8G1TECWQ8gdwl3VHdToePNEW5wd/vKHocT2tE/6IMnrMOkDfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547153; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EXPHia+QY6PWIiHlRICaayf4bn1MBVx2ww07ykyxOSM=; b=N/s0I+xOeE06PzpqAiezTcJvEoYHmyZIjLrZp3iNuYHoz5D3rAtuMJQLqCqoTA/Fe64WxzfTG6WwGKyUD26TgnpuAjfBS3kyq91k4J9cz3pVsOUI4FooGK/aSTWuRBtiKZHzKH/5qiQui7vif+6t5iROYOPNmwWd1z5KjCBFk6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547153812760.1652756566285; Fri, 15 May 2020 05:52:33 -0700 (PDT) Received: from localhost ([::1]:36078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZpI-0005c4-67 for importer@patchew.org; Fri, 15 May 2020 08:52:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZid-0002AJ-3u for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:39 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49150 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZiZ-00025b-CA for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-348-V9et0d0FNU6yIqU36aZEVQ-1; Fri, 15 May 2020 08:45:32 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CBD1835B42; Fri, 15 May 2020 12:45:31 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C8F92E16F; Fri, 15 May 2020 12:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EXPHia+QY6PWIiHlRICaayf4bn1MBVx2ww07ykyxOSM=; b=OSWhddbfI2Ty4JAlkdR3vAC75bwqx65QGJL0SEZCJweoK7Um86Q7Rnlj132fFF+LIuqki6 8zf+DzEuhMQMBSYLY9NE64oU2iroeY5fN3slsF++GgZ2iQ8tSG3eOYDO4iAyXKRNZUsp5e Fj/oilVgw5nLLHKRSdsCbwSXvitQ+0s= X-MC-Unique: V9et0d0FNU6yIqU36aZEVQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 01/51] iotests/109: Don't mirror with mismatched size Date: Fri, 15 May 2020 14:44:31 +0200 Message-Id: <20200515124521.335403-2-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This patch makes the raw image the same size as the file in a different format that is mirrored as raw to it to avoid errors when mirror starts to enforce that source and target are the same size. We check only that the first 512 bytes are zeroed (instead of 64k) because some image formats create image files that are smaller than 64k, so trying to read 64k would result in I/O errors. Apart from this, 512 is more appropriate anyway because the raw format driver protects specifically the first 512 bytes. Signed-off-by: Kevin Wolf Message-Id: <20200511135825.219437-2-kwolf@redhat.com> Reviewed-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- tests/qemu-iotests/109 | 10 ++--- tests/qemu-iotests/109.out | 74 +++++++++++++------------------- tests/qemu-iotests/common.filter | 5 +++ 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109 index 5bc2e9b001..3ffeaf3c55 100755 --- a/tests/qemu-iotests/109 +++ b/tests/qemu-iotests/109 @@ -77,14 +77,14 @@ for fmt in qcow qcow2 qed vdi vmdk vpc; do echo "=3D=3D=3D Writing a $fmt header into raw =3D=3D=3D" echo =20 - _make_test_img 64M TEST_IMG=3D"$TEST_IMG.src" IMGFMT=3D$fmt _make_test_img 64M + _make_test_img $(du -b "$TEST_IMG.src" | cut -f1) | _filter_img_create= _size =20 # This first test should fail: The image format was probed, we may not # write an image header at the start of the image run_qemu "$TEST_IMG" "$TEST_IMG.src" "" "BLOCK_JOB_ERROR" | _filter_block_job_len - $QEMU_IO -c 'read -P 0 0 64k' "$TEST_IMG" | _filter_qemu_io + $QEMU_IO -c 'read -P 0 0 512' "$TEST_IMG" | _filter_qemu_io =20 =20 # When raw was explicitly specified, the same must succeed @@ -103,12 +103,12 @@ for sample_img in empty.bochs iotest-dirtylog-10G-4M.= vhdx parallels-v1 \ =20 # Can't use _use_sample_img because that isn't designed to be used mul= tiple # times and it overwrites $TEST_IMG (both breaks cleanup) - _make_test_img 64M bzcat "$SAMPLE_IMG_DIR/$sample_img.bz2" > "$TEST_IMG.src" + _make_test_img $(du -b "$TEST_IMG.src" | cut -f1) | _filter_img_create= _size =20 run_qemu "$TEST_IMG" "$TEST_IMG.src" "" "BLOCK_JOB_ERROR" | _filter_block_job_offset | _filter_block_job_len - $QEMU_IO -c 'read -P 0 0 64k' "$TEST_IMG" | _filter_qemu_io + $QEMU_IO -c 'read -P 0 0 512' "$TEST_IMG" | _filter_qemu_io =20 run_qemu "$TEST_IMG" "$TEST_IMG.src" "'format': 'raw'," "BLOCK_JOB_REA= DY" $QEMU_IMG compare -f raw -F raw "$TEST_IMG" "$TEST_IMG.src" @@ -119,8 +119,8 @@ echo "=3D=3D=3D Write legitimate MBR into raw =3D=3D=3D" echo =20 for sample_img in grub_mbr.raw; do - _make_test_img 64M bzcat "$SAMPLE_IMG_DIR/$sample_img.bz2" > "$TEST_IMG.src" + _make_test_img $(du -b "$TEST_IMG.src" | cut -f1) | _filter_img_create= _size =20 run_qemu "$TEST_IMG" "$TEST_IMG.src" "" "BLOCK_JOB_READY" $QEMU_IMG compare -f raw -F raw "$TEST_IMG" "$TEST_IMG.src" diff --git a/tests/qemu-iotests/109.out b/tests/qemu-iotests/109.out index 884f65f18d..ad739df46c 100644 --- a/tests/qemu-iotests/109.out +++ b/tests/qemu-iotests/109.out @@ -2,8 +2,8 @@ QA output created by 109 =20 =3D=3D=3D Writing a qcow header into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -23,8 +23,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t.r= aw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -43,13 +43,12 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1= 024, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Writing a qcow2 header into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -69,8 +68,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t.r= aw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -89,13 +88,12 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 197120, "offset":= 197120, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Writing a qed header into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -115,8 +113,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -135,13 +133,12 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset":= 327680, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Writing a vdi header into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -161,8 +158,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -181,13 +178,12 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 1024, "offset": 1= 024, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Writing a vmdk header into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -207,8 +203,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -227,13 +223,12 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 65536, "offset": = 65536, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Writing a vpc header into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -253,8 +248,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -273,12 +268,11 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2= 560, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Copying sample image empty.bochs into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -298,8 +292,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -318,12 +312,11 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2560, "offset": 2= 560, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Copying sample image iotest-dirtylog-10G-4M.vhdx into raw =3D=3D= =3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -343,8 +336,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -363,12 +356,11 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 31457280, "offset= ": 31457280, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Copying sample image parallels-v1 into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -388,8 +380,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -408,12 +400,11 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 327680, "offset":= 327680, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Copying sample image simple-pattern.cloop into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -433,8 +424,8 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"execute":"quit"} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} -read 65536/65536 bytes at offset 0 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -453,12 +444,11 @@ read 65536/65536 bytes at offset 0 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 2048, "offset": 2= 048, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. =20 =3D=3D=3D Write legitimate MBR into raw =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3DSIZE { 'execute': 'qmp_capabilities' } {"return": {}} {'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_= DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}} @@ -480,7 +470,6 @@ WARNING: Image format was not specified for 'TEST_DIR/t= .raw' and probing guessed {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 51= 2, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. { 'execute': 'qmp_capabilities' } {"return": {}} @@ -500,6 +489,5 @@ Images are identical. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "src", "len": 512, "offset": 51= 2, "speed": 0, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "src"}} -Warning: Image size mismatch! Images are identical. *** done diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 279e0bbb0d..03e4f71808 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -156,6 +156,11 @@ _filter_img_create() -e "s# compression_type=3D[a-zA-Z0-9]\\+##g" } =20 +_filter_img_create_size() +{ + $SED -e "s# size=3D[0-9]\\+# size=3DSIZE#g" +} + _filter_img_info() { if [[ "$1" =3D=3D "--format-specific" ]]; then --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547023; cv=none; d=zohomail.com; s=zohoarc; b=ZUYRlfl5KphmrdLW5RZk+xCLslYt7Y4in0eovqfje6Ve3Oopnb0BMkR1YXlk4gvkvUZXSMlP5+ULYAtQzYaTDqsr7kdp+evgJc94BbijLW1PvJhHhVrxR+IgnVfnNb27zZjTaCqe2yOt8adGdKREQhnWynq0dKZjtcOLZpQD7AU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547023; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UDyGmwNluSmj3AKzcdp88iWWWctet5DfvVCBxbzUFQk=; b=CRWSw3UwlKH0dty7MDpYDQ/s6V2cUf4Xcw4/IWrY+Ax49H0oyhX2GRflNW/jjeuGA+DX2ebVswi7pxl1hbGQi5q4BVGMMaXMx+S5ZBqjBOgk79oEaSLCUkyPqYWPpQv1e0Me8BEzuf0wB0m5kpxEpsCBi7/B7juOwynzzO0pQOc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158954702332611.315750458839034; Fri, 15 May 2020 05:50:23 -0700 (PDT) Received: from localhost ([::1]:55574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZnC-0001yU-0g for importer@patchew.org; Fri, 15 May 2020 08:50:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZic-000295-Ir for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:38 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:58551 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZib-000260-7d for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-Uec38bWgOMOH3dTzbeKLlg-1; Fri, 15 May 2020 08:45:33 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8068B8014D7; Fri, 15 May 2020 12:45:32 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 860F82E024; Fri, 15 May 2020 12:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UDyGmwNluSmj3AKzcdp88iWWWctet5DfvVCBxbzUFQk=; b=EiLvKn9TdVIf/J0y3ehkYnbYcjGb9v0QbdXKxp0VpP0Isvf92+6nF0xQVKIWUfnVzMC3uR K48GY3bBMb27M/ECTVgTdGR9Er1e3CMxj7lLyWZ79TRjer8jiQki2yk+RIoxaF4qGRepSb hEkO0spW0LRuzWGB58GCENOjJ1e+9wI= X-MC-Unique: Uec38bWgOMOH3dTzbeKLlg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 02/51] iotests/229: Use blkdebug to inject an error Date: Fri, 15 May 2020 14:44:32 +0200 Message-Id: <20200515124521.335403-3-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 229 relies on the mirror running into an I/O error when the target is smaller than the source. After changing mirror to catch this condition while starting the job, this test case won't get a job that is paused for an I/O error any more. Use blkdebug instead to inject an error. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Message-Id: <20200511135825.219437-3-kwolf@redhat.com> Reviewed-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- tests/qemu-iotests/229 | 15 +++++++++++---- tests/qemu-iotests/229.out | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229 index 866168b236..a5d4e5d4f2 100755 --- a/tests/qemu-iotests/229 +++ b/tests/qemu-iotests/229 @@ -33,6 +33,7 @@ _cleanup() _cleanup_test_img _rm_test_img "$TEST_IMG" _rm_test_img "$DEST_IMG" + rm -f "$TEST_DIR/blkdebug.conf" } trap "_cleanup; exit \$status" 0 1 2 3 15 =20 @@ -49,11 +50,10 @@ _supported_os Linux =20 DEST_IMG=3D"$TEST_DIR/d.$IMGFMT" TEST_IMG=3D"$TEST_DIR/b.$IMGFMT" +BLKDEBUG_CONF=3D"$TEST_DIR/blkdebug.conf" =20 _make_test_img 2M - -# destination for mirror will be too small, causing error -TEST_IMG=3D$DEST_IMG _make_test_img 1M +TEST_IMG=3D$DEST_IMG _make_test_img 2M =20 $QEMU_IO -c 'write 0 2M' "$TEST_IMG" | _filter_qemu_io =20 @@ -67,11 +67,18 @@ echo echo '=3D=3D=3D Starting drive-mirror, causing error & stop =3D=3D=3D' echo =20 +cat > "$BLKDEBUG_CONF" < (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589546984956760.257557966141; Fri, 15 May 2020 05:49:44 -0700 (PDT) Received: from localhost ([::1]:52502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZmZ-0000YZ-Ia for importer@patchew.org; Fri, 15 May 2020 08:49:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZid-0002BR-LG for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:39 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45008 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZib-00026D-JE for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-zIq8GXQUOj2LwJdjBP49Cw-1; Fri, 15 May 2020 08:45:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C37598015D2; Fri, 15 May 2020 12:45:33 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA5302E024; Fri, 15 May 2020 12:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tTDQuOj6/vfhHiyb5JXmwnqTWh9Otn9kphldHSufG2A=; b=XR4YO6shE7XgTxhJO6OeVCHW4nS6P8K9KL47zGEQp5lDVXFw4jkuCv4BCqm+0d+Rv3wW5L DTUoLHKXfW4ltm/6N6SAHQSEKcBVVohsb5lc3ISqz001dEXVlKV1Z+sEgpRRl6O1e9D554 YWhcu5kvmLkebWIDTU8xXhfoEWjP2vA= X-MC-Unique: zIq8GXQUOj2LwJdjBP49Cw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 03/51] mirror: Make sure that source and target size match Date: Fri, 15 May 2020 14:44:33 +0200 Message-Id: <20200515124521.335403-4-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If the target is shorter than the source, mirror would copy data until it reaches the end of the target and then fail with an I/O error when trying to write past the end. If the target is longer than the source, the mirror job would complete successfully, but the target wouldn't actually be an accurate copy of the source image (it would contain some additional garbage at the end). Fix this by checking that both images have the same size when the job starts. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Message-Id: <20200511135825.219437-4-kwolf@redhat.com> Reviewed-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- block/mirror.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index aca95c9bc9..201ffa26f9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -872,6 +872,7 @@ static int coroutine_fn mirror_run(Job *job, Error **er= rp) BlockDriverState *target_bs =3D blk_bs(s->target); bool need_drain =3D true; int64_t length; + int64_t target_length; BlockDriverInfo bdi; char backing_filename[2]; /* we only need 2 characters because we are = only checking for a NULL string */ @@ -887,24 +888,26 @@ static int coroutine_fn mirror_run(Job *job, Error **= errp) goto immediate_exit; } =20 + target_length =3D blk_getlength(s->target); + if (target_length < 0) { + ret =3D target_length; + goto immediate_exit; + } + /* Active commit must resize the base image if its size differs from t= he * active layer. */ if (s->base =3D=3D blk_bs(s->target)) { - int64_t base_length; - - base_length =3D blk_getlength(s->target); - if (base_length < 0) { - ret =3D base_length; - goto immediate_exit; - } - - if (s->bdev_length > base_length) { + if (s->bdev_length > target_length) { ret =3D blk_truncate(s->target, s->bdev_length, false, PREALLOC_MODE_OFF, 0, NULL); if (ret < 0) { goto immediate_exit; } } + } else if (s->bdev_length !=3D target_length) { + error_setg(errp, "Source and target image have different sizes"); + ret =3D -EINVAL; + goto immediate_exit; } =20 if (s->bdev_length =3D=3D 0) { --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547098; cv=none; d=zohomail.com; s=zohoarc; b=ZVazYqMb4uHoOxe/X1seyNBKAcfHlacqcy4fl7xWklV54noQw2mU/UE0n2UO2Qjh7vY/smN6DvvJ8OyjyY8CUORe4lub/1rpAazO9ASh5Kg7O4SNCWENJodX7NwBTFa4JS+nx1Q/YZ3E0xBubXlwnBH+vR575If99jzX6gJztZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547098; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tCfxbEtQqZs5JrNHeQ27Uq5tlNIM45o4v+oWJ8/63g0=; b=IyKXU/Md6leCTJe5sz8Xyn0Wc2iEWcj9mRQHGEwgN98A+sdZwXrfqkMrC8tIF/AwKUqHEXe6+tzq0uxDbsyZ0+GTsjTAg9KoPH0v4lg8mewMsIklTH3UxflkSZO4fJE9BHJSeAF4YNrDKUNq2rMlgXKrvzEMv50qcSnH5Xh52GM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547098815142.58934741084886; Fri, 15 May 2020 05:51:38 -0700 (PDT) Received: from localhost ([::1]:60958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZoP-0004Fe-JS for importer@patchew.org; Fri, 15 May 2020 08:51:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZih-0002JU-2n for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47692 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZif-000278-4x for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-GSGZH1FbNkWyx4jDjJqMfw-1; Fri, 15 May 2020 08:45:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1186819200C1; Fri, 15 May 2020 12:45:35 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18A3C2E024; Fri, 15 May 2020 12:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tCfxbEtQqZs5JrNHeQ27Uq5tlNIM45o4v+oWJ8/63g0=; b=OPML/uexAboaINJMdoTReN+3eVTwV4lT2HSmQvIOltGbMaY7vnelht7n1VsdTK65pAtMag 1IoaWdOJT6IAiT+48fhxGWSiH3/wSV55t+ASTOc8vraU2xynEDfuu4K01A+rnAQEsnV6Gl zgymgXYsN+pzSEdqztiJPIJOULzax6g= X-MC-Unique: GSGZH1FbNkWyx4jDjJqMfw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 04/51] iotests: Mirror with different source/target size Date: Fri, 15 May 2020 14:44:34 +0200 Message-Id: <20200515124521.335403-5-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This tests that the mirror job catches situations where the target node has a different size than the source node. It must also forbid resize operations when the job is already running. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Message-Id: <20200511135825.219437-5-kwolf@redhat.com> Reviewed-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- tests/qemu-iotests/041 | 45 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/041.out | 4 ++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 1812dd8479..601c756117 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -240,6 +240,49 @@ class TestSingleBlockdev(TestSingleDrive): target=3Dself.qmp_target) self.assert_qmp(result, 'error/class', 'GenericError') =20 + def do_test_resize(self, device, node): + def pre_finalize(): + if device: + result =3D self.vm.qmp('block_resize', device=3Ddevice, si= ze=3D65536) + self.assert_qmp(result, 'error/class', 'GenericError') + + result =3D self.vm.qmp('block_resize', node_name=3Dnode, size= =3D65536) + self.assert_qmp(result, 'error/class', 'GenericError') + + result =3D self.vm.qmp(self.qmp_cmd, job_id=3D'job0', device=3D'dr= ive0', + sync=3D'full', target=3Dself.qmp_target, + auto_finalize=3DFalse, auto_dismiss=3DFalse) + self.assert_qmp(result, 'return', {}) + + result =3D self.vm.run_job('job0', auto_finalize=3DFalse, + pre_finalize=3Dpre_finalize) + self.assertEqual(result, None) + + def test_source_resize(self): + self.do_test_resize('drive0', 'top') + + def test_target_resize(self): + self.do_test_resize(None, self.qmp_target) + + def do_test_target_size(self, size): + result =3D self.vm.qmp('block_resize', node_name=3Dself.qmp_target, + size=3Dsize) + self.assert_qmp(result, 'return', {}) + + result =3D self.vm.qmp(self.qmp_cmd, job_id=3D'job0', + device=3D'drive0', sync=3D'full', auto_dismis= s=3DFalse, + target=3Dself.qmp_target) + self.assert_qmp(result, 'return', {}) + + result =3D self.vm.run_job('job0') + self.assertEqual(result, 'Source and target image have different s= izes') + + def test_small_target(self): + self.do_test_target_size(self.image_len // 2) + + def test_large_target(self): + self.do_test_target_size(self.image_len * 2) + test_large_cluster =3D None test_image_not_found =3D None test_small_buffer2 =3D None @@ -251,6 +294,8 @@ class TestSingleDriveZeroLength(TestSingleDrive): =20 class TestSingleBlockdevZeroLength(TestSingleBlockdev): image_len =3D 0 + test_small_target =3D None + test_large_target =3D None =20 class TestSingleDriveUnalignedLength(TestSingleDrive): image_len =3D 1025 * 1024 diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index 877b76fd31..53abe11d73 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -..........................................................................= .................... +..........................................................................= .............................. ---------------------------------------------------------------------- -Ran 94 tests +Ran 104 tests =20 OK --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547020; cv=none; d=zohomail.com; s=zohoarc; b=GiaIyivEGb3woEnNnnoJjKGPlqNx8dUpuoja4GmXaFDPSz5+FN9t7P+yEy5FzKHwHBAyGKHb54kIWlsbg1qIwOPIp1tTAoY0BCxp73/r5OMTu8gTNaeW3547nDSGAB8iV+wCAmPbyGS+90QNDWG8s3IGNDOQ7lk4it8xvGbj17Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547020; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Fyi3nukATwLELbAJliwdhiY94zBfnD+xlptums6tQDk=; b=I2pmPjfRzGrm8x96QOfYmWeQ5qC1CYA0ieUlypFMNwiUu0fvweQyu7uRMC5u6KrzNVt1tjJTC1yExmYnKYhMi0t5ekaqhl5VomAsIslfARIxs4CRrI4sXOd/jYMbw6i8d91f5RpElDGv0wMFvBQbYI83UuznPx8mjgEkm6gMIeo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547020522446.4498381914284; Fri, 15 May 2020 05:50:20 -0700 (PDT) Received: from localhost ([::1]:55402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZn9-0001uT-5v for importer@patchew.org; Fri, 15 May 2020 08:50:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZif-0002F9-8X for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:41 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:35204 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZie-00026r-AI for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-Pz34IHz2Od6nLof-l0qzpQ-1; Fri, 15 May 2020 08:45:37 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 533C319200C2; Fri, 15 May 2020 12:45:36 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A79E2E024; Fri, 15 May 2020 12:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fyi3nukATwLELbAJliwdhiY94zBfnD+xlptums6tQDk=; b=UXMI/cQxgKKpBNTB7l7uNfxJSI7F1oUsJvLocwBq1E/CFgpk92FNqPhFx5Jp71TPA0kyF9 Yux8y8EapKFQv+A41lNzU2aO5xyuyg/E0QTFI/B0dub3FPKqg4B1UTQ3dzhcQoPTwcJyoa KP9lR49Q6rtbZ3hYR+8WcwDRqYyVfvE= X-MC-Unique: Pz34IHz2Od6nLof-l0qzpQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 05/51] block/replication.c: Avoid cancelling the job twice Date: Fri, 15 May 2020 14:44:35 +0200 Message-Id: <20200515124521.335403-6-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Lukas Straub If qemu in colo secondary mode is stopped, it crashes because s->backup_job is canceled twice: First with job_cancel_sync_all() in qemu_cleanup() and then in replication_stop(). Fix this by assigning NULL to s->backup_job when the job completes so replication_stop() and replication_do_checkpoint() won't touch the job. Signed-off-by: Lukas Straub Message-Id: <20200511090801.7ed5d8f3@luklap> Signed-off-by: Kevin Wolf --- block/replication.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/replication.c b/block/replication.c index 971f0fe266..c03980a192 100644 --- a/block/replication.c +++ b/block/replication.c @@ -398,6 +398,8 @@ static void backup_job_cleanup(BlockDriverState *bs) BDRVReplicationState *s =3D bs->opaque; BlockDriverState *top_bs; =20 + s->backup_job =3D NULL; + top_bs =3D bdrv_lookup_bs(s->top_id, s->top_id, NULL); if (!top_bs) { return; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547195; cv=none; d=zohomail.com; s=zohoarc; b=EdXYBAxmE+trV1K//Aqt7jAfyXzz3Q2CszyHxH1P96UAiic/HnpaNJUD05z9oNoi+oadFVToddFSUqerm6JTdVmZjK5mc8IEJsnUFn/kCace5ii2cW8mx5i9XrQCxFZ3WdTmsk4A3CfiP0K6vB5mlNuAhAsO41JuKQZuxiuGnE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547195; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=45oXRsfshnOH1954iXfeEdixhGXfX9DsYo4dNlXFFn4=; b=etjzw6ES0AXAbBGAgTL8kT5sfMR59O1I6IFHBawjmaKEdMxALaBrAhTiLn9PkGh+4zUNYavJyiQQQlfG+JUFuOX7IBopJAeWQBP5sryXXIJKOlaJ520iekNUwFGfzwAVq/ee32icT2vi7SD66lMvmB9X2XdACAWHhgO1VgQ31CY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547195060554.8249055044184; Fri, 15 May 2020 05:53:15 -0700 (PDT) Received: from localhost ([::1]:38186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZpx-0006Zq-84 for importer@patchew.org; Fri, 15 May 2020 08:53:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZij-0002OU-Ss for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:45 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42955 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZih-00027i-RB for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-1JvlwALlN82uMiHsKFGFVA-1; Fri, 15 May 2020 08:45:38 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95219107ACF3; Fri, 15 May 2020 12:45:37 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BD062E024; Fri, 15 May 2020 12:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=45oXRsfshnOH1954iXfeEdixhGXfX9DsYo4dNlXFFn4=; b=XuYjkf+QU3AomzKFEYPqrAle3myGxVtsyhR2/zCJck0wBfTBrqbv7BcATvKkFKPK/3iP6s aDGtPu5k8hZfwKauIFoI2P65kTagzbWR2kbP93KcfoaEVpG7Uxv7H1Gd8xsMFpwkOEfXR2 hWiYkAuYsB9iQ4XGHlk2rmgCnBeM6Ag= X-MC-Unique: 1JvlwALlN82uMiHsKFGFVA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 06/51] iotests: Fix incomplete type declarations Date: Fri, 15 May 2020 14:44:36 +0200 Message-Id: <20200515124521.335403-7-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We need to fix only a few places so that iotests.py can pass mypy --disallow-incomplete-defs, which seems to be a desirable option to have enabled in the long run. Signed-off-by: Kevin Wolf Message-Id: <20200511163529.349329-2-kwolf@redhat.com> Reviewed-by: Max Reitz Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6c0e781af7..1d7f6fd7cf 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1040,7 +1040,7 @@ def _verify_cache_mode(supported_cache_modes: Sequenc= e[str] =3D ()) -> None: if supported_cache_modes and (cachemode not in supported_cache_modes): notrun('not suitable for this cache mode: %s' % cachemode) =20 -def _verify_aio_mode(supported_aio_modes: Sequence[str] =3D ()): +def _verify_aio_mode(supported_aio_modes: Sequence[str] =3D ()) -> None: if supported_aio_modes and (aiomode not in supported_aio_modes): notrun('not suitable for this aio mode: %s' % aiomode) =20 @@ -1087,7 +1087,8 @@ def skip_if_unsupported(required_formats=3D(), read_o= nly=3DFalse): '''Skip Test Decorator Runs the test if all the required formats are whitelisted''' def skip_test_decorator(func): - def func_wrapper(test_case: QMPTestCase, *args, **kwargs): + def func_wrapper(test_case: QMPTestCase, *args: List[Any], + **kwargs: Dict[str, Any]) -> None: if callable(required_formats): fmts =3D required_formats(test_case) else: @@ -1097,9 +1098,8 @@ def skip_if_unsupported(required_formats=3D(), read_o= nly=3DFalse): if usf_list: msg =3D f'{test_case}: formats {usf_list} are not whitelis= ted' test_case.case_skip(msg) - return None else: - return func(test_case, *args, **kwargs) + func(test_case, *args, **kwargs) return func_wrapper return skip_test_decorator =20 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547413; cv=none; d=zohomail.com; s=zohoarc; b=NebNAOy3UkdG80yPcg4HlhSKd25VFw8sf6uHUVyANB9QBAkcL4sT1VEMZMblP4MAUh2oZ3WrJzhCcgb3LsxkbQNdftTHbvdh8docCzluni+OtrWQ+ZhRGQk1T+SisB0mfRwFN7WcSiqclwb0ap1G6/t/TyTlT/5MYfLHfkG8ISA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547413; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zFGIYOTWtWLuRkue4L5tXUmyf/BGmje7dO/Hk+0/J2M=; b=nscs9s+lWQtZcoFgiRN0CF6MSo3DsYo+5ei6CbA+S7NwvLEPiWZmw1auWjAVAdsmyZv7Z1QA0ZDTZsfsxywDKPJ1qpNixqhsXFo8woE4XSlZhrTpZ7aXJlLIJbIUDxElYgpjItd8mGKPOrx8+3iQvVE5eA7ZYzmzgYZ6FpQesLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547413956325.4698494377052; Fri, 15 May 2020 05:56:53 -0700 (PDT) Received: from localhost ([::1]:55138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZtU-0005py-L9 for importer@patchew.org; Fri, 15 May 2020 08:56:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZil-0002Qu-CU for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:47 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:46146 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZik-00028F-5P for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-RZvtCyK-Or25bHgr_tWd2w-1; Fri, 15 May 2020 08:45:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8C9219200C2; Fri, 15 May 2020 12:45:38 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFC1A2E024; Fri, 15 May 2020 12:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zFGIYOTWtWLuRkue4L5tXUmyf/BGmje7dO/Hk+0/J2M=; b=AflrEWQqCoJf4SmPSE1AAAhOnVLbyQu3AzXfcz9RI1MnrAH5sb1O7NZ9lQ6sJZn8FDPgLN Rl82rmOaqh4Ap9Fn+ASOEMoz1pZaRk5Pm6h89hU27AI5frujuESJvURv2YpMwArM55JG0S a6ubn81JbP/Q7NXrLMngeVrL1+ZdShQ= X-MC-Unique: RZvtCyK-Or25bHgr_tWd2w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 07/51] iotests: Run pylint and mypy in a testcase Date: Fri, 15 May 2020 14:44:37 +0200 Message-Id: <20200515124521.335403-8-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We made sure that iotests.py passes pylint. It would be a shame if we allowed new patches in that break this again, so let's just add a meta-test case that runs pylint on it. While we don't pass mypy --strict yet, we can already run it with a few options that would be part of --strict to make sure that we won't regress on these aspects at least until we can enable the full thing. Signed-off-by: Kevin Wolf Message-Id: <20200511163529.349329-3-kwolf@redhat.com> Reviewed-by: Max Reitz Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- tests/qemu-iotests/297 | 44 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/297.out | 3 +++ tests/qemu-iotests/group | 1 + 3 files changed, 48 insertions(+) create mode 100755 tests/qemu-iotests/297 create mode 100644 tests/qemu-iotests/297.out diff --git a/tests/qemu-iotests/297 b/tests/qemu-iotests/297 new file mode 100755 index 0000000000..5c5420712b --- /dev/null +++ b/tests/qemu-iotests/297 @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2020 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 . + +seq=3D$(basename $0) +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +# get standard environment +. ./common.rc + +if ! type -p "pylint-3" > /dev/null; then + _notrun "pylint-3 not found" +fi +if ! type -p "mypy" > /dev/null; then + _notrun "mypy not found" +fi + +pylint-3 --score=3Dn iotests.py + +MYPYPATH=3D../../python/ mypy --warn-unused-configs --disallow-subclassing= -any \ + --disallow-any-generics --disallow-incomplete-defs \ + --disallow-untyped-decorators --no-implicit-optional \ + --warn-redundant-casts --warn-unused-ignores \ + --no-implicit-reexport iotests.py + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/297.out b/tests/qemu-iotests/297.out new file mode 100644 index 0000000000..6acc843649 --- /dev/null +++ b/tests/qemu-iotests/297.out @@ -0,0 +1,3 @@ +QA output created by 297 +Success: no issues found in 1 source file +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 34175fd437..445c26f8d2 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -300,3 +300,4 @@ 289 rw quick 290 rw auto quick 292 rw auto quick +297 meta --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547511; cv=none; d=zohomail.com; s=zohoarc; b=MoSfLPkQHdx2N/2zGeL6FfGmYQHOCglIujRmUA6fisIt3tnsPMUHHsX6IfF46wvfWBomlmjZyc+hdT6/5PO+I3z0tkgjHlRYswxcSU3JRv4E6mO3v2jm0NnAjbVtSzSbKndy+jxGIhtPD9E0tvsLREQq8jCt9rcEnprYjzYqDXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547511; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BBEmMGqi6ZNN1IyZqPkJsTyC3XdJqJlJpc+mdmfSHvc=; b=FByDCBl9Z19w2Ch7WwVvicHCV3yH9tzfj9SAMT8PerJCCONWxysEE/4NsbA8qPiv06DfaiXy+myJb9xSiCn21BYyJO+rnjQrauVomGuvKxUKSCmIC/V0vR7D/SoG2ZJLSQhjBzHUc4HOvQwh5F0n/tDhHQMAJsEkNgvtyf5TwyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547511327356.84592776988336; Fri, 15 May 2020 05:58:31 -0700 (PDT) Received: from localhost ([::1]:35252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZv3-0001U6-VW for importer@patchew.org; Fri, 15 May 2020 08:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZil-0002Re-OL for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53231 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZik-00028Y-Ol for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-xXo0nGq6MbCS5OCEtoT_ZQ-1; Fri, 15 May 2020 08:45:41 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2620F100CCC6; Fri, 15 May 2020 12:45:40 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E1222E024; Fri, 15 May 2020 12:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BBEmMGqi6ZNN1IyZqPkJsTyC3XdJqJlJpc+mdmfSHvc=; b=XwFk3L//j96UTR+LwFb7+qf5tUmYD73YjDskn1UQgtKLzKQxlxS2/HOLZhLcr9q1s+sPky rZ7m+8zx4Iru8VlC9YAa0fLVkoIM1LBIHqjqTf+10joGGESHL27mHrZUGQe0W84YMZdqpj OYhQYP/YKxngPzxcwewnJiuBnTzju+A= X-MC-Unique: xXo0nGq6MbCS5OCEtoT_ZQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 08/51] block: Add bdrv_make_empty() Date: Fri, 15 May 2020 14:44:38 +0200 Message-Id: <20200515124521.335403-9-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Right now, all users of bdrv_make_empty() call the BlockDriver method directly. That is not only bad style, it is also wrong, unless the caller has a BdrvChild with a WRITE or WRITE_UNCHANGED permission. (WRITE_UNCHANGED suffices, because callers generally use this function to clear a node with a backing file after a commit operation.) Introduce bdrv_make_empty() that verifies that it does. Signed-off-by: Max Reitz Message-Id: <20200429141126.85159-2-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block.h | 1 + block.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index 4de8d8f8a6..8f3eb70df4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -352,6 +352,7 @@ BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOp= ts *opts, void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); void bdrv_refresh_limits(BlockDriverState *bs, Error **errp); int bdrv_commit(BlockDriverState *bs); +int bdrv_make_empty(BdrvChild *c, Error **errp); int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt); void bdrv_register(BlockDriver *bdrv); diff --git a/block.c b/block.c index 0653ccb913..c6a5c144b7 100644 --- a/block.c +++ b/block.c @@ -6764,3 +6764,26 @@ void bdrv_del_child(BlockDriverState *parent_bs, Bdr= vChild *child, Error **errp) =20 parent_bs->drv->bdrv_del_child(parent_bs, child, errp); } + +int bdrv_make_empty(BdrvChild *c, Error **errp) +{ + BlockDriver *drv =3D c->bs->drv; + int ret; + + assert(c->perm & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)); + + if (!drv->bdrv_make_empty) { + error_setg(errp, "%s does not support emptying nodes", + drv->format_name); + return -ENOTSUP; + } + + ret =3D drv->bdrv_make_empty(c->bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to empty %s", + c->bs->filename); + return ret; + } + + return 0; +} --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547296; cv=none; d=zohomail.com; s=zohoarc; b=ewIV1l657E07tbmuEwHytTfPBI+KRAGBI047Ahz5Q39aUCD4mH2TxFYveRQ9O/dbOIrdWMcwtOmL5HPGnjZDi/3B36xEba0y5mXKFIHMcaSe4oASw4xvRlh+g6D72Eu06M++w9uiu/TDqNdCxvLo5wlSLcEGs3V29W9WkM3RVaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547296; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oBF7fCfMe5jbzsXW//h34ma+BN+TM4yPDi0NoZ45ZdM=; b=KL6sDtW0ByfvqK67eNGAacdQmy+Tc0LEZx0mQxi+lmwSUrRIXaWaSrOJXqgiv5v7WGVUHpuNtmHhBDe0OhHcRoICxSEcOVkivH+cCcF8ZqonZVqdsgjGIGktYdQy9lDpfNZ3NncLe4JSFyJcLvBsz8jTkZu5FghJhxp82yKsgbo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547296913161.63553360695312; Fri, 15 May 2020 05:54:56 -0700 (PDT) Received: from localhost ([::1]:46686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZrZ-00020K-K0 for importer@patchew.org; Fri, 15 May 2020 08:54:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZil-0002QP-0z for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:47 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23510 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZij-00027z-EV for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-506-Wpcmy6lTOZOXnvqqbKhAAw-1; Fri, 15 May 2020 08:45:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69030835B41; Fri, 15 May 2020 12:45:41 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7005F2E024; Fri, 15 May 2020 12:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oBF7fCfMe5jbzsXW//h34ma+BN+TM4yPDi0NoZ45ZdM=; b=OS+4hVugmsi4wnTx+hbQUj589kHlzSIDwVFJhJWeUlWX+0jZQSArVoELFPzbH2seeD9RnY rAuwlil93jtNCYN9mGXxMKEzqnrY4f5DJzSG1ZknAJGTddpsZCyoh1aZJtOCdumABBENGB ++jDWrSYPZQY4CL6yRxwAH5gh7DWX0U= X-MC-Unique: Wpcmy6lTOZOXnvqqbKhAAw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 09/51] block: Add blk_make_empty() Date: Fri, 15 May 2020 14:44:39 +0200 Message-Id: <20200515124521.335403-10-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Two callers of BlockDriver.bdrv_make_empty() remain that should not call this method directly. Both do not have access to a BdrvChild, but they can use a BlockBackend, so we add this function that lets them use it. Signed-off-by: Max Reitz Message-Id: <20200429141126.85159-4-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/sysemu/block-backend.h | 2 ++ block/block-backend.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 0917663d89..8203d7f6f9 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -266,4 +266,6 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in= , int64_t off_in, =20 const BdrvChild *blk_root(BlockBackend *blk); =20 +int blk_make_empty(BlockBackend *blk, Error **errp); + #endif diff --git a/block/block-backend.c b/block/block-backend.c index f4944861fa..47bd56244d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2402,3 +2402,13 @@ const BdrvChild *blk_root(BlockBackend *blk) { return blk->root; } + +int blk_make_empty(BlockBackend *blk, Error **errp) +{ + if (!blk_is_available(blk)) { + error_setg(errp, "No medium inserted"); + return -ENOMEDIUM; + } + + return bdrv_make_empty(blk->root, errp); +} --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547257; cv=none; d=zohomail.com; s=zohoarc; b=gIzFBlz6LsuQAs6sIOTkZU7538sfZrbephjOBLgbzdc/9KvVzB15/94O8VL57DKOFecvFUCFkQ/9QiJSzW6FyQKxSEDxGv0btRddo3WTDKSaM/RcVtKT4MdUL5TW1AczPViw5GozukT6Gz038dk0lmx99moJrSFR/T4Q9mHN3H0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547257; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gLP1vSf5gjXtk+qahPllKtJXXNWmS0u8AqefUbRbHVY=; b=L4Nkb787yvqCNQEeHSglA7z0JF8+Z2k5F2HaqSNUnDJ0IN4BCDpCz+oalyoxbPT1VgkvTNRlaZHPFg0fnKx4/inDCXES3QbftJTQMJb5PMrLHL9pOYGt/LPDfG14thNPES+o23WocdgQPZQY35rR1j3q8fwEuSbotY19UYF2Lv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547257439822.2749952390332; Fri, 15 May 2020 05:54:17 -0700 (PDT) Received: from localhost ([::1]:43078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZqy-0000YB-2H for importer@patchew.org; Fri, 15 May 2020 08:54:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZip-0002Xc-Vx for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53011 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZim-00029J-FU for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-509-9SQ6hxL7N0qNk5AK1D8naA-1; Fri, 15 May 2020 08:45:43 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADD8019200C2; Fri, 15 May 2020 12:45:42 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2CBB2E16F; Fri, 15 May 2020 12:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gLP1vSf5gjXtk+qahPllKtJXXNWmS0u8AqefUbRbHVY=; b=HkiO9jDSzUeH7YK1eXexSbCGst6Qb+dl6k47YOoapblJGUj2GiB6tDRkvUPknk08KYmiEd 54K23/IwDMbiJKPr6mzGYPmjsafIQSd5zCsSvFfR4/E5B2sKFekaa2twFO6FqeQC5wU+c3 l7wIOeQxpS70kR2Sx7bHp/8H5ptD21w= X-MC-Unique: 9SQ6hxL7N0qNk5AK1D8naA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 10/51] block: Use blk_make_empty() after commits Date: Fri, 15 May 2020 14:44:40 +0200 Message-Id: <20200515124521.335403-11-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz bdrv_commit() already has a BlockBackend pointing to the BDS that we want to empty, it just has the wrong permissions. qemu-img commit has no BlockBackend pointing to the old backing file yet, but introducing one is simple. After this commit, bdrv_make_empty() is the only remaining caller of BlockDriver.bdrv_make_empty(). Signed-off-by: Max Reitz Message-Id: <20200429141126.85159-5-mreitz@redhat.com> Reviewed-by: Eric Blake [kwolf: Fixed up reference output for 098] Signed-off-by: Kevin Wolf --- block/commit.c | 16 +++++++++------- qemu-img.c | 19 ++++++++++++++----- tests/qemu-iotests/098.out | 8 ++++---- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/block/commit.c b/block/commit.c index 87f6096d90..ba60fb7955 100644 --- a/block/commit.c +++ b/block/commit.c @@ -414,7 +414,9 @@ int bdrv_commit(BlockDriverState *bs) } =20 ctx =3D bdrv_get_aio_context(bs); - src =3D blk_new(ctx, BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL); + /* WRITE_UNCHANGED is required for bdrv_make_empty() */ + src =3D blk_new(ctx, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANG= ED, + BLK_PERM_ALL); backing =3D blk_new(ctx, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_AL= L); =20 ret =3D blk_insert_bs(src, bs, &local_err); @@ -492,14 +494,14 @@ int bdrv_commit(BlockDriverState *bs) } } =20 - if (drv->bdrv_make_empty) { - ret =3D drv->bdrv_make_empty(bs); - if (ret < 0) { - goto ro_cleanup; - } - blk_flush(src); + ret =3D blk_make_empty(src, NULL); + /* Ignore -ENOTSUP */ + if (ret < 0 && ret !=3D -ENOTSUP) { + goto ro_cleanup; } =20 + blk_flush(src); + /* * Make sure all data we wrote to the backing device is actually * stable on disk. diff --git a/qemu-img.c b/qemu-img.c index 6a4327aaba..f1795c788c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1104,11 +1104,20 @@ static int img_commit(int argc, char **argv) goto unref_backing; } =20 - if (!drop && bs->drv->bdrv_make_empty) { - ret =3D bs->drv->bdrv_make_empty(bs); - if (ret) { - error_setg_errno(&local_err, -ret, "Could not empty %s", - filename); + if (!drop) { + BlockBackend *old_backing_blk; + + old_backing_blk =3D blk_new_with_bs(bs, BLK_PERM_WRITE, BLK_PERM_A= LL, + &local_err); + if (!old_backing_blk) { + goto unref_backing; + } + ret =3D blk_make_empty(old_backing_blk, &local_err); + blk_unref(old_backing_blk); + if (ret =3D=3D -ENOTSUP) { + error_free(local_err); + local_err =3D NULL; + } else if (ret < 0) { goto unref_backing; } } diff --git a/tests/qemu-iotests/098.out b/tests/qemu-iotests/098.out index 7634d0e8b0..23cf371f53 100644 --- a/tests/qemu-iotests/098.out +++ b/tests/qemu-iotests/098.out @@ -6,7 +6,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D67= 108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.base wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error +qemu-img: Failed to empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error No errors were found on the image. =20 =3D=3D=3D empty_image_prepare =3D=3D=3D @@ -15,7 +15,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D= 67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.base wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error +qemu-img: Failed to empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error Leaked cluster 4 refcount=3D1 reference=3D0 Leaked cluster 5 refcount=3D1 reference=3D0 Repairing cluster 4 refcount=3D1 reference=3D0 @@ -28,7 +28,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D= 67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.base wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error +qemu-img: Failed to empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error ERROR cluster 0 refcount=3D0 reference=3D1 ERROR cluster 1 refcount=3D0 reference=3D1 ERROR cluster 3 refcount=3D0 reference=3D1 @@ -42,7 +42,7 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D= 67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.base wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: Could not empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error +qemu-img: Failed to empty blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFM= T: Input/output error ERROR cluster 0 refcount=3D0 reference=3D1 ERROR cluster 1 refcount=3D0 reference=3D1 ERROR cluster 3 refcount=3D0 reference=3D1 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547010; cv=none; d=zohomail.com; s=zohoarc; b=Z+QY/RDdcFKfwDLccXoLyJixKZT2nDA7rLQwZ8eUPpiSkbtt/l60EerZDXijd4XQ/gYlzTok+trcHjZD/1LZUYAhL7I7HOHFGHM/uV9Mq+utjrPi/o39M/1+bg4EpE0alxo8ULc2LUF3I8rLekFsP+N7i7vPbNCBaIwI3QwFxkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547010; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dJDtGGcIP6+8LgMCcsMZV1AiSWgUqZdbNItFO9gCMLo=; b=EJu/s8ZQ3kpYfP9Sfi084Sa2FWtNh3ZhPXKhjrdxwu7TtqhSjwOcmZY5MBYrX3IPgSfsENjCYLeaxxUYJ+k1L93bAlFfj7n2Vzusqdd385fn+H+exxzx+x6ZEZfUJAdIWklReooh/i2hn3zJvv4NXztdoFgL110jsNW2cBSv+CY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547010784885.1143378245686; Fri, 15 May 2020 05:50:10 -0700 (PDT) Received: from localhost ([::1]:54546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZmz-0001Xi-FO for importer@patchew.org; Fri, 15 May 2020 08:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZim-0002TT-Fq for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:48 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:25621 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZil-00028v-G9 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-_eWyIroaOa-sKEFhg9og_g-1; Fri, 15 May 2020 08:45:45 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF8D51005510; Fri, 15 May 2020 12:45:43 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 016292E166; Fri, 15 May 2020 12:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dJDtGGcIP6+8LgMCcsMZV1AiSWgUqZdbNItFO9gCMLo=; b=OAXJo6JZZCw3NV4f6uUx2k3APMFtrLuuk1oH4NfJHjyGKfnYD30BW1kkcLdRumLCcpWPYn iEYi4SjXNSEvkdknH4bSMgTxq+9ODrKSdPzwwI/hI3iqrat+HLoMld24Mw1M7RWvq2AVMb hUfTGUJcPWe7s8bmCZzI/Ax/Y98XD9c= X-MC-Unique: _eWyIroaOa-sKEFhg9og_g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 11/51] replication: Avoid blk_make_empty() on read-only child Date: Fri, 15 May 2020 14:44:41 +0200 Message-Id: <20200515124521.335403-12-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is just a bandaid to keep tests/test-replication working after bdrv_make_empty() starts to assert that we're not trying to call it on a read-only child. For the real solution in the future, replication should not steal the BdrvChild from its backing file (this is never correct to do!), but instead have its own child node references, with the appropriate permissions. Signed-off-by: Kevin Wolf --- block/replication.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/block/replication.c b/block/replication.c index c03980a192..eb480a8e08 100644 --- a/block/replication.c +++ b/block/replication.c @@ -343,9 +343,18 @@ static void secondary_do_checkpoint(BDRVReplicationSta= te *s, Error **errp) return; } =20 - ret =3D s->hidden_disk->bs->drv->bdrv_make_empty(s->hidden_disk->bs); + BlockBackend *blk =3D blk_new(qemu_get_current_aio_context(), + BLK_PERM_WRITE, BLK_PERM_ALL); + blk_insert_bs(blk, s->hidden_disk->bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + blk_unref(blk); + return; + } + + ret =3D blk_make_empty(blk, errp); + blk_unref(blk); if (ret < 0) { - error_setg(errp, "Cannot make hidden disk empty"); return; } } --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547643; cv=none; d=zohomail.com; s=zohoarc; b=M0Ude5HjGxF3DIGaDwjiSt/zjRQRZQazVTQ1UGWDlWwkpNUvJEP5IiwgwEoKh95V684oe0JLufDHKXAZfMnrgiFX6jpGFPFfFzXzzYng6qEs28EbVf+8WFpdn9ybiZ+jwzZvzqGtcW+dWW1H6BlFDvJMQJr/oZ5mBppjqCgjZvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547643; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LhnJGFzeKaIi/ojLCCBmmi5M+k7UnDjT4Eviqdn7LQE=; b=SQ0buVBjP5kPkPsI9z2Fl4IonEUawwAP+mH9vDA7ad1LxXwzsL1trbcg/zvkXSOxJYozMrzdjtx1bzhh2N8SauiDy1QnGi/wcG0MN2hKVKk7R2wlGw5RQi5UbI/42Yg1PqwaolkkUF4ZIKVQEJpSRi/474hZXgckKXmxS0CNXlM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547643258400.0515074313872; Fri, 15 May 2020 06:00:43 -0700 (PDT) Received: from localhost ([::1]:43608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZx9-0004pW-V4 for importer@patchew.org; Fri, 15 May 2020 09:00:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZip-0002Xd-Vz for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:52 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:44964 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZin-00029V-5H for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-357-xAZZdpBGOsSg9_eGUYCcug-1; Fri, 15 May 2020 08:45:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 419C3107ACF2; Fri, 15 May 2020 12:45:45 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A1752E024; Fri, 15 May 2020 12:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LhnJGFzeKaIi/ojLCCBmmi5M+k7UnDjT4Eviqdn7LQE=; b=GJPKRaqphQ8rg1w5pJ/R7SMV1g910f7dSyahgJRM/uV3APJcPhyOj6Ns0ReUOCnosduE8D XbQnQqjTCTGH85exExILOen0pIHAMy6YtGIvyCIHSo08EvQg6aeJyBZLK+N41wWhnj9/VS WF6IHBoNreY7Jvtz0Gs0bLRlYYO7GTE= X-MC-Unique: xAZZdpBGOsSg9_eGUYCcug-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 12/51] block: Use bdrv_make_empty() where possible Date: Fri, 15 May 2020 14:44:42 +0200 Message-Id: <20200515124521.335403-13-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Message-Id: <20200429141126.85159-3-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/replication.c | 3 +-- block/vvfat.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/block/replication.c b/block/replication.c index eb480a8e08..9a9f36e524 100644 --- a/block/replication.c +++ b/block/replication.c @@ -331,9 +331,8 @@ static void secondary_do_checkpoint(BDRVReplicationStat= e *s, Error **errp) return; } =20 - ret =3D s->active_disk->bs->drv->bdrv_make_empty(s->active_disk->bs); + ret =3D bdrv_make_empty(s->active_disk, errp); if (ret < 0) { - error_setg(errp, "Cannot make active disk empty"); return; } =20 diff --git a/block/vvfat.c b/block/vvfat.c index 6d5c090dec..34c121c07a 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2960,9 +2960,7 @@ static int do_commit(BDRVVVFATState* s) return ret; } =20 - if (s->qcow->bs->drv && s->qcow->bs->drv->bdrv_make_empty) { - s->qcow->bs->drv->bdrv_make_empty(s->qcow->bs); - } + bdrv_make_empty(s->qcow, NULL); =20 memset(s->used_clusters, 0, sector2cluster(s, s->sector_count)); =20 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547366; cv=none; d=zohomail.com; s=zohoarc; b=MsUypQOtOQ0Vj5ru8owlfD/b45eXnGnY5c184OcSTZkfyiKkjc+Nw5hsRDu6gRLjQ90iWXke1N5gvNZaZlF+AMhqImoWfPfH0Yd+zt0+rhCAJPZC6VUD1E7B0sq7UywpcLVCtYnWBWEE89PuyVBmoz+HAxHj0axb9BYFLLrcTGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547366; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1GgpEq3s0Jb8P6J4BnskQIwRhlavReodaR5hmvqqBv4=; b=PsH/HhaKQrJDj76VNEX09N14SWMFQEvMU8V6qkg1OFc8vlTceS/HoyIU8Ad/76mlaBVx6hp8Uh8P/3yfnLf+DtcpODjY5AAPU0sB1FJLYU2lpGoSMH0pHgUpIzoJrhHwReL2bHBg3f+od1lEYyEZc8yuUZ1sSzrkX1Bdf6F2MCw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158954736601029.297444992450664; Fri, 15 May 2020 05:56:06 -0700 (PDT) Received: from localhost ([::1]:51654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZsi-00044y-OV for importer@patchew.org; Fri, 15 May 2020 08:56:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZis-0002bt-Ck for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:55 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36303 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZip-0002Au-1b for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-119-d8Z6Ql_LMhiZ3T5dTv0z6A-1; Fri, 15 May 2020 08:45:47 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85846474; Fri, 15 May 2020 12:45:46 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DEA92E024; Fri, 15 May 2020 12:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1GgpEq3s0Jb8P6J4BnskQIwRhlavReodaR5hmvqqBv4=; b=LjUZY7xJGQ+SWpXKROjQoyraMi/pg30cDWwAceOlqlDDV7q7Zni6zbiqiqbnzeVUOLuOM8 XM73djzAfNS05oNiiQR1uHF9CyIMtEbyzPJHbyv3iAegSLOXt0w6Tay3vc20qXXUAa6z7j 0HCai2dTtkNL3pfNffaNVaM+fDPGgX0= X-MC-Unique: d8Z6Ql_LMhiZ3T5dTv0z6A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 13/51] block: Mark commit, mirror, blkreplay as filters Date: Fri, 15 May 2020 14:44:43 +0200 Message-Id: <20200515124521.335403-14-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz The commit, mirror, and blkreplay block nodes are filters, so they should be marked as such. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-2-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/blkreplay.c | 1 + block/commit.c | 2 ++ block/mirror.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/block/blkreplay.c b/block/blkreplay.c index c96ac8f4bc..131c9e8477 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -135,6 +135,7 @@ static int blkreplay_snapshot_goto(BlockDriverState *bs, static BlockDriver bdrv_blkreplay =3D { .format_name =3D "blkreplay", .instance_size =3D 0, + .is_filter =3D true, =20 .bdrv_open =3D blkreplay_open, .bdrv_child_perm =3D bdrv_filter_default_perms, diff --git a/block/commit.c b/block/commit.c index ba60fb7955..b0a8a793cd 100644 --- a/block/commit.c +++ b/block/commit.c @@ -240,6 +240,8 @@ static BlockDriver bdrv_commit_top =3D { .bdrv_co_block_status =3D bdrv_co_block_status_from_backing, .bdrv_refresh_filename =3D bdrv_commit_top_refresh_filename, .bdrv_child_perm =3D bdrv_commit_top_child_perm, + + .is_filter =3D true, }; =20 void commit_start(const char *job_id, BlockDriverState *bs, diff --git a/block/mirror.c b/block/mirror.c index 201ffa26f9..55e992670a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1530,6 +1530,8 @@ static BlockDriver bdrv_mirror_top =3D { .bdrv_co_block_status =3D bdrv_co_block_status_from_backing, .bdrv_refresh_filename =3D bdrv_mirror_top_refresh_filename, .bdrv_child_perm =3D bdrv_mirror_top_child_perm, + + .is_filter =3D true, }; =20 static BlockJob *mirror_start_job( --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547177; cv=none; d=zohomail.com; s=zohoarc; b=RPBlVsUUPT+l37l2bAY9+t/d/3U1n679awkSEn1p9JDYPlZn9M9xdTIVbjl2RapgU8GXwXwJESBnNkJwPLwueFC03xC0gzLBid9ncGqccuXMWPt/2jgU5l1TQMKOkuFRi/d37VB3NCFJyCW00GQcJpFbGixHPJvETNjtfZ9Wvmc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547177; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tVyhiR0n+Jp3lZ9I7Z5cN7gaZ3axxDiWezI8vxNxYgQ=; b=WuLzfaRNlnYxT0au+M6v+o4s8yNE86C5YEHowYpJJoMU7+FBc1BW/ndR4AzxYMgANWV6SaE9IhYqwWvrhzlWzenwo2CENtWYkRa5UgLJIq5hofRjlFavy9hGy/jO9a+gX1LF6BVzoRg9NFXN58eBsdv5MxU1zILjDQ8FNX8MF2c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547177025426.60524409370623; Fri, 15 May 2020 05:52:57 -0700 (PDT) Received: from localhost ([::1]:37786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZpf-0006NN-PL for importer@patchew.org; Fri, 15 May 2020 08:52:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZiu-0002dW-9P for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:56 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:38088 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZir-0002Bs-OS for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-jjJZFcHpOSeKscCZ5_vROw-1; Fri, 15 May 2020 08:45:48 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD30E19200C0; Fri, 15 May 2020 12:45:47 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFAC32E024; Fri, 15 May 2020 12:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tVyhiR0n+Jp3lZ9I7Z5cN7gaZ3axxDiWezI8vxNxYgQ=; b=bxd8L4FF19S5p1fEBGqlI035vtzQ5tIwotoXjvztB4V4c/XxONvtwhvuxf86x0DXRuRRBZ +1B21baXJRVnjjR3/eW2m+rP0yyPmbNCNMJ8BjPl5JWX8o8L4ZWHpFBQzULlQwXujn6GHx um4yVzRE0IycNpMhzI5KAFEqIZMNbus= X-MC-Unique: jjJZFcHpOSeKscCZ5_vROw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 14/51] block: Add BlockDriver.is_format Date: Fri, 15 May 2020 14:44:44 +0200 Message-Id: <20200515124521.335403-15-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz We want to unify child_format and child_file at some point. One of the important things that set format drivers apart from other drivers is that they do not expect other format nodes under them (except in the backing chain), i.e. we must not probe formats inside of formats. That means we need something on which to distinguish format drivers from others, and hence this flag. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia Message-Id: <20200513110544.176672-3-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 7 +++++++ block/bochs.c | 1 + block/cloop.c | 1 + block/crypto.c | 2 ++ block/dmg.c | 1 + block/parallels.c | 1 + block/qcow.c | 1 + block/qcow2.c | 1 + block/qed.c | 1 + block/raw-format.c | 1 + block/vdi.c | 1 + block/vhdx.c | 1 + block/vmdk.c | 1 + block/vpc.c | 1 + 14 files changed, 21 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index 7ba8c89036..1c24df53fd 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -95,6 +95,13 @@ struct BlockDriver { * must implement them and return -ENOTSUP. */ bool is_filter; + /* + * Set to true if the BlockDriver is a format driver. Format nodes + * generally do not expect their children to be other format nodes + * (except for backing files), and so format probing is disabled + * on those children. + */ + bool is_format; /* * Return true if @to_replace can be replaced by a BDS with the * same data as @bs without it affecting @bs's behavior (that is, diff --git a/block/bochs.c b/block/bochs.c index 32bb83b268..e7bbeaa1c4 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -301,6 +301,7 @@ static BlockDriver bdrv_bochs =3D { .bdrv_refresh_limits =3D bochs_refresh_limits, .bdrv_co_preadv =3D bochs_co_preadv, .bdrv_close =3D bochs_close, + .is_format =3D true, }; =20 static void bdrv_bochs_init(void) diff --git a/block/cloop.c b/block/cloop.c index 4de94876d4..f90f1a4b4c 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -297,6 +297,7 @@ static BlockDriver bdrv_cloop =3D { .bdrv_refresh_limits =3D cloop_refresh_limits, .bdrv_co_preadv =3D cloop_co_preadv, .bdrv_close =3D cloop_close, + .is_format =3D true, }; =20 static void bdrv_cloop_init(void) diff --git a/block/crypto.c b/block/crypto.c index 6b21d6bf6c..bdb2b27475 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -771,6 +771,8 @@ static BlockDriver bdrv_crypto_luks =3D { .bdrv_get_info =3D block_crypto_get_info_luks, .bdrv_get_specific_info =3D block_crypto_get_specific_info_luks, =20 + .is_format =3D true, + .strong_runtime_opts =3D block_crypto_strong_runtime_opts, }; =20 diff --git a/block/dmg.c b/block/dmg.c index 4a045f2b3e..ef3c6e771d 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -753,6 +753,7 @@ static BlockDriver bdrv_dmg =3D { .bdrv_child_perm =3D bdrv_format_default_perms, .bdrv_co_preadv =3D dmg_co_preadv, .bdrv_close =3D dmg_close, + .is_format =3D true, }; =20 static void bdrv_dmg_init(void) diff --git a/block/parallels.c b/block/parallels.c index e7717c508e..bd5f6ffa09 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -918,6 +918,7 @@ static BlockDriver bdrv_parallels =3D { .bdrv_co_flush_to_os =3D parallels_co_flush_to_os, .bdrv_co_readv =3D parallels_co_readv, .bdrv_co_writev =3D parallels_co_writev, + .is_format =3D true, .supports_backing =3D true, .bdrv_co_create =3D parallels_co_create, .bdrv_co_create_opts =3D parallels_co_create_opts, diff --git a/block/qcow.c b/block/qcow.c index b0475b73a5..6a72dea049 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -1185,6 +1185,7 @@ static BlockDriver bdrv_qcow =3D { .bdrv_co_create =3D qcow_co_create, .bdrv_co_create_opts =3D qcow_co_create_opts, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, + .is_format =3D true, .supports_backing =3D true, .bdrv_refresh_limits =3D qcow_refresh_limits, =20 diff --git a/block/qcow2.c b/block/qcow2.c index ad9ab4fafa..76bec61ee9 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5767,6 +5767,7 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_save_vmstate =3D qcow2_save_vmstate, .bdrv_load_vmstate =3D qcow2_load_vmstate, =20 + .is_format =3D true, .supports_backing =3D true, .bdrv_change_backing_file =3D qcow2_change_backing_file, =20 diff --git a/block/qed.c b/block/qed.c index 5da9726518..337eb6dbb6 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1665,6 +1665,7 @@ static BlockDriver bdrv_qed =3D { .format_name =3D "qed", .instance_size =3D sizeof(BDRVQEDState), .create_opts =3D &qed_create_opts, + .is_format =3D true, .supports_backing =3D true, =20 .bdrv_probe =3D bdrv_qed_probe, diff --git a/block/raw-format.c b/block/raw-format.c index 9108e43696..00e13bb41e 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -566,6 +566,7 @@ BlockDriver bdrv_raw =3D { .bdrv_co_copy_range_to =3D &raw_co_copy_range_to, .bdrv_co_truncate =3D &raw_co_truncate, .bdrv_getlength =3D &raw_getlength, + .is_format =3D true, .has_variable_length =3D true, .bdrv_measure =3D &raw_measure, .bdrv_get_info =3D &raw_get_info, diff --git a/block/vdi.c b/block/vdi.c index 2d28046615..0ef733ae19 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -1053,6 +1053,7 @@ static BlockDriver bdrv_vdi =3D { =20 .bdrv_get_info =3D vdi_get_info, =20 + .is_format =3D true, .create_opts =3D &vdi_create_opts, .bdrv_co_check =3D vdi_co_check, }; diff --git a/block/vhdx.c b/block/vhdx.c index 53e756438a..e692cf80cc 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2254,6 +2254,7 @@ static BlockDriver bdrv_vhdx =3D { .bdrv_co_check =3D vhdx_co_check, .bdrv_has_zero_init =3D vhdx_has_zero_init, =20 + .is_format =3D true, .create_opts =3D &vhdx_create_opts, }; =20 diff --git a/block/vmdk.c b/block/vmdk.c index b18f128816..56e85689f3 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -3070,6 +3070,7 @@ static BlockDriver bdrv_vmdk =3D { .bdrv_get_info =3D vmdk_get_info, .bdrv_gather_child_options =3D vmdk_gather_child_options, =20 + .is_format =3D true, .supports_backing =3D true, .create_opts =3D &vmdk_create_opts, }; diff --git a/block/vpc.c b/block/vpc.c index 5e31dd1e47..46a2d48659 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1250,6 +1250,7 @@ static BlockDriver bdrv_vpc =3D { =20 .bdrv_get_info =3D vpc_get_info, =20 + .is_format =3D true, .create_opts =3D &vpc_create_opts, .bdrv_has_zero_init =3D vpc_has_zero_init, .strong_runtime_opts =3D vpc_strong_runtime_opts, --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547785; cv=none; d=zohomail.com; s=zohoarc; b=c/o863af1bvFZNpVSzjFhZsYipCVnJeo+uywMfY5D0NywuqPRlRZsuWd3GHlvZrxPHcKRufrJfLcdjdh2uo9BA8iMiGoTx9pStAbpP8VsIJPx4m0GtVjySXWIPJXW64OjdF5Y/Q/Fmt8xyQbGXV3wPKRIN+Fqmrt7X8VDPqi/Go= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547785; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IY1nwyUB3Dxvw7aUEwYfXa/HPrFcprtFEHyyJ2kjRkw=; b=imGm/dfS+LHBv/g91YFcfZrGQxdopgslyGm0/Yy3dxBjVJMdBy9qOsUNmiAbPWSqa5zw6HHisZzm4HALKj75aDfKq0PnLuE5yRPuLBeQQJr8ImGB+1OgeR7s/9QohDF8bozxz/JXfDlznDY00/j93CArZ78Nh5pmaMWRwOfe3YU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547785500969.0175266747104; Fri, 15 May 2020 06:03:05 -0700 (PDT) Received: from localhost ([::1]:53118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZzU-00017u-IJ for importer@patchew.org; Fri, 15 May 2020 09:03:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZiy-0002el-Tk for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38307 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZit-0002DS-FX for qemu-devel@nongnu.org; Fri, 15 May 2020 08:45:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96-3rEVrcSnNdOxEwPkNWm58A-1; Fri, 15 May 2020 08:45:50 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 433978005AD; Fri, 15 May 2020 12:45:49 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24DF72E166; Fri, 15 May 2020 12:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IY1nwyUB3Dxvw7aUEwYfXa/HPrFcprtFEHyyJ2kjRkw=; b=ViYLTYa5PkytDpdzxrO8PVA0dzxRhapMGkLNXuWxT6DzlnwXgZEdlHZ6JRXplibk7kbJp7 NMAqINVK7uhvbjBkA/Vi8hTgEWgamK+6/HqzPyuSOOUjrup0cnlxJI69caASV7bN2GjEe2 pp3F38AFiGlvZcqaKxYcnIdXUZAoP1M= X-MC-Unique: 3rEVrcSnNdOxEwPkNWm58A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 15/51] block: Rename BdrvChildRole to BdrvChildClass Date: Fri, 15 May 2020 14:44:45 +0200 Message-Id: <20200515124521.335403-16-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz This structure nearly only contains parent callbacks for child state changes. It cannot really reflect a child's role, because different roles may overlap (as we will see when real roles are introduced), and because parents can have custom callbacks even when the child fulfills a standard role. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia Message-Id: <20200513110544.176672-4-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block.h | 6 +- include/block/block_int.h | 22 +++--- block.c | 142 ++++++++++++++++++------------------ block/backup-top.c | 8 +- block/blkdebug.c | 4 +- block/blklogwrites.c | 8 +- block/block-backend.c | 6 +- block/commit.c | 2 +- block/copy-on-read.c | 2 +- block/io.c | 22 +++--- block/mirror.c | 2 +- block/quorum.c | 2 +- block/replication.c | 2 +- block/vvfat.c | 6 +- blockjob.c | 2 +- tests/test-bdrv-drain.c | 36 ++++----- tests/test-bdrv-graph-mod.c | 2 +- 17 files changed, 141 insertions(+), 133 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 8f3eb70df4..bc42e507bb 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -13,7 +13,7 @@ /* block.c */ typedef struct BlockDriver BlockDriver; typedef struct BdrvChild BdrvChild; -typedef struct BdrvChildRole BdrvChildRole; +typedef struct BdrvChildClass BdrvChildClass; =20 typedef struct BlockDriverInfo { /* in bytes, 0 if irrelevant */ @@ -296,7 +296,7 @@ int bdrv_parse_discard_flags(const char *mode, int *fla= gs); BdrvChild *bdrv_open_child(const char *filename, QDict *options, const char *bdref_key, BlockDriverState* parent, - const BdrvChildRole *child_role, + const BdrvChildClass *child_class, bool allow_none, Error **errp); BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_h= d, @@ -541,7 +541,7 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChi= ld *child); BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, const char *child_name, - const BdrvChildRole *child_role, + const BdrvChildClass *child_class, Error **errp); =20 bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp= ); diff --git a/include/block/block_int.h b/include/block/block_int.h index 1c24df53fd..9a78b981e4 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -556,14 +556,14 @@ struct BlockDriver { * the parents in @parent_perm and @parent_shared. * * If @c is NULL, return the permissions for attaching a new child for= the - * given @role. + * given @child_class. * * If @reopen_queue is non-NULL, don't return the currently needed * permissions, but those that will be needed after applying the * @reopen_queue. */ void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared); @@ -665,7 +665,7 @@ typedef struct BdrvAioNotifier { QLIST_ENTRY(BdrvAioNotifier) list; } BdrvAioNotifier; =20 -struct BdrvChildRole { +struct BdrvChildClass { /* If true, bdrv_replace_node() doesn't change the node this BdrvChild * points to. */ bool stay_at_node; @@ -738,14 +738,14 @@ struct BdrvChildRole { void (*set_aio_ctx)(BdrvChild *child, AioContext *ctx, GSList **ignore= ); }; =20 -extern const BdrvChildRole child_file; -extern const BdrvChildRole child_format; -extern const BdrvChildRole child_backing; +extern const BdrvChildClass child_file; +extern const BdrvChildClass child_format; +extern const BdrvChildClass child_backing; =20 struct BdrvChild { BlockDriverState *bs; char *name; - const BdrvChildRole *role; + const BdrvChildClass *klass; void *opaque; =20 /** @@ -772,7 +772,7 @@ struct BdrvChild { =20 /* * How many times the parent of this child has been drained - * (through role->drained_*). + * (through klass->drained_*). * Usually, this is equal to bs->quiesce_counter (potentially * reduced by bdrv_drain_all_count). It may differ while the * child is entering or leaving a drained section. @@ -1232,7 +1232,7 @@ BlockJob *backup_job_create(const char *job_id, Block= DriverState *bs, =20 BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, const char *child_name, - const BdrvChildRole *child_role, + const BdrvChildClass *child_class, AioContext *ctx, uint64_t perm, uint64_t shared_perm, void *opaque, Error **errp); @@ -1263,7 +1263,7 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, Bd= rvChild *c, Error **errp); * block filters: Forward CONSISTENT_READ, WRITE, WRITE_UNCHANGED and RESI= ZE to * all children */ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); @@ -1273,7 +1273,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, = BdrvChild *c, * requires WRITE | RESIZE for read-write images, always requires * CONSISTENT_READ and doesn't share WRITE. */ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); diff --git a/block.c b/block.c index c6a5c144b7..0ce9b61c97 100644 --- a/block.c +++ b/block.c @@ -76,7 +76,7 @@ static BlockDriverState *bdrv_open_inherit(const char *fi= lename, const char *reference, QDict *options, int flags, BlockDriverState *parent, - const BdrvChildRole *child_role, + const BdrvChildClass *child_cla= ss, Error **errp); =20 /* If non-zero, use only whitelisted block drivers */ @@ -1183,7 +1183,7 @@ static void bdrv_inherited_options(int *child_flags, = QDict *child_options, *child_flags =3D flags; } =20 -const BdrvChildRole child_file =3D { +const BdrvChildClass child_file =3D { .parent_is_bds =3D true, .get_parent_desc =3D bdrv_child_get_parent_desc, .inherit_options =3D bdrv_inherited_options, @@ -1211,7 +1211,7 @@ static void bdrv_inherited_fmt_options(int *child_fla= gs, QDict *child_options, *child_flags &=3D ~(BDRV_O_PROTOCOL | BDRV_O_NO_IO); } =20 -const BdrvChildRole child_format =3D { +const BdrvChildClass child_format =3D { .parent_is_bds =3D true, .get_parent_desc =3D bdrv_child_get_parent_desc, .inherit_options =3D bdrv_inherited_fmt_options, @@ -1335,7 +1335,7 @@ static int bdrv_backing_update_filename(BdrvChild *c,= BlockDriverState *base, return ret; } =20 -const BdrvChildRole child_backing =3D { +const BdrvChildClass child_backing =3D { .parent_is_bds =3D true, .get_parent_desc =3D bdrv_child_get_parent_desc, .attach =3D bdrv_backing_attach, @@ -1953,13 +1953,13 @@ bool bdrv_is_writable(BlockDriverState *bs) } =20 static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_= bs, - BdrvChild *c, const BdrvChildRole *role, + BdrvChild *c, const BdrvChildClass *child_clas= s, BlockReopenQueue *reopen_queue, uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared) { assert(bs->drv && bs->drv->bdrv_child_perm); - bs->drv->bdrv_child_perm(bs, c, role, reopen_queue, + bs->drv->bdrv_child_perm(bs, c, child_class, reopen_queue, parent_perm, parent_shared, nperm, nshared); /* TODO Take force_share from reopen_queue */ @@ -2053,7 +2053,7 @@ static int bdrv_check_perm(BlockDriverState *bs, Bloc= kReopenQueue *q, uint64_t cur_perm, cur_shared; bool child_tighten_restr; =20 - bdrv_child_perm(bs, c->bs, c, c->role, q, + bdrv_child_perm(bs, c->bs, c, c->klass, q, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); ret =3D bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_c= hildren, @@ -2120,7 +2120,7 @@ static void bdrv_set_perm(BlockDriverState *bs, uint6= 4_t cumulative_perms, /* Update all children */ QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; - bdrv_child_perm(bs, c->bs, c, c->role, NULL, + bdrv_child_perm(bs, c->bs, c, c->klass, NULL, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); bdrv_child_set_perm(c, cur_perm, cur_shared); @@ -2145,8 +2145,8 @@ void bdrv_get_cumulative_perm(BlockDriverState *bs, u= int64_t *perm, =20 static char *bdrv_child_user_desc(BdrvChild *c) { - if (c->role->get_parent_desc) { - return c->role->get_parent_desc(c); + if (c->klass->get_parent_desc) { + return c->klass->get_parent_desc(c); } =20 return g_strdup("another user"); @@ -2348,14 +2348,14 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, = BdrvChild *c, Error **errp) uint64_t perms, shared; =20 bdrv_get_cumulative_perm(bs, &parent_perms, &parent_shared); - bdrv_child_perm(bs, c->bs, c, c->role, NULL, parent_perms, parent_shar= ed, + bdrv_child_perm(bs, c->bs, c, c->klass, NULL, parent_perms, parent_sha= red, &perms, &shared); =20 return bdrv_child_try_set_perm(c, perms, shared, errp); } =20 void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) @@ -2365,21 +2365,21 @@ void bdrv_filter_default_perms(BlockDriverState *bs= , BdrvChild *c, } =20 void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - bool backing =3D (role =3D=3D &child_backing); - assert(role =3D=3D &child_backing || role =3D=3D &child_file); + bool backing =3D (child_class =3D=3D &child_backing); + assert(child_class =3D=3D &child_backing || child_class =3D=3D &child_= file); =20 if (!backing) { int flags =3D bdrv_reopen_get_flags(reopen_queue, bs); =20 /* Apart from the modifications below, the same permissions are * forwarded and left alone as for filters */ - bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, - &perm, &shared); + bdrv_filter_default_perms(bs, c, child_class, reopen_queue, + perm, shared, &perm, &shared); =20 /* Format drivers may touch metadata even if the guest doesn't wri= te */ if (bdrv_is_writable_after_reopen(bs, reopen_queue)) { @@ -2456,7 +2456,7 @@ static void bdrv_replace_child_noperm(BdrvChild *chil= d, * If the new child node is drained but the old one was not, flush * all outstanding requests to the old child node. */ - while (drain_saldo > 0 && child->role->drained_begin) { + while (drain_saldo > 0 && child->klass->drained_begin) { bdrv_parent_drained_begin_single(child, true); drain_saldo--; } @@ -2465,8 +2465,8 @@ static void bdrv_replace_child_noperm(BdrvChild *chil= d, /* Detach first so that the recursive drain sections coming from @= child * are already gone and we only end the drain sections that came f= rom * elsewhere. */ - if (child->role->detach) { - child->role->detach(child); + if (child->klass->detach) { + child->klass->detach(child); } QLIST_REMOVE(child, next_parent); } @@ -2488,8 +2488,8 @@ static void bdrv_replace_child_noperm(BdrvChild *chil= d, /* Attach only after starting new drained sections, so that recurs= ive * drain sections coming from @child don't get an extra .drained_b= egin * callback. */ - if (child->role->attach) { - child->role->attach(child); + if (child->klass->attach) { + child->klass->attach(child); } } =20 @@ -2497,7 +2497,7 @@ static void bdrv_replace_child_noperm(BdrvChild *chil= d, * If the old child node was drained but the new one is not, allow * requests to come in only after the new node has been attached. */ - while (drain_saldo < 0 && child->role->drained_end) { + while (drain_saldo < 0 && child->klass->drained_end) { bdrv_parent_drained_end_single(child); drain_saldo++; } @@ -2570,7 +2570,7 @@ static void bdrv_replace_child(BdrvChild *child, Bloc= kDriverState *new_bs) */ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, const char *child_name, - const BdrvChildRole *child_role, + const BdrvChildClass *child_class, AioContext *ctx, uint64_t perm, uint64_t shared_perm, void *opaque, Error **errp) @@ -2591,7 +2591,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, *child =3D (BdrvChild) { .bs =3D NULL, .name =3D g_strdup(child_name), - .role =3D child_role, + .klass =3D child_class, .perm =3D perm, .shared_perm =3D shared_perm, .opaque =3D opaque, @@ -2602,15 +2602,15 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState = *child_bs, * try moving the parent into the AioContext of child_bs instead. */ if (bdrv_get_aio_context(child_bs) !=3D ctx) { ret =3D bdrv_try_set_aio_context(child_bs, ctx, &local_err); - if (ret < 0 && child_role->can_set_aio_ctx) { + if (ret < 0 && child_class->can_set_aio_ctx) { GSList *ignore =3D g_slist_prepend(NULL, child); ctx =3D bdrv_get_aio_context(child_bs); - if (child_role->can_set_aio_ctx(child, ctx, &ignore, NULL)) { + if (child_class->can_set_aio_ctx(child, ctx, &ignore, NULL)) { error_free(local_err); ret =3D 0; g_slist_free(ignore); ignore =3D g_slist_prepend(NULL, child); - child_role->set_aio_ctx(child, ctx, &ignore); + child_class->set_aio_ctx(child, ctx, &ignore); } g_slist_free(ignore); } @@ -2643,7 +2643,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, const char *child_name, - const BdrvChildRole *child_role, + const BdrvChildClass *child_class, Error **errp) { BdrvChild *child; @@ -2652,10 +2652,10 @@ BdrvChild *bdrv_attach_child(BlockDriverState *pare= nt_bs, bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm); =20 assert(parent_bs->drv); - bdrv_child_perm(parent_bs, child_bs, NULL, child_role, NULL, + bdrv_child_perm(parent_bs, child_bs, NULL, child_class, NULL, perm, shared_perm, &perm, &shared_perm); =20 - child =3D bdrv_root_attach_child(child_bs, child_name, child_role, + child =3D bdrv_root_attach_child(child_bs, child_name, child_class, bdrv_get_aio_context(parent_bs), perm, shared_perm, parent_bs, errp); if (child =3D=3D NULL) { @@ -2728,8 +2728,8 @@ static void bdrv_parent_cb_change_media(BlockDriverSt= ate *bs, bool load) { BdrvChild *c; QLIST_FOREACH(c, &bs->parents, next_parent) { - if (c->role->change_media) { - c->role->change_media(c, load); + if (c->klass->change_media) { + c->klass->change_media(c, load); } } } @@ -2905,7 +2905,7 @@ free_exit: =20 static BlockDriverState * bdrv_open_child_bs(const char *filename, QDict *options, const char *bdref= _key, - BlockDriverState *parent, const BdrvChildRole *child_ro= le, + BlockDriverState *parent, const BdrvChildClass *child_c= lass, bool allow_none, Error **errp) { BlockDriverState *bs =3D NULL; @@ -2913,7 +2913,7 @@ bdrv_open_child_bs(const char *filename, QDict *optio= ns, const char *bdref_key, char *bdref_key_dot; const char *reference; =20 - assert(child_role !=3D NULL); + assert(child_class !=3D NULL); =20 bdref_key_dot =3D g_strdup_printf("%s.", bdref_key); qdict_extract_subqdict(options, &image_options, bdref_key_dot); @@ -2937,7 +2937,7 @@ bdrv_open_child_bs(const char *filename, QDict *optio= ns, const char *bdref_key, } =20 bs =3D bdrv_open_inherit(filename, reference, image_options, 0, - parent, child_role, errp); + parent, child_class, errp); if (!bs) { goto done; } @@ -2964,22 +2964,24 @@ done: BdrvChild *bdrv_open_child(const char *filename, QDict *options, const char *bdref_key, BlockDriverState *parent, - const BdrvChildRole *child_role, + const BdrvChildClass *child_class, bool allow_none, Error **errp) { BlockDriverState *bs; =20 - bs =3D bdrv_open_child_bs(filename, options, bdref_key, parent, child_= role, + bs =3D bdrv_open_child_bs(filename, options, bdref_key, parent, child_= class, allow_none, errp); if (bs =3D=3D NULL) { return NULL; } =20 - return bdrv_attach_child(parent, bs, bdref_key, child_role, errp); + return bdrv_attach_child(parent, bs, bdref_key, child_class, errp); } =20 -/* TODO Future callers may need to specify parent/child_role in order for - * option inheritance to work. Existing callers use it for the root node. = */ +/* + * TODO Future callers may need to specify parent/child_class in order for + * option inheritance to work. Existing callers use it for the root node. + */ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) { BlockDriverState *bs =3D NULL; @@ -3107,7 +3109,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, const char *reference, QDict *options, int flags, BlockDriverState *parent, - const BdrvChildRole *child_role, + const BdrvChildClass *child_cla= ss, Error **errp) { int ret; @@ -3121,8 +3123,8 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, QDict *snapshot_options =3D NULL; int snapshot_flags =3D 0; =20 - assert(!child_role || !flags); - assert(!child_role =3D=3D !parent); + assert(!child_class || !flags); + assert(!child_class =3D=3D !parent); =20 if (reference) { bool options_non_empty =3D options ? qdict_size(options) : false; @@ -3158,10 +3160,10 @@ static BlockDriverState *bdrv_open_inherit(const ch= ar *filename, =20 bs->explicit_options =3D qdict_clone_shallow(options); =20 - if (child_role) { + if (child_class) { bs->inherits_from =3D parent; - child_role->inherit_options(&flags, options, - parent->open_flags, parent->options); + child_class->inherit_options(&flags, options, + parent->open_flags, parent->options); } =20 ret =3D bdrv_fill_options(&options, filename, &flags, &local_err); @@ -3472,7 +3474,7 @@ static bool bdrv_recurse_has_child(BlockDriverState *= bs, static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queu= e, BlockDriverState *bs, QDict *options, - const BdrvChildRole *role, + const BdrvChildClass *kla= ss, QDict *parent_options, int parent_flags, bool keep_old_opts) @@ -3528,7 +3530,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, /* Inherit from parent node */ if (parent_options) { flags =3D 0; - role->inherit_options(&flags, options, parent_flags, parent_option= s); + klass->inherit_options(&flags, options, parent_flags, parent_optio= ns); } else { flags =3D bdrv_get_flags(bs); } @@ -3619,7 +3621,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, } =20 bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, - child->role, options, flags, child_keep_ol= d); + child->klass, options, flags, child_keep_o= ld); } =20 return bs_queue; @@ -3799,7 +3801,7 @@ static void bdrv_reopen_perm(BlockReopenQueue *q, Blo= ckDriverState *bs, } else { uint64_t nperm, nshared; =20 - bdrv_child_perm(parent->state.bs, bs, c, c->role, q, + bdrv_child_perm(parent->state.bs, bs, c, c->klass, q, parent->state.perm, parent->state.shared_perm, &nperm, &nshared); =20 @@ -4305,7 +4307,7 @@ static bool should_update_child(BdrvChild *c, BlockDr= iverState *to) GHashTable *found; bool ret; =20 - if (c->role->stay_at_node) { + if (c->klass->stay_at_node) { return false; } =20 @@ -4776,9 +4778,9 @@ int bdrv_drop_intermediate(BlockDriverState *top, Blo= ckDriverState *base, } =20 /* If so, update the backing file path in the image file */ - if (c->role->update_filename) { - ret =3D c->role->update_filename(c, base, backing_file_str, - &local_err); + if (c->klass->update_filename) { + ret =3D c->klass->update_filename(c, base, backing_file_str, + &local_err); if (ret < 0) { bdrv_abort_perm_update(base); error_report_err(local_err); @@ -5226,8 +5228,8 @@ const char *bdrv_get_parent_name(const BlockDriverSta= te *bs) =20 /* If multiple parents have a name, just pick the first one. */ QLIST_FOREACH(c, &bs->parents, next_parent) { - if (c->role->get_name) { - name =3D c->role->get_name(c); + if (c->klass->get_name) { + name =3D c->klass->get_name(c); if (name && *name) { return name; } @@ -5586,8 +5588,8 @@ static void coroutine_fn bdrv_co_invalidate_cache(Blo= ckDriverState *bs, } =20 QLIST_FOREACH(parent, &bs->parents, next_parent) { - if (parent->role->activate) { - parent->role->activate(parent, &local_err); + if (parent->klass->activate) { + parent->klass->activate(parent, &local_err); if (local_err) { bs->open_flags |=3D BDRV_O_INACTIVE; error_propagate(errp, local_err); @@ -5655,7 +5657,7 @@ static bool bdrv_has_bds_parent(BlockDriverState *bs,= bool only_active) BdrvChild *parent; =20 QLIST_FOREACH(parent, &bs->parents, next_parent) { - if (parent->role->parent_is_bds) { + if (parent->klass->parent_is_bds) { BlockDriverState *parent_bs =3D parent->opaque; if (!only_active || !(parent_bs->open_flags & BDRV_O_INACTIVE)= ) { return true; @@ -5694,8 +5696,8 @@ static int bdrv_inactivate_recurse(BlockDriverState *= bs) } =20 QLIST_FOREACH(parent, &bs->parents, next_parent) { - if (parent->role->inactivate) { - ret =3D parent->role->inactivate(parent); + if (parent->klass->inactivate) { + ret =3D parent->klass->inactivate(parent); if (ret < 0) { return ret; } @@ -6195,9 +6197,9 @@ void bdrv_set_aio_context_ignore(BlockDriverState *bs, if (g_slist_find(*ignore, child)) { continue; } - assert(child->role->set_aio_ctx); + assert(child->klass->set_aio_ctx); *ignore =3D g_slist_prepend(*ignore, child); - child->role->set_aio_ctx(child, new_context, ignore); + child->klass->set_aio_ctx(child, new_context, ignore); } =20 bdrv_detach_aio_context(bs); @@ -6237,15 +6239,17 @@ static bool bdrv_parent_can_set_aio_context(BdrvChi= ld *c, AioContext *ctx, } *ignore =3D g_slist_prepend(*ignore, c); =20 - /* A BdrvChildRole that doesn't handle AioContext changes cannot - * tolerate any AioContext changes */ - if (!c->role->can_set_aio_ctx) { + /* + * A BdrvChildClass that doesn't handle AioContext changes cannot + * tolerate any AioContext changes + */ + if (!c->klass->can_set_aio_ctx) { char *user =3D bdrv_child_user_desc(c); error_setg(errp, "Changing iothreads is not supported by %s", user= ); g_free(user); return false; } - if (!c->role->can_set_aio_ctx(c, ctx, ignore, errp)) { + if (!c->klass->can_set_aio_ctx(c, ctx, ignore, errp)) { assert(!errp || *errp); return false; } @@ -6631,7 +6635,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) drv->bdrv_gather_child_options(bs, opts, backing_overridden); } else { QLIST_FOREACH(child, &bs->children, next) { - if (child->role =3D=3D &child_backing && !backing_overridden) { + if (child->klass =3D=3D &child_backing && !backing_overridden)= { /* We can skip the backing BDS if it has not been overridd= en */ continue; } diff --git a/block/backup-top.c b/block/backup-top.c index 79b268e6dc..282845a410 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -122,7 +122,7 @@ static void backup_top_refresh_filename(BlockDriverStat= e *bs) } =20 static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) @@ -142,7 +142,7 @@ static void backup_top_child_perm(BlockDriverState *bs,= BdrvChild *c, return; } =20 - if (role =3D=3D &child_file) { + if (child_class =3D=3D &child_file) { /* * Target child * @@ -155,8 +155,8 @@ static void backup_top_child_perm(BlockDriverState *bs,= BdrvChild *c, *nperm =3D BLK_PERM_WRITE; } else { /* Source child */ - bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, - nperm, nshared); + bdrv_filter_default_perms(bs, c, child_class, reopen_queue, + perm, shared, nperm, nshared); =20 if (perm & BLK_PERM_WRITE) { *nperm =3D *nperm | BLK_PERM_CONSISTENT_READ; diff --git a/block/blkdebug.c b/block/blkdebug.c index af44aa973f..f369d54ee4 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -993,14 +993,14 @@ static int blkdebug_reopen_prepare(BDRVReopenState *r= eopen_state, } =20 static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { BDRVBlkdebugState *s =3D bs->opaque; =20 - bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, + bdrv_filter_default_perms(bs, c, child_class, reopen_queue, perm, shar= ed, nperm, nshared); =20 *nperm |=3D s->take_child_perms; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 04d8b33607..f3b3259d8d 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -282,7 +282,7 @@ static int64_t blk_log_writes_getlength(BlockDriverStat= e *bs) } =20 static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *ro_q, uint64_t perm, uint64_t shrd, uint64_t *nperm, uint64_t *nshrd) @@ -294,9 +294,11 @@ static void blk_log_writes_child_perm(BlockDriverState= *bs, BdrvChild *c, } =20 if (!strcmp(c->name, "log")) { - bdrv_format_default_perms(bs, c, role, ro_q, perm, shrd, nperm, ns= hrd); + bdrv_format_default_perms(bs, c, child_class, ro_q, perm, shrd, np= erm, + nshrd); } else { - bdrv_filter_default_perms(bs, c, role, ro_q, perm, shrd, nperm, ns= hrd); + bdrv_filter_default_perms(bs, c, child_class, ro_q, perm, shrd, np= erm, + nshrd); } } =20 diff --git a/block/block-backend.c b/block/block-backend.c index 47bd56244d..c0af79147a 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -297,7 +297,7 @@ static void blk_root_detach(BdrvChild *child) } } =20 -static const BdrvChildRole child_root =3D { +static const BdrvChildClass child_root =3D { .inherit_options =3D blk_root_inherit_options, =20 .change_media =3D blk_root_change_media, @@ -716,7 +716,7 @@ static BlockBackend *bdrv_first_blk(BlockDriverState *b= s) { BdrvChild *child; QLIST_FOREACH(child, &bs->parents, next_parent) { - if (child->role =3D=3D &child_root) { + if (child->klass =3D=3D &child_root) { return child->opaque; } } @@ -740,7 +740,7 @@ bool bdrv_is_root_node(BlockDriverState *bs) BdrvChild *c; =20 QLIST_FOREACH(c, &bs->parents, next_parent) { - if (c->role !=3D &child_root) { + if (c->klass !=3D &child_root) { return false; } } diff --git a/block/commit.c b/block/commit.c index b0a8a793cd..834eeae412 100644 --- a/block/commit.c +++ b/block/commit.c @@ -223,7 +223,7 @@ static void bdrv_commit_top_refresh_filename(BlockDrive= rState *bs) } =20 static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 242d3ff055..7504ca6ffc 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -51,7 +51,7 @@ static int cor_open(BlockDriverState *bs, QDict *options,= int flags, #define PERM_UNCHANGED (BLK_PERM_ALL & ~PERM_PASSTHROUGH) =20 static void cor_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/io.c b/block/io.c index 7d30e61edc..121ce17a49 100644 --- a/block/io.c +++ b/block/io.c @@ -50,7 +50,7 @@ static void bdrv_parent_drained_begin(BlockDriverState *b= s, BdrvChild *ignore, BdrvChild *c, *next; =20 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { - if (c =3D=3D ignore || (ignore_bds_parents && c->role->parent_is_b= ds)) { + if (c =3D=3D ignore || (ignore_bds_parents && c->klass->parent_is_= bds)) { continue; } bdrv_parent_drained_begin_single(c, false); @@ -62,8 +62,8 @@ static void bdrv_parent_drained_end_single_no_poll(BdrvCh= ild *c, { assert(c->parent_quiesce_counter > 0); c->parent_quiesce_counter--; - if (c->role->drained_end) { - c->role->drained_end(c, drained_end_counter); + if (c->klass->drained_end) { + c->klass->drained_end(c, drained_end_counter); } } =20 @@ -81,7 +81,7 @@ static void bdrv_parent_drained_end(BlockDriverState *bs,= BdrvChild *ignore, BdrvChild *c; =20 QLIST_FOREACH(c, &bs->parents, next_parent) { - if (c =3D=3D ignore || (ignore_bds_parents && c->role->parent_is_b= ds)) { + if (c =3D=3D ignore || (ignore_bds_parents && c->klass->parent_is_= bds)) { continue; } bdrv_parent_drained_end_single_no_poll(c, drained_end_counter); @@ -90,8 +90,8 @@ static void bdrv_parent_drained_end(BlockDriverState *bs,= BdrvChild *ignore, =20 static bool bdrv_parent_drained_poll_single(BdrvChild *c) { - if (c->role->drained_poll) { - return c->role->drained_poll(c); + if (c->klass->drained_poll) { + return c->klass->drained_poll(c); } return false; } @@ -103,7 +103,7 @@ static bool bdrv_parent_drained_poll(BlockDriverState *= bs, BdrvChild *ignore, bool busy =3D false; =20 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { - if (c =3D=3D ignore || (ignore_bds_parents && c->role->parent_is_b= ds)) { + if (c =3D=3D ignore || (ignore_bds_parents && c->klass->parent_is_= bds)) { continue; } busy |=3D bdrv_parent_drained_poll_single(c); @@ -115,8 +115,8 @@ static bool bdrv_parent_drained_poll(BlockDriverState *= bs, BdrvChild *ignore, void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) { c->parent_quiesce_counter++; - if (c->role->drained_begin) { - c->role->drained_begin(c); + if (c->klass->drained_begin) { + c->klass->drained_begin(c); } if (poll) { BDRV_POLL_WHILE(c->bs, bdrv_parent_drained_poll_single(c)); @@ -3326,8 +3326,8 @@ static void bdrv_parent_cb_resize(BlockDriverState *b= s) { BdrvChild *c; QLIST_FOREACH(c, &bs->parents, next_parent) { - if (c->role->resize) { - c->role->resize(c); + if (c->klass->resize) { + c->klass->resize(c); } } } diff --git a/block/mirror.c b/block/mirror.c index 55e992670a..d6598463d5 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1492,7 +1492,7 @@ static void bdrv_mirror_top_refresh_filename(BlockDri= verState *bs) } =20 static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/quorum.c b/block/quorum.c index 6d7a56bd93..a0824c300d 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1151,7 +1151,7 @@ static char *quorum_dirname(BlockDriverState *bs, Err= or **errp) } =20 static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/replication.c b/block/replication.c index 9a9f36e524..af428c5b66 100644 --- a/block/replication.c +++ b/block/replication.c @@ -163,7 +163,7 @@ static void replication_close(BlockDriverState *bs) } =20 static void replication_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/vvfat.c b/block/vvfat.c index 34c121c07a..f845d9b485 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3136,7 +3136,7 @@ static void vvfat_qcow_options(int *child_flags, QDic= t *child_options, qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on"); } =20 -static const BdrvChildRole child_vvfat_qcow =3D { +static const BdrvChildClass child_vvfat_qcow =3D { .parent_is_bds =3D true, .inherit_options =3D vvfat_qcow_options, }; @@ -3210,14 +3210,14 @@ err: } =20 static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { BDRVVVFATState *s =3D bs->opaque; =20 - assert(c =3D=3D s->qcow || role =3D=3D &child_backing); + assert(c =3D=3D s->qcow || child_class =3D=3D &child_backing); =20 if (c =3D=3D s->qcow) { /* This is a private node, nobody should try to attach to it */ diff --git a/blockjob.c b/blockjob.c index 2affa1844d..be38c8c550 100644 --- a/blockjob.c +++ b/blockjob.c @@ -163,7 +163,7 @@ static void child_job_set_aio_ctx(BdrvChild *c, AioCont= ext *ctx, job->job.aio_context =3D ctx; } =20 -static const BdrvChildRole child_job =3D { +static const BdrvChildClass child_job =3D { .get_parent_desc =3D child_job_get_parent_desc, .drained_begin =3D child_job_drained_begin, .drained_poll =3D child_job_drained_poll, diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index fa0e6a648b..9d683a6c11 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -86,18 +86,20 @@ static int coroutine_fn bdrv_test_co_preadv(BlockDriver= State *bs, } =20 static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - /* bdrv_format_default_perms() accepts only these two, so disguise - * detach_by_driver_cb_role as one of them. */ - if (role !=3D &child_file && role !=3D &child_backing) { - role =3D &child_file; + /* + * bdrv_format_default_perms() accepts only these two, so disguise + * detach_by_driver_cb_parent as one of them. + */ + if (child_class !=3D &child_file && child_class !=3D &child_backing) { + child_class =3D &child_file; } =20 - bdrv_format_default_perms(bs, c, role, reopen_queue, perm, shared, + bdrv_format_default_perms(bs, c, child_class, reopen_queue, perm, shar= ed, nperm, nshared); } =20 @@ -1332,7 +1334,7 @@ static void detach_by_driver_cb_drained_begin(BdrvChi= ld *child) child_file.drained_begin(child); } =20 -static BdrvChildRole detach_by_driver_cb_role; +static BdrvChildClass detach_by_driver_cb_class; =20 /* * Initial graph: @@ -1349,7 +1351,7 @@ static BdrvChildRole detach_by_driver_cb_role; * * by_parent_cb =3D=3D false: Test that bdrv_drain_invoke() doesn't poll * - * PA's BdrvChildRole has a .drained_begin callback that schedules a BH + * PA's BdrvChildClass has a .drained_begin callback that schedules a = BH * that does the same graph change. If bdrv_drain_invoke() calls it, t= he * state is messed up, but if it is only polled in the single * BDRV_POLL_WHILE() at the end of the drain, this should work fine. @@ -1364,8 +1366,8 @@ static void test_detach_indirect(bool by_parent_cb) QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 if (!by_parent_cb) { - detach_by_driver_cb_role =3D child_file; - detach_by_driver_cb_role.drained_begin =3D + detach_by_driver_cb_class =3D child_file; + detach_by_driver_cb_class.drained_begin =3D detach_by_driver_cb_drained_begin; } =20 @@ -1399,7 +1401,7 @@ static void test_detach_indirect(bool by_parent_cb) =20 bdrv_ref(a); bdrv_attach_child(parent_a, a, "PA-A", - by_parent_cb ? &child_file : &detach_by_driver_cb_ro= le, + by_parent_cb ? &child_file : &detach_by_driver_cb_cl= ass, &error_abort); =20 g_assert_cmpint(parent_a->refcnt, =3D=3D, 1); @@ -1735,7 +1737,7 @@ static int drop_intermediate_poll_update_filename(Bdr= vChild *child, /** * Test a poll in the midst of bdrv_drop_intermediate(). * - * bdrv_drop_intermediate() calls BdrvChildRole.update_filename(), + * bdrv_drop_intermediate() calls BdrvChildClass.update_filename(), * which can yield or poll. This may lead to graph changes, unless * the whole subtree in question is drained. * @@ -1772,7 +1774,7 @@ static int drop_intermediate_poll_update_filename(Bdr= vChild *child, * * The solution is for bdrv_drop_intermediate() to drain top's * subtree. This prevents graph changes from happening just because - * BdrvChildRole.update_filename() yields or polls. Thus, the block + * BdrvChildClass.update_filename() yields or polls. Thus, the block * job is paused during that drained section and must finish before or * after. * @@ -1780,7 +1782,7 @@ static int drop_intermediate_poll_update_filename(Bdr= vChild *child, */ static void test_drop_intermediate_poll(void) { - static BdrvChildRole chain_child_role; + static BdrvChildClass chain_child_class; BlockDriverState *chain[3]; TestSimpleBlockJob *job; BlockDriverState *job_node; @@ -1788,8 +1790,8 @@ static void test_drop_intermediate_poll(void) int i; int ret; =20 - chain_child_role =3D child_backing; - chain_child_role.update_filename =3D drop_intermediate_poll_update_fil= ename; + chain_child_class =3D child_backing; + chain_child_class.update_filename =3D drop_intermediate_poll_update_fi= lename; =20 for (i =3D 0; i < 3; i++) { char name[32]; @@ -1810,7 +1812,7 @@ static void test_drop_intermediate_poll(void) if (i) { /* Takes the reference to chain[i - 1] */ chain[i]->backing =3D bdrv_attach_child(chain[i], chain[i - 1], - "chain", &chain_child_ro= le, + "chain", &chain_child_cl= ass, &error_abort); } } diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index a007754d9e..fef42cb294 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -30,7 +30,7 @@ static BlockDriver bdrv_pass_through =3D { }; =20 static void no_perm_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildRole *role, + const BdrvChildClass *child_class, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshare= d) --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547292; cv=none; d=zohomail.com; s=zohoarc; b=QrSpnIFBctnotlwiMm66ukTl3+RpFPfJrQHC3/i6rylT5zWP8y2C4y1XtEqWpIEtVpInMU7e6yNH+wZ5XJUeyWNvlz05t+rgoiNhI7Bg3NGHYKuBGiMzMVl21BGWW2IEcAL1gkrvBGtf5T4a91JYTdkUwZJsDKm2fx1MVyuSq8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547292; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E6lTg6a3QM18al2S3+S2XLqdZEbQ4UGskqMO+IKKf34=; b=CWu8VitXNKBDywG/kUapTZYj6PHpyRKfDb5Nb5oacnNMeyCgchgHovWIAT9w387qHQIQqHvVaXbfV2COusivb1GoOcy+bYHRhujDJXnXAM60RwDYGbnSYR/S+Y2UbWh7Deubd4sDK4pkBr2smdMQy0blRkmbr85cqWXynHtK4WE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547292266799.2885365298794; Fri, 15 May 2020 05:54:52 -0700 (PDT) Received: from localhost ([::1]:46380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZrW-0001sp-RR for importer@patchew.org; Fri, 15 May 2020 08:54:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZj2-0002fV-0X for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:04 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:55473 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZiy-0002HZ-Se for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-IaqU17rrO2agvILcRLZY5Q-1; Fri, 15 May 2020 08:45:54 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 197EF460; Fri, 15 May 2020 12:45:53 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D70A2E047; Fri, 15 May 2020 12:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E6lTg6a3QM18al2S3+S2XLqdZEbQ4UGskqMO+IKKf34=; b=OtYjOoXXz4R5u5IxW88NrAfUBKL3RP0Jhv2JNBbzYwWPbTa1qEVUqiiKzuKoubN7ZkZqFm lwTAGaJQsiOyYTFUq4ciTTXpXOgNlUs3TtxK6zL9naHRATijgZ60T6fzNLndssy7/X2v6h LuSxMLTYF/mTsHOXBrsIhcK9vY4bLoA= X-MC-Unique: IaqU17rrO2agvILcRLZY5Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 16/51] block: Add BdrvChildRole and BdrvChildRoleBits Date: Fri, 15 May 2020 14:44:46 +0200 Message-Id: <20200515124521.335403-17-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) From: Max Reitz This mask will supplement BdrvChildClass when it comes to what role (or combination of roles) a child takes for its parent. It consists of BdrvChildRoleBits values (which is an enum). Because empty enums are not allowed, let us just start with it filled. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-5-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index bc42e507bb..35f1a1cecf 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -268,6 +268,62 @@ enum { DEFAULT_PERM_UNCHANGED =3D BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROU= GH, }; =20 +/* + * Flags that parent nodes assign to child nodes to specify what kind of + * role(s) they take. + * + * At least one of DATA, METADATA, FILTERED, or COW must be set for + * every child. + */ +enum BdrvChildRoleBits { + /* + * This child stores data. + * Any node may have an arbitrary number of such children. + */ + BDRV_CHILD_DATA =3D (1 << 0), + + /* + * This child stores metadata. + * Any node may have an arbitrary number of metadata-storing + * children. + */ + BDRV_CHILD_METADATA =3D (1 << 1), + + /* + * A child that always presents exactly the same visible data as + * the parent, e.g. by virtue of the parent forwarding all reads + * and writes. + * This flag is mutually exclusive with DATA, METADATA, and COW. + * Any node may have at most one filtered child at a time. + */ + BDRV_CHILD_FILTERED =3D (1 << 2), + + /* + * Child from which to read all data that isn=E2=80=99t allocated in t= he + * parent (i.e., the backing child); such data is copied to the + * parent through COW (and optionally COR). + * This field is mutually exclusive with DATA, METADATA, and + * FILTERED. + * Any node may have at most one such backing child at a time. + */ + BDRV_CHILD_COW =3D (1 << 3), + + /* + * The primary child. For most drivers, this is the child whose + * filename applies best to the parent node. + * Any node may have at most one primary child at a time. + */ + BDRV_CHILD_PRIMARY =3D (1 << 4), + + /* Useful combination of flags */ + BDRV_CHILD_IMAGE =3D BDRV_CHILD_DATA + | BDRV_CHILD_METADATA + | BDRV_CHILD_PRIMARY, +}; + +/* Mask of BdrvChildRoleBits values */ +typedef unsigned int BdrvChildRole; + char *bdrv_perm_names(uint64_t perm); uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm); =20 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547414; cv=none; d=zohomail.com; s=zohoarc; b=F/P3fWpilF62iUV2B6Umy+/lexCkAurFLoS+IYffu/YT4CHdFG10xLH76yax2YLzKBpuyRQppvsjG3slEudJppHp169ObY4DTOYmvxNCHwTqXqzoXy8+1ZcFjU3ccwnEXeFMTLp3wWQvfG1PohVktH6IQpsqI3mOmMswNYPpwrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547414; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=psdhIKzz+o+i3IjFZobqM93vouvy1hiHnI9SQsiL3ws=; b=NsCkJKmrxImIYPz+SeraW50h4WWi8tr5thccB/PixtKFNhhbMWBJWNood8L2uOMlacyzXujJF2zUdvAuzRMLVOWpPQMivDJgLSN0Si6GeUrRINProZ2OV0Ne8I4n5iuvgIBVDBi1ZTVRbFy29s4AW3T26Lfu8Az096qozEbDj3Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547414793519.0631901458831; Fri, 15 May 2020 05:56:54 -0700 (PDT) Received: from localhost ([::1]:55068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZtV-0005nw-BA for importer@patchew.org; Fri, 15 May 2020 08:56:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZj6-0002hJ-IQ for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:08 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:60954 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZiy-0002GS-SS for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-HhixXpIwM-G5Uy77WTVkgw-1; Fri, 15 May 2020 08:45:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F28E3A0BDD; Fri, 15 May 2020 12:45:55 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64E0B2E165; Fri, 15 May 2020 12:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=psdhIKzz+o+i3IjFZobqM93vouvy1hiHnI9SQsiL3ws=; b=dntAXcbPHTfZh4wrw/+or+rvmfgHjFc2nhO2UpKhRpGmfXVOJniawIBf0S0ujG/2l1MLH1 CRh9pvlwMHS4NDBO9t5Av5zFSxljhKcfGWG9MrpIbKLMoLANoCLfvjA+LCU18HpoRPBAt7 MU7udAj5t2cZW37oAPJZ/TM4hyq1z8s= X-MC-Unique: HhixXpIwM-G5Uy77WTVkgw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 17/51] block: Add BdrvChildRole to BdrvChild Date: Fri, 15 May 2020 14:44:47 +0200 Message-Id: <20200515124521.335403-18-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz For now, it is always set to 0. Later patches in this series will ensure that all callers pass an appropriate combination of flags. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-6-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block.h | 2 ++ include/block/block_int.h | 2 ++ block.c | 11 ++++++++--- block/backup-top.c | 3 ++- block/blkdebug.c | 2 +- block/blklogwrites.c | 6 +++--- block/blkreplay.c | 2 +- block/blkverify.c | 4 ++-- block/block-backend.c | 4 ++-- block/bochs.c | 2 +- block/cloop.c | 2 +- block/copy-on-read.c | 2 +- block/crypto.c | 2 +- block/dmg.c | 2 +- block/filter-compress.c | 2 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 6 +++--- block/qed.c | 2 +- block/quorum.c | 4 ++-- block/raw-format.c | 2 +- block/replication.c | 2 +- block/throttle.c | 2 +- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 4 ++-- block/vpc.c | 2 +- block/vvfat.c | 2 +- blockjob.c | 5 +++-- tests/test-bdrv-drain.c | 20 +++++++++++--------- tests/test-bdrv-graph-mod.c | 4 ++-- 31 files changed, 62 insertions(+), 49 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 35f1a1cecf..25e299605e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -353,6 +353,7 @@ BdrvChild *bdrv_open_child(const char *filename, QDict *options, const char *bdref_key, BlockDriverState* parent, const BdrvChildClass *child_class, + BdrvChildRole child_role, bool allow_none, Error **errp); BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_h= d, @@ -598,6 +599,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_b= s, BlockDriverState *child_bs, const char *child_name, const BdrvChildClass *child_class, + BdrvChildRole child_role, Error **errp); =20 bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp= ); diff --git a/include/block/block_int.h b/include/block/block_int.h index 9a78b981e4..1c6641c17a 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -746,6 +746,7 @@ struct BdrvChild { BlockDriverState *bs; char *name; const BdrvChildClass *klass; + BdrvChildRole role; void *opaque; =20 /** @@ -1233,6 +1234,7 @@ BlockJob *backup_job_create(const char *job_id, Block= DriverState *bs, BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, const char *child_name, const BdrvChildClass *child_class, + BdrvChildRole child_role, AioContext *ctx, uint64_t perm, uint64_t shared_perm, void *opaque, Error **errp); diff --git a/block.c b/block.c index 0ce9b61c97..14810e0426 100644 --- a/block.c +++ b/block.c @@ -2571,6 +2571,7 @@ static void bdrv_replace_child(BdrvChild *child, Bloc= kDriverState *new_bs) BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, const char *child_name, const BdrvChildClass *child_class, + BdrvChildRole child_role, AioContext *ctx, uint64_t perm, uint64_t shared_perm, void *opaque, Error **errp) @@ -2592,6 +2593,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, .bs =3D NULL, .name =3D g_strdup(child_name), .klass =3D child_class, + .role =3D child_role, .perm =3D perm, .shared_perm =3D shared_perm, .opaque =3D opaque, @@ -2644,6 +2646,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, BlockDriverState *child_bs, const char *child_name, const BdrvChildClass *child_class, + BdrvChildRole child_role, Error **errp) { BdrvChild *child; @@ -2656,7 +2659,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, perm, shared_perm, &perm, &shared_perm); =20 child =3D bdrv_root_attach_child(child_bs, child_name, child_class, - bdrv_get_aio_context(parent_bs), + child_role, bdrv_get_aio_context(parent= _bs), perm, shared_perm, parent_bs, errp); if (child =3D=3D NULL) { return NULL; @@ -2774,7 +2777,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockD= riverState *backing_hd, } =20 bs->backing =3D bdrv_attach_child(bs, backing_hd, "backing", &child_ba= cking, - errp); + 0, errp); /* If backing_hd was already part of bs's backing chain, and * inherits_from pointed recursively to bs then let's update it to * point directly to bs (else it will become NULL). */ @@ -2965,6 +2968,7 @@ BdrvChild *bdrv_open_child(const char *filename, QDict *options, const char *bdref_key, BlockDriverState *parent, const BdrvChildClass *child_class, + BdrvChildRole child_role, bool allow_none, Error **errp) { BlockDriverState *bs; @@ -2975,7 +2979,8 @@ BdrvChild *bdrv_open_child(const char *filename, return NULL; } =20 - return bdrv_attach_child(parent, bs, bdref_key, child_class, errp); + return bdrv_attach_child(parent, bs, bdref_key, child_class, child_rol= e, + errp); } =20 /* diff --git a/block/backup-top.c b/block/backup-top.c index 282845a410..f891dd7838 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -214,7 +214,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverSta= te *source, source->supported_zero_flags); =20 bdrv_ref(target); - state->target =3D bdrv_attach_child(top, target, "target", &child_file= , errp); + state->target =3D bdrv_attach_child(top, target, "target", &child_file= , 0, + errp); if (!state->target) { bdrv_unref(target); bdrv_unref(top); diff --git a/block/blkdebug.c b/block/blkdebug.c index f369d54ee4..c91e78d5c8 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -497,7 +497,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *o= ptions, int flags, =20 /* Open the image file */ bs->file =3D bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "= image", - bs, &child_file, false, &local_err); + bs, &child_file, 0, false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/blklogwrites.c b/block/blklogwrites.c index f3b3259d8d..739db6dcf6 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -157,7 +157,7 @@ static int blk_log_writes_open(BlockDriverState *bs, QD= ict *options, int flags, } =20 /* Open the file */ - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, f= alse, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0= , false, &local_err); if (local_err) { ret =3D -EINVAL; @@ -166,8 +166,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QD= ict *options, int flags, } =20 /* Open the log file */ - s->log_file =3D bdrv_open_child(NULL, options, "log", bs, &child_file,= false, - &local_err); + s->log_file =3D bdrv_open_child(NULL, options, "log", bs, &child_file,= 0, + false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/blkreplay.c b/block/blkreplay.c index 131c9e8477..9b2814fc58 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -28,7 +28,7 @@ static int blkreplay_open(BlockDriverState *bs, QDict *op= tions, int flags, =20 /* Open the image file */ bs->file =3D bdrv_open_child(NULL, options, "image", - bs, &child_file, false, &local_err); + bs, &child_file, 0, false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/blkverify.c b/block/blkverify.c index ba6b1853ae..ba4f6d7b7c 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -125,7 +125,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *= options, int flags, =20 /* Open the raw file */ bs->file =3D bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "ra= w", - bs, &child_file, false, &local_err); + bs, &child_file, 0, false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); @@ -134,7 +134,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *= options, int flags, =20 /* Open the test file */ s->test_file =3D bdrv_open_child(qemu_opt_get(opts, "x-image"), option= s, - "test", bs, &child_format, false, + "test", bs, &child_format, 0, false, &local_err); if (local_err) { ret =3D -EINVAL; diff --git a/block/block-backend.c b/block/block-backend.c index c0af79147a..efc7acb3d8 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -423,7 +423,7 @@ BlockBackend *blk_new_open(const char *filename, const = char *reference, return NULL; } =20 - blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, blk->ctx, + blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, 0, blk->= ctx, perm, BLK_PERM_ALL, blk, errp); if (!blk->root) { blk_unref(blk); @@ -834,7 +834,7 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *= bs, Error **errp) { ThrottleGroupMember *tgm =3D &blk->public.throttle_group_member; bdrv_ref(bs); - blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, blk->ctx, + blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, 0, blk->= ctx, blk->perm, blk->shared_perm, blk, e= rrp); if (blk->root =3D=3D NULL) { return -EPERM; diff --git a/block/bochs.c b/block/bochs.c index e7bbeaa1c4..b013e73063 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -110,7 +110,7 @@ static int bochs_open(BlockDriverState *bs, QDict *opti= ons, int flags, return ret; } =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/cloop.c b/block/cloop.c index f90f1a4b4c..3ed9fa63cc 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -71,7 +71,7 @@ static int cloop_open(BlockDriverState *bs, QDict *option= s, int flags, return ret; } =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/copy-on-read.c b/block/copy-on-read.c index 7504ca6ffc..a2c4e6dc58 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -28,7 +28,7 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, f= alse, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0= , false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/crypto.c b/block/crypto.c index bdb2b27475..8b516bfee2 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -218,7 +218,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat= format, unsigned int cflags =3D 0; QDict *cryptoopts =3D NULL; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/dmg.c b/block/dmg.c index ef3c6e771d..af8188638c 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -439,7 +439,7 @@ static int dmg_open(BlockDriverState *bs, QDict *option= s, int flags, return ret; } =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/filter-compress.c b/block/filter-compress.c index 82c315b298..4dc5f9fb8c 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -30,7 +30,7 @@ static int compress_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, f= alse, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0= , false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/parallels.c b/block/parallels.c index bd5f6ffa09..9855ac1162 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -739,7 +739,7 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, Error *local_err =3D NULL; char *buf; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/qcow.c b/block/qcow.c index 6a72dea049..13583f0339 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -130,7 +130,7 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, qdict_extract_subqdict(options, &encryptopts, "encrypt."); encryptfmt =3D qdict_get_try_str(encryptopts, "format"); =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { ret =3D -EINVAL; diff --git a/block/qcow2.c b/block/qcow2.c index 76bec61ee9..86335d9403 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1591,7 +1591,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, =20 /* Open external data file */ s->data_file =3D bdrv_open_child(NULL, options, "data-file", bs, &chil= d_file, - true, &local_err); + 0, true, &local_err); if (local_err) { error_propagate(errp, local_err); ret =3D -EINVAL; @@ -1601,7 +1601,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) { if (!s->data_file && s->image_data_file) { s->data_file =3D bdrv_open_child(s->image_data_file, options, - "data-file", bs, &child_file, + "data-file", bs, &child_file, 0, false, errp); if (!s->data_file) { ret =3D -EINVAL; @@ -1863,7 +1863,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *op= tions, int flags, .ret =3D -EINPROGRESS }; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/qed.c b/block/qed.c index 337eb6dbb6..1ad2aba810 100644 --- a/block/qed.c +++ b/block/qed.c @@ -547,7 +547,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *o= ptions, int flags, .ret =3D -EINPROGRESS }; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/quorum.c b/block/quorum.c index a0824c300d..024de76e6f 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -977,7 +977,7 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, assert(ret < 32); =20 s->children[i] =3D bdrv_open_child(NULL, options, indexstr, bs, - &child_format, false, &local_err); + &child_format, 0, false, &local_e= rr); if (local_err) { ret =3D -EINVAL; goto close_exit; @@ -1053,7 +1053,7 @@ static void quorum_add_child(BlockDriverState *bs, Bl= ockDriverState *child_bs, /* We can safely add the child now */ bdrv_ref(child_bs); =20 - child =3D bdrv_attach_child(bs, child_bs, indexstr, &child_format, err= p); + child =3D bdrv_attach_child(bs, child_bs, indexstr, &child_format, 0, = errp); if (child =3D=3D NULL) { s->next_child_index--; goto out; diff --git a/block/raw-format.c b/block/raw-format.c index 00e13bb41e..4b8d4ce8be 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -428,7 +428,7 @@ static int raw_open(BlockDriverState *bs, QDict *option= s, int flags, BDRVRawState *s =3D bs->opaque; int ret; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/replication.c b/block/replication.c index af428c5b66..052c7ef601 100644 --- a/block/replication.c +++ b/block/replication.c @@ -90,7 +90,7 @@ static int replication_open(BlockDriverState *bs, QDict *= options, const char *mode; const char *top_id; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/throttle.c b/block/throttle.c index 71f4bb0ad1..2dea913be7 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -82,7 +82,7 @@ static int throttle_open(BlockDriverState *bs, QDict *opt= ions, int ret; =20 bs->file =3D bdrv_open_child(NULL, options, "file", bs, - &child_file, false, errp); + &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/vdi.c b/block/vdi.c index 0ef733ae19..653acb5fc1 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -378,7 +378,7 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, Error *local_err =3D NULL; QemuUUID uuid_link, uuid_parent; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/vhdx.c b/block/vhdx.c index e692cf80cc..dde156c97b 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -996,7 +996,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *optio= ns, int flags, uint64_t signature; Error *local_err =3D NULL; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/vmdk.c b/block/vmdk.c index 56e85689f3..c2cb741e2d 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1152,7 +1152,7 @@ static int vmdk_parse_extents(const char *desc, Block= DriverState *bs, assert(ret < 32); =20 extent_file =3D bdrv_open_child(extent_path, options, extent_opt_p= refix, - bs, &child_file, false, &local_err); + bs, &child_file, 0, false, &local_er= r); g_free(extent_path); if (local_err) { error_propagate(errp, local_err); @@ -1257,7 +1257,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *opt= ions, int flags, uint32_t magic; Error *local_err =3D NULL; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/vpc.c b/block/vpc.c index 46a2d48659..b2a86074a5 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -228,7 +228,7 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, int ret; int64_t bs_size; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/vvfat.c b/block/vvfat.c index f845d9b485..cd8ae50a2c 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3183,7 +3183,7 @@ static int enable_write_target(BlockDriverState *bs, = Error **errp) options =3D qdict_new(); qdict_put_str(options, "write-target.driver", "qcow"); s->qcow =3D bdrv_open_child(s->qcow_filename, options, "write-target",= bs, - &child_vvfat_qcow, false, errp); + &child_vvfat_qcow, 0, false, errp); qobject_unref(options); if (!s->qcow) { ret =3D -EINVAL; diff --git a/blockjob.c b/blockjob.c index be38c8c550..470facfd47 100644 --- a/blockjob.c +++ b/blockjob.c @@ -217,8 +217,9 @@ int block_job_add_bdrv(BlockJob *job, const char *name,= BlockDriverState *bs, if (job->job.aio_context !=3D qemu_get_aio_context()) { aio_context_release(job->job.aio_context); } - c =3D bdrv_root_attach_child(bs, name, &child_job, job->job.aio_contex= t, - perm, shared_perm, job, errp); + c =3D bdrv_root_attach_child(bs, name, &child_job, 0, + job->job.aio_context, perm, shared_perm, jo= b, + errp); if (job->job.aio_context !=3D qemu_get_aio_context()) { aio_context_acquire(job->job.aio_context); } diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 9d683a6c11..c03705ea37 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -1202,7 +1202,7 @@ static void do_test_delete_by_drain(bool detach_inste= ad_of_delete, =20 null_bs =3D bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_P= ROTOCOL, &error_abort); - bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort= ); + bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_ab= ort); =20 /* This child will be the one to pass to requests through to, and * it will stall until a drain occurs */ @@ -1211,13 +1211,13 @@ static void do_test_delete_by_drain(bool detach_ins= tead_of_delete, child_bs->total_sectors =3D 65536 >> BDRV_SECTOR_BITS; /* Takes our reference to child_bs */ tts->wait_child =3D bdrv_attach_child(bs, child_bs, "wait-child", &chi= ld_file, - &error_abort); + 0, &error_abort); =20 /* This child is just there to be deleted * (for detach_instead_of_delete =3D=3D true) */ null_bs =3D bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_P= ROTOCOL, &error_abort); - bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort= ); + bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_ab= ort); =20 blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); blk_insert_bs(blk, bs, &error_abort); @@ -1314,7 +1314,7 @@ static void detach_indirect_bh(void *opaque) =20 bdrv_ref(data->c); data->child_c =3D bdrv_attach_child(data->parent_b, data->c, "PB-C", - &child_file, &error_abort); + &child_file, 0, &error_abort); } =20 static void detach_by_parent_aio_cb(void *opaque, int ret) @@ -1396,13 +1396,15 @@ static void test_detach_indirect(bool by_parent_cb) /* Set child relationships */ bdrv_ref(b); bdrv_ref(a); - child_b =3D bdrv_attach_child(parent_b, b, "PB-B", &child_file, &error= _abort); - child_a =3D bdrv_attach_child(parent_b, a, "PB-A", &child_backing, &er= ror_abort); + child_b =3D bdrv_attach_child(parent_b, b, "PB-B", &child_file, 0, + &error_abort); + child_a =3D bdrv_attach_child(parent_b, a, "PB-A", &child_backing, 0, + &error_abort); =20 bdrv_ref(a); bdrv_attach_child(parent_a, a, "PA-A", by_parent_cb ? &child_file : &detach_by_driver_cb_cl= ass, - &error_abort); + 0, &error_abort); =20 g_assert_cmpint(parent_a->refcnt, =3D=3D, 1); g_assert_cmpint(parent_b->refcnt, =3D=3D, 1); @@ -1813,7 +1815,7 @@ static void test_drop_intermediate_poll(void) /* Takes the reference to chain[i - 1] */ chain[i]->backing =3D bdrv_attach_child(chain[i], chain[i - 1], "chain", &chain_child_cl= ass, - &error_abort); + 0, &error_abort); } } =20 @@ -2031,7 +2033,7 @@ static void do_test_replace_child_mid_drain(int old_d= rain_count, =20 bdrv_ref(old_child_bs); parent_bs->backing =3D bdrv_attach_child(parent_bs, old_child_bs, "chi= ld", - &child_backing, &error_abort); + &child_backing, 0, &error_abort= ); =20 for (i =3D 0; i < old_drain_count; i++) { bdrv_drained_begin(old_child_bs); diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index fef42cb294..8b8c186c9f 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -111,7 +111,7 @@ static void test_update_perm_tree(void) =20 blk_insert_bs(root, bs, &error_abort); =20 - bdrv_attach_child(filter, bs, "child", &child_file, &error_abort); + bdrv_attach_child(filter, bs, "child", &child_file, 0, &error_abort); =20 bdrv_append(filter, bs, &local_err); =20 @@ -177,7 +177,7 @@ static void test_should_update_child(void) bdrv_set_backing_hd(target, bs, &error_abort); =20 g_assert(target->backing->bs =3D=3D bs); - bdrv_attach_child(filter, target, "target", &child_file, &error_abort); + bdrv_attach_child(filter, target, "target", &child_file, 0, &error_abo= rt); bdrv_append(filter, bs, &error_abort); g_assert(target->backing->bs =3D=3D bs); =20 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547492; cv=none; d=zohomail.com; s=zohoarc; b=AUKo3o/sZHl2Z99CGES49tCsrIfAEj6cQ0bvj9ih56gQ/hRkyV73J04ZEprP0nHXKl0iH0s6yt77+BPgBCjJLIl61g8qvrRjQYxNW8l55Fh3QSpWRTBhMT3ZA7+xYclSJGNBocJhGvDRTaOvc6a+wB22x1MbKLulrAV8sUqoXnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547492; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cXbZmViBCSNXKe0OjVMWlzRN0Eg8d8uaFthSAn+STKI=; b=JUn0pNjuGDXxzr8jCPOx81tEKjqU6oHjs0kI6K8vaL1c6+gSvmsb08hexUDxWVtxkysJQFnxFvGSrHiGdRdZUqg6kpUQTwAiwDdud3pkEnQ3HrvrGKSn9FVfCh+nW9d1p7n6nKhIq0uatZTyyNk4X0lcYKMCtVBfaSJ8oZZppds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547492806303.4855198206609; Fri, 15 May 2020 05:58:12 -0700 (PDT) Received: from localhost ([::1]:33260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZul-0000c1-GU for importer@patchew.org; Fri, 15 May 2020 08:58:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZj8-0002kX-NA for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38096 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj5-0002IL-96 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-TVeHH-sdM4yAK4Xuaf157w-1; Fri, 15 May 2020 08:45:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D053C19200C5; Fri, 15 May 2020 12:45:58 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 477CD2E16D; Fri, 15 May 2020 12:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cXbZmViBCSNXKe0OjVMWlzRN0Eg8d8uaFthSAn+STKI=; b=Iq0LBgOIHmDnbdsTGjYJQbqXKA9GbjIZKAhuPhm7319BtP+7qtTB1j5d6xSF4optHZYFMD bFzgVTQ0Ycj6cM74zjcjPDbAZg+LvLUY35tgVayC1RR5OZBWk2e1/SFVnfoEl9ibPay/d8 L33m1EWbIr9oazsXRQThnmpvuJrwPS4= X-MC-Unique: TVeHH-sdM4yAK4Xuaf157w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 18/51] block: Pass BdrvChildRole to bdrv_child_perm() Date: Fri, 15 May 2020 14:44:48 +0200 Message-Id: <20200515124521.335403-19-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz For now, all callers pass 0 and no callee evaluates this value. Later patches will change both. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-7-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 5 ++++- block.c | 22 ++++++++++++---------- block/backup-top.c | 3 ++- block/blkdebug.c | 5 +++-- block/blklogwrites.c | 9 +++++---- block/commit.c | 1 + block/copy-on-read.c | 1 + block/mirror.c | 1 + block/quorum.c | 1 + block/replication.c | 1 + block/vvfat.c | 1 + tests/test-bdrv-drain.c | 5 +++-- tests/test-bdrv-graph-mod.c | 1 + 13 files changed, 36 insertions(+), 20 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 1c6641c17a..dc4bc486d6 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -556,7 +556,7 @@ struct BlockDriver { * the parents in @parent_perm and @parent_shared. * * If @c is NULL, return the permissions for attaching a new child for= the - * given @child_class. + * given @child_class and @role. * * If @reopen_queue is non-NULL, don't return the currently needed * permissions, but those that will be needed after applying the @@ -564,6 +564,7 @@ struct BlockDriver { */ void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared); @@ -1266,6 +1267,7 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, Bd= rvChild *c, Error **errp); * all children */ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole child_role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); @@ -1276,6 +1278,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, = BdrvChild *c, * CONSISTENT_READ and doesn't share WRITE. */ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole child_role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); diff --git a/block.c b/block.c index 14810e0426..5d9a331f5b 100644 --- a/block.c +++ b/block.c @@ -1954,12 +1954,12 @@ bool bdrv_is_writable(BlockDriverState *bs) =20 static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_= bs, BdrvChild *c, const BdrvChildClass *child_clas= s, - BlockReopenQueue *reopen_queue, + BdrvChildRole role, BlockReopenQueue *reopen_q= ueue, uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared) { assert(bs->drv && bs->drv->bdrv_child_perm); - bs->drv->bdrv_child_perm(bs, c, child_class, reopen_queue, + bs->drv->bdrv_child_perm(bs, c, child_class, role, reopen_queue, parent_perm, parent_shared, nperm, nshared); /* TODO Take force_share from reopen_queue */ @@ -2053,7 +2053,7 @@ static int bdrv_check_perm(BlockDriverState *bs, Bloc= kReopenQueue *q, uint64_t cur_perm, cur_shared; bool child_tighten_restr; =20 - bdrv_child_perm(bs, c->bs, c, c->klass, q, + bdrv_child_perm(bs, c->bs, c, c->klass, c->role, q, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); ret =3D bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_c= hildren, @@ -2120,7 +2120,7 @@ static void bdrv_set_perm(BlockDriverState *bs, uint6= 4_t cumulative_perms, /* Update all children */ QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; - bdrv_child_perm(bs, c->bs, c, c->klass, NULL, + bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); bdrv_child_set_perm(c, cur_perm, cur_shared); @@ -2348,14 +2348,15 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, = BdrvChild *c, Error **errp) uint64_t perms, shared; =20 bdrv_get_cumulative_perm(bs, &parent_perms, &parent_shared); - bdrv_child_perm(bs, c->bs, c, c->klass, NULL, parent_perms, parent_sha= red, - &perms, &shared); + bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL, + parent_perms, parent_shared, &perms, &shared); =20 return bdrv_child_try_set_perm(c, perms, shared, errp); } =20 void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) @@ -2366,6 +2367,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, = BdrvChild *c, =20 void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) @@ -2378,7 +2380,7 @@ void bdrv_format_default_perms(BlockDriverState *bs, = BdrvChild *c, =20 /* Apart from the modifications below, the same permissions are * forwarded and left alone as for filters */ - bdrv_filter_default_perms(bs, c, child_class, reopen_queue, + bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, perm, shared, &perm, &shared); =20 /* Format drivers may touch metadata even if the guest doesn't wri= te */ @@ -2655,7 +2657,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm); =20 assert(parent_bs->drv); - bdrv_child_perm(parent_bs, child_bs, NULL, child_class, NULL, + bdrv_child_perm(parent_bs, child_bs, NULL, child_class, child_role, NU= LL, perm, shared_perm, &perm, &shared_perm); =20 child =3D bdrv_root_attach_child(child_bs, child_name, child_class, @@ -3683,7 +3685,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, = Error **errp) if (state->replace_backing_bs && state->new_backing_bs) { uint64_t nperm, nshared; bdrv_child_perm(state->bs, state->new_backing_bs, - NULL, &child_backing, bs_queue, + NULL, &child_backing, 0, bs_queue, state->perm, state->shared_perm, &nperm, &nshared); ret =3D bdrv_check_update_perm(state->new_backing_bs, NULL, @@ -3806,7 +3808,7 @@ static void bdrv_reopen_perm(BlockReopenQueue *q, Blo= ckDriverState *bs, } else { uint64_t nperm, nshared; =20 - bdrv_child_perm(parent->state.bs, bs, c, c->klass, q, + bdrv_child_perm(parent->state.bs, bs, c, c->klass, c->role, q, parent->state.perm, parent->state.shared_perm, &nperm, &nshared); =20 diff --git a/block/backup-top.c b/block/backup-top.c index f891dd7838..e2b4d2acd3 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -123,6 +123,7 @@ static void backup_top_refresh_filename(BlockDriverStat= e *bs) =20 static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) @@ -155,7 +156,7 @@ static void backup_top_child_perm(BlockDriverState *bs,= BdrvChild *c, *nperm =3D BLK_PERM_WRITE; } else { /* Source child */ - bdrv_filter_default_perms(bs, c, child_class, reopen_queue, + bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, perm, shared, nperm, nshared); =20 if (perm & BLK_PERM_WRITE) { diff --git a/block/blkdebug.c b/block/blkdebug.c index c91e78d5c8..8dd8ed6055 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -994,14 +994,15 @@ static int blkdebug_reopen_prepare(BDRVReopenState *r= eopen_state, =20 static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { BDRVBlkdebugState *s =3D bs->opaque; =20 - bdrv_filter_default_perms(bs, c, child_class, reopen_queue, perm, shar= ed, - nperm, nshared); + bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); =20 *nperm |=3D s->take_child_perms; *nshared &=3D ~s->unshare_child_perms; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 739db6dcf6..4faf912ef1 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -283,6 +283,7 @@ static int64_t blk_log_writes_getlength(BlockDriverStat= e *bs) =20 static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *ro_q, uint64_t perm, uint64_t shrd, uint64_t *nperm, uint64_t *nshrd) @@ -294,11 +295,11 @@ static void blk_log_writes_child_perm(BlockDriverStat= e *bs, BdrvChild *c, } =20 if (!strcmp(c->name, "log")) { - bdrv_format_default_perms(bs, c, child_class, ro_q, perm, shrd, np= erm, - nshrd); + bdrv_format_default_perms(bs, c, child_class, role, ro_q, perm, sh= rd, + nperm, nshrd); } else { - bdrv_filter_default_perms(bs, c, child_class, ro_q, perm, shrd, np= erm, - nshrd); + bdrv_filter_default_perms(bs, c, child_class, role, ro_q, perm, sh= rd, + nperm, nshrd); } } =20 diff --git a/block/commit.c b/block/commit.c index 834eeae412..6af1c808bc 100644 --- a/block/commit.c +++ b/block/commit.c @@ -224,6 +224,7 @@ static void bdrv_commit_top_refresh_filename(BlockDrive= rState *bs) =20 static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/copy-on-read.c b/block/copy-on-read.c index a2c4e6dc58..a2d92ac394 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -52,6 +52,7 @@ static int cor_open(BlockDriverState *bs, QDict *options,= int flags, =20 static void cor_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/mirror.c b/block/mirror.c index d6598463d5..cb4bdad32a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1493,6 +1493,7 @@ static void bdrv_mirror_top_refresh_filename(BlockDri= verState *bs) =20 static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/quorum.c b/block/quorum.c index 024de76e6f..d37b77a522 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1152,6 +1152,7 @@ static char *quorum_dirname(BlockDriverState *bs, Err= or **errp) =20 static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/replication.c b/block/replication.c index 052c7ef601..ea87b1a4f0 100644 --- a/block/replication.c +++ b/block/replication.c @@ -164,6 +164,7 @@ static void replication_close(BlockDriverState *bs) =20 static void replication_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/block/vvfat.c b/block/vvfat.c index cd8ae50a2c..6cf3c74fe3 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3211,6 +3211,7 @@ err: =20 static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index c03705ea37..b3d7960bd0 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -87,6 +87,7 @@ static int coroutine_fn bdrv_test_co_preadv(BlockDriverSt= ate *bs, =20 static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) @@ -99,8 +100,8 @@ static void bdrv_test_child_perm(BlockDriverState *bs, B= drvChild *c, child_class =3D &child_file; } =20 - bdrv_format_default_perms(bs, c, child_class, reopen_queue, perm, shar= ed, - nperm, nshared); + bdrv_format_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); } =20 static int bdrv_test_change_backing_file(BlockDriverState *bs, diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index 8b8c186c9f..3707e2533c 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -31,6 +31,7 @@ static BlockDriver bdrv_pass_through =3D { =20 static void no_perm_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshare= d) --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548082; cv=none; d=zohomail.com; s=zohoarc; b=Hh/QF0R4fcpWP7j/bPBt/0cfFOsjUOUTVdi9GTvvkLfnLkFD6JUYrIbB6WQnFVmx5Rsablal17qMBt8Tg2+Ai4TuUy+3pWhbUrwVQIg+1x1qupfn7Zkcy0oJFaMIqiUPNc37kIEfyyRrxUziHXVHJAruauC/LQw+RVuv95jqni0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548082; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v1s3t/dRBy4GneDB2K8TpjvTo7ZENHwEgbFNG0JqQes=; b=Q0/bAqFG/0PSyPkw+owog7rWyh3G2hdYX+HucviupmXPK0p3Sm7F7ZMLXcoIngJveAgT2M171hnzzbC2Mef2PL25b5RN9wm1l9ZRkBL2mOTahhLDe/UZU2R69ThGHvZhidBcEp2lEy1KPfVaf001fsMQpWXposcPEXpDXv0IEko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548082447221.8122201839402; Fri, 15 May 2020 06:08:02 -0700 (PDT) Received: from localhost ([::1]:45168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa4H-0001PR-7Q for importer@patchew.org; Fri, 15 May 2020 09:08:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjA-0002oY-EX for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:12 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54244 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj6-0002IX-Pm for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-cwpNEo4bOYyQBUk8gH8NbA-1; Fri, 15 May 2020 08:46:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A60B8015CE; Fri, 15 May 2020 12:46:00 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D0EC2E047; Fri, 15 May 2020 12:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v1s3t/dRBy4GneDB2K8TpjvTo7ZENHwEgbFNG0JqQes=; b=FLcwMJRiMrINmZST5egzvSiWF6phRDiNtPU7HF2adZTL0YZhiPN1+6X7YEXBidbOB+s4Ir kLpPzi5AV80SKsXEAhenOYHmIFVCXG7PK8AKpPOwmZ1UapKpVmxrcmvaYebgDJbPc+fxx1 TvSXBMKsa67x0tZa+WPXVwWvdp0XyrU= X-MC-Unique: cwpNEo4bOYyQBUk8gH8NbA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 19/51] block: Pass BdrvChildRole to .inherit_options() Date: Fri, 15 May 2020 14:44:49 +0200 Message-Id: <20200515124521.335403-20-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz For now, all callers (effectively) pass 0 and no callee evaluates thie value. Later patches will change both. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-8-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 3 ++- block.c | 40 +++++++++++++++++++++++---------------- block/block-backend.c | 3 ++- block/vvfat.c | 3 ++- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index dc4bc486d6..8c1160a577 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -677,7 +677,8 @@ struct BdrvChildClass { * non-BDS parents. */ bool parent_is_bds; =20 - void (*inherit_options)(int *child_flags, QDict *child_options, + void (*inherit_options)(BdrvChildRole role, + int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options); =20 void (*change_media)(BdrvChild *child, bool load); diff --git a/block.c b/block.c index 5d9a331f5b..40db0b78b9 100644 --- a/block.c +++ b/block.c @@ -77,6 +77,7 @@ static BlockDriverState *bdrv_open_inherit(const char *fi= lename, QDict *options, int flags, BlockDriverState *parent, const BdrvChildClass *child_cla= ss, + BdrvChildRole child_role, Error **errp); =20 /* If non-zero, use only whitelisted block drivers */ @@ -1153,7 +1154,8 @@ static void bdrv_temp_snapshot_options(int *child_fla= gs, QDict *child_options, * Returns the options and flags that bs->file should get if a protocol dr= iver * is expected, based on the given options and flags for the parent BDS */ -static void bdrv_inherited_options(int *child_flags, QDict *child_options, +static void bdrv_inherited_options(BdrvChildRole role, + int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { int flags =3D parent_flags; @@ -1202,10 +1204,11 @@ const BdrvChildClass child_file =3D { * (and not only protocols) is permitted for it, based on the given option= s and * flags for the parent BDS */ -static void bdrv_inherited_fmt_options(int *child_flags, QDict *child_opti= ons, +static void bdrv_inherited_fmt_options(BdrvChildRole role, + int *child_flags, QDict *child_opti= ons, int parent_flags, QDict *parent_opt= ions) { - child_file.inherit_options(child_flags, child_options, + child_file.inherit_options(role, child_flags, child_options, parent_flags, parent_options); =20 *child_flags &=3D ~(BDRV_O_PROTOCOL | BDRV_O_NO_IO); @@ -1286,7 +1289,8 @@ static void bdrv_backing_detach(BdrvChild *c) * Returns the options and flags that bs->backing should get, based on the * given options and flags for the parent BDS */ -static void bdrv_backing_options(int *child_flags, QDict *child_options, +static void bdrv_backing_options(BdrvChildRole role, + int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { int flags =3D parent_flags; @@ -2876,7 +2880,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, } =20 backing_hd =3D bdrv_open_inherit(backing_filename, reference, options,= 0, bs, - &child_backing, errp); + &child_backing, 0, errp); if (!backing_hd) { bs->open_flags |=3D BDRV_O_NO_BACKING; error_prepend(errp, "Could not open backing file: "); @@ -2911,7 +2915,7 @@ free_exit: static BlockDriverState * bdrv_open_child_bs(const char *filename, QDict *options, const char *bdref= _key, BlockDriverState *parent, const BdrvChildClass *child_c= lass, - bool allow_none, Error **errp) + BdrvChildRole child_role, bool allow_none, Error **errp) { BlockDriverState *bs =3D NULL; QDict *image_options; @@ -2942,7 +2946,7 @@ bdrv_open_child_bs(const char *filename, QDict *optio= ns, const char *bdref_key, } =20 bs =3D bdrv_open_inherit(filename, reference, image_options, 0, - parent, child_class, errp); + parent, child_class, child_role, errp); if (!bs) { goto done; } @@ -2976,7 +2980,7 @@ BdrvChild *bdrv_open_child(const char *filename, BlockDriverState *bs; =20 bs =3D bdrv_open_child_bs(filename, options, bdref_key, parent, child_= class, - allow_none, errp); + child_role, allow_none, errp); if (bs =3D=3D NULL) { return NULL; } @@ -3020,7 +3024,7 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef = *ref, Error **errp) =20 } =20 - bs =3D bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp); + bs =3D bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, 0, err= p); obj =3D NULL; qobject_unref(obj); visit_free(v); @@ -3117,6 +3121,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, QDict *options, int flags, BlockDriverState *parent, const BdrvChildClass *child_cla= ss, + BdrvChildRole child_role, Error **errp) { int ret; @@ -3169,7 +3174,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, =20 if (child_class) { bs->inherits_from =3D parent; - child_class->inherit_options(&flags, options, + child_class->inherit_options(child_role, &flags, options, parent->open_flags, parent->options); } =20 @@ -3198,7 +3203,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, flags, options); /* Let bdrv_backing_options() override "read-only" */ qdict_del(options, BDRV_OPT_READ_ONLY); - bdrv_backing_options(&flags, options, flags, options); + bdrv_backing_options(0, &flags, options, flags, options); } =20 bs->open_flags =3D flags; @@ -3240,7 +3245,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, BlockDriverState *file_bs; =20 file_bs =3D bdrv_open_child_bs(filename, options, "file", bs, - &child_file, true, &local_err); + &child_file, 0, true, &local_err); if (local_err) { goto fail; } @@ -3385,7 +3390,7 @@ BlockDriverState *bdrv_open(const char *filename, con= st char *reference, QDict *options, int flags, Error **errp) { return bdrv_open_inherit(filename, reference, options, flags, NULL, - NULL, errp); + NULL, 0, errp); } =20 /* Return true if the NULL-terminated @list contains @str */ @@ -3482,6 +3487,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, BlockDriverState *bs, QDict *options, const BdrvChildClass *kla= ss, + BdrvChildRole role, QDict *parent_options, int parent_flags, bool keep_old_opts) @@ -3537,7 +3543,8 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, /* Inherit from parent node */ if (parent_options) { flags =3D 0; - klass->inherit_options(&flags, options, parent_flags, parent_optio= ns); + klass->inherit_options(role, &flags, options, + parent_flags, parent_options); } else { flags =3D bdrv_get_flags(bs); } @@ -3628,7 +3635,8 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, } =20 bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, - child->klass, options, flags, child_keep_o= ld); + child->klass, child->role, options, flags, + child_keep_old); } =20 return bs_queue; @@ -3638,7 +3646,7 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue = *bs_queue, BlockDriverState *bs, QDict *options, bool keep_old_opts) { - return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, NULL, 0, + return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, 0, NULL, 0, keep_old_opts); } =20 diff --git a/block/block-backend.c b/block/block-backend.c index efc7acb3d8..5539ca8816 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -120,7 +120,8 @@ static QTAILQ_HEAD(, BlockBackend) block_backends =3D static QTAILQ_HEAD(, BlockBackend) monitor_block_backends =3D QTAILQ_HEAD_INITIALIZER(monitor_block_backends); =20 -static void blk_root_inherit_options(int *child_flags, QDict *child_option= s, +static void blk_root_inherit_options(BdrvChildRole role, + int *child_flags, QDict *child_option= s, int parent_flags, QDict *parent_optio= ns) { /* We're not supposed to call this function for root nodes */ diff --git a/block/vvfat.c b/block/vvfat.c index 6cf3c74fe3..4033e4f369 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3128,7 +3128,8 @@ static BlockDriver vvfat_write_target =3D { .bdrv_co_pwritev =3D write_target_commit, }; =20 -static void vvfat_qcow_options(int *child_flags, QDict *child_options, +static void vvfat_qcow_options(BdrvChildRole role, + int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off"); --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547920; cv=none; d=zohomail.com; s=zohoarc; b=lofWmcDzaufQrtU7JBLVpVcf9/vKLXBAdhw4rN8dKModG/KpsamhEe45CY6oN+JVngSjOv0WN6wXKRltZuh4+pyM3tNf/t5GlwnE0gRKKzIL6UPptRyYNTkMHJQ33MCDeiIo0GscNpCOj4p4hJB521j4xj6hnMqYALXGXGX96pA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547920; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kZuazOMUwRLLzk5qHTUyroYUdMh+epEeiUtdPFvTmns=; b=KdOT/vTqe0+5IbTSTOsRqOrdEg+e7N7yTes8AN2URhTuhC72xIBySjreReNIp1GCAmHfu837O/2uwwoMFdC3g7h1+40IfAw2hZ+NUWShuoAzMzfSJUxMLd4+9c67L6JyYM2JGjRo2st4NLTmdzozzcojNcbj6EArGklfPfWXcRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547920933133.5502236787396; Fri, 15 May 2020 06:05:20 -0700 (PDT) Received: from localhost ([::1]:34086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa1g-0005CW-4B for importer@patchew.org; Fri, 15 May 2020 09:05:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZj8-0002jN-5Y for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46919 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj5-0002IP-Ha for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-5dvDr0AQMH2nLzQ4XhG53g-1; Fri, 15 May 2020 08:46:02 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7196DA0BD7; Fri, 15 May 2020 12:46:01 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 734C62E170; Fri, 15 May 2020 12:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kZuazOMUwRLLzk5qHTUyroYUdMh+epEeiUtdPFvTmns=; b=RqaxBLi5DHGZabnjb2CbiR3fZuupE30UuNxQeQJmv2YkLYdxsVEZ20V1wgtYj/fLFGfDpC gDf8Yztu9GlOqtX8Qk9lnRHKLFBui7THvzXDZIExPEs4MyO6OsjYMJqu7LcPHmWLgnHQjD rwxfPZXzJ+r7bQZK06BW6LQ/sxjnALc= X-MC-Unique: 5dvDr0AQMH2nLzQ4XhG53g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 20/51] block: Pass parent_is_format to .inherit_options() Date: Fri, 15 May 2020 14:44:50 +0200 Message-Id: <20200515124521.335403-21-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz We plan to unify the generic .inherit_options() functions. The resulting common function will need to decide whether to force-enable format probing, force-disable it, or leave it as-is. To make this decision, it will need to know whether the parent node is a format node or not (because we never want format probing if the parent is a format node already (except for the backing chain)). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-9-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 2 +- block.c | 37 +++++++++++++++++++++++++++---------- block/block-backend.c | 2 +- block/vvfat.c | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 8c1160a577..6245d8a18d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -677,7 +677,7 @@ struct BdrvChildClass { * non-BDS parents. */ bool parent_is_bds; =20 - void (*inherit_options)(BdrvChildRole role, + void (*inherit_options)(BdrvChildRole role, bool parent_is_format, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options); =20 diff --git a/block.c b/block.c index 40db0b78b9..b78e2dc141 100644 --- a/block.c +++ b/block.c @@ -1154,7 +1154,7 @@ static void bdrv_temp_snapshot_options(int *child_fla= gs, QDict *child_options, * Returns the options and flags that bs->file should get if a protocol dr= iver * is expected, based on the given options and flags for the parent BDS */ -static void bdrv_inherited_options(BdrvChildRole role, +static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_form= at, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { @@ -1205,10 +1205,12 @@ const BdrvChildClass child_file =3D { * flags for the parent BDS */ static void bdrv_inherited_fmt_options(BdrvChildRole role, + bool parent_is_format, int *child_flags, QDict *child_opti= ons, int parent_flags, QDict *parent_opt= ions) { - child_file.inherit_options(role, child_flags, child_options, + child_file.inherit_options(role, parent_is_format, + child_flags, child_options, parent_flags, parent_options); =20 *child_flags &=3D ~(BDRV_O_PROTOCOL | BDRV_O_NO_IO); @@ -1289,7 +1291,7 @@ static void bdrv_backing_detach(BdrvChild *c) * Returns the options and flags that bs->backing should get, based on the * given options and flags for the parent BDS */ -static void bdrv_backing_options(BdrvChildRole role, +static void bdrv_backing_options(BdrvChildRole role, bool parent_is_format, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { @@ -3173,8 +3175,22 @@ static BlockDriverState *bdrv_open_inherit(const cha= r *filename, bs->explicit_options =3D qdict_clone_shallow(options); =20 if (child_class) { + bool parent_is_format; + + if (parent->drv) { + parent_is_format =3D parent->drv->is_format; + } else { + /* + * parent->drv is not set yet because this node is opened for + * (potential) format probing. That means that @parent is goi= ng + * to be a format node. + */ + parent_is_format =3D true; + } + bs->inherits_from =3D parent; - child_class->inherit_options(child_role, &flags, options, + child_class->inherit_options(child_role, parent_is_format, + &flags, options, parent->open_flags, parent->options); } =20 @@ -3203,7 +3219,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, flags, options); /* Let bdrv_backing_options() override "read-only" */ qdict_del(options, BDRV_OPT_READ_ONLY); - bdrv_backing_options(0, &flags, options, flags, options); + bdrv_backing_options(0, true, &flags, options, flags, options); } =20 bs->open_flags =3D flags; @@ -3488,6 +3504,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, QDict *options, const BdrvChildClass *kla= ss, BdrvChildRole role, + bool parent_is_format, QDict *parent_options, int parent_flags, bool keep_old_opts) @@ -3543,7 +3560,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, /* Inherit from parent node */ if (parent_options) { flags =3D 0; - klass->inherit_options(role, &flags, options, + klass->inherit_options(role, parent_is_format, &flags, options, parent_flags, parent_options); } else { flags =3D bdrv_get_flags(bs); @@ -3635,8 +3652,8 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, } =20 bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, - child->klass, child->role, options, flags, - child_keep_old); + child->klass, child->role, bs->drv->is_for= mat, + options, flags, child_keep_old); } =20 return bs_queue; @@ -3646,8 +3663,8 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue = *bs_queue, BlockDriverState *bs, QDict *options, bool keep_old_opts) { - return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, 0, NULL, 0, - keep_old_opts); + return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, 0, false, + NULL, 0, keep_old_opts); } =20 /* diff --git a/block/block-backend.c b/block/block-backend.c index 5539ca8816..f2e81af27d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -120,7 +120,7 @@ static QTAILQ_HEAD(, BlockBackend) block_backends =3D static QTAILQ_HEAD(, BlockBackend) monitor_block_backends =3D QTAILQ_HEAD_INITIALIZER(monitor_block_backends); =20 -static void blk_root_inherit_options(BdrvChildRole role, +static void blk_root_inherit_options(BdrvChildRole role, bool parent_is_fo= rmat, int *child_flags, QDict *child_option= s, int parent_flags, QDict *parent_optio= ns) { diff --git a/block/vvfat.c b/block/vvfat.c index 4033e4f369..b4c8417dbd 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3128,7 +3128,7 @@ static BlockDriver vvfat_write_target =3D { .bdrv_co_pwritev =3D write_target_commit, }; =20 -static void vvfat_qcow_options(BdrvChildRole role, +static void vvfat_qcow_options(BdrvChildRole role, bool parent_is_format, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547612; cv=none; d=zohomail.com; s=zohoarc; b=jNOQlRT4FlylAITvUc30BSb6hYFDZb5F1iALLWCvwGa/17apDfOk1be+NAw2KqZu/Rhj4MbGx1OWBPwwq15nRdGAxE4gSYSXUJNzm2o1ZsEGHhh6v3Isu5ulcmlIuJLjvl3ArjKAblEknb6l/6soBMLM7lzlsRF1D4XE/9eRnCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LI8hWiVUlR+qR8sXUC4GxrhVDHxiB8nQBBhLhbUSF4M=; b=IM3nEnRzfkbu2ZdKvL5H37XBPTyzAQPCQYeUT9W7GraZRgrePB/0iQhr0qHwf/0/BVHW140PS34jjg08GQzftix+Wk4+KoQ4xC9GFEyz2Ke7z9J1ZNes8GaQFfx79+Mx429ArJ+T3TDZ5MMp/gluM/wGFLTJ0AAH+ZagrVvmHlA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547612574568.3897973971282; Fri, 15 May 2020 06:00:12 -0700 (PDT) Received: from localhost ([::1]:42132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZwf-0004FK-8Z for importer@patchew.org; Fri, 15 May 2020 09:00:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZj9-0002m9-DL for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54425 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj6-0002Iq-Q6 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-GSt4jjX3NUKeGUyNFOXrtQ-1; Fri, 15 May 2020 08:46:03 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4711107ACCA; Fri, 15 May 2020 12:46:02 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC2C62E047; Fri, 15 May 2020 12:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LI8hWiVUlR+qR8sXUC4GxrhVDHxiB8nQBBhLhbUSF4M=; b=cs7REZ66ruZQ0VkAom78fEF/8IwKza2tKApwDLviaAqQLoQDcOTfD34yWjUy4JFfiJQmjd RlSiZ7CtcWGqYuMdzpUiNcAYvtqakyZ1lPg6fUdYowc79HB+rU6e7dQ6InttIJLexO21zK Abu/ioeiRWYqwvUQkGVa1/VV4mluQvs= X-MC-Unique: GSt4jjX3NUKeGUyNFOXrtQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 21/51] block: Rename bdrv_inherited_options() Date: Fri, 15 May 2020 14:44:51 +0200 Message-Id: <20200515124521.335403-22-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz The other two .inherit_options implementations specify exactly for what case they are used in their name, so do it for this one as well. (The actual intention behind this patch is to follow it up with a generic bdrv_inherited_options() that works for all three cases.) Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-10-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index b78e2dc141..a17c29f54b 100644 --- a/block.c +++ b/block.c @@ -1154,9 +1154,9 @@ static void bdrv_temp_snapshot_options(int *child_fla= gs, QDict *child_options, * Returns the options and flags that bs->file should get if a protocol dr= iver * is expected, based on the given options and flags for the parent BDS */ -static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_form= at, - int *child_flags, QDict *child_options, - int parent_flags, QDict *parent_options) +static void bdrv_protocol_options(BdrvChildRole role, bool parent_is_forma= t, + int *child_flags, QDict *child_options, + int parent_flags, QDict *parent_options) { int flags =3D parent_flags; =20 @@ -1188,7 +1188,7 @@ static void bdrv_inherited_options(BdrvChildRole role= , bool parent_is_format, const BdrvChildClass child_file =3D { .parent_is_bds =3D true, .get_parent_desc =3D bdrv_child_get_parent_desc, - .inherit_options =3D bdrv_inherited_options, + .inherit_options =3D bdrv_protocol_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_poll =3D bdrv_child_cb_drained_poll, .drained_end =3D bdrv_child_cb_drained_end, --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547878; cv=none; d=zohomail.com; s=zohoarc; b=IwD5AyAi/g0Xe0hwHmjlW03gb/31J883rE+lvjaK7qPpuvB8to1DTjge3qU2Pm9mxakPHoUSVOhUIvkUvsC6eTl0AzyP9OlMgmCWaI6PlHDkQLauv/eGPFwrIZaJrNZLN32V/ncrGsJOzrvSVJtikBRAbquJkiS38a2gnF4jLPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547878; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xau3w4/FDTCzH9G17oEDTboAtqMKxSW7pRrLRICh2vU=; b=f4rWj2o43I56iaJjX3EfD7cGQUkGoYgQLVPoqGruMujtKGCzO5xBjBCug4KBF9tz0evdPplUw4of61WQnrt9lDB3bgLMz4UooTYsThoDj2aFZwCTtaDMvIUzcXktKyfMZ4R80nbw8DStdUi0SB1NkLLyBgdYZK/1j/6NNAP+5aM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158954787804881.28077387265921; Fri, 15 May 2020 06:04:38 -0700 (PDT) Received: from localhost ([::1]:58972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa0x-0003V7-DR for importer@patchew.org; Fri, 15 May 2020 09:04:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjB-0002pX-1q for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:13 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:21499 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj8-0002Jn-9R for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-G8xk_zt-MqmFh8LOpinW7Q-1; Fri, 15 May 2020 08:46:05 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 025E1460; Fri, 15 May 2020 12:46:04 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09E892E024; Fri, 15 May 2020 12:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xau3w4/FDTCzH9G17oEDTboAtqMKxSW7pRrLRICh2vU=; b=FhsEULHKhIEmFn5e2nKKp5eCc4DKF26ysnAZFa9bo04Qc/dzpZpF3gDfShEQaEFDBEhv/+ VZ/DgjHpPQbx+SIRDuquYO3FK8OEQWLbP8uH4Vn3ctjwduCaqVu45hJSl4kNfaaW8Kl8fx eaJwfXmbmGCQ+Akg7KKii7SXBtAZgvs= X-MC-Unique: G8xk_zt-MqmFh8LOpinW7Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 22/51] block: Add generic bdrv_inherited_options() Date: Fri, 15 May 2020 14:44:52 +0200 Message-Id: <20200515124521.335403-23-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz After the series this patch belongs to, we want to have a common BdrvChildClass that encompasses all of child_file, child_format, and child_backing. Such a single class needs a single .inherit_options() implementation, and this patch introduces it. The next patch will show how the existing implementations can fall back to it just by passing appropriate BdrvChildRole and parent_is_format values. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-11-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/block.c b/block.c index a17c29f54b..9b0e13d537 100644 --- a/block.c +++ b/block.c @@ -1356,6 +1356,87 @@ const BdrvChildClass child_backing =3D { .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, }; =20 +/* + * Returns the options and flags that a generic child of a BDS should + * get, based on the given options and flags for the parent BDS. + */ +static void __attribute__((unused)) + bdrv_inherited_options(BdrvChildRole role, bool parent_is_format, + int *child_flags, QDict *child_options, + int parent_flags, QDict *parent_options) +{ + int flags =3D parent_flags; + + /* + * First, decide whether to set, clear, or leave BDRV_O_PROTOCOL. + * Generally, the question to answer is: Should this child be + * format-probed by default? + */ + + /* + * Pure and non-filtered data children of non-format nodes should + * be probed by default (even when the node itself has BDRV_O_PROTOCOL + * set). This only affects a very limited set of drivers (namely + * quorum and blkverify when this comment was written). + * Force-clear BDRV_O_PROTOCOL then. + */ + if (!parent_is_format && + (role & BDRV_CHILD_DATA) && + !(role & (BDRV_CHILD_METADATA | BDRV_CHILD_FILTERED))) + { + flags &=3D ~BDRV_O_PROTOCOL; + } + + /* + * All children of format nodes (except for COW children) and all + * metadata children in general should never be format-probed. + * Force-set BDRV_O_PROTOCOL then. + */ + if ((parent_is_format && !(role & BDRV_CHILD_COW)) || + (role & BDRV_CHILD_METADATA)) + { + flags |=3D BDRV_O_PROTOCOL; + } + + /* + * If the cache mode isn't explicitly set, inherit direct and no-flush= from + * the parent. + */ + qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIREC= T); + qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FL= USH); + qdict_copy_default(child_options, parent_options, BDRV_OPT_FORCE_SHARE= ); + + if (role & BDRV_CHILD_COW) { + /* backing files are opened read-only by default */ + qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on"); + qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off= "); + } else { + /* Inherit the read-only option from the parent if it's not set */ + qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ON= LY); + qdict_copy_default(child_options, parent_options, + BDRV_OPT_AUTO_READ_ONLY); + } + + /* + * bdrv_co_pdiscard() respects unmap policy for the parent, so we + * can default to enable it on lower layers regardless of the + * parent option. + */ + qdict_set_default_str(child_options, BDRV_OPT_DISCARD, "unmap"); + + /* Clear flags that only apply to the top layer */ + flags &=3D ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_READ= ); + + if (role & BDRV_CHILD_METADATA) { + flags &=3D ~BDRV_O_NO_IO; + } + if (role & BDRV_CHILD_COW) { + flags &=3D ~BDRV_O_TEMPORARY; + } + + *child_flags =3D flags; +} + static int bdrv_open_flags(BlockDriverState *bs, int flags) { int open_flags =3D flags; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547747; cv=none; d=zohomail.com; s=zohoarc; b=V1KMcPjK54/svoWPPInF7QZV1hmxQwxDAhCnVly8//mP1zC5eoOA4X7a8zDwthsxtNK24A/626ANdNEbhr4GjxoP9QhX7JjRR5SL+L0/CMkqsO7oAmEVi3apSAaUsELwqK8P3P2Voz+7XefS5hitF/1n9Q7eGxfcTXbH8U4guLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547747; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mk9ReFM1xpWL+5m+Wa5jigFpLRzNSjDioJie81B+hQE=; b=F6NLfL8pDdctaW5ueJbVQGDf3nYHfwI/KnTPb3CBhPHkPJ2zIsZf6w5SHRHSp37u7jJfU80THMMsaX5aYCRkTFIHQ5MdUaMXgHdqlcUk7HvZpYIy4+8AvheP4JR0KA7KiZJbbtsXTJS0lFBUIKd2eSZCacXrnq+LaC0NsqNK6Co= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547747396654.326665993383; Fri, 15 May 2020 06:02:27 -0700 (PDT) Received: from localhost ([::1]:50680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZys-00006k-IF for importer@patchew.org; Fri, 15 May 2020 09:02:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjA-0002oR-DM for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:12 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40639 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj7-0002Ix-PX for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-UBhOJoXpMS6FtpEPYy-bog-1; Fri, 15 May 2020 08:46:06 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44B4E107ACCA; Fri, 15 May 2020 12:46:05 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C08A2E024; Fri, 15 May 2020 12:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mk9ReFM1xpWL+5m+Wa5jigFpLRzNSjDioJie81B+hQE=; b=ATrTEEVQ3TVq/Ha2A1aL+lVehMzUyTehfb3WGgG4MCYwbNXDrrJIIjA2Zuk+QlrO2SMyOf eMt7Z86A8GJpnIZLfxJoso9epp9ue19pBO4KcszXPzL6ROP3y5aZUxmBoVbMN9meYlskbW YAlwNCgvD1MLB1aMp/q76J8LU6NQfiE= X-MC-Unique: UBhOJoXpMS6FtpEPYy-bog-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 23/51] block: Use bdrv_inherited_options() Date: Fri, 15 May 2020 14:44:53 +0200 Message-Id: <20200515124521.335403-24-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Let child_file's, child_format's, and child_backing's .inherit_options() implementations fall back to bdrv_inherited_options() to show that it would really work for all of these cases, if only the parents passed the appropriate BdrvChildRole and parent_is_format values. (Also, make bdrv_open_inherit(), the only place to explicitly call bdrv_backing_options(), call bdrv_inherited_options() instead.) This patch should incur only two visible changes, both for child_format children, both of which are effectively bug fixes: First, they no longer have discard=3Dunmap set by default. This reason it was set is because bdrv_inherited_fmt_options() fell through to bdrv_protocol_options(), and that set it because "format drivers take care to send flushes and respect unmap policy". None of the drivers that use child_format for their children (quorum and blkverify) are format drivers, though, so this reasoning does not apply here. Second, they no longer have BDRV_O_NO_IO force-cleared. child_format was used solely for children that do not store any metadata and as such will not be accessed by their parents as long as those parents do not receive I/O themselves. Thus, such children should inherit BDRV_O_NO_IO. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-12-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 71 +++++++++++++++------------------------------------------ 1 file changed, 19 insertions(+), 52 deletions(-) diff --git a/block.c b/block.c index 9b0e13d537..b3b978a092 100644 --- a/block.c +++ b/block.c @@ -80,6 +80,11 @@ static BlockDriverState *bdrv_open_inherit(const char *f= ilename, BdrvChildRole child_role, Error **errp); =20 +/* TODO: Remove when no longer needed */ +static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_form= at, + int *child_flags, QDict *child_options, + int parent_flags, QDict *parent_options= ); + /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; =20 @@ -1158,31 +1163,9 @@ static void bdrv_protocol_options(BdrvChildRole role= , bool parent_is_format, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { - int flags =3D parent_flags; - - /* Enable protocol handling, disable format probing for bs->file */ - flags |=3D BDRV_O_PROTOCOL; - - /* If the cache mode isn't explicitly set, inherit direct and no-flush= from - * the parent. */ - qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIREC= T); - qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FL= USH); - qdict_copy_default(child_options, parent_options, BDRV_OPT_FORCE_SHARE= ); - - /* Inherit the read-only option from the parent if it's not set */ - qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY); - qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_O= NLY); - - /* Our block drivers take care to send flushes and respect unmap polic= y, - * so we can default to enable both on lower layers regardless of the - * corresponding parent options. */ - qdict_set_default_str(child_options, BDRV_OPT_DISCARD, "unmap"); - - /* Clear flags that only apply to the top layer */ - flags &=3D ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_COPY_ON_READ= | - BDRV_O_NO_IO); - - *child_flags =3D flags; + bdrv_inherited_options(BDRV_CHILD_IMAGE, true, + child_flags, child_options, + parent_flags, parent_options); } =20 const BdrvChildClass child_file =3D { @@ -1209,11 +1192,9 @@ static void bdrv_inherited_fmt_options(BdrvChildRole= role, int *child_flags, QDict *child_opti= ons, int parent_flags, QDict *parent_opt= ions) { - child_file.inherit_options(role, parent_is_format, - child_flags, child_options, - parent_flags, parent_options); - - *child_flags &=3D ~(BDRV_O_PROTOCOL | BDRV_O_NO_IO); + bdrv_inherited_options(BDRV_CHILD_DATA, false, + child_flags, child_options, + parent_flags, parent_options); } =20 const BdrvChildClass child_format =3D { @@ -1295,23 +1276,9 @@ static void bdrv_backing_options(BdrvChildRole role,= bool parent_is_format, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options) { - int flags =3D parent_flags; - - /* The cache mode is inherited unmodified for backing files; except WC= E, - * which is only applied on the top level (BlockBackend) */ - qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIREC= T); - qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FL= USH); - qdict_copy_default(child_options, parent_options, BDRV_OPT_FORCE_SHARE= ); - - /* backing files always opened read-only */ - qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on"); - qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off"); - flags &=3D ~BDRV_O_COPY_ON_READ; - - /* snapshot=3Don is handled on the top layer */ - flags &=3D ~(BDRV_O_SNAPSHOT | BDRV_O_TEMPORARY); - - *child_flags =3D flags; + bdrv_inherited_options(BDRV_CHILD_COW, true, + child_flags, child_options, + parent_flags, parent_options); } =20 static int bdrv_backing_update_filename(BdrvChild *c, BlockDriverState *ba= se, @@ -1360,10 +1327,9 @@ const BdrvChildClass child_backing =3D { * Returns the options and flags that a generic child of a BDS should * get, based on the given options and flags for the parent BDS. */ -static void __attribute__((unused)) - bdrv_inherited_options(BdrvChildRole role, bool parent_is_format, - int *child_flags, QDict *child_options, - int parent_flags, QDict *parent_options) +static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_form= at, + int *child_flags, QDict *child_options, + int parent_flags, QDict *parent_options) { int flags =3D parent_flags; =20 @@ -3300,7 +3266,8 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, flags, options); /* Let bdrv_backing_options() override "read-only" */ qdict_del(options, BDRV_OPT_READ_ONLY); - bdrv_backing_options(0, true, &flags, options, flags, options); + bdrv_inherited_options(BDRV_CHILD_COW, true, + &flags, options, flags, options); } =20 bs->open_flags =3D flags; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548011; cv=none; d=zohomail.com; s=zohoarc; b=mv6rcTaVUP8ZldHrzCLQC+O1ixv+okYzKcvyK2ytX7vq5uWNARXtOoiphMSk/HJ5zZVp6j2udNkyiznaGuazRhxBuxKhZ0TAnyFFdmjXU/hlVuuH1rXZAFZfMIWxjC705ZbyU3zt2pB8IYXil9AEx7RcRQJfkkjZTyZ6SEHVs5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548011; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NbJfsYfo07GaMxBwWalEQHpvwpMDYTD/7dFv2WLaHhQ=; b=W15W+6di3Aq8MAtFTmDD9O+W2mRCNfAtXc71BU00VSiAgDV2D0wwMo72UTyyjTJsaN1L8nVcfoRbci7Aiu/aMmBIzW8nqFl23F+dSmlLAIQnVTeNEp4x9iKI7dY+kr9DS45zMyvUjUe7RolRHhRYkM3+5hJrcNmvtmiwpW8mKmw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548011182744.9786510368322; Fri, 15 May 2020 06:06:51 -0700 (PDT) Received: from localhost ([::1]:40040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa37-0007lW-Q1 for importer@patchew.org; Fri, 15 May 2020 09:06:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjF-0002zA-9G for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29764 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj9-0002KT-47 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-MGC3ZNoHPOitsbqmGZPFsQ-1; Fri, 15 May 2020 08:46:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87078801503; Fri, 15 May 2020 12:46:06 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EFA12E024; Fri, 15 May 2020 12:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NbJfsYfo07GaMxBwWalEQHpvwpMDYTD/7dFv2WLaHhQ=; b=QKhdvCtPQHP8NzXPfKTDk3uxyVCDx7uFrUwcxBsAq/+p5dtbbMLhpnxpto/TuXA4AEoqaJ MsypIyBajZDq2sHHKtsgHBHBQVt3WnAnKBT9+HdNENL2dAI0CHE3yWuD06V+maR3sllXkl u0COnEQ+pSmCnENJ4QhWtwXcKQeg+z0= X-MC-Unique: MGC3ZNoHPOitsbqmGZPFsQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 24/51] block: Unify bdrv_child_cb_attach() Date: Fri, 15 May 2020 14:44:54 +0200 Message-Id: <20200515124521.335403-25-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Make bdrv_child_cb_attach() call bdrv_backing_attach() for children with a COW role (and drop the reverse call from bdrv_backing_attach()), so it can be used for any child (with a proper role set). Because so far no child has a proper role set, we need a temporary new callback for child_backing.attach that ensures bdrv_backing_attach() is called for all COW children that do not have their role set yet. (Also, move bdrv_child_cb_attach() down to group it with bdrv_inherited_options().) Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-13-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index b3b978a092..755704a54c 100644 --- a/block.c +++ b/block.c @@ -84,6 +84,7 @@ static BlockDriverState *bdrv_open_inherit(const char *fi= lename, static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_form= at, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options= ); +static void bdrv_child_cb_attach(BdrvChild *child); =20 /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; @@ -1099,12 +1100,6 @@ static void bdrv_child_cb_drained_end(BdrvChild *chi= ld, bdrv_drained_end_no_poll(bs, drained_end_counter); } =20 -static void bdrv_child_cb_attach(BdrvChild *child) -{ - BlockDriverState *bs =3D child->opaque; - bdrv_apply_subtree_drain(child, bs); -} - static void bdrv_child_cb_detach(BdrvChild *child) { BlockDriverState *bs =3D child->opaque; @@ -1252,7 +1247,14 @@ static void bdrv_backing_attach(BdrvChild *c) parent->backing_blocker); bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_TARGET, parent->backing_blocker); +} =20 +/* XXX: Will be removed along with child_backing */ +static void bdrv_child_cb_attach_backing(BdrvChild *c) +{ + if (!(c->role & BDRV_CHILD_COW)) { + bdrv_backing_attach(c); + } bdrv_child_cb_attach(c); } =20 @@ -1311,7 +1313,7 @@ static int bdrv_backing_update_filename(BdrvChild *c,= BlockDriverState *base, const BdrvChildClass child_backing =3D { .parent_is_bds =3D true, .get_parent_desc =3D bdrv_child_get_parent_desc, - .attach =3D bdrv_backing_attach, + .attach =3D bdrv_child_cb_attach_backing, .detach =3D bdrv_backing_detach, .inherit_options =3D bdrv_backing_options, .drained_begin =3D bdrv_child_cb_drained_begin, @@ -1403,6 +1405,17 @@ static void bdrv_inherited_options(BdrvChildRole rol= e, bool parent_is_format, *child_flags =3D flags; } =20 +static void bdrv_child_cb_attach(BdrvChild *child) +{ + BlockDriverState *bs =3D child->opaque; + + if (child->role & BDRV_CHILD_COW) { + bdrv_backing_attach(child); + } + + bdrv_apply_subtree_drain(child, bs); +} + static int bdrv_open_flags(BlockDriverState *bs, int flags) { int open_flags =3D flags; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547529; cv=none; d=zohomail.com; s=zohoarc; b=mGiMwV6uRbH7vVFyqtUCxSVLSKl2QzpqThvxscZvNMW6xD09PJSHNxLHQKnkObeTaKU3VdcD44KGna2LdOZDTYNS8VQcxzaj0pWOtCNfGgKGdCOr7VFS0DlU9m6Kwp4nKA86yRgYI6Rzmfacu43Xg5PQw2FkrdRpNUFyCwy9Hh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547529; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zQUje6L++K+HCykTJZlsV1fOYXQaL1kXm8P3kuauhOk=; b=hVPLECrAa2fpDVEFD8aE9A88scH6rdZeyl6uyJjEAoQl7nIWPzliwFrCOnhEVk6uBrsHFonCzhKGbD4z2BettxQbB9o5+1N/xz71oL4rFuLbQSmqN6SGBde3TNE+rHzU80XzPiePbf7geMc36g/tPjPi616UOzDpSAKhiOBi5+Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547529670328.59060782782853; Fri, 15 May 2020 05:58:49 -0700 (PDT) Received: from localhost ([::1]:36934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZvM-00029H-C2 for importer@patchew.org; Fri, 15 May 2020 08:58:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjC-0002sV-IV for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22893 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZj9-0002LK-Vg for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-348-To8sZwWdM2a5n2HkH0-flA-1; Fri, 15 May 2020 08:46:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C959CA0BD7; Fri, 15 May 2020 12:46:07 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0A262E024; Fri, 15 May 2020 12:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zQUje6L++K+HCykTJZlsV1fOYXQaL1kXm8P3kuauhOk=; b=T4cQsXthTPpRXsbHzMC4aYtSIvWTAX+A3XIlnegbWRSTno0pcuTcoN0g5v08u9t5ZteOHG 1jd7zUsZCdUFIEHbq07UygnDtbBwqcQNaFzfT4ObUJoWExeq37UZ4hBF6Y/okDpYSdIZKp ER/XiwAiNqhDG9eF/ZdBvxHPzFRtlhY= X-MC-Unique: To8sZwWdM2a5n2HkH0-flA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 25/51] block: Unify bdrv_child_cb_detach() Date: Fri, 15 May 2020 14:44:55 +0200 Message-Id: <20200515124521.335403-26-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Make bdrv_child_cb_detach() call bdrv_backing_detach() for children with a COW role (and drop the reverse call from bdrv_backing_detach()), so it can be used for any child (with a proper role set). Because so far no child has a proper role set, we need a temporary new callback for child_backing.detach that ensures bdrv_backing_detach() is called for all COW children that do not have their role set yet. (Also, move bdrv_child_cb_detach() down to group it with bdrv_inherited_options() and bdrv_child_cb_attach().) Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-14-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index 755704a54c..f63417c06d 100644 --- a/block.c +++ b/block.c @@ -85,6 +85,7 @@ static void bdrv_inherited_options(BdrvChildRole role, bo= ol parent_is_format, int *child_flags, QDict *child_options, int parent_flags, QDict *parent_options= ); static void bdrv_child_cb_attach(BdrvChild *child); +static void bdrv_child_cb_detach(BdrvChild *child); =20 /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; @@ -1100,12 +1101,6 @@ static void bdrv_child_cb_drained_end(BdrvChild *chi= ld, bdrv_drained_end_no_poll(bs, drained_end_counter); } =20 -static void bdrv_child_cb_detach(BdrvChild *child) -{ - BlockDriverState *bs =3D child->opaque; - bdrv_unapply_subtree_drain(child, bs); -} - static int bdrv_child_cb_inactivate(BdrvChild *child) { BlockDriverState *bs =3D child->opaque; @@ -1266,7 +1261,14 @@ static void bdrv_backing_detach(BdrvChild *c) bdrv_op_unblock_all(c->bs, parent->backing_blocker); error_free(parent->backing_blocker); parent->backing_blocker =3D NULL; +} =20 +/* XXX: Will be removed along with child_backing */ +static void bdrv_child_cb_detach_backing(BdrvChild *c) +{ + if (!(c->role & BDRV_CHILD_COW)) { + bdrv_backing_detach(c); + } bdrv_child_cb_detach(c); } =20 @@ -1314,7 +1316,7 @@ const BdrvChildClass child_backing =3D { .parent_is_bds =3D true, .get_parent_desc =3D bdrv_child_get_parent_desc, .attach =3D bdrv_child_cb_attach_backing, - .detach =3D bdrv_backing_detach, + .detach =3D bdrv_child_cb_detach_backing, .inherit_options =3D bdrv_backing_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_poll =3D bdrv_child_cb_drained_poll, @@ -1416,6 +1418,17 @@ static void bdrv_child_cb_attach(BdrvChild *child) bdrv_apply_subtree_drain(child, bs); } =20 +static void bdrv_child_cb_detach(BdrvChild *child) +{ + BlockDriverState *bs =3D child->opaque; + + if (child->role & BDRV_CHILD_COW) { + bdrv_backing_detach(child); + } + + bdrv_unapply_subtree_drain(child, bs); +} + static int bdrv_open_flags(BlockDriverState *bs, int flags) { int open_flags =3D flags; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548192; cv=none; d=zohomail.com; s=zohoarc; b=AH1MsoHFHkaHZcZmAcdOQbpdoDQrsG7pyvCo0ZNF6k5Q4Milmg7OeBmzm/wDmmS3UqDC6JMuRNZiVP1Dch1J7rV7usFND/xfkPEaA11DzMTlQWzsiXt+HTqDSi2nPwAT9nxV9Z2nCq7yVv62qzwCge2a9brg0IcwDTSFv+aDGvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548192; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=exmpVgQdn1BPIsIvyOs3f+hoWImPMi+7oYKNGj+Heao=; b=d3/XxcAUKYzl3RXKvAQMFg6SV4+2+l3oaU6Dth1t+fNDjL7Or4EPi+K0D8dydFgOkjj+o7aCHMoe2Rb7o8tbd6b+JuyS6U9cPDRRkO4m3RekUBGXZ+bzQhwp2ECvtUR8+H8WoXkm/ju1qJQNS9a2ZpimNQ68CDeVrrUGqSUFV5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548192393909.109661389454; Fri, 15 May 2020 06:09:52 -0700 (PDT) Received: from localhost ([::1]:53688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa63-0004uY-9k for importer@patchew.org; Fri, 15 May 2020 09:09:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjD-0002vW-O8 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:15 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:41867 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjB-0002Li-4m for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-wHxyvcgvMFedikEP6aL6_w-1; Fri, 15 May 2020 08:46:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 170AC8005AD; Fri, 15 May 2020 12:46:09 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E8EB2E024; Fri, 15 May 2020 12:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=exmpVgQdn1BPIsIvyOs3f+hoWImPMi+7oYKNGj+Heao=; b=Fk2nGxxDi5Jh2HWXhE3lOK3I1yCXSjE3EWI9E/9J1gsgWQnjhb+1p+m7mmhU/+MkyjMQOX LrBgUWHYARw5r946Rn/LaaY+DXDDF6QhZO8hjrWu7jmlnWv4xmhxZOI8L8aNPRWi2N+eLW HGIGOvZSLE63WOMhoM/fk0jwNYF1ZoY= X-MC-Unique: wHxyvcgvMFedikEP6aL6_w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 26/51] block: Add child_of_bds Date: Fri, 15 May 2020 14:44:56 +0200 Message-Id: <20200515124521.335403-27-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Any current user of child_file, child_format, and child_backing can and should use this generic BdrvChildClass instead, as it can handle all of these cases. However, to be able to do so, the users must pass the appropriate BdrvChildRole when the child is created/attached. (The following commits will take care of that.) Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-15-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 + block.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index 6245d8a18d..54df821d61 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -740,6 +740,7 @@ struct BdrvChildClass { void (*set_aio_ctx)(BdrvChild *child, AioContext *ctx, GSList **ignore= ); }; =20 +extern const BdrvChildClass child_of_bds; extern const BdrvChildClass child_file; extern const BdrvChildClass child_format; extern const BdrvChildClass child_backing; diff --git a/block.c b/block.c index f63417c06d..be9bfa9d46 100644 --- a/block.c +++ b/block.c @@ -1429,6 +1429,30 @@ static void bdrv_child_cb_detach(BdrvChild *child) bdrv_unapply_subtree_drain(child, bs); } =20 +static int bdrv_child_cb_update_filename(BdrvChild *c, BlockDriverState *b= ase, + const char *filename, Error **err= p) +{ + if (c->role & BDRV_CHILD_COW) { + return bdrv_backing_update_filename(c, base, filename, errp); + } + return 0; +} + +const BdrvChildClass child_of_bds =3D { + .parent_is_bds =3D true, + .get_parent_desc =3D bdrv_child_get_parent_desc, + .inherit_options =3D bdrv_inherited_options, + .drained_begin =3D bdrv_child_cb_drained_begin, + .drained_poll =3D bdrv_child_cb_drained_poll, + .drained_end =3D bdrv_child_cb_drained_end, + .attach =3D bdrv_child_cb_attach, + .detach =3D bdrv_child_cb_detach, + .inactivate =3D bdrv_child_cb_inactivate, + .can_set_aio_ctx =3D bdrv_child_cb_can_set_aio_ctx, + .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, + .update_filename =3D bdrv_child_cb_update_filename, +}; + static int bdrv_open_flags(BlockDriverState *bs, int flags) { int open_flags =3D flags; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547699; cv=none; d=zohomail.com; s=zohoarc; b=bFNJ5ZaFfNeq8tdsN3rjlDbtYDOob00CciKR9XIb5idlr3HPevObVHly5bHk4VK/+PZfJnv1J6fK+HxuwtlUqTLEsGK59TT21DtJEKKfY3pszgrwEQjM20uPeXrARjT/74/oG3AcLVlRHrD/9VoJX9BoW2JQgCz1FA7JNOBZ9nI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547699; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sm/qRcwDPq4vdnCh5mJncEVjAOLyTL0JGlAiJzBzdqA=; b=JuWHs0d5WMGJIU3qF9ikfdlqca13x1uTzfj+oNLeSA4AxghvTQKgti5Yg+t6Gau3Svlca2qYmhS2OItTomptybrgljI0UoyEOunivPwg6vFrc0r6cRRO70iJJcvvsY35z1o3I4CKxXxiGZd3pJHG+WI1Y/0Bl4zyPGv/j5sOcjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547699034497.50478006794106; Fri, 15 May 2020 06:01:39 -0700 (PDT) Received: from localhost ([::1]:46932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZy5-0006rg-DW for importer@patchew.org; Fri, 15 May 2020 09:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjE-0002xF-GI for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:16 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41518 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjC-0002MD-8x for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-WyGEG8dIOZ-be9N8EBvE8A-1; Fri, 15 May 2020 08:46:11 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5936C108BD15; Fri, 15 May 2020 12:46:10 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60AE42E16D; Fri, 15 May 2020 12:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sm/qRcwDPq4vdnCh5mJncEVjAOLyTL0JGlAiJzBzdqA=; b=dwWzEQlRyjexaduquJ2+ji1W+SamMKewmChvTuCj+BXF+MZjZ/02TtlsC04+ChS2262Fsv pCQDXh8RDJAoB7G0yIOMteUQ4zKgXMmbJt2/enS0Yr3fpat9b7Bf3lgiEudml7tM5I7kHX qZ8VO+uCTwnARJISQY9MgW/ugQnSR0Q= X-MC-Unique: WyGEG8dIOZ-be9N8EBvE8A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 27/51] block: Distinguish paths in *_format_default_perms Date: Fri, 15 May 2020 14:44:57 +0200 Message-Id: <20200515124521.335403-28-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz bdrv_format_default_perms() has one code path for backing files, and one for storage files. We want to pull them out into their own functions, so make sure they are completely distinct before so the next patches will be a bit cleaner. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-16-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index be9bfa9d46..b3e7ae70c7 100644 --- a/block.c +++ b/block.c @@ -2497,6 +2497,13 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, perm |=3D BLK_PERM_CONSISTENT_READ; } shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + + if (bs->open_flags & BDRV_O_INACTIVE) { + shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } + + *nperm =3D perm; + *nshared =3D shared; } else { /* We want consistent read from backing files if the parent needs = it. * No other operations are performed on backing files. */ @@ -2513,14 +2520,14 @@ void bdrv_format_default_perms(BlockDriverState *bs= , BdrvChild *c, =20 shared |=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | BLK_PERM_WRITE_UNCHANGED; - } =20 - if (bs->open_flags & BDRV_O_INACTIVE) { - shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; - } + if (bs->open_flags & BDRV_O_INACTIVE) { + shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } =20 - *nperm =3D perm; - *nshared =3D shared; + *nperm =3D perm; + *nshared =3D shared; + } } =20 uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547817; cv=none; d=zohomail.com; s=zohoarc; b=hdrwadjWwv/tcHk1AWJCb7l74x2Zrqg7Nt7sdo9tJVaeIKtvoRDizO+X7iiYw8kS/oYcGicHLqd7VTMG36rQAsL27pxZuy5u1l9wrdyCO67PgwHoDUspYuGtrgperwHK1Cl4SMgecGDLgX3/K0eoi+iNAXfDYAyQv6WPD8DpnhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547817; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nXmlJBI08iCrvv2Fjzsccnd+uFEZ5bU04UQLWc261dg=; b=JnVuolZVVeATubpWoWommGMdN/OKImnOFxbxMMKM+2tPKh9V3RhppecA6SCRDyE7WaZLBOjmco1x2KrPqweYG0Y+RorxgdClYaKFgaM6oG+kkzl3mYpdtchHrU4b8ZIBeoT3WuJAhpC4ZgsYQvr/KEswwAmXgQCSS1peRmi5O2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547817475652.3392997271786; Fri, 15 May 2020 06:03:37 -0700 (PDT) Received: from localhost ([::1]:55294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa00-00020f-LK for importer@patchew.org; Fri, 15 May 2020 09:03:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjE-0002yV-VT for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51863 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjD-0002Mc-D6 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-334-ox-k4WhmObq2haeSPA2LCg-1; Fri, 15 May 2020 08:46:12 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EC95835B42; Fri, 15 May 2020 12:46:11 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id A266F2E16D; Fri, 15 May 2020 12:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546774; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nXmlJBI08iCrvv2Fjzsccnd+uFEZ5bU04UQLWc261dg=; b=AsaiUB69ZKXF8SkM2ppq2An1RMYY2M57JHHW4t8LQsypxv4TzrbJRCVOS2lL+0klaE+1VI N9WImV7QeLLMqT0Pk/4Ob0yi3OR67k9VC5Dg+nQYpJgTh/W8vZPdr/g++oNZFqBkmc3Ct3 mK3cXc4q7rsi6XPHoFMFFm2itMG7ny4= X-MC-Unique: ox-k4WhmObq2haeSPA2LCg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 28/51] block: Pull out bdrv_default_perms_for_cow() Date: Fri, 15 May 2020 14:44:58 +0200 Message-Id: <20200515124521.335403-29-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Right now, bdrv_format_default_perms() is used by format parents (generally). We want to switch to a model where most parents use a single BdrvChildClass, which then decides the permissions based on the child role. To do so, we have to split bdrv_format_default_perms() into separate functions for each such role. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-17-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 62 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/block.c b/block.c index b3e7ae70c7..b12222a471 100644 --- a/block.c +++ b/block.c @@ -2468,6 +2468,44 @@ void bdrv_filter_default_perms(BlockDriverState *bs,= BdrvChild *c, *nshared =3D (shared & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHAN= GED; } =20 +static void bdrv_default_perms_for_cow(BlockDriverState *bs, BdrvChild *c, + const BdrvChildClass *child_class, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + assert(child_class =3D=3D &child_backing || + (child_class =3D=3D &child_of_bds && (role & BDRV_CHILD_COW))); + + /* + * We want consistent read from backing files if the parent needs it. + * No other operations are performed on backing files. + */ + perm &=3D BLK_PERM_CONSISTENT_READ; + + /* + * If the parent can deal with changing data, we're okay with a + * writable and resizable backing file. + * TODO Require !(perm & BLK_PERM_CONSISTENT_READ), too? + */ + if (shared & BLK_PERM_WRITE) { + shared =3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } else { + shared =3D 0; + } + + shared |=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | + BLK_PERM_WRITE_UNCHANGED; + + if (bs->open_flags & BDRV_O_INACTIVE) { + shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } + + *nperm =3D perm; + *nshared =3D shared; +} + void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, BdrvChildRole role, @@ -2505,28 +2543,8 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, *nperm =3D perm; *nshared =3D shared; } else { - /* We want consistent read from backing files if the parent needs = it. - * No other operations are performed on backing files. */ - perm &=3D BLK_PERM_CONSISTENT_READ; - - /* If the parent can deal with changing data, we're okay with a - * writable and resizable backing file. */ - /* TODO Require !(perm & BLK_PERM_CONSISTENT_READ), too? */ - if (shared & BLK_PERM_WRITE) { - shared =3D BLK_PERM_WRITE | BLK_PERM_RESIZE; - } else { - shared =3D 0; - } - - shared |=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | - BLK_PERM_WRITE_UNCHANGED; - - if (bs->open_flags & BDRV_O_INACTIVE) { - shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; - } - - *nperm =3D perm; - *nshared =3D shared; + bdrv_default_perms_for_cow(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); } } =20 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547947; cv=none; d=zohomail.com; s=zohoarc; b=na4OOxviXO//ZS3ayPzUvBjGRyKlu9UroVAd+tJC1lQZ5ae7PA4q8Owrc6DAxJh1xLlNelPeTdV5VOKgDZl0Mdu7JMMqnox/ss55U2Jjmr/vqNDFfqe7/thOKXuVz9tflqonQcDs32klZIdNQj6kDZu/Xr9p6xqzry/99G9hErw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547947; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AuY+Dbh3/ukNTTpzfm0qDSVDwuPn80YJkfSix/LeENg=; b=gDIfnJQH+7GUljTA+/KHGIF+SDdVPuua2WaSNtF44rQB9WRhUsK11RZD1f+NK+SDX2JZL9gFQR+PQauEP/WwsGMiELn2zxeSPN5wzWW+HN/AekbgM2En/pMZ6QcfUxR22yNF7ab3R4vRyutdxAD62FnFZieEgHP3aR+GjLMLeM8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158954794795422.86294724517336; Fri, 15 May 2020 06:05:47 -0700 (PDT) Received: from localhost ([::1]:36150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa27-0006B1-5U for importer@patchew.org; Fri, 15 May 2020 09:05:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjH-00033v-0i for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32984 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjE-0002NI-SR for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-yL2xoS64OnS4vVgaTaMaNQ-1; Fri, 15 May 2020 08:46:13 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E13ED107ACF4; Fri, 15 May 2020 12:46:12 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id E85FF2E024; Fri, 15 May 2020 12:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AuY+Dbh3/ukNTTpzfm0qDSVDwuPn80YJkfSix/LeENg=; b=av07ypymPE3DW/6f9p8bFkth1z8wilsOKwZ5719e3h9T4xM6cTWwmhbjy28SBmqGfkcMC9 wthHI0A5U/29DSQfyWdeovPpEd2qb7F2LTGFlFu8ICmLk14bSS4lmJnGnw9cc+o3HIFotI +PWe+pvPrWg52JVQrs6wAJY9FXSGN68= X-MC-Unique: yL2xoS64OnS4vVgaTaMaNQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 29/51] block: Pull out bdrv_default_perms_for_storage() Date: Fri, 15 May 2020 14:44:59 +0200 Message-Id: <20200515124521.335403-30-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Right now, bdrv_format_default_perms() is used by format parents (generally). We want to switch to a model where most parents use a single BdrvChildClass, which then decides the permissions based on the child role. To do so, we have to split bdrv_format_default_perms() into separate functions for each such role. Note that bdrv_default_perms_for_storage() currently handles all DATA | METADATA children. A follow-up patch is going to split it further into one function for each case. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-18-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block.c | 71 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/block.c b/block.c index b12222a471..5d17aa1cc3 100644 --- a/block.c +++ b/block.c @@ -2506,6 +2506,50 @@ static void bdrv_default_perms_for_cow(BlockDriverSt= ate *bs, BdrvChild *c, *nshared =3D shared; } =20 +static void bdrv_default_perms_for_storage(BlockDriverState *bs, BdrvChild= *c, + const BdrvChildClass *child_cla= ss, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nsha= red) +{ + int flags; + + assert(child_class =3D=3D &child_file || + (child_class =3D=3D &child_of_bds && + (role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA)))); + + flags =3D bdrv_reopen_get_flags(reopen_queue, bs); + + /* + * Apart from the modifications below, the same permissions are + * forwarded and left alone as for filters + */ + bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, &perm, &shared); + + /* Format drivers may touch metadata even if the guest doesn't write */ + if (bdrv_is_writable_after_reopen(bs, reopen_queue)) { + perm |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } + + /* + * bs->file always needs to be consistent because of the metadata. We + * can never allow other users to resize or write to it. + */ + if (!(flags & BDRV_O_NO_IO)) { + perm |=3D BLK_PERM_CONSISTENT_READ; + } + shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + + if (bs->open_flags & BDRV_O_INACTIVE) { + shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } + + *nperm =3D perm; + *nshared =3D shared; +} + void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, BdrvChildRole role, @@ -2517,31 +2561,8 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, assert(child_class =3D=3D &child_backing || child_class =3D=3D &child_= file); =20 if (!backing) { - int flags =3D bdrv_reopen_get_flags(reopen_queue, bs); - - /* Apart from the modifications below, the same permissions are - * forwarded and left alone as for filters */ - bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, - perm, shared, &perm, &shared); - - /* Format drivers may touch metadata even if the guest doesn't wri= te */ - if (bdrv_is_writable_after_reopen(bs, reopen_queue)) { - perm |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; - } - - /* bs->file always needs to be consistent because of the metadata.= We - * can never allow other users to resize or write to it. */ - if (!(flags & BDRV_O_NO_IO)) { - perm |=3D BLK_PERM_CONSISTENT_READ; - } - shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); - - if (bs->open_flags & BDRV_O_INACTIVE) { - shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; - } - - *nperm =3D perm; - *nshared =3D shared; + bdrv_default_perms_for_storage(bs, c, child_class, role, reopen_qu= eue, + perm, shared, nperm, nshared); } else { bdrv_default_perms_for_cow(bs, c, child_class, role, reopen_queue, perm, shared, nperm, nshared); --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547338; cv=none; d=zohomail.com; s=zohoarc; b=XKLCFRsG7AtxZ10S87xnyQnvtDfM6EZXbIQpfOn+lDxJZuiUbrSh70AYmQPq/BpSdLMIqBQ/wKouf3dFdf+gcSFg5hu1KuZ+SWIgcCjiUrNffBhQjrYcj8si4z8MeZCBqug08n4uiD0kIDa3XgCc0VcR4s9AW0j8nsm2DZ9kQAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547338; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zeE4iNX9RByu1DW8AR7ZX+mPV4S9p+H/9LoHgCtDmTM=; b=gtBPH5mkjpA8nStXq3F7CMiFY4XHnqaK+E565LUspeLXsJCovYi7DcCkBec/rVYTwdtb9zt0vxEjJlGjzjD/QcgKmwOLUG9bmrGz7SFChNZSZFR/86+FNV+JFpJSApi3Lq3lHRzqL4L1vqJOTGgJU5XGBxYIUY249lDWpA5FLto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547338503105.62856442823966; Fri, 15 May 2020 05:55:38 -0700 (PDT) Received: from localhost ([::1]:50468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZsG-0003Wo-77 for importer@patchew.org; Fri, 15 May 2020 08:55:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjK-0003BZ-9i for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:22 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:51928 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjJ-0002PC-GU for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-dKaF34I9Ma2CgA8wo3wYUg-1; Fri, 15 May 2020 08:46:15 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30CF18014D7; Fri, 15 May 2020 12:46:14 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3721C2E166; Fri, 15 May 2020 12:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zeE4iNX9RByu1DW8AR7ZX+mPV4S9p+H/9LoHgCtDmTM=; b=TiTW7wcZuWiAhh0XCE+o92Q8408eN3osKdSksI62gurvCjF8tVDFd3jIQnEGzeTkPGm3NR ArlLpIgqkWP9JEbBYqIc61aOiFEJI/A6mgSfxrEh2zWhuZcddQvF9ix+TUjUsSFmNSTnDX z7IWc3W7iJGXWsKjEZRDUaW7jfSfxls= X-MC-Unique: dKaF34I9Ma2CgA8wo3wYUg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 30/51] block: Relax *perms_for_storage for data children Date: Fri, 15 May 2020 14:45:00 +0200 Message-Id: <20200515124521.335403-31-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz We can be less restrictive about pure data children than those with metadata on them, so let bdrv_default_perms_for_storage() handle metadata children differently from pure data children. As explained in the code, the restrictions on metadata children are strictly stricter than those for pure data children, so in theory we just have to distinguish between pure-data and all other storage children (pure metadata or data+metadata). In practice, that is not obvious, though, so we have two independent code paths for metadata and for data children, and data+metadata children will go through both (without the path for data children doing anything meaningful). Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-19-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/block.c b/block.c index 5d17aa1cc3..5ff6cbd796 100644 --- a/block.c +++ b/block.c @@ -2528,19 +2528,57 @@ static void bdrv_default_perms_for_storage(BlockDri= verState *bs, BdrvChild *c, bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, perm, shared, &perm, &shared); =20 - /* Format drivers may touch metadata even if the guest doesn't write */ - if (bdrv_is_writable_after_reopen(bs, reopen_queue)) { - perm |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + if (role & BDRV_CHILD_METADATA) { + /* Format drivers may touch metadata even if the guest doesn't wri= te */ + if (bdrv_is_writable_after_reopen(bs, reopen_queue)) { + perm |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; + } + + /* + * bs->file always needs to be consistent because of the + * metadata. We can never allow other users to resize or write + * to it. + */ + if (!(flags & BDRV_O_NO_IO)) { + perm |=3D BLK_PERM_CONSISTENT_READ; + } + shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); } =20 - /* - * bs->file always needs to be consistent because of the metadata. We - * can never allow other users to resize or write to it. - */ - if (!(flags & BDRV_O_NO_IO)) { - perm |=3D BLK_PERM_CONSISTENT_READ; + if (role & BDRV_CHILD_DATA) { + /* + * Technically, everything in this block is a subset of the + * BDRV_CHILD_METADATA path taken above, and so this could + * be an "else if" branch. However, that is not obvious, and + * this function is not performance critical, therefore we let + * this be an independent "if". + */ + + /* + * We cannot allow other users to resize the file because the + * format driver might have some assumptions about the size + * (e.g. because it is stored in metadata, or because the file + * is split into fixed-size data files). + */ + shared &=3D ~BLK_PERM_RESIZE; + + /* + * WRITE_UNCHANGED often cannot be performed as such on the + * data file. For example, the qcow2 driver may still need to + * write copied clusters on copy-on-read. + */ + if (perm & BLK_PERM_WRITE_UNCHANGED) { + perm |=3D BLK_PERM_WRITE; + } + + /* + * If the data file is written to, the format driver may + * expect to be able to resize it by writing beyond the EOF. + */ + if (perm & BLK_PERM_WRITE) { + perm |=3D BLK_PERM_RESIZE; + } } - shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); =20 if (bs->open_flags & BDRV_O_INACTIVE) { shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548082; cv=none; d=zohomail.com; s=zohoarc; b=DtHW6NZgH63v7NbXHMVer6gSXV67WtT1mOX8o3A10MT17sWoZt09GgBszD4I3S4/PFJqDYT0hOEIQNts3NNWtyaFBjPqDGv/3diH/37DNM3kLNZ/YK0h6KI59wgm1M7BIqbWNJmy6UeKEU2tt4+LpVC6QpRjwEXTcElho+xE614= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548082; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U9+KdOV9yTQVEKgc0FKwq52v6OMnOO74fOmEyKdES9I=; b=hpRnXHkVG9Vi1L3+kvUFIK/8U6TchLHwFNettQQatWwWn6fYpqWFEkhWSLoDRsEc+ZFyiZmEL9TgC2bPSuVOsNkqTP+cDgyXk0q1DUygQioakGzh3Y1aLYzxnEiyr4fJ5Pk07S26nlaT5bW6827kVDqEKSgiF6sQYjhinSSF8ew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548082880644.197035579161; Fri, 15 May 2020 06:08:02 -0700 (PDT) Received: from localhost ([::1]:45226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa4I-0001R4-13 for importer@patchew.org; Fri, 15 May 2020 09:08:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjK-0003BS-A2 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:22 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:48138 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjH-0002O3-F5 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-0mXkFcOJP1-DosiQRkm7zw-1; Fri, 15 May 2020 08:46:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74BF98018A7; Fri, 15 May 2020 12:46:15 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A7D02E166; Fri, 15 May 2020 12:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U9+KdOV9yTQVEKgc0FKwq52v6OMnOO74fOmEyKdES9I=; b=JMCwHWFKpH9v7f1i84IOzZiZe9ExDJbmv3shJIDVcFct/yT3Qv8Yku/q6zN9jFW9alWxug 99VkmOX0/VldTfHJHN09QoOn32BVPvqEWybASgvmN690WePf6n43ohuO8ZP4PLvEDDR4xZ IlxQ+qjKKBJ8Ry2q2a89G7nEUZ7h7DI= X-MC-Unique: 0mXkFcOJP1-DosiQRkm7zw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 31/51] block: Add bdrv_default_perms() Date: Fri, 15 May 2020 14:45:01 +0200 Message-Id: <20200515124521.335403-32-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz This callback can be used by BDSs that use child_of_bds with the appropriate BdrvChildRole for their children. Also, make bdrv_format_default_perms() use it for child_of_bds children (just a temporary solution until we can drop bdrv_format_default_perms() altogether). Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-20-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block_int.h | 11 +++++++++++ block.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index 54df821d61..3a9dda9be7 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1288,6 +1288,17 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, bool bdrv_recurse_can_replace(BlockDriverState *bs, BlockDriverState *to_replace); =20 +/* + * Default implementation for BlockDriver.bdrv_child_perm() that can + * be used by block filters and image formats, as long as they use the + * child_of_bds child class and set an appropriate BdrvChildRole. + */ +void bdrv_default_perms(BlockDriverState *bs, BdrvChild *c, + const BdrvChildClass *child_class, BdrvChildRole r= ole, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared); + /* * Default implementation for drivers to pass bdrv_co_block_status() to * their file. diff --git a/block.c b/block.c index 5ff6cbd796..088727fdbe 100644 --- a/block.c +++ b/block.c @@ -2596,6 +2596,13 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, uint64_t *nperm, uint64_t *nshared) { bool backing =3D (child_class =3D=3D &child_backing); + + if (child_class =3D=3D &child_of_bds) { + bdrv_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); + return; + } + assert(child_class =3D=3D &child_backing || child_class =3D=3D &child_= file); =20 if (!backing) { @@ -2607,6 +2614,31 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, } } =20 +void bdrv_default_perms(BlockDriverState *bs, BdrvChild *c, + const BdrvChildClass *child_class, BdrvChildRole r= ole, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + assert(child_class =3D=3D &child_of_bds); + + if (role & BDRV_CHILD_FILTERED) { + assert(!(role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA | + BDRV_CHILD_COW))); + bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); + } else if (role & BDRV_CHILD_COW) { + assert(!(role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA))); + bdrv_default_perms_for_cow(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); + } else if (role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA)) { + bdrv_default_perms_for_storage(bs, c, child_class, role, reopen_qu= eue, + perm, shared, nperm, nshared); + } else { + g_assert_not_reached(); + } +} + uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) { static const uint64_t permissions[] =3D { --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548295; cv=none; d=zohomail.com; s=zohoarc; b=FPpTkjZQpWOuc5bYEA0qrn5OThNmyojKgh31qyQzKOyxVkN9Hzhn5ge8j/rV52mAKR6XuIdXImQ8KYs9Z3/9WYGb+3sz/knWD/Vi79GRp8bQpfY8GNqpqXnttvHrDOqxM+McM7+IaRcDM25FAFt5I2AeeUJM4mc1xP7o8luppn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548295; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+fNuQV4hGWz58pDqojWEjpoo53PoevCTwyj+pmS+U2g=; b=dTju2ZvgKbuydfVEd/L3XWATGzEXEX/7y4kyBj5R4arMfjCzWLBjbG47RVqvowvH2Ttbxz+9nJxY8PXA/Wqp7LakYiEAPZ7XyMD1Nmj3/i1SZeRWiv80Ok/0B2Nb3PsYRlQpMKUMzzdkqoqph2EFZ0loQ4KqeLGN3Iz+s+rMoag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158954829557431.45342394822353; Fri, 15 May 2020 06:11:35 -0700 (PDT) Received: from localhost ([::1]:60268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa7i-00084w-Nq for importer@patchew.org; Fri, 15 May 2020 09:11:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjJ-0003AE-HZ for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45533 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjI-0002OT-6c for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507--jzLnZAzPMiBV09CwPGKSw-1; Fri, 15 May 2020 08:46:17 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B815D460; Fri, 15 May 2020 12:46:16 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEC1F2E166; Fri, 15 May 2020 12:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+fNuQV4hGWz58pDqojWEjpoo53PoevCTwyj+pmS+U2g=; b=B1m/GfmVR79sAM1rZPNK9rGv0dgi0hRRJyfNCWZQhDT62DDFFpeaX2H705cU7qMN6fw02/ dt8pDl7Y+b1yi3udQS0ayeK0PHV/ypGrgy4JPQvr8hfICRMXbFio5qc279pePg0b3iDS36 Tr7Zpi0d428ugw/9Hj7Zdc/mtDNkJXs= X-MC-Unique: -jzLnZAzPMiBV09CwPGKSw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 32/51] raw-format: Split raw_read_options() Date: Fri, 15 May 2020 14:45:02 +0200 Message-Id: <20200515124521.335403-33-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Split raw_read_options() into one function that actually just reads the options, and another that applies them. This will allow us to detect whether the user has specified any options before attaching the file child (so we can decide on its role based on the options). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-21-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/raw-format.c | 110 ++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 45 deletions(-) diff --git a/block/raw-format.c b/block/raw-format.c index 4b8d4ce8be..824fe70686 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -71,20 +71,13 @@ static QemuOptsList raw_create_opts =3D { } }; =20 -static int raw_read_options(QDict *options, BlockDriverState *bs, - BDRVRawState *s, Error **errp) +static int raw_read_options(QDict *options, uint64_t *offset, bool *has_si= ze, + uint64_t *size, Error **errp) { Error *local_err =3D NULL; QemuOpts *opts =3D NULL; - int64_t real_size =3D 0; int ret; =20 - real_size =3D bdrv_getlength(bs->file->bs); - if (real_size < 0) { - error_setg_errno(errp, -real_size, "Could not get image size"); - return real_size; - } - opts =3D qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { @@ -93,64 +86,84 @@ static int raw_read_options(QDict *options, BlockDriver= State *bs, goto end; } =20 - s->offset =3D qemu_opt_get_size(opts, "offset", 0); - if (s->offset > real_size) { - error_setg(errp, "Offset (%" PRIu64 ") cannot be greater than " - "size of the containing file (%" PRId64 ")", - s->offset, real_size); - ret =3D -EINVAL; - goto end; - } + *offset =3D qemu_opt_get_size(opts, "offset", 0); + *has_size =3D qemu_opt_find(opts, "size"); + *size =3D qemu_opt_get_size(opts, "size", 0); =20 - if (qemu_opt_find(opts, "size") !=3D NULL) { - s->size =3D qemu_opt_get_size(opts, "size", 0); - s->has_size =3D true; - } else { - s->has_size =3D false; - s->size =3D real_size - s->offset; + ret =3D 0; +end: + qemu_opts_del(opts); + return ret; +} + +static int raw_apply_options(BlockDriverState *bs, BDRVRawState *s, + uint64_t offset, bool has_size, uint64_t size, + Error **errp) +{ + int64_t real_size =3D 0; + + real_size =3D bdrv_getlength(bs->file->bs); + if (real_size < 0) { + error_setg_errno(errp, -real_size, "Could not get image size"); + return real_size; } =20 /* Check size and offset */ - if ((real_size - s->offset) < s->size) { + if (offset > real_size) { + error_setg(errp, "Offset (%" PRIu64 ") cannot be greater than " + "size of the containing file (%" PRId64 ")", + s->offset, real_size); + return -EINVAL; + } + + if (has_size && (real_size - offset) < size) { error_setg(errp, "The sum of offset (%" PRIu64 ") and size " - "(%" PRIu64 ") has to be smaller or equal to the " - " actual size of the containing file (%" PRId64 ")", - s->offset, s->size, real_size); - ret =3D -EINVAL; - goto end; + "(%" PRIu64 ") has to be smaller or equal to the " + " actual size of the containing file (%" PRId64 ")", + s->offset, s->size, real_size); + return -EINVAL; } =20 /* Make sure size is multiple of BDRV_SECTOR_SIZE to prevent rounding * up and leaking out of the specified area. */ - if (s->has_size && !QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) { + if (has_size && !QEMU_IS_ALIGNED(size, BDRV_SECTOR_SIZE)) { error_setg(errp, "Specified size is not multiple of %llu", - BDRV_SECTOR_SIZE); - ret =3D -EINVAL; - goto end; + BDRV_SECTOR_SIZE); + return -EINVAL; } =20 - ret =3D 0; - -end: + s->offset =3D offset; + s->has_size =3D has_size; + s->size =3D has_size ? size : real_size - offset; =20 - qemu_opts_del(opts); - - return ret; + return 0; } =20 static int raw_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp) { + bool has_size; + uint64_t offset, size; + int ret; + assert(reopen_state !=3D NULL); assert(reopen_state->bs !=3D NULL); =20 reopen_state->opaque =3D g_new0(BDRVRawState, 1); =20 - return raw_read_options( - reopen_state->options, - reopen_state->bs, - reopen_state->opaque, - errp); + ret =3D raw_read_options(reopen_state->options, &offset, &has_size, &s= ize, + errp); + if (ret < 0) { + return ret; + } + + ret =3D raw_apply_options(reopen_state->bs, reopen_state->opaque, + offset, has_size, size, errp); + if (ret < 0) { + return ret; + } + + return 0; } =20 static void raw_reopen_commit(BDRVReopenState *state) @@ -426,8 +439,15 @@ static int raw_open(BlockDriverState *bs, QDict *optio= ns, int flags, Error **errp) { BDRVRawState *s =3D bs->opaque; + bool has_size; + uint64_t offset, size; int ret; =20 + ret =3D raw_read_options(options, &offset, &has_size, &size, errp); + if (ret < 0) { + return ret; + } + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false, errp); if (!bs->file) { @@ -455,7 +475,7 @@ static int raw_open(BlockDriverState *bs, QDict *option= s, int flags, bs->file->bs->filename); } =20 - ret =3D raw_read_options(options, bs, s, errp); + ret =3D raw_apply_options(bs, s, offset, has_size, size, errp); if (ret < 0) { return ret; } --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548375; cv=none; d=zohomail.com; s=zohoarc; b=CYjL24fQwzO9+o4YC/+gYTm1o9W+6JmMsfkQbpEt7DW+5MWHr51SabAyWxpENMvh4q4l42yYps0EqmkJ/9hzdVtQU0E4LR8HgJiJz12kyahXHvCvLbHSyboZmxfTULp10PvCygaCDmHx6wj1HEwMOe4N6NyMwuZjFedYHD64IaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548375; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5yWFrsZNvGraareqe/NUSTnwE5L7vXAW/Cf9K9Gh+KI=; b=C8V06qhmkuQg+pVgp1Rz0P6u3dJBy9NkhXPqJ3jLucCnLsuWnoI6TP+47Yixog3UpItxNo9BmFq7Ex/g/kDvkvLlMaeXG01x4QRb0eOq/29iUGQ+c+A+KqIqJXxYoijtSb1jpNawaNXm0HaC6H77PGA4HJh6g4DtkEzlzeSuaO8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548375438784.845378618762; Fri, 15 May 2020 06:12:55 -0700 (PDT) Received: from localhost ([::1]:40250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa90-00035g-KB for importer@patchew.org; Fri, 15 May 2020 09:12:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjL-0003Ed-Fe for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:23 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55016 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjK-0002PR-Eh for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-223-3Udn3e_9NNydU3lxYUyx0A-1; Fri, 15 May 2020 08:46:19 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04F4F835B47; Fri, 15 May 2020 12:46:18 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CF792E024; Fri, 15 May 2020 12:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5yWFrsZNvGraareqe/NUSTnwE5L7vXAW/Cf9K9Gh+KI=; b=eChoRuj+QaMdf0ppIwAXJp9KC7oBSm7qY+8eIt/r0ZXBp+L0ytBDoU7t+uIrY3TteW4TED 9wYYlz3FHsfVTreOoscXL7MitFxY9UbGXB0Z+ApXK6IIZGLuC5hGD6vR1RyctT2fzCly+B 1P0v8lxGRVJfp7divGW5V+WI73+BSm4= X-MC-Unique: 3Udn3e_9NNydU3lxYUyx0A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 33/51] block: Switch child_format users to child_of_bds Date: Fri, 15 May 2020 14:45:03 +0200 Message-Id: <20200515124521.335403-34-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Both users (quorum and blkverify) use child_format for not-really-filtered children, so the appropriate BdrvChildRole in both cases is DATA. (Note that this will cause bdrv_inherited_options() to force-allow format probing.) Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-22-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/blkverify.c | 4 ++-- block/quorum.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/block/blkverify.c b/block/blkverify.c index ba4f6d7b7c..1684b7aa2e 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -134,8 +134,8 @@ static int blkverify_open(BlockDriverState *bs, QDict *= options, int flags, =20 /* Open the test file */ s->test_file =3D bdrv_open_child(qemu_opt_get(opts, "x-image"), option= s, - "test", bs, &child_format, 0, false, - &local_err); + "test", bs, &child_of_bds, BDRV_CHILD_D= ATA, + false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/quorum.c b/block/quorum.c index d37b77a522..616ac3a927 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -977,7 +977,8 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, assert(ret < 32); =20 s->children[i] =3D bdrv_open_child(NULL, options, indexstr, bs, - &child_format, 0, false, &local_e= rr); + &child_of_bds, BDRV_CHILD_DATA, f= alse, + &local_err); if (local_err) { ret =3D -EINVAL; goto close_exit; @@ -1053,7 +1054,8 @@ static void quorum_add_child(BlockDriverState *bs, Bl= ockDriverState *child_bs, /* We can safely add the child now */ bdrv_ref(child_bs); =20 - child =3D bdrv_attach_child(bs, child_bs, indexstr, &child_format, 0, = errp); + child =3D bdrv_attach_child(bs, child_bs, indexstr, &child_of_bds, + BDRV_CHILD_DATA, errp); if (child =3D=3D NULL) { s->next_child_index--; goto out; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548113; cv=none; d=zohomail.com; s=zohoarc; b=XLdU5w6BeMphAz4E50h4/FGGytC2D67MKRLscWSE3atqw7sujxHien82W1zs6XEWViAJhZq7JKKx0mlUiyfAZRh4t+5fRE3VCvXRfML+5f64IKAeNf3Hz1HhNxDK4IKhWRr48FtGElRZAuHB983D3u+gcUdlyM/+0zlTvtYsY7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548113; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tg8lpyOV45BMwhihe2Api6pEF6d2b7vaoAExMz/46tI=; b=NGWTaSFEEgUB8dU6NfsldyJrrcbKiXUrDToobVhXpwORbNg6+YgJB5PSxkjYvncSjteqrzOSpiSLHIoYEu4aASXn2ZrwkifBwp+eOUUNU8Rj9vuvscKBsyDDLus7cIUFoEpy4ljOCCKiYhreukLu3Z6/1L1Eibt3ywUnuhVhCXA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548113681153.89471672221646; Fri, 15 May 2020 06:08:33 -0700 (PDT) Received: from localhost ([::1]:48442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa4m-0002jh-FH for importer@patchew.org; Fri, 15 May 2020 09:08:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjM-0003Hc-Nk for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:24 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47762 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjL-0002Pi-Cp for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-5LdJUFrUOfy_ASegCmYzDg-1; Fri, 15 May 2020 08:46:20 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46D051005510; Fri, 15 May 2020 12:46:19 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EC422E024; Fri, 15 May 2020 12:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tg8lpyOV45BMwhihe2Api6pEF6d2b7vaoAExMz/46tI=; b=hZyX3lC/zu6fB0/LT/Dce9CGg4qxs4XAtCHAco0B0XrvcZ9ECwJTYrrEQqlxd2q/33DDqu z2JFKsFbQs+4FUJsaAe5NFQpKer26mKQ99FNYTLFbYzey/dw1IQiAmD3hKfrEBBg/KBhla YDNl4fOUHYrrUX3CfJHAG9T89ZgN4os= X-MC-Unique: 5LdJUFrUOfy_ASegCmYzDg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 34/51] block: Drop child_format Date: Fri, 15 May 2020 14:45:04 +0200 Message-Id: <20200515124521.335403-35-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-23-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 - block.c | 29 ----------------------------- 2 files changed, 30 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 3a9dda9be7..4b09fa1124 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -742,7 +742,6 @@ struct BdrvChildClass { =20 extern const BdrvChildClass child_of_bds; extern const BdrvChildClass child_file; -extern const BdrvChildClass child_format; extern const BdrvChildClass child_backing; =20 struct BdrvChild { diff --git a/block.c b/block.c index 088727fdbe..85b4f947ba 100644 --- a/block.c +++ b/block.c @@ -1172,35 +1172,6 @@ const BdrvChildClass child_file =3D { .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, }; =20 -/* - * Returns the options and flags that bs->file should get if the use of fo= rmats - * (and not only protocols) is permitted for it, based on the given option= s and - * flags for the parent BDS - */ -static void bdrv_inherited_fmt_options(BdrvChildRole role, - bool parent_is_format, - int *child_flags, QDict *child_opti= ons, - int parent_flags, QDict *parent_opt= ions) -{ - bdrv_inherited_options(BDRV_CHILD_DATA, false, - child_flags, child_options, - parent_flags, parent_options); -} - -const BdrvChildClass child_format =3D { - .parent_is_bds =3D true, - .get_parent_desc =3D bdrv_child_get_parent_desc, - .inherit_options =3D bdrv_inherited_fmt_options, - .drained_begin =3D bdrv_child_cb_drained_begin, - .drained_poll =3D bdrv_child_cb_drained_poll, - .drained_end =3D bdrv_child_cb_drained_end, - .attach =3D bdrv_child_cb_attach, - .detach =3D bdrv_child_cb_detach, - .inactivate =3D bdrv_child_cb_inactivate, - .can_set_aio_ctx =3D bdrv_child_cb_can_set_aio_ctx, - .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, -}; - static void bdrv_backing_attach(BdrvChild *c) { BlockDriverState *parent =3D c->opaque; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548226; cv=none; d=zohomail.com; s=zohoarc; b=Ofuhc0TpaDEy9GE1fdV16DKi96g5uwkEHOTKdo7jH8yY/jrCfaLgtmzCarVd0OjNfI7MQc7X7OIQcWH5RM+iJ/MFVCZKDZTReDl/Z4nBa2Z8INB/5996UClc/ghn4bkrsdh+bjCPwpBb33w69ooW0XE7uo7uxTXW5NjNa842Uvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548226; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3sxjdEzqm+O4BxjKrJ83R2UCaj3HoODFTniC+AiCCFw=; b=W26enKXaOLHvqh9sbr4Lht3+Md4++Ltg9sRIYKRYBklX8HwO9agfHpwSfOAxTkjuABhbJQGN8bzL6lRsV3DNO/sh52T2U0eAfqumyQvEVBypJiW4OyNidkD/Cswo7dUW5cX0jlJor/EQNtNEtUpQG6SOmmFyzVf/fj1Y3TqHowE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548226199138.39800002370953; Fri, 15 May 2020 06:10:26 -0700 (PDT) Received: from localhost ([::1]:55664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa6Y-0005iE-DT for importer@patchew.org; Fri, 15 May 2020 09:10:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjP-0003NK-6J for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:27 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:60570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjO-0002Qk-9r for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-Q-2sDPN3NROImFef7siOpw-1; Fri, 15 May 2020 08:46:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AEC319200C0; Fri, 15 May 2020 12:46:20 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92F492E024; Fri, 15 May 2020 12:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3sxjdEzqm+O4BxjKrJ83R2UCaj3HoODFTniC+AiCCFw=; b=bjwhYjYjFNqGb5UCN4ZFjPh+1GHMxOBgxStZAmGlHWEDbmgGLjGO/yeL2/tqFm1zt6kl+F 63PUZobqH1fxRkm5oLld3HQ+bbtplH5FjM6K1izF7KL6bINc3E5ub4CyUHsUkS2bfOSwzL bN+dKbfvnGVc0trwuyL4V0fNEkXH8+Y= X-MC-Unique: Q-2sDPN3NROImFef7siOpw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 35/51] block: Make backing files child_of_bds children Date: Fri, 15 May 2020 14:45:05 +0200 Message-Id: <20200515124521.335403-36-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Make all parents of backing files pass the appropriate BdrvChildRole. By doing so, we can switch their BdrvChildClass over to the generic child_of_bds, which will do the right thing when given a correct BdrvChildRole. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-24-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 26 ++++++++++++++++++++------ block/backup-top.c | 2 +- block/vvfat.c | 3 ++- tests/test-bdrv-drain.c | 13 +++++++------ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 85b4f947ba..131ae20ffc 100644 --- a/block.c +++ b/block.c @@ -2941,6 +2941,20 @@ static bool bdrv_inherits_from_recursive(BlockDriver= State *child, return child !=3D NULL; } =20 +/* + * Return the BdrvChildRole for @bs's backing child. bs->backing is + * mostly used for COW backing children (role =3D COW), but also for + * filtered children (role =3D FILTERED | PRIMARY). + */ +static BdrvChildRole bdrv_backing_role(BlockDriverState *bs) +{ + if (bs->drv && bs->drv->is_filter) { + return BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY; + } else { + return BDRV_CHILD_COW; + } +} + /* * Sets the backing file link of a BDS. A new reference is created; callers * which don't need their own reference any more must call bdrv_unref(). @@ -2968,8 +2982,8 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockD= riverState *backing_hd, goto out; } =20 - bs->backing =3D bdrv_attach_child(bs, backing_hd, "backing", &child_ba= cking, - 0, errp); + bs->backing =3D bdrv_attach_child(bs, backing_hd, "backing", &child_of= _bds, + bdrv_backing_role(bs), errp); /* If backing_hd was already part of bs's backing chain, and * inherits_from pointed recursively to bs then let's update it to * point directly to bs (else it will become NULL). */ @@ -3066,7 +3080,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDic= t *parent_options, } =20 backing_hd =3D bdrv_open_inherit(backing_filename, reference, options,= 0, bs, - &child_backing, 0, errp); + &child_of_bds, bdrv_backing_role(bs), e= rrp); if (!backing_hd) { bs->open_flags |=3D BDRV_O_NO_BACKING; error_prepend(errp, "Could not open backing file: "); @@ -3895,8 +3909,8 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, = Error **errp) if (state->replace_backing_bs && state->new_backing_bs) { uint64_t nperm, nshared; bdrv_child_perm(state->bs, state->new_backing_bs, - NULL, &child_backing, 0, bs_queue, - state->perm, state->shared_perm, + NULL, &child_of_bds, bdrv_backing_role(state->= bs), + bs_queue, state->perm, state->shared_perm, &nperm, &nshared); ret =3D bdrv_check_update_perm(state->new_backing_bs, NULL, nperm, nshared, NULL, NULL, errp); @@ -6852,7 +6866,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) drv->bdrv_gather_child_options(bs, opts, backing_overridden); } else { QLIST_FOREACH(child, &bs->children, next) { - if (child->klass =3D=3D &child_backing && !backing_overridden)= { + if (child =3D=3D bs->backing && !backing_overridden) { /* We can skip the backing BDS if it has not been overridd= en */ continue; } diff --git a/block/backup-top.c b/block/backup-top.c index e2b4d2acd3..f059617095 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -143,7 +143,7 @@ static void backup_top_child_perm(BlockDriverState *bs,= BdrvChild *c, return; } =20 - if (child_class =3D=3D &child_file) { + if (!(role & BDRV_CHILD_FILTERED)) { /* * Target child * diff --git a/block/vvfat.c b/block/vvfat.c index b4c8417dbd..e8848a0497 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3219,7 +3219,8 @@ static void vvfat_child_perm(BlockDriverState *bs, Bd= rvChild *c, { BDRVVVFATState *s =3D bs->opaque; =20 - assert(c =3D=3D s->qcow || child_class =3D=3D &child_backing); + assert(c =3D=3D s->qcow || + (child_class =3D=3D &child_of_bds && (role & BDRV_CHILD_COW))); =20 if (c =3D=3D s->qcow) { /* This is a private node, nobody should try to attach to it */ diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index b3d7960bd0..15393a0140 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -96,7 +96,7 @@ static void bdrv_test_child_perm(BlockDriverState *bs, Bd= rvChild *c, * bdrv_format_default_perms() accepts only these two, so disguise * detach_by_driver_cb_parent as one of them. */ - if (child_class !=3D &child_file && child_class !=3D &child_backing) { + if (child_class !=3D &child_file && child_class !=3D &child_of_bds) { child_class =3D &child_file; } =20 @@ -1399,8 +1399,8 @@ static void test_detach_indirect(bool by_parent_cb) bdrv_ref(a); child_b =3D bdrv_attach_child(parent_b, b, "PB-B", &child_file, 0, &error_abort); - child_a =3D bdrv_attach_child(parent_b, a, "PB-A", &child_backing, 0, - &error_abort); + child_a =3D bdrv_attach_child(parent_b, a, "PB-A", &child_of_bds, + BDRV_CHILD_COW, &error_abort); =20 bdrv_ref(a); bdrv_attach_child(parent_a, a, "PA-A", @@ -1793,7 +1793,7 @@ static void test_drop_intermediate_poll(void) int i; int ret; =20 - chain_child_class =3D child_backing; + chain_child_class =3D child_of_bds; chain_child_class.update_filename =3D drop_intermediate_poll_update_fi= lename; =20 for (i =3D 0; i < 3; i++) { @@ -1816,7 +1816,7 @@ static void test_drop_intermediate_poll(void) /* Takes the reference to chain[i - 1] */ chain[i]->backing =3D bdrv_attach_child(chain[i], chain[i - 1], "chain", &chain_child_cl= ass, - 0, &error_abort); + BDRV_CHILD_COW, &error_a= bort); } } =20 @@ -2034,7 +2034,8 @@ static void do_test_replace_child_mid_drain(int old_d= rain_count, =20 bdrv_ref(old_child_bs); parent_bs->backing =3D bdrv_attach_child(parent_bs, old_child_bs, "chi= ld", - &child_backing, 0, &error_abort= ); + &child_of_bds, BDRV_CHILD_COW, + &error_abort); =20 for (i =3D 0; i < old_drain_count; i++) { bdrv_drained_begin(old_child_bs); --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548328; cv=none; d=zohomail.com; s=zohoarc; b=KivxTtBFpIj85FC98yh18kI4B7f4JuIn28bAwr/xiGmKRHjaKkvmL9nS3EjSR2bAbbC9yRvKRUFu/uqPauDRSaCb0UU5jV4gFJC5W0HkIy+15yI8asLXedxV5r+Z7IiP7zFJysPYJJqCM5CQ1eAkKVVZC66rNJBHFSbPYqQvFsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548328; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WO1RmzvUGN7QwMZ7IB3cZAT2Hj4r6SJ5n0/HFJEnUmk=; b=HWD4w1TAIISIj0MKBMFMVS6wGRnXVtlTAOcoONgaNODvjb+R4BM+2MFpXlo0Figue7NC7Pz+jioT4xSHmjOc0HejCSjpFmEmanqTEuc+9cknPyoeJImLmIzoXClFV9DOh2F8vnuyW8l/p/efEROjTYdDj3KwAqR714RU1VkEQ6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548328182661.5421852094278; Fri, 15 May 2020 06:12:08 -0700 (PDT) Received: from localhost ([::1]:35508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa8F-00012A-Aj for importer@patchew.org; Fri, 15 May 2020 09:12:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjR-0003UE-HS for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:29 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22192 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjP-0002R0-Fn for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-YVdfH5uNPgCr0TYvt1k2qg-1; Fri, 15 May 2020 08:46:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2408835B5E; Fri, 15 May 2020 12:46:21 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id D70422E024; Fri, 15 May 2020 12:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WO1RmzvUGN7QwMZ7IB3cZAT2Hj4r6SJ5n0/HFJEnUmk=; b=OyH/YsYQEB9epxlNbybcqf2nGXfzG0VmqfexQ8H0vspAhjv3irB1oMl9j3UcxhuInMJaxP tacxPMsD7FUFESrQa0ldMwqneJElWhKNkYFPZc4GAi5lcpFmcHuxy1/v0XXNXxHSreZw4T 3+huvI2Ab9/FlAl0e2pctrVAeb8aYl4= X-MC-Unique: YVdfH5uNPgCr0TYvt1k2qg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 36/51] block: Drop child_backing Date: Fri, 15 May 2020 14:45:06 +0200 Message-Id: <20200515124521.335403-37-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-25-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 - block.c | 60 ++------------------------------------- 2 files changed, 3 insertions(+), 58 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 4b09fa1124..0781d43af5 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -742,7 +742,6 @@ struct BdrvChildClass { =20 extern const BdrvChildClass child_of_bds; extern const BdrvChildClass child_file; -extern const BdrvChildClass child_backing; =20 struct BdrvChild { BlockDriverState *bs; diff --git a/block.c b/block.c index 131ae20ffc..d138a3c261 100644 --- a/block.c +++ b/block.c @@ -1215,15 +1215,6 @@ static void bdrv_backing_attach(BdrvChild *c) parent->backing_blocker); } =20 -/* XXX: Will be removed along with child_backing */ -static void bdrv_child_cb_attach_backing(BdrvChild *c) -{ - if (!(c->role & BDRV_CHILD_COW)) { - bdrv_backing_attach(c); - } - bdrv_child_cb_attach(c); -} - static void bdrv_backing_detach(BdrvChild *c) { BlockDriverState *parent =3D c->opaque; @@ -1234,28 +1225,6 @@ static void bdrv_backing_detach(BdrvChild *c) parent->backing_blocker =3D NULL; } =20 -/* XXX: Will be removed along with child_backing */ -static void bdrv_child_cb_detach_backing(BdrvChild *c) -{ - if (!(c->role & BDRV_CHILD_COW)) { - bdrv_backing_detach(c); - } - bdrv_child_cb_detach(c); -} - -/* - * Returns the options and flags that bs->backing should get, based on the - * given options and flags for the parent BDS - */ -static void bdrv_backing_options(BdrvChildRole role, bool parent_is_format, - int *child_flags, QDict *child_options, - int parent_flags, QDict *parent_options) -{ - bdrv_inherited_options(BDRV_CHILD_COW, true, - child_flags, child_options, - parent_flags, parent_options); -} - static int bdrv_backing_update_filename(BdrvChild *c, BlockDriverState *ba= se, const char *filename, Error **errp) { @@ -1283,21 +1252,6 @@ static int bdrv_backing_update_filename(BdrvChild *c= , BlockDriverState *base, return ret; } =20 -const BdrvChildClass child_backing =3D { - .parent_is_bds =3D true, - .get_parent_desc =3D bdrv_child_get_parent_desc, - .attach =3D bdrv_child_cb_attach_backing, - .detach =3D bdrv_child_cb_detach_backing, - .inherit_options =3D bdrv_backing_options, - .drained_begin =3D bdrv_child_cb_drained_begin, - .drained_poll =3D bdrv_child_cb_drained_poll, - .drained_end =3D bdrv_child_cb_drained_end, - .inactivate =3D bdrv_child_cb_inactivate, - .update_filename =3D bdrv_backing_update_filename, - .can_set_aio_ctx =3D bdrv_child_cb_can_set_aio_ctx, - .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, -}; - /* * Returns the options and flags that a generic child of a BDS should * get, based on the given options and flags for the parent BDS. @@ -2446,8 +2400,7 @@ static void bdrv_default_perms_for_cow(BlockDriverSta= te *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - assert(child_class =3D=3D &child_backing || - (child_class =3D=3D &child_of_bds && (role & BDRV_CHILD_COW))); + assert(child_class =3D=3D &child_of_bds && (role & BDRV_CHILD_COW)); =20 /* * We want consistent read from backing files if the parent needs it. @@ -2566,23 +2519,16 @@ void bdrv_format_default_perms(BlockDriverState *bs= , BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - bool backing =3D (child_class =3D=3D &child_backing); - if (child_class =3D=3D &child_of_bds) { bdrv_default_perms(bs, c, child_class, role, reopen_queue, perm, shared, nperm, nshared); return; } =20 - assert(child_class =3D=3D &child_backing || child_class =3D=3D &child_= file); + assert(child_class =3D=3D &child_file); =20 - if (!backing) { - bdrv_default_perms_for_storage(bs, c, child_class, role, reopen_qu= eue, - perm, shared, nperm, nshared); - } else { - bdrv_default_perms_for_cow(bs, c, child_class, role, reopen_queue, + bdrv_default_perms_for_storage(bs, c, child_class, role, reopen_queue, perm, shared, nperm, nshared); - } } =20 void bdrv_default_perms(BlockDriverState *bs, BdrvChild *c, --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548230; cv=none; d=zohomail.com; s=zohoarc; b=OiMQ333+UJd2aJlxEbHTD+TZU0I62Sdf2sDjJMJjoNiB+RikvTxQ0jLfABKdeMP1Y/DSSLUsU2147vtmb6U3iXh1D7WHvPjTVv0YGVw4BrltDfiKRMW3w5jGWGBN+1Qrb06DOHVk6+6iwKZSmqiP+MyVTrQRYvq7hjvw9jypZYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548230; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZdZ9Ng9D2S+MWyTy/IA76hQD8meauYjfqfc65E4W2I0=; b=CJ1h66nnAMcIOnSKGNa5nN2NHe/h2jiEUVqY70j19diPxeNx3bZMd1KuueVpIq7dDHeebFRsoAnIMRj23XSi3vYHTo2Xo1+KXGLIeNBoUkQSO+brI+tYgwsAi8Xjv9l9Tpqm0yjAYW1RwfNw7VWvgW5g/7UTOqp/XzFfn+dgCaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548230412842.9403634622832; Fri, 15 May 2020 06:10:30 -0700 (PDT) Received: from localhost ([::1]:56120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa6f-0005tZ-GR for importer@patchew.org; Fri, 15 May 2020 09:10:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjR-0003VE-UE for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:29 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:40106 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjQ-0002RD-SM for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-PJZnAgGSPnyvMHmLztxYDw-1; Fri, 15 May 2020 08:46:24 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 212F51005512; Fri, 15 May 2020 12:46:23 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272D72E024; Fri, 15 May 2020 12:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZdZ9Ng9D2S+MWyTy/IA76hQD8meauYjfqfc65E4W2I0=; b=WKpfIKHD3JrFmP3N04guZ/uD+DtltTPqdQK/uHt0vp2xrptYOaVXm4TjVhd8A+osqdZuzT 5kWgSCnmhd8E7g7ZWYZdHTjNNeiAT/MZBjbSNib8f2DVfAAo25sbJeXx72wluuX84RP1Rn cV/kcRmcHXpwd3KLiP1Qzi8lQISab68= X-MC-Unique: PJZnAgGSPnyvMHmLztxYDw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 37/51] block: Make format drivers use child_of_bds Date: Fri, 15 May 2020 14:45:07 +0200 Message-Id: <20200515124521.335403-38-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Commonly, they need to pass the BDRV_CHILD_IMAGE set as the BdrvChildRole; but there are exceptions for drivers with external data files (qcow2 and vmdk). Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-26-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/bochs.c | 4 ++-- block/cloop.c | 4 ++-- block/crypto.c | 4 ++-- block/dmg.c | 4 ++-- block/parallels.c | 4 ++-- block/qcow.c | 4 ++-- block/qcow2.c | 19 +++++++++++++------ block/qed.c | 4 ++-- block/vdi.c | 4 ++-- block/vhdx.c | 4 ++-- block/vmdk.c | 20 +++++++++++++++++--- block/vpc.c | 4 ++-- 12 files changed, 50 insertions(+), 29 deletions(-) diff --git a/block/bochs.c b/block/bochs.c index b013e73063..62c3f42548 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -110,8 +110,8 @@ static int bochs_open(BlockDriverState *bs, QDict *opti= ons, int flags, return ret; } =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/cloop.c b/block/cloop.c index 3ed9fa63cc..d374a8427d 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -71,8 +71,8 @@ static int cloop_open(BlockDriverState *bs, QDict *option= s, int flags, return ret; } =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/crypto.c b/block/crypto.c index 8b516bfee2..457f3a06a5 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -218,8 +218,8 @@ static int block_crypto_open_generic(QCryptoBlockFormat= format, unsigned int cflags =3D 0; QDict *cryptoopts =3D NULL; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/dmg.c b/block/dmg.c index af8188638c..bc64194577 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -439,8 +439,8 @@ static int dmg_open(BlockDriverState *bs, QDict *option= s, int flags, return ret; } =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/parallels.c b/block/parallels.c index 9855ac1162..168d6c531a 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -739,8 +739,8 @@ static int parallels_open(BlockDriverState *bs, QDict *= options, int flags, Error *local_err =3D NULL; char *buf; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/qcow.c b/block/qcow.c index 13583f0339..5347037720 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -130,8 +130,8 @@ static int qcow_open(BlockDriverState *bs, QDict *optio= ns, int flags, qdict_extract_subqdict(options, &encryptopts, "encrypt."); encryptfmt =3D qdict_get_try_str(encryptopts, "format"); =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { ret =3D -EINVAL; goto fail; diff --git a/block/qcow2.c b/block/qcow2.c index 86335d9403..8d7230dca8 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1590,8 +1590,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, } =20 /* Open external data file */ - s->data_file =3D bdrv_open_child(NULL, options, "data-file", bs, &chil= d_file, - 0, true, &local_err); + s->data_file =3D bdrv_open_child(NULL, options, "data-file", bs, + &child_of_bds, BDRV_CHILD_DATA, + true, &local_err); if (local_err) { error_propagate(errp, local_err); ret =3D -EINVAL; @@ -1601,8 +1602,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) { if (!s->data_file && s->image_data_file) { s->data_file =3D bdrv_open_child(s->image_data_file, options, - "data-file", bs, &child_file, 0, - false, errp); + "data-file", bs, &child_of_bds, + BDRV_CHILD_DATA, false, errp); if (!s->data_file) { ret =3D -EINVAL; goto fail; @@ -1613,6 +1614,12 @@ static int coroutine_fn qcow2_do_open(BlockDriverSta= te *bs, QDict *options, ret =3D -EINVAL; goto fail; } + + /* No data here */ + bs->file->role &=3D ~BDRV_CHILD_DATA; + + /* Must succeed because we have given up permissions if anything */ + bdrv_child_refresh_perms(bs, bs->file, &error_abort); } else { if (s->data_file) { error_setg(errp, "'data-file' can only be set for images with = an " @@ -1863,8 +1870,8 @@ static int qcow2_open(BlockDriverState *bs, QDict *op= tions, int flags, .ret =3D -EINPROGRESS }; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/qed.c b/block/qed.c index 1ad2aba810..ef6463b48d 100644 --- a/block/qed.c +++ b/block/qed.c @@ -547,8 +547,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *o= ptions, int flags, .ret =3D -EINPROGRESS }; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/vdi.c b/block/vdi.c index 653acb5fc1..d20698b3cc 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -378,8 +378,8 @@ static int vdi_open(BlockDriverState *bs, QDict *option= s, int flags, Error *local_err =3D NULL; QemuUUID uuid_link, uuid_parent; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/vhdx.c b/block/vhdx.c index dde156c97b..62c6bd69ff 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -996,8 +996,8 @@ static int vhdx_open(BlockDriverState *bs, QDict *optio= ns, int flags, uint64_t signature; Error *local_err =3D NULL; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/vmdk.c b/block/vmdk.c index c2cb741e2d..fadc98a262 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1089,6 +1089,7 @@ static int vmdk_parse_extents(const char *desc, Block= DriverState *bs, char *desc_file_dir =3D NULL; char *extent_path; BdrvChild *extent_file; + BdrvChildRole extent_role; BDRVVmdkState *s =3D bs->opaque; VmdkExtent *extent; char extent_opt_prefix[32]; @@ -1151,8 +1152,15 @@ static int vmdk_parse_extents(const char *desc, Bloc= kDriverState *bs, ret =3D snprintf(extent_opt_prefix, 32, "extents.%d", s->num_exten= ts); assert(ret < 32); =20 + extent_role =3D BDRV_CHILD_DATA; + if (strcmp(type, "FLAT") !=3D 0 && strcmp(type, "VMFS") !=3D 0) { + /* non-flat extents have metadata */ + extent_role |=3D BDRV_CHILD_METADATA; + } + extent_file =3D bdrv_open_child(extent_path, options, extent_opt_p= refix, - bs, &child_file, 0, false, &local_er= r); + bs, &child_of_bds, extent_role, fals= e, + &local_err); g_free(extent_path); if (local_err) { error_propagate(errp, local_err); @@ -1257,8 +1265,8 @@ static int vmdk_open(BlockDriverState *bs, QDict *opt= ions, int flags, uint32_t magic; Error *local_err =3D NULL; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } @@ -1277,6 +1285,12 @@ static int vmdk_open(BlockDriverState *bs, QDict *op= tions, int flags, s->desc_offset =3D 0x200; break; default: + /* No data in the descriptor file */ + bs->file->role &=3D ~BDRV_CHILD_DATA; + + /* Must succeed because we have given up permissions if anythi= ng */ + bdrv_child_refresh_perms(bs, bs->file, &error_abort); + ret =3D vmdk_open_desc_file(bs, flags, buf, options, errp); break; } diff --git a/block/vpc.c b/block/vpc.c index b2a86074a5..651a6737b6 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -228,8 +228,8 @@ static int vpc_open(BlockDriverState *bs, QDict *option= s, int flags, int ret; int64_t bs_size; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_IMAGE, false, errp); if (!bs->file) { return -EINVAL; } --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547571; cv=none; d=zohomail.com; s=zohoarc; b=eK649zpyDPulqHFmqnhzGuwuucRSbjlZUCkMqJk5Qc5h4ZO90hjGFr1dzyDHv8XbbECnYbZbnPfO4rEVpBzszdL4ty2C3yLNvYX134LQIbGfll1SoZNWJtcn9Zdmu9b2GxaY/kXBoz6LwkZvq3qpp+ZwYQoFVe4qymiFb+EeS5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547571; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rXkWQF7zMNe9vRQ/O61J0ZGPPFhfb43UNePE/k2sSJA=; b=c7QlEg3yFJu/ACE2+TEZyGAfM03nGNQQvMVCjSDSXLuf6ZThs4r92ynbYBI0Q0XPRHg0W7vP/Jc7YNEMsOW40anV+RYjPy8+pEKjSwmqHlvvn+emDsjAUUBoy5UAGcogoZ3zBq07Rtxjiud/z0X/nj1LIMUVh8uO8ll2geXYOCc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547571641566.7716755062555; Fri, 15 May 2020 05:59:31 -0700 (PDT) Received: from localhost ([::1]:39340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZw2-00035t-Cw for importer@patchew.org; Fri, 15 May 2020 08:59:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjV-0003ev-9Y for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36702 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjS-0002RN-Rf for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-se6z8eABMwGuutAc9L_vZg-1; Fri, 15 May 2020 08:46:25 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 625AE460; Fri, 15 May 2020 12:46:24 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A0BB2E024; Fri, 15 May 2020 12:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rXkWQF7zMNe9vRQ/O61J0ZGPPFhfb43UNePE/k2sSJA=; b=ZFnWykYeK/LpGfJCJ/zu8pxa1ZoXBz1C5Bptria+zFxAqYmM5SYnzx/Uvj6yLY7GrFqRxI 3jEv4B2l76C8V0sG05RBzAcW3XJsSJzxKaEZSGIosrZAwwRcH8cfpUtBNdBq0IdFxd6emv 1VCGa430+lxiQjlH1MwfDKWwc/lru68= X-MC-Unique: se6z8eABMwGuutAc9L_vZg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 38/51] block: Make filter drivers use child_of_bds Date: Fri, 15 May 2020 14:45:08 +0200 Message-Id: <20200515124521.335403-39-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Note that some filters have secondary children, namely blkverify (the image to be verified) and blklogwrites (the log). This patch does not touch those children. Note that for blkverify, the filtered child should not be format-probed. While there is nothing enforcing this here, in practice, it will not be: blkverify implements .bdrv_file_open. The block layer ensures (and in fact, asserts) that BDRV_O_PROTOCOL is set for every BDS whose driver implements .bdrv_file_open. This flag will then be bequeathed to blkverify's children, and they will thus (by default) not be probed either. ("By default" refers to the fact that blkverify's other child (the non-filtered one) will have BDRV_O_PROTOCOL force-unset, because that is what happens for all non-filtered children of non-format drivers.) Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-27-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/blkdebug.c | 4 +++- block/blklogwrites.c | 3 ++- block/blkreplay.c | 5 +++-- block/blkverify.c | 4 +++- block/copy-on-read.c | 5 +++-- block/filter-compress.c | 5 +++-- block/replication.c | 3 ++- block/throttle.c | 5 +++-- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 8dd8ed6055..b31fa40b0e 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -497,7 +497,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *o= ptions, int flags, =20 /* Open the image file */ bs->file =3D bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "= image", - bs, &child_file, 0, false, &local_err); + bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 4faf912ef1..78b0c49460 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -157,7 +157,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QD= ict *options, int flags, } =20 /* Open the file */ - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0= , false, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, f= alse, &local_err); if (local_err) { ret =3D -EINVAL; diff --git a/block/blkreplay.c b/block/blkreplay.c index 9b2814fc58..20d6139baa 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -27,8 +27,9 @@ static int blkreplay_open(BlockDriverState *bs, QDict *op= tions, int flags, int ret; =20 /* Open the image file */ - bs->file =3D bdrv_open_child(NULL, options, "image", - bs, &child_file, 0, false, &local_err); + bs->file =3D bdrv_open_child(NULL, options, "image", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/blkverify.c b/block/blkverify.c index 1684b7aa2e..5c3b29244a 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -125,7 +125,9 @@ static int blkverify_open(BlockDriverState *bs, QDict *= options, int flags, =20 /* Open the raw file */ bs->file =3D bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "ra= w", - bs, &child_file, 0, false, &local_err); + bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/copy-on-read.c b/block/copy-on-read.c index a2d92ac394..c857ea0da7 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -28,8 +28,9 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0= , false, - errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/filter-compress.c b/block/filter-compress.c index 4dc5f9fb8c..9edd937645 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -30,8 +30,9 @@ static int compress_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0= , false, - errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, errp); if (!bs->file) { return -EINVAL; } diff --git a/block/replication.c b/block/replication.c index ea87b1a4f0..cc9c473ad1 100644 --- a/block/replication.c +++ b/block/replication.c @@ -90,7 +90,8 @@ static int replication_open(BlockDriverState *bs, QDict *= options, const char *mode; const char *top_id; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, false, errp); if (!bs->file) { return -EINVAL; diff --git a/block/throttle.c b/block/throttle.c index 2dea913be7..47b0a3522d 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -81,8 +81,9 @@ static int throttle_open(BlockDriverState *bs, QDict *opt= ions, char *group; int ret; =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, - &child_file, 0, false, errp); + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, errp); if (!bs->file) { return -EINVAL; } --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548406; cv=none; d=zohomail.com; s=zohoarc; b=RlTxmXT9iLbvPOAxw+C5X31DrSTmH+4kFU+F2RKRuphv19qnFVH8UeslGqNFwHCkTOC5z+R+FGFX8S45Tzwd0BSWCf2+aAVW73pAWE6kUig0w6Gj58P+n1kys/z+LBN7ezSXGzPa+Idc/GfZWcqjESUdkz18cbe3nc4xn+xEJFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548406; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zOBw476omY7OFIkRtU2ry57F3vRSBEyDuj+xDG+u5Rk=; b=REAhMJhbWU8lQY2evgK/fvBXx607Ci1f1rPzzWWABZW3nEpsKHOSo0OdxuEvRXmrOosjYNjq0SG7h3vjLuod6DHCQHWy6UkSzEFKnVGIjNfdbnFCV+4auU9CimhMg2mATBZz6WiXZFQoF5g32rWFiBhd7lPdVp9lVhy/SAWzD/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548406902607.5123677136897; Fri, 15 May 2020 06:13:26 -0700 (PDT) Received: from localhost ([::1]:42828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa9V-0004Ss-Th for importer@patchew.org; Fri, 15 May 2020 09:13:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjX-0003j1-3Y for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57633 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjW-0002SH-Bk for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-EvLtcNynOJSZkURQYOxS2w-1; Fri, 15 May 2020 08:46:26 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5B5A835B40; Fri, 15 May 2020 12:46:25 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC4062E024; Fri, 15 May 2020 12:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zOBw476omY7OFIkRtU2ry57F3vRSBEyDuj+xDG+u5Rk=; b=hE+7HrRE3q8Aq5Ry8Zs+yfrDyZlAyM9Pe7lsGxbI9eY5mybHuRNNnrtOzZjSR7C/uG88kJ XK19RTnZwaPaMxsP+Wfc7hoXVxVMx2XB8poaZVeLEBEVzXPBP1fJ56Tf7qLPjpiSXDml17 0AvpaXuJ27emcmhSFNYJNzro3gKcKq0= X-MC-Unique: EvLtcNynOJSZkURQYOxS2w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 39/51] block: Use child_of_bds in remaining places Date: Fri, 15 May 2020 14:45:09 +0200 Message-Id: <20200515124521.335403-40-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Replace child_file by child_of_bds in all remaining places (excluding tests). Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-28-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 3 ++- block/backup-top.c | 4 ++-- block/blklogwrites.c | 4 ++-- block/raw-format.c | 15 +++++++++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index d138a3c261..fb94adcca4 100644 --- a/block.c +++ b/block.c @@ -3406,7 +3406,8 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, BlockDriverState *file_bs; =20 file_bs =3D bdrv_open_child_bs(filename, options, "file", bs, - &child_file, 0, true, &local_err); + &child_of_bds, BDRV_CHILD_IMAGE, + true, &local_err); if (local_err) { goto fail; } diff --git a/block/backup-top.c b/block/backup-top.c index f059617095..8af2c5fe9b 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -215,8 +215,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverSta= te *source, source->supported_zero_flags); =20 bdrv_ref(target); - state->target =3D bdrv_attach_child(top, target, "target", &child_file= , 0, - errp); + state->target =3D bdrv_attach_child(top, target, "target", &child_of_b= ds, + BDRV_CHILD_DATA, errp); if (!state->target) { bdrv_unref(target); bdrv_unref(top); diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 78b0c49460..3a57b273fc 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -167,8 +167,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QD= ict *options, int flags, } =20 /* Open the log file */ - s->log_file =3D bdrv_open_child(NULL, options, "log", bs, &child_file,= 0, - false, &local_err); + s->log_file =3D bdrv_open_child(NULL, options, "log", bs, &child_of_bd= s, + BDRV_CHILD_METADATA, false, &local_err); if (local_err) { ret =3D -EINVAL; error_propagate(errp, local_err); diff --git a/block/raw-format.c b/block/raw-format.c index 824fe70686..bfb4d7ddb7 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -441,6 +441,7 @@ static int raw_open(BlockDriverState *bs, QDict *option= s, int flags, BDRVRawState *s =3D bs->opaque; bool has_size; uint64_t offset, size; + BdrvChildRole file_role; int ret; =20 ret =3D raw_read_options(options, &offset, &has_size, &size, errp); @@ -448,8 +449,18 @@ static int raw_open(BlockDriverState *bs, QDict *optio= ns, int flags, return ret; } =20 - bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, 0, - false, errp); + /* + * Without offset and a size limit, this driver behaves very much + * like a filter. With any such limit, it does not. + */ + if (offset || has_size) { + file_role =3D BDRV_CHILD_DATA | BDRV_CHILD_PRIMARY; + } else { + file_role =3D BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY; + } + + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + file_role, false, errp); if (!bs->file) { return -EINVAL; } --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547453; cv=none; d=zohomail.com; s=zohoarc; b=NFph79MdUyvWp7duNNf1iMZjuQwvFTUypTjBHOjew2Wt980OW8sXzZav0tEOJ3K39nDpbeASaZi90L/CkCLFGlUFxnjBr70TiSCuZ5ZZynuSDBBrd6YxZUDbFjnzXpRv+OOsMs4NB7PBQnVDL8+EhZ89CzN+oBGZ5m/ut+LsaFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547453; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/ndpxIbT3g3hTWUzNBsH+TAmQkz9wEJcQCVo3gxg/p8=; b=az2/bOe/2p9FErhXlPnznsvnHI3b1j8Q76bUnul0i8bss7Z8B7VU6oYlH9BxpGhATw+1Rrznb1uVG1V1pCuiRnEp4RbnBfJChDRDNur7BCKwyZewWyQwbVi6QHOwHHSKFtCtwGdvsUSxVv0yYNBoXXx7gOdvaVXZmC7PeE+3t5M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547453114457.49248897313726; Fri, 15 May 2020 05:57:33 -0700 (PDT) Received: from localhost ([::1]:59018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZu7-0007oo-U0 for importer@patchew.org; Fri, 15 May 2020 08:57:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjU-0003e9-VX for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:33 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:56827 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjT-0002RW-FP for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-tz3f7zvNMO2Li8LupFQckA-1; Fri, 15 May 2020 08:46:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7E2E8014D7; Fri, 15 May 2020 12:46:26 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE6A52E024; Fri, 15 May 2020 12:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/ndpxIbT3g3hTWUzNBsH+TAmQkz9wEJcQCVo3gxg/p8=; b=Gb5Gn8NFxd3izXsu+Lr4kSOJjwdl/G5jgeApT7xZqr5FoN9FRWOoqN49YzSmgyh9kBKCBw qEK9bMORI2jruuQEj4eHSpVLY9epVOBxIuqKBts/5yYyFQ4fR/1dr9VjniqOl4OUmIFrNC dTfU55Ltc7/edHDSY9J2MkdEhav0PWs= X-MC-Unique: tz3f7zvNMO2Li8LupFQckA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 40/51] tests: Use child_of_bds instead of child_file Date: Fri, 15 May 2020 14:45:10 +0200 Message-Id: <20200515124521.335403-41-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-29-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- tests/test-bdrv-drain.c | 29 +++++++++++++++++------------ tests/test-bdrv-graph-mod.c | 6 ++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 15393a0140..91567ca97d 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -97,7 +97,7 @@ static void bdrv_test_child_perm(BlockDriverState *bs, Bd= rvChild *c, * detach_by_driver_cb_parent as one of them. */ if (child_class !=3D &child_file && child_class !=3D &child_of_bds) { - child_class =3D &child_file; + child_class =3D &child_of_bds; } =20 bdrv_format_default_perms(bs, c, child_class, role, reopen_queue, @@ -1203,7 +1203,8 @@ static void do_test_delete_by_drain(bool detach_inste= ad_of_delete, =20 null_bs =3D bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_P= ROTOCOL, &error_abort); - bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_ab= ort); + bdrv_attach_child(bs, null_bs, "null-child", &child_of_bds, + BDRV_CHILD_DATA, &error_abort); =20 /* This child will be the one to pass to requests through to, and * it will stall until a drain occurs */ @@ -1211,14 +1212,17 @@ static void do_test_delete_by_drain(bool detach_ins= tead_of_delete, &error_abort); child_bs->total_sectors =3D 65536 >> BDRV_SECTOR_BITS; /* Takes our reference to child_bs */ - tts->wait_child =3D bdrv_attach_child(bs, child_bs, "wait-child", &chi= ld_file, - 0, &error_abort); + tts->wait_child =3D bdrv_attach_child(bs, child_bs, "wait-child", + &child_of_bds, + BDRV_CHILD_DATA | BDRV_CHILD_PRIMA= RY, + &error_abort); =20 /* This child is just there to be deleted * (for detach_instead_of_delete =3D=3D true) */ null_bs =3D bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_P= ROTOCOL, &error_abort); - bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_ab= ort); + bdrv_attach_child(bs, null_bs, "null-child", &child_of_bds, BDRV_CHILD= _DATA, + &error_abort); =20 blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); blk_insert_bs(blk, bs, &error_abort); @@ -1315,7 +1319,8 @@ static void detach_indirect_bh(void *opaque) =20 bdrv_ref(data->c); data->child_c =3D bdrv_attach_child(data->parent_b, data->c, "PB-C", - &child_file, 0, &error_abort); + &child_of_bds, BDRV_CHILD_DATA, + &error_abort); } =20 static void detach_by_parent_aio_cb(void *opaque, int ret) @@ -1332,7 +1337,7 @@ static void detach_by_driver_cb_drained_begin(BdrvChi= ld *child) { aio_bh_schedule_oneshot(qemu_get_current_aio_context(), detach_indirect_bh, &detach_by_parent_data); - child_file.drained_begin(child); + child_of_bds.drained_begin(child); } =20 static BdrvChildClass detach_by_driver_cb_class; @@ -1367,7 +1372,7 @@ static void test_detach_indirect(bool by_parent_cb) QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 if (!by_parent_cb) { - detach_by_driver_cb_class =3D child_file; + detach_by_driver_cb_class =3D child_of_bds; detach_by_driver_cb_class.drained_begin =3D detach_by_driver_cb_drained_begin; } @@ -1397,15 +1402,15 @@ static void test_detach_indirect(bool by_parent_cb) /* Set child relationships */ bdrv_ref(b); bdrv_ref(a); - child_b =3D bdrv_attach_child(parent_b, b, "PB-B", &child_file, 0, - &error_abort); + child_b =3D bdrv_attach_child(parent_b, b, "PB-B", &child_of_bds, + BDRV_CHILD_DATA, &error_abort); child_a =3D bdrv_attach_child(parent_b, a, "PB-A", &child_of_bds, BDRV_CHILD_COW, &error_abort); =20 bdrv_ref(a); bdrv_attach_child(parent_a, a, "PA-A", - by_parent_cb ? &child_file : &detach_by_driver_cb_cl= ass, - 0, &error_abort); + by_parent_cb ? &child_of_bds : &detach_by_driver_cb_= class, + BDRV_CHILD_DATA, &error_abort); =20 g_assert_cmpint(parent_a->refcnt, =3D=3D, 1); g_assert_cmpint(parent_b->refcnt, =3D=3D, 1); diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index 3707e2533c..6ae91ff171 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -112,7 +112,8 @@ static void test_update_perm_tree(void) =20 blk_insert_bs(root, bs, &error_abort); =20 - bdrv_attach_child(filter, bs, "child", &child_file, 0, &error_abort); + bdrv_attach_child(filter, bs, "child", &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abo= rt); =20 bdrv_append(filter, bs, &local_err); =20 @@ -178,7 +179,8 @@ static void test_should_update_child(void) bdrv_set_backing_hd(target, bs, &error_abort); =20 g_assert(target->backing->bs =3D=3D bs); - bdrv_attach_child(filter, target, "target", &child_file, 0, &error_abo= rt); + bdrv_attach_child(filter, target, "target", &child_of_bds, + BDRV_CHILD_DATA, &error_abort); bdrv_append(filter, bs, &error_abort); g_assert(target->backing->bs =3D=3D bs); =20 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548544; cv=none; d=zohomail.com; s=zohoarc; b=HSALZkUv3YNO2WU47Kx30vC8z+oslkslCyJzyIv4GlDI3vrFyKe+xV1DcefmVkfZK98ToKqeLHkbokHVlURgKhCL4hJt62+FiWwxXH16qYNF71zKIRKQPWJrrtd+wcbQV95BYVRNU3i1AEZgWg4TITUSBVQ6XyRrYvll5uhO6pc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548544; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XJRUIxf7Xku8giGbw2UOf5t7CUbquF7LkxYHCxUswBw=; b=FXlpZurpwsAzC2FMWjSWwdvZuqhok2ba5UHdlEpQr/vpnBLg0jb9jF81s9fIoPyNwemwG/qMPPmmkHp8upH6YUD3nVaKgu4UMM5m7TLQwCQQe++Sge3pwcUAhENzJBwxSax7sScNuIaPB2DbapxSObaqMeoCDOT7tH22R1JDGpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548544353669.77580047129; Fri, 15 May 2020 06:15:44 -0700 (PDT) Received: from localhost ([::1]:49384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaBj-0008KO-Fp for importer@patchew.org; Fri, 15 May 2020 09:15:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjW-0003gZ-5f for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:34 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:57275 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjU-0002Ra-60 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-TJTsRnVDPpSBu_iBzH8cUw-1; Fri, 15 May 2020 08:46:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36EBF19200C0; Fri, 15 May 2020 12:46:28 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D8F52E024; Fri, 15 May 2020 12:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XJRUIxf7Xku8giGbw2UOf5t7CUbquF7LkxYHCxUswBw=; b=IzVLcjFf+N+YVxcrCL3xRpgf3AgRB/JknMU/Z0Ref5pS0etY0w0eD1OXJxAtudSxKb0va9 EJRHYCrsSxbhMakq+D0C+tr4XUZbznbVRCYjAC0j3JowXkSnfQ92qPObVRTbCVn8/qC5j/ LKcnzEdyLq8ZYs+hHwW7USWD//ilbM0= X-MC-Unique: TJTsRnVDPpSBu_iBzH8cUw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 41/51] block: Use bdrv_default_perms() Date: Fri, 15 May 2020 14:45:11 +0200 Message-Id: <20200515124521.335403-42-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:07:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz bdrv_default_perms() can decide which permission profile to use based on the BdrvChildRole, so block drivers do not need to select it explicitly. The blkverify driver now no longer shares the WRITE permission for the image to verify. We thus have to adjust two places in test-block-iothread not to take it. (Note that in theory, blkverify should behave like quorum in this regard and share neither WRITE nor RESIZE for both of its children. In practice, it does not really matter, because blkverify is used only for debugging, so we might as well keep its permissions rather liberal.) Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-30-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- block/backup-top.c | 4 ++-- block/blkdebug.c | 4 ++-- block/blklogwrites.c | 9 ++------- block/blkreplay.c | 2 +- block/blkverify.c | 2 +- block/bochs.c | 2 +- block/cloop.c | 2 +- block/crypto.c | 2 +- block/dmg.c | 2 +- block/filter-compress.c | 2 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 2 +- block/qed.c | 2 +- block/raw-format.c | 2 +- block/throttle.c | 2 +- block/vdi.c | 2 +- block/vhdx.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- tests/test-bdrv-drain.c | 10 +++++----- tests/test-bdrv-graph-mod.c | 2 +- tests/test-block-iothread.c | 17 ++++++++++++++--- 23 files changed, 43 insertions(+), 37 deletions(-) diff --git a/block/backup-top.c b/block/backup-top.c index 8af2c5fe9b..f0efec18b5 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -156,8 +156,8 @@ static void backup_top_child_perm(BlockDriverState *bs,= BdrvChild *c, *nperm =3D BLK_PERM_WRITE; } else { /* Source child */ - bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, - perm, shared, nperm, nshared); + bdrv_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); =20 if (perm & BLK_PERM_WRITE) { *nperm =3D *nperm | BLK_PERM_CONSISTENT_READ; diff --git a/block/blkdebug.c b/block/blkdebug.c index b31fa40b0e..a925d8295e 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -1003,8 +1003,8 @@ static void blkdebug_child_perm(BlockDriverState *bs,= BdrvChild *c, { BDRVBlkdebugState *s =3D bs->opaque; =20 - bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, - perm, shared, nperm, nshared); + bdrv_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); =20 *nperm |=3D s->take_child_perms; *nshared &=3D ~s->unshare_child_perms; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 3a57b273fc..8684fb1c74 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -295,13 +295,8 @@ static void blk_log_writes_child_perm(BlockDriverState= *bs, BdrvChild *c, return; } =20 - if (!strcmp(c->name, "log")) { - bdrv_format_default_perms(bs, c, child_class, role, ro_q, perm, sh= rd, - nperm, nshrd); - } else { - bdrv_filter_default_perms(bs, c, child_class, role, ro_q, perm, sh= rd, - nperm, nshrd); - } + bdrv_default_perms(bs, c, child_class, role, ro_q, perm, shrd, + nperm, nshrd); } =20 static void blk_log_writes_refresh_limits(BlockDriverState *bs, Error **er= rp) diff --git a/block/blkreplay.c b/block/blkreplay.c index 20d6139baa..30a0f5d57a 100644 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -139,7 +139,7 @@ static BlockDriver bdrv_blkreplay =3D { .is_filter =3D true, =20 .bdrv_open =3D blkreplay_open, - .bdrv_child_perm =3D bdrv_filter_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_getlength =3D blkreplay_getlength, =20 .bdrv_co_preadv =3D blkreplay_co_preadv, diff --git a/block/blkverify.c b/block/blkverify.c index 5c3b29244a..2f261de24b 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -319,7 +319,7 @@ static BlockDriver bdrv_blkverify =3D { .bdrv_parse_filename =3D blkverify_parse_filename, .bdrv_file_open =3D blkverify_open, .bdrv_close =3D blkverify_close, - .bdrv_child_perm =3D bdrv_filter_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_getlength =3D blkverify_getlength, .bdrv_refresh_filename =3D blkverify_refresh_filename, .bdrv_dirname =3D blkverify_dirname, diff --git a/block/bochs.c b/block/bochs.c index 62c3f42548..2f010ab40a 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -297,7 +297,7 @@ static BlockDriver bdrv_bochs =3D { .instance_size =3D sizeof(BDRVBochsState), .bdrv_probe =3D bochs_probe, .bdrv_open =3D bochs_open, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_refresh_limits =3D bochs_refresh_limits, .bdrv_co_preadv =3D bochs_co_preadv, .bdrv_close =3D bochs_close, diff --git a/block/cloop.c b/block/cloop.c index d374a8427d..c99192a57f 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -293,7 +293,7 @@ static BlockDriver bdrv_cloop =3D { .instance_size =3D sizeof(BDRVCloopState), .bdrv_probe =3D cloop_probe, .bdrv_open =3D cloop_open, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_refresh_limits =3D cloop_refresh_limits, .bdrv_co_preadv =3D cloop_co_preadv, .bdrv_close =3D cloop_close, diff --git a/block/crypto.c b/block/crypto.c index 457f3a06a5..b216e12c31 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -756,7 +756,7 @@ static BlockDriver bdrv_crypto_luks =3D { .bdrv_close =3D block_crypto_close, /* This driver doesn't modify LUKS metadata except when creating image. * Allow share-rw=3Don as a special case. */ - .bdrv_child_perm =3D bdrv_filter_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_create =3D block_crypto_co_create_luks, .bdrv_co_create_opts =3D block_crypto_co_create_opts_luks, .bdrv_co_truncate =3D block_crypto_co_truncate, diff --git a/block/dmg.c b/block/dmg.c index bc64194577..0d6c317296 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -750,7 +750,7 @@ static BlockDriver bdrv_dmg =3D { .bdrv_probe =3D dmg_probe, .bdrv_open =3D dmg_open, .bdrv_refresh_limits =3D dmg_refresh_limits, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_preadv =3D dmg_co_preadv, .bdrv_close =3D dmg_close, .is_format =3D true, diff --git a/block/filter-compress.c b/block/filter-compress.c index 9edd937645..8ec1991c1f 100644 --- a/block/filter-compress.c +++ b/block/filter-compress.c @@ -133,7 +133,7 @@ static BlockDriver bdrv_compress =3D { .format_name =3D "compress", =20 .bdrv_open =3D compress_open, - .bdrv_child_perm =3D bdrv_filter_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, =20 .bdrv_getlength =3D compress_getlength, =20 diff --git a/block/parallels.c b/block/parallels.c index 168d6c531a..63a1cde8af 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -912,7 +912,7 @@ static BlockDriver bdrv_parallels =3D { .bdrv_probe =3D parallels_probe, .bdrv_open =3D parallels_open, .bdrv_close =3D parallels_close, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_block_status =3D parallels_co_block_status, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, .bdrv_co_flush_to_os =3D parallels_co_flush_to_os, diff --git a/block/qcow.c b/block/qcow.c index 5347037720..ee5d35fe20 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -1180,7 +1180,7 @@ static BlockDriver bdrv_qcow =3D { .bdrv_probe =3D qcow_probe, .bdrv_open =3D qcow_open, .bdrv_close =3D qcow_close, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_reopen_prepare =3D qcow_reopen_prepare, .bdrv_co_create =3D qcow_co_create, .bdrv_co_create_opts =3D qcow_co_create_opts, diff --git a/block/qcow2.c b/block/qcow2.c index 8d7230dca8..fe0ce39799 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5744,7 +5744,7 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_reopen_commit_post =3D qcow2_reopen_commit_post, .bdrv_reopen_abort =3D qcow2_reopen_abort, .bdrv_join_options =3D qcow2_join_options, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_create_opts =3D qcow2_co_create_opts, .bdrv_co_create =3D qcow2_co_create, .bdrv_has_zero_init =3D qcow2_has_zero_init, diff --git a/block/qed.c b/block/qed.c index ef6463b48d..c0c65015c7 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1672,7 +1672,7 @@ static BlockDriver bdrv_qed =3D { .bdrv_open =3D bdrv_qed_open, .bdrv_close =3D bdrv_qed_close, .bdrv_reopen_prepare =3D bdrv_qed_reopen_prepare, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_create =3D bdrv_qed_co_create, .bdrv_co_create_opts =3D bdrv_qed_co_create_opts, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, diff --git a/block/raw-format.c b/block/raw-format.c index bfb4d7ddb7..018441bddf 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -586,7 +586,7 @@ BlockDriver bdrv_raw =3D { .bdrv_reopen_commit =3D &raw_reopen_commit, .bdrv_reopen_abort =3D &raw_reopen_abort, .bdrv_open =3D &raw_open, - .bdrv_child_perm =3D bdrv_filter_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_create_opts =3D &raw_co_create_opts, .bdrv_co_preadv =3D &raw_co_preadv, .bdrv_co_pwritev =3D &raw_co_pwritev, diff --git a/block/throttle.c b/block/throttle.c index 47b0a3522d..0ebbad0743 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -237,7 +237,7 @@ static BlockDriver bdrv_throttle =3D { .bdrv_close =3D throttle_close, .bdrv_co_flush =3D throttle_co_flush, =20 - .bdrv_child_perm =3D bdrv_filter_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, =20 .bdrv_getlength =3D throttle_getlength, =20 diff --git a/block/vdi.c b/block/vdi.c index d20698b3cc..2f506a01ba 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -1039,7 +1039,7 @@ static BlockDriver bdrv_vdi =3D { .bdrv_open =3D vdi_open, .bdrv_close =3D vdi_close, .bdrv_reopen_prepare =3D vdi_reopen_prepare, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_create =3D vdi_co_create, .bdrv_co_create_opts =3D vdi_co_create_opts, .bdrv_has_zero_init =3D vdi_has_zero_init, diff --git a/block/vhdx.c b/block/vhdx.c index 62c6bd69ff..fa9e544a5e 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2245,7 +2245,7 @@ static BlockDriver bdrv_vhdx =3D { .bdrv_open =3D vhdx_open, .bdrv_close =3D vhdx_close, .bdrv_reopen_prepare =3D vhdx_reopen_prepare, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_readv =3D vhdx_co_readv, .bdrv_co_writev =3D vhdx_co_writev, .bdrv_co_create =3D vhdx_co_create, diff --git a/block/vmdk.c b/block/vmdk.c index fadc98a262..62da465126 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -3067,7 +3067,7 @@ static BlockDriver bdrv_vmdk =3D { .bdrv_open =3D vmdk_open, .bdrv_co_check =3D vmdk_co_check, .bdrv_reopen_prepare =3D vmdk_reopen_prepare, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_preadv =3D vmdk_co_preadv, .bdrv_co_pwritev =3D vmdk_co_pwritev, .bdrv_co_pwritev_compressed =3D vmdk_co_pwritev_compressed, diff --git a/block/vpc.c b/block/vpc.c index 651a6737b6..c055591641 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1240,7 +1240,7 @@ static BlockDriver bdrv_vpc =3D { .bdrv_open =3D vpc_open, .bdrv_close =3D vpc_close, .bdrv_reopen_prepare =3D vpc_reopen_prepare, - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, .bdrv_co_create =3D vpc_co_create, .bdrv_co_create_opts =3D vpc_co_create_opts, =20 diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 91567ca97d..0da5a3a6a1 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -93,15 +93,15 @@ static void bdrv_test_child_perm(BlockDriverState *bs, = BdrvChild *c, uint64_t *nperm, uint64_t *nshared) { /* - * bdrv_format_default_perms() accepts only these two, so disguise + * bdrv_default_perms() accepts only these two, so disguise * detach_by_driver_cb_parent as one of them. */ if (child_class !=3D &child_file && child_class !=3D &child_of_bds) { child_class =3D &child_of_bds; } =20 - bdrv_format_default_perms(bs, c, child_class, role, reopen_queue, - perm, shared, nperm, nshared); + bdrv_default_perms(bs, c, child_class, role, reopen_queue, + perm, shared, nperm, nshared); } =20 static int bdrv_test_change_backing_file(BlockDriverState *bs, @@ -1137,7 +1137,7 @@ static BlockDriver bdrv_test_top_driver =3D { .bdrv_close =3D bdrv_test_top_close, .bdrv_co_preadv =3D bdrv_test_top_co_preadv, =20 - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, }; =20 typedef struct TestCoDeleteByDrainData { @@ -1966,7 +1966,7 @@ static BlockDriver bdrv_replace_test =3D { .bdrv_co_drain_begin =3D bdrv_replace_test_co_drain_begin, .bdrv_co_drain_end =3D bdrv_replace_test_co_drain_end, =20 - .bdrv_child_perm =3D bdrv_format_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, }; =20 static void coroutine_fn test_replace_child_mid_drain_read_co(void *opaque) diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index 6ae91ff171..a2d0318b16 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -26,7 +26,7 @@ =20 static BlockDriver bdrv_pass_through =3D { .format_name =3D "pass-through", - .bdrv_child_perm =3D bdrv_filter_default_perms, + .bdrv_child_perm =3D bdrv_default_perms, }; =20 static void no_perm_default_perms(BlockDriverState *bs, BdrvChild *c, diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c index 71e9bce3b1..a953794be2 100644 --- a/tests/test-block-iothread.c +++ b/tests/test-block-iothread.c @@ -482,8 +482,13 @@ static void test_propagate_basic(void) BlockDriverState *bs_a, *bs_b, *bs_verify; QDict *options; =20 - /* Create bs_a and its BlockBackend */ - blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); + /* + * Create bs_a and its BlockBackend. We cannot take the RESIZE + * permission because blkverify will not share it on the test + * image. + */ + blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL & ~BLK_PERM_RESIZ= E, + BLK_PERM_ALL); bs_a =3D bdrv_new_open_driver(&bdrv_test, "bs_a", BDRV_O_RDWR, &error_= abort); blk_insert_bs(blk, bs_a, &error_abort); =20 @@ -566,7 +571,13 @@ static void test_propagate_diamond(void) qdict_put_str(options, "raw", "bs_c"); =20 bs_verify =3D bdrv_open(NULL, NULL, options, BDRV_O_RDWR, &error_abort= ); - blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); + /* + * Do not take the RESIZE permission: This would require the same + * from bs_c and thus from bs_a; however, blkverify will not share + * it on bs_b, and thus it will not be available for bs_a. + */ + blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL & ~BLK_PERM_RESIZ= E, + BLK_PERM_ALL); blk_insert_bs(blk, bs_verify, &error_abort); =20 /* Switch the AioContext */ --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548334; cv=none; d=zohomail.com; s=zohoarc; b=TLTYAxWBywlWgoiA5gkHS9549f4KgESYSwKK6f7wiPTXjopRAx/4OcKcGvQtPX5fF3BxnzI+keaLhLKvfw3/y68kRln11xp1BSD1juWkq0dAKqDZT4USkpjyxY3DDJcnNcHtuGqG2iqfgBkHWK+JEL0JO/TpNi8wTrEogUPuJKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548334; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LDGsnLDI8IaWcEnFssbldchDVX1hD20WpYF66NiSroU=; b=M2Rwf3IM3v8NY0XKZseEqRoqdfoAXHT60RjWF5kyai1oCZMzi7LICKQE+y/I4kIlzMdtvhoevyBR2JXf8aO5E+1EtmLQ9XmFQkXZZbFyrdW4ElRztrzfowLmMNx1/bxjxUI16NDot56gw72xEJdzNIM08Z02M7ctd2Z8+WZhlS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548334563934.1525462276564; Fri, 15 May 2020 06:12:14 -0700 (PDT) Received: from localhost ([::1]:36114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa8L-0001Gy-M5 for importer@patchew.org; Fri, 15 May 2020 09:12:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjX-0003kK-Ik for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26566 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjV-0002Rp-Bl for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-134-iBcRM3SeMNmpdgS9vEpcZA-1; Fri, 15 May 2020 08:46:30 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B194835B40; Fri, 15 May 2020 12:46:29 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8068B2E179; Fri, 15 May 2020 12:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LDGsnLDI8IaWcEnFssbldchDVX1hD20WpYF66NiSroU=; b=A771+96hoZDg16DDkTR4AofzsAJAKfixCSiAJjcUhtYQ+H2F5qhodGE0yJrBXwqY9d+D4O LyIyGAuGPer3lU8jiSzJl0wNKRlb6oJWtrIaYwmBdjDAgp3L/UXbhz7Zp3mukdn1qNEp3+ j92ZVBFxuWipdWi7nOh5H547eBSfeFA= X-MC-Unique: iBcRM3SeMNmpdgS9vEpcZA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 42/51] block: Make bdrv_filter_default_perms() static Date: Fri, 15 May 2020 14:45:12 +0200 Message-Id: <20200515124521.335403-43-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-31-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 10 ---------- block.c | 17 +++++++++++------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 0781d43af5..6fc5f0d333 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1262,16 +1262,6 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t p= erm, uint64_t shared, */ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **e= rrp); =20 -/* Default implementation for BlockDriver.bdrv_child_perm() that can be us= ed by - * block filters: Forward CONSISTENT_READ, WRITE, WRITE_UNCHANGED and RESI= ZE to - * all children */ -void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, - BdrvChildRole child_role, - BlockReopenQueue *reopen_queue, - uint64_t perm, uint64_t shared, - uint64_t *nperm, uint64_t *nshared); - /* Default implementation for BlockDriver.bdrv_child_perm() that can be us= ed by * (non-raw) image formats: Like above for bs->backing, but for bs->file it * requires WRITE | RESIZE for read-write images, always requires diff --git a/block.c b/block.c index fb94adcca4..54bc1c3b2d 100644 --- a/block.c +++ b/block.c @@ -2382,12 +2382,17 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, = BdrvChild *c, Error **errp) return bdrv_child_try_set_perm(c, perms, shared, errp); } =20 -void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, - BdrvChildRole role, - BlockReopenQueue *reopen_queue, - uint64_t perm, uint64_t shared, - uint64_t *nperm, uint64_t *nshared) +/* + * Default implementation for .bdrv_child_perm() for block filters: + * Forward CONSISTENT_READ, WRITE, WRITE_UNCHANGED, and RESIZE to the + * filtered child. + */ +static void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, + const BdrvChildClass *child_class, + BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) { *nperm =3D perm & DEFAULT_PERM_PASSTHROUGH; *nshared =3D (shared & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHAN= GED; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548672; cv=none; d=zohomail.com; s=zohoarc; b=hRPTOybVbjiIHvaIuQPMxfrPt5LsO/0cQRnVZqsN88J+5t8loqCC7He/cgo8YNgejtaajbdF1Oxs0lBzTclcYleifd7/AlOSZv5oVm7i7xA80PHiviMR4AlNpNO+eQZoclbT2kGMEo7QFkV7cEZozNoZlgLnWJyd7qa5P4VV0oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548672; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gwvoMeDp5/atI7Q3+wOTVC/LfaWZAnTD2JUMyjBjAaY=; b=XN5KSNgJcSUucCakwD7tr+V2iKfugq/fM1jaOjNSZ2U83S4MHZpiXWrRuiamhKe9nMPzuwTSYHbXhuFEjOIjD2fByanwszJxHEDNICRSkVHDIAUrEOl2sDifq0GHC93+DyYEAo26Qz1B6/E3gKeH1ECfsE9EoVezirHzZSpmNA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548672427692.3425805147524; Fri, 15 May 2020 06:17:52 -0700 (PDT) Received: from localhost ([::1]:56634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaDn-0003pX-2N for importer@patchew.org; Fri, 15 May 2020 09:17:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjb-0003oL-NB for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:39 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:55115 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjZ-0002T3-J1 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315-EDu2QyhfOnK0Ck91b1PZSA-1; Fri, 15 May 2020 08:46:31 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD3A0100CCC4; Fri, 15 May 2020 12:46:30 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id C52692E024; Fri, 15 May 2020 12:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gwvoMeDp5/atI7Q3+wOTVC/LfaWZAnTD2JUMyjBjAaY=; b=OeHQK9FmUblJAyHMOnFLS/P5Mpp9F/zBZJTu7N/aELD1v06WSr2pGYrNpvU2LiT01hTGt1 7ZuiKTRuOd6fiXRgoqEI4L1N/HRG6EodnyC8+NVFqwN1n/6qggCqT26MdhVEC0GigTrwuK hU9r1TOfG/MPpTHMPcbfafEe5ttMwgo= X-MC-Unique: EDu2QyhfOnK0Ck91b1PZSA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 43/51] block: Drop bdrv_format_default_perms() Date: Fri, 15 May 2020 14:45:13 +0200 Message-Id: <20200515124521.335403-44-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-Id: <20200513110544.176672-32-mreitz@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 11 ----------- block.c | 19 ------------------- 2 files changed, 30 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 6fc5f0d333..e791c40496 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1262,17 +1262,6 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t p= erm, uint64_t shared, */ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **e= rrp); =20 -/* Default implementation for BlockDriver.bdrv_child_perm() that can be us= ed by - * (non-raw) image formats: Like above for bs->backing, but for bs->file it - * requires WRITE | RESIZE for read-write images, always requires - * CONSISTENT_READ and doesn't share WRITE. */ -void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, - BdrvChildRole child_role, - BlockReopenQueue *reopen_queue, - uint64_t perm, uint64_t shared, - uint64_t *nperm, uint64_t *nshared); - bool bdrv_recurse_can_replace(BlockDriverState *bs, BlockDriverState *to_replace); =20 diff --git a/block.c b/block.c index 54bc1c3b2d..e79fe6e07e 100644 --- a/block.c +++ b/block.c @@ -2517,25 +2517,6 @@ static void bdrv_default_perms_for_storage(BlockDriv= erState *bs, BdrvChild *c, *nshared =3D shared; } =20 -void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, - BdrvChildRole role, - BlockReopenQueue *reopen_queue, - uint64_t perm, uint64_t shared, - uint64_t *nperm, uint64_t *nshared) -{ - if (child_class =3D=3D &child_of_bds) { - bdrv_default_perms(bs, c, child_class, role, reopen_queue, - perm, shared, nperm, nshared); - return; - } - - assert(child_class =3D=3D &child_file); - - bdrv_default_perms_for_storage(bs, c, child_class, role, reopen_queue, - perm, shared, nperm, nshared); -} - void bdrv_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildClass *child_class, BdrvChildRole r= ole, BlockReopenQueue *reopen_queue, --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548414; cv=none; d=zohomail.com; s=zohoarc; b=OvDA0x1zaqGpCJQlF4lYlEcMbh2vZEC8u7rptwg6O/5p0+Dha2Qq/7WpTIPbK9JjFVSuYo6wabyxwjGk9Qi5EEwkl6TPr/EzEfjX24zSypTA5B9SNnG9glr1YfBa2BWZjoRcj3+NRhQJFZ4Mpen646E6sS/7OFFGjRF5jRis5jM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548414; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IfX4VCGZDPU4PYs46rf6RBiW3prU7c4DsxlQ5f0f+rg=; b=I8JbeWIvUG6Lijnjq663FhU4Rb5VcvetyxmXz/STqQX3XVMNY9wXHmOy+1MzutehcmJ4lAHGPYpVxLN7kMasIx3oDiHxmaDbOAWL0d3nm4jbDrGlOw/Vh1QEkcypNrXYE6bu9QrazFr2SkqNJPysQfRPutCGgkuvkcpNio84Shk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15895484140771006.4738690336367; Fri, 15 May 2020 06:13:34 -0700 (PDT) Received: from localhost ([::1]:43358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZa9d-0004m2-1d for importer@patchew.org; Fri, 15 May 2020 09:13:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjZ-0003mb-Tz for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:37 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28512 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjY-0002Sn-1I for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-297-jO9RFfsPPZyEhqbM2sMTQg-1; Fri, 15 May 2020 08:46:33 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B1BF8014D7; Fri, 15 May 2020 12:46:32 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12B5A2E024; Fri, 15 May 2020 12:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IfX4VCGZDPU4PYs46rf6RBiW3prU7c4DsxlQ5f0f+rg=; b=UpN1er70rF01eKlcy/hoaGIXnZMAXtlEEAwi7BWgTDhxwYFytyJNfaMvBNViMeryBbA6wM eCzPmgP0dMVrlWxViQAqyqDV5stiFL27fk9DPRGRq2ECDXyj/p4mxr+CrKXT+Vq4O5P1T0 V0y0nsr+FWCBAsqORRM0ogYLZ1XFtiE= X-MC-Unique: jO9RFfsPPZyEhqbM2sMTQg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 44/51] block: Drop child_file Date: Fri, 15 May 2020 14:45:14 +0200 Message-Id: <20200515124521.335403-45-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-33-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 - block.c | 39 ++------------------------------------- tests/test-bdrv-drain.c | 8 +++----- 3 files changed, 5 insertions(+), 43 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index e791c40496..7fbe3206b4 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -741,7 +741,6 @@ struct BdrvChildClass { }; =20 extern const BdrvChildClass child_of_bds; -extern const BdrvChildClass child_file; =20 struct BdrvChild { BlockDriverState *bs; diff --git a/block.c b/block.c index e79fe6e07e..6a24b23d51 100644 --- a/block.c +++ b/block.c @@ -80,13 +80,6 @@ static BlockDriverState *bdrv_open_inherit(const char *f= ilename, BdrvChildRole child_role, Error **errp); =20 -/* TODO: Remove when no longer needed */ -static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_form= at, - int *child_flags, QDict *child_options, - int parent_flags, QDict *parent_options= ); -static void bdrv_child_cb_attach(BdrvChild *child); -static void bdrv_child_cb_detach(BdrvChild *child); - /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; =20 @@ -1145,33 +1138,6 @@ static void bdrv_temp_snapshot_options(int *child_fl= ags, QDict *child_options, *child_flags &=3D ~BDRV_O_NATIVE_AIO; } =20 -/* - * Returns the options and flags that bs->file should get if a protocol dr= iver - * is expected, based on the given options and flags for the parent BDS - */ -static void bdrv_protocol_options(BdrvChildRole role, bool parent_is_forma= t, - int *child_flags, QDict *child_options, - int parent_flags, QDict *parent_options) -{ - bdrv_inherited_options(BDRV_CHILD_IMAGE, true, - child_flags, child_options, - parent_flags, parent_options); -} - -const BdrvChildClass child_file =3D { - .parent_is_bds =3D true, - .get_parent_desc =3D bdrv_child_get_parent_desc, - .inherit_options =3D bdrv_protocol_options, - .drained_begin =3D bdrv_child_cb_drained_begin, - .drained_poll =3D bdrv_child_cb_drained_poll, - .drained_end =3D bdrv_child_cb_drained_end, - .attach =3D bdrv_child_cb_attach, - .detach =3D bdrv_child_cb_detach, - .inactivate =3D bdrv_child_cb_inactivate, - .can_set_aio_ctx =3D bdrv_child_cb_can_set_aio_ctx, - .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, -}; - static void bdrv_backing_attach(BdrvChild *c) { BlockDriverState *parent =3D c->opaque; @@ -2444,9 +2410,8 @@ static void bdrv_default_perms_for_storage(BlockDrive= rState *bs, BdrvChild *c, { int flags; =20 - assert(child_class =3D=3D &child_file || - (child_class =3D=3D &child_of_bds && - (role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA)))); + assert(child_class =3D=3D &child_of_bds && + (role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA))); =20 flags =3D bdrv_reopen_get_flags(reopen_queue, bs); =20 diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 0da5a3a6a1..655fd0d085 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -93,12 +93,10 @@ static void bdrv_test_child_perm(BlockDriverState *bs, = BdrvChild *c, uint64_t *nperm, uint64_t *nshared) { /* - * bdrv_default_perms() accepts only these two, so disguise - * detach_by_driver_cb_parent as one of them. + * bdrv_default_perms() accepts nothing else, so disguise + * detach_by_driver_cb_parent. */ - if (child_class !=3D &child_file && child_class !=3D &child_of_bds) { - child_class =3D &child_of_bds; - } + child_class =3D &child_of_bds; =20 bdrv_default_perms(bs, c, child_class, role, reopen_queue, perm, shared, nperm, nshared); --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548559; cv=none; d=zohomail.com; s=zohoarc; b=gcMr8mJ6Nf3/2I6M/SWCjZNIXHfZ9jqzQtUvOuMX/4TDcKG4pDCMqDAak008YB2GE/AnEQ7avQvRQlfT/2JXxRmDOnDpV6iGLvuHhQCqAe27D0wqh6XekrjHO5gEpRuRnf5JH7roKDYdWCdxfHyX6eMei2QHf089YWi8XOSTHHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548559; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S83isIXzSMWcUNUD+G6daMYXj8AGmtILAs7bhnHWgbc=; b=DZm8txFOL18EY4Zeh3LvbTHH2TT4wbjc0mT3rywWv1ljvySJ6ChAAKD99NsZm7Eib6/ByAKA6bbYG5xCpPKxuRoIGZ7ccMzqkvrFxkRgZqwQ+LxVyTfd8jQ8YcegUEw6U5SkqM+dN5F/Ok+jztYfQ/bVI+UaPOA1RUQnPSlBdWY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548559524155.61314869658452; Fri, 15 May 2020 06:15:59 -0700 (PDT) Received: from localhost ([::1]:50186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaBy-0000DA-PM for importer@patchew.org; Fri, 15 May 2020 09:15:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjb-0003oI-43 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:39 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22519 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjZ-0002TB-MF for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-zUHU1CN0PhCCu4J_xYJg3w-1; Fri, 15 May 2020 08:46:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EACF107ACF7; Fri, 15 May 2020 12:46:33 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5480D2E170; Fri, 15 May 2020 12:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S83isIXzSMWcUNUD+G6daMYXj8AGmtILAs7bhnHWgbc=; b=ie06BwTX5KCq0v2wBpRapkJrepUtRqPcCtXlkReYHo5Tbl5vxHBFFegzYuEx0gYgl5B2Ao iBGJqt4OSESLv6MKWn50fzcs8tXkXPwpcLe8lsb/9tqzsEjGyIEiLkaZ24IRyAtEUBQeWQ ap4ZqWrO2q0JpfkIQ7lUr/7GQopm1u8= X-MC-Unique: zUHU1CN0PhCCu4J_xYJg3w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 45/51] block: Pass BdrvChildRole in remaining cases Date: Fri, 15 May 2020 14:45:15 +0200 Message-Id: <20200515124521.335403-46-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz These calls have no real use for the child role yet, but it will not harm to give one. Notably, the bdrv_root_attach_child() call in blockjob.c is left unmodified because there is not much the generic BlockJob object wants from its children. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-34-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/block-backend.c | 11 +++++++---- block/vvfat.c | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index f2e81af27d..6936b25c83 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -424,8 +424,9 @@ BlockBackend *blk_new_open(const char *filename, const = char *reference, return NULL; } =20 - blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, 0, blk->= ctx, - perm, BLK_PERM_ALL, blk, errp); + blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, + BDRV_CHILD_FILTERED | BDRV_CHILD_PR= IMARY, + blk->ctx, perm, BLK_PERM_ALL, blk, = errp); if (!blk->root) { blk_unref(blk); return NULL; @@ -835,8 +836,10 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState = *bs, Error **errp) { ThrottleGroupMember *tgm =3D &blk->public.throttle_group_member; bdrv_ref(bs); - blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, 0, blk->= ctx, - blk->perm, blk->shared_perm, blk, e= rrp); + blk->root =3D bdrv_root_attach_child(bs, "root", &child_root, + BDRV_CHILD_FILTERED | BDRV_CHILD_PR= IMARY, + blk->ctx, blk->perm, blk->shared_pe= rm, + blk, errp); if (blk->root =3D=3D NULL) { return -EPERM; } diff --git a/block/vvfat.c b/block/vvfat.c index e8848a0497..089abe1e29 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3184,7 +3184,9 @@ static int enable_write_target(BlockDriverState *bs, = Error **errp) options =3D qdict_new(); qdict_put_str(options, "write-target.driver", "qcow"); s->qcow =3D bdrv_open_child(s->qcow_filename, options, "write-target",= bs, - &child_vvfat_qcow, 0, false, errp); + &child_vvfat_qcow, + BDRV_CHILD_DATA | BDRV_CHILD_METADATA, + false, errp); qobject_unref(options); if (!s->qcow) { ret =3D -EINVAL; --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548554; cv=none; d=zohomail.com; s=zohoarc; b=LF+ZO1S6IilF5zQokgpSvW+hUmB2MPQobHTqYi8Fnee6AAuraPW+pv735ZbMrY47kwj8aXhIanZevuhcOpRaKS7QkS4w4af/uM2x7HcqphQps/Yjjje4dCUEuTdGZjNHPAgTtnyH61RZlVdI7MjaZX0m//gn+gDC8kcW8u/fzV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548554; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h/fknbCpDX4Rqz976/8tznfqTx3nyWAzIGoSeF304Ek=; b=JliRZ6vtpZrJKGj94AS5Y7cxHnfZFIxQURET8gDMlXuJiUwn3xgnm2+xZhSvMLDak9/qJNJSLYyB/r89lbYD9I4hAzwo6ZnH//YjV6RQOHQWgiw1gxDbDo6+nt8xCAmmrB75nq5Uxpx6unCL7chMCPvaOR5tTuK9McgMhDBDMlY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548554591143.84653344497815; Fri, 15 May 2020 06:15:54 -0700 (PDT) Received: from localhost ([::1]:49802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaBt-0008V6-PO for importer@patchew.org; Fri, 15 May 2020 09:15:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjd-0003pC-EF for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:41 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22964 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZja-0002TU-IQ for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-_rM0k2jHOIyo2S3Ktw0L5A-1; Fri, 15 May 2020 08:46:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92D0A19200C0; Fri, 15 May 2020 12:46:34 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 998A42E024; Fri, 15 May 2020 12:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h/fknbCpDX4Rqz976/8tznfqTx3nyWAzIGoSeF304Ek=; b=aTfXzYqORgylU3WkWuvk1rgmqa9Kvb/ak7seOPG1oaEu7VWGnMrfZmm312Wz/K7jPUU2T3 Nxrpl/qaxhLm4Os21iVzirmODBB386r0copNeTgYdGTaiK2h2AcF9EF0x0P0XDy+trap2N Juz5pOeoVGUM8HLD7IsbJv1qu7p6xjk= X-MC-Unique: _rM0k2jHOIyo2S3Ktw0L5A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 46/51] block: Drop @child_class from bdrv_child_perm() Date: Fri, 15 May 2020 14:45:16 +0200 Message-Id: <20200515124521.335403-47-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Max Reitz Implementations should decide the necessary permissions based on @role. Signed-off-by: Max Reitz Message-Id: <20200513110544.176672-35-mreitz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/block/block_int.h | 4 +--- block.c | 39 +++++++++++++++---------------------- block/backup-top.c | 3 +-- block/blkdebug.c | 3 +-- block/blklogwrites.c | 3 +-- block/commit.c | 1 - block/copy-on-read.c | 1 - block/mirror.c | 1 - block/quorum.c | 1 - block/replication.c | 1 - block/vvfat.c | 4 +--- tests/test-bdrv-drain.c | 19 +----------------- tests/test-bdrv-graph-mod.c | 1 - 13 files changed, 22 insertions(+), 59 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 7fbe3206b4..5e4f4c348c 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -563,7 +563,6 @@ struct BlockDriver { * @reopen_queue. */ void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t parent_perm, uint64_t parent_shared, @@ -1270,8 +1269,7 @@ bool bdrv_recurse_can_replace(BlockDriverState *bs, * child_of_bds child class and set an appropriate BdrvChildRole. */ void bdrv_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole r= ole, - BlockReopenQueue *reopen_queue, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); =20 diff --git a/block.c b/block.c index 6a24b23d51..8416376c9b 100644 --- a/block.c +++ b/block.c @@ -1947,13 +1947,13 @@ bool bdrv_is_writable(BlockDriverState *bs) } =20 static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_= bs, - BdrvChild *c, const BdrvChildClass *child_clas= s, - BdrvChildRole role, BlockReopenQueue *reopen_q= ueue, + BdrvChild *c, BdrvChildRole role, + BlockReopenQueue *reopen_queue, uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared) { assert(bs->drv && bs->drv->bdrv_child_perm); - bs->drv->bdrv_child_perm(bs, c, child_class, role, reopen_queue, + bs->drv->bdrv_child_perm(bs, c, role, reopen_queue, parent_perm, parent_shared, nperm, nshared); /* TODO Take force_share from reopen_queue */ @@ -2047,7 +2047,7 @@ static int bdrv_check_perm(BlockDriverState *bs, Bloc= kReopenQueue *q, uint64_t cur_perm, cur_shared; bool child_tighten_restr; =20 - bdrv_child_perm(bs, c->bs, c, c->klass, c->role, q, + bdrv_child_perm(bs, c->bs, c, c->role, q, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); ret =3D bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_c= hildren, @@ -2114,7 +2114,7 @@ static void bdrv_set_perm(BlockDriverState *bs, uint6= 4_t cumulative_perms, /* Update all children */ QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; - bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL, + bdrv_child_perm(bs, c->bs, c, c->role, NULL, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); bdrv_child_set_perm(c, cur_perm, cur_shared); @@ -2342,7 +2342,7 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, Bd= rvChild *c, Error **errp) uint64_t perms, shared; =20 bdrv_get_cumulative_perm(bs, &parent_perms, &parent_shared); - bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL, + bdrv_child_perm(bs, c->bs, c, c->role, NULL, parent_perms, parent_shared, &perms, &shared); =20 return bdrv_child_try_set_perm(c, perms, shared, errp); @@ -2354,7 +2354,6 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, Bd= rvChild *c, Error **errp) * filtered child. */ static void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, @@ -2365,13 +2364,12 @@ static void bdrv_filter_default_perms(BlockDriverSt= ate *bs, BdrvChild *c, } =20 static void bdrv_default_perms_for_cow(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - assert(child_class =3D=3D &child_of_bds && (role & BDRV_CHILD_COW)); + assert(role & BDRV_CHILD_COW); =20 /* * We want consistent read from backing files if the parent needs it. @@ -2402,7 +2400,6 @@ static void bdrv_default_perms_for_cow(BlockDriverSta= te *bs, BdrvChild *c, } =20 static void bdrv_default_perms_for_storage(BlockDriverState *bs, BdrvChild= *c, - const BdrvChildClass *child_cla= ss, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, @@ -2410,8 +2407,7 @@ static void bdrv_default_perms_for_storage(BlockDrive= rState *bs, BdrvChild *c, { int flags; =20 - assert(child_class =3D=3D &child_of_bds && - (role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA))); + assert(role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA)); =20 flags =3D bdrv_reopen_get_flags(reopen_queue, bs); =20 @@ -2419,7 +2415,7 @@ static void bdrv_default_perms_for_storage(BlockDrive= rState *bs, BdrvChild *c, * Apart from the modifications below, the same permissions are * forwarded and left alone as for filters */ - bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, + bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, &perm, &shared); =20 if (role & BDRV_CHILD_METADATA) { @@ -2483,24 +2479,21 @@ static void bdrv_default_perms_for_storage(BlockDri= verState *bs, BdrvChild *c, } =20 void bdrv_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole r= ole, - BlockReopenQueue *reopen_queue, + BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - assert(child_class =3D=3D &child_of_bds); - if (role & BDRV_CHILD_FILTERED) { assert(!(role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA | BDRV_CHILD_COW))); - bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue, + bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); } else if (role & BDRV_CHILD_COW) { assert(!(role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA))); - bdrv_default_perms_for_cow(bs, c, child_class, role, reopen_queue, + bdrv_default_perms_for_cow(bs, c, role, reopen_queue, perm, shared, nperm, nshared); } else if (role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA)) { - bdrv_default_perms_for_storage(bs, c, child_class, role, reopen_qu= eue, + bdrv_default_perms_for_storage(bs, c, role, reopen_queue, perm, shared, nperm, nshared); } else { g_assert_not_reached(); @@ -2744,7 +2737,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent= _bs, bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm); =20 assert(parent_bs->drv); - bdrv_child_perm(parent_bs, child_bs, NULL, child_class, child_role, NU= LL, + bdrv_child_perm(parent_bs, child_bs, NULL, child_role, NULL, perm, shared_perm, &perm, &shared_perm); =20 child =3D bdrv_root_attach_child(child_bs, child_name, child_class, @@ -3807,7 +3800,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, = Error **errp) if (state->replace_backing_bs && state->new_backing_bs) { uint64_t nperm, nshared; bdrv_child_perm(state->bs, state->new_backing_bs, - NULL, &child_of_bds, bdrv_backing_role(state->= bs), + NULL, bdrv_backing_role(state->bs), bs_queue, state->perm, state->shared_perm, &nperm, &nshared); ret =3D bdrv_check_update_perm(state->new_backing_bs, NULL, @@ -3930,7 +3923,7 @@ static void bdrv_reopen_perm(BlockReopenQueue *q, Blo= ckDriverState *bs, } else { uint64_t nperm, nshared; =20 - bdrv_child_perm(parent->state.bs, bs, c, c->klass, c->role, q, + bdrv_child_perm(parent->state.bs, bs, c, c->role, q, parent->state.perm, parent->state.shared_perm, &nperm, &nshared); =20 diff --git a/block/backup-top.c b/block/backup-top.c index f0efec18b5..af2f20f346 100644 --- a/block/backup-top.c +++ b/block/backup-top.c @@ -122,7 +122,6 @@ static void backup_top_refresh_filename(BlockDriverStat= e *bs) } =20 static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, @@ -156,7 +155,7 @@ static void backup_top_child_perm(BlockDriverState *bs,= BdrvChild *c, *nperm =3D BLK_PERM_WRITE; } else { /* Source child */ - bdrv_default_perms(bs, c, child_class, role, reopen_queue, + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); =20 if (perm & BLK_PERM_WRITE) { diff --git a/block/blkdebug.c b/block/blkdebug.c index a925d8295e..7194bc7f06 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -995,7 +995,6 @@ static int blkdebug_reopen_prepare(BDRVReopenState *reo= pen_state, } =20 static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, @@ -1003,7 +1002,7 @@ static void blkdebug_child_perm(BlockDriverState *bs,= BdrvChild *c, { BDRVBlkdebugState *s =3D bs->opaque; =20 - bdrv_default_perms(bs, c, child_class, role, reopen_queue, + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); =20 *nperm |=3D s->take_child_perms; diff --git a/block/blklogwrites.c b/block/blklogwrites.c index 8684fb1c74..6753bd9a3e 100644 --- a/block/blklogwrites.c +++ b/block/blklogwrites.c @@ -283,7 +283,6 @@ static int64_t blk_log_writes_getlength(BlockDriverStat= e *bs) } =20 static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *ro_q, uint64_t perm, uint64_t shrd, @@ -295,7 +294,7 @@ static void blk_log_writes_child_perm(BlockDriverState = *bs, BdrvChild *c, return; } =20 - bdrv_default_perms(bs, c, child_class, role, ro_q, perm, shrd, + bdrv_default_perms(bs, c, role, ro_q, perm, shrd, nperm, nshrd); } =20 diff --git a/block/commit.c b/block/commit.c index 6af1c808bc..7732d02dfe 100644 --- a/block/commit.c +++ b/block/commit.c @@ -223,7 +223,6 @@ static void bdrv_commit_top_refresh_filename(BlockDrive= rState *bs) } =20 static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, diff --git a/block/copy-on-read.c b/block/copy-on-read.c index c857ea0da7..a6e3c74a68 100644 --- a/block/copy-on-read.c +++ b/block/copy-on-read.c @@ -52,7 +52,6 @@ static int cor_open(BlockDriverState *bs, QDict *options,= int flags, #define PERM_UNCHANGED (BLK_PERM_ALL & ~PERM_PASSTHROUGH) =20 static void cor_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, diff --git a/block/mirror.c b/block/mirror.c index cb4bdad32a..e8e8844afc 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1492,7 +1492,6 @@ static void bdrv_mirror_top_refresh_filename(BlockDri= verState *bs) } =20 static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, diff --git a/block/quorum.c b/block/quorum.c index 616ac3a927..7cf7ab1546 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1153,7 +1153,6 @@ static char *quorum_dirname(BlockDriverState *bs, Err= or **errp) } =20 static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, diff --git a/block/replication.c b/block/replication.c index cc9c473ad1..ccf7b78160 100644 --- a/block/replication.c +++ b/block/replication.c @@ -164,7 +164,6 @@ static void replication_close(BlockDriverState *bs) } =20 static void replication_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, diff --git a/block/vvfat.c b/block/vvfat.c index 089abe1e29..c65a98e3ee 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3213,7 +3213,6 @@ err: } =20 static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, @@ -3221,8 +3220,7 @@ static void vvfat_child_perm(BlockDriverState *bs, Bd= rvChild *c, { BDRVVVFATState *s =3D bs->opaque; =20 - assert(c =3D=3D s->qcow || - (child_class =3D=3D &child_of_bds && (role & BDRV_CHILD_COW))); + assert(c =3D=3D s->qcow || (role & BDRV_CHILD_COW)); =20 if (c =3D=3D s->qcow) { /* This is a private node, nobody should try to attach to it */ diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 655fd0d085..1107271840 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -85,23 +85,6 @@ static int coroutine_fn bdrv_test_co_preadv(BlockDriverS= tate *bs, return 0; } =20 -static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, - BdrvChildRole role, - BlockReopenQueue *reopen_queue, - uint64_t perm, uint64_t shared, - uint64_t *nperm, uint64_t *nshared) -{ - /* - * bdrv_default_perms() accepts nothing else, so disguise - * detach_by_driver_cb_parent. - */ - child_class =3D &child_of_bds; - - bdrv_default_perms(bs, c, child_class, role, reopen_queue, - perm, shared, nperm, nshared); -} - static int bdrv_test_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt) @@ -119,7 +102,7 @@ static BlockDriver bdrv_test =3D { .bdrv_co_drain_begin =3D bdrv_test_co_drain_begin, .bdrv_co_drain_end =3D bdrv_test_co_drain_end, =20 - .bdrv_child_perm =3D bdrv_test_child_perm, + .bdrv_child_perm =3D bdrv_default_perms, =20 .bdrv_change_backing_file =3D bdrv_test_change_backing_file, }; diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c index a2d0318b16..f93f3168b0 100644 --- a/tests/test-bdrv-graph-mod.c +++ b/tests/test-bdrv-graph-mod.c @@ -30,7 +30,6 @@ static BlockDriver bdrv_pass_through =3D { }; =20 static void no_perm_default_perms(BlockDriverState *bs, BdrvChild *c, - const BdrvChildClass *child_class, BdrvChildRole role, BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589547748; cv=none; d=zohomail.com; s=zohoarc; b=jTcZ0p8JJriZGyaS6sF/mydTEuf0HQ613sVxWtkzaUgxr+4IwrllOHZyeufjeZB7tPozRm5R0KhriS5E8CD5ueAbNtlmY6DfdS9beYhkzKvepNsk/ch84jbS+eNaSCymn1601BQ4rp2kZ8VvYY+jDCRCvMD/o0PtMfF4mvrxHVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589547748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KtpNI9TIpqyeC8eNPxlzs8E9Rtgz2FJ7kWU3lqald08=; b=ZLxLk2HsXzgjZ82k4ZTMAErtWBUpxcc4NhdoXfAofmQ8coTBT9iAyHibUTS3Fbe1J1lek/pnUpybcSzluCJ7T8zCIxdltMPjWtGxsNTyM2yhBjQbo65sNr+6h+JFXqhyIaW1k/AJNBo/K9G3Izrh7Ja5jPycZEnDYZyYvvkPxwg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589547748176394.0062325704206; Fri, 15 May 2020 06:02:28 -0700 (PDT) Received: from localhost ([::1]:50764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZZyt-00008y-8g for importer@patchew.org; Fri, 15 May 2020 09:02:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjd-0003pB-DB for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:41 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25300 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjb-0002Ty-LP for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-nMnhWcBuNjuiX8PLe-Zz-A-1; Fri, 15 May 2020 08:46:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6F138005AD; Fri, 15 May 2020 12:46:35 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCD662E166; Fri, 15 May 2020 12:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KtpNI9TIpqyeC8eNPxlzs8E9Rtgz2FJ7kWU3lqald08=; b=JZWEhborc3l6ModitRrTf5TZXd2VdB3krYHjwzbxE1jFvabxBOxc1w5+CBk4jLLzxPph5y wLu0XuQGVbwem2MSL/bNgfjmHHkOxZMMaj8Ttet8FpBwz4Op3wur+WpqKCVQVU9UFLA439 QPa16FLXNGkz8kp7QMn6sugY4DIwY9Y= X-MC-Unique: nMnhWcBuNjuiX8PLe-Zz-A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 47/51] block/block-copy: Fix uninitialized variable in block_copy_task_entry Date: Fri, 15 May 2020 14:45:17 +0200 Message-Id: <20200515124521.335403-48-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 Fix when building with -Os: CC block/block-copy.o block/block-copy.c: In function =E2=80=98block_copy_task_entry=E2=80=99: block/block-copy.c:428:38: error: =E2=80=98error_is_read=E2=80=99 may be = used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 428 | t->call_state->error_is_read =3D error_is_read; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200507121129.29760-2-philmd@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/block-copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/block-copy.c b/block/block-copy.c index 4713c8f2a3..7c7f7acbae 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -418,7 +418,7 @@ out: static coroutine_fn int block_copy_task_entry(AioTask *task) { BlockCopyTask *t =3D container_of(task, BlockCopyTask, task); - bool error_is_read; + bool error_is_read =3D false; int ret; =20 ret =3D block_copy_do_copy(t->s, t->offset, t->bytes, t->zeroes, --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548674; cv=none; d=zohomail.com; s=zohoarc; b=JHexRMtC9nFze/pDlqWYCPUgcjjb/F1/PVgEOutN+n/UiGcesNumdl8DOMYsC8+DBnuJuEmVidIYGVe8RrxJto1dhp8nTWuYm2QgdzHzoruZMwTcNr+XiWDgsg/ARRt8WrUiQdL+rzrDJpB1GPvHNb82nj8K7cOFjecIQsOM5uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548674; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IrAIxJcjh5A8J6Ib5EEpUk0UGIpNUfO0ZmICznK/aY8=; b=mAcmWOfkPULDHe8ptsFOsaPoFw1+u2LcK+VkhJOJglo8DA/bX3zueFy4eiQ9UcOkErt+psFnIJVktVuupyHWlkHns8PKJgpjKVoUCn84e0L+mVCa+ObO916QO9xMJtvoWq6i8WfmliVsvLHegaRV3XeXx6bGt2ifZ7YO4UpB/No= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548674460727.1968429969994; Fri, 15 May 2020 06:17:54 -0700 (PDT) Received: from localhost ([::1]:56852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaDp-0003un-9n for importer@patchew.org; Fri, 15 May 2020 09:17:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjf-0003qR-BY for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:43 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:46835 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjd-0002Uc-Jr for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-cDxvFGNsN7iIoRS3RfisCw-1; Fri, 15 May 2020 08:46:38 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 256DE474; Fri, 15 May 2020 12:46:37 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C2AB2E024; Fri, 15 May 2020 12:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IrAIxJcjh5A8J6Ib5EEpUk0UGIpNUfO0ZmICznK/aY8=; b=EAFzGzjpwLEvnpkgzw8Bq+OCt6YgeXnYWn3+//lsQyZar0GI61DA5643TUIkPVqR1bv3Mv 1sabmA5vQ5vQYSBtP7/VnGoKHWjgmNq7yi9ihYSDLnsXEk1CeC1Ed+4AP9lD5DAPq6yNBG ehsjk84gBsxkxuUiy29j4IH/JdUe9ik= X-MC-Unique: cDxvFGNsN7iIoRS3RfisCw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 48/51] block/block-copy: Simplify block_copy_do_copy() Date: Fri, 15 May 2020 14:45:18 +0200 Message-Id: <20200515124521.335403-49-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 block_copy_do_copy() is static, only used in block_copy_task_entry with the error_is_read argument set. No need to check for it, simplify. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200507121129.29760-3-philmd@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block/block-copy.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index 7c7f7acbae..bb8d0569f2 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -343,9 +343,7 @@ static int coroutine_fn block_copy_do_copy(BlockCopySta= te *s, ~BDRV_REQ_WRITE_COMPRESSED); if (ret < 0) { trace_block_copy_write_zeroes_fail(s, offset, ret); - if (error_is_read) { - *error_is_read =3D false; - } + *error_is_read =3D false; } return ret; } @@ -393,9 +391,7 @@ static int coroutine_fn block_copy_do_copy(BlockCopySta= te *s, ret =3D bdrv_co_pread(s->source, offset, nbytes, bounce_buffer, 0); if (ret < 0) { trace_block_copy_read_fail(s, offset, ret); - if (error_is_read) { - *error_is_read =3D true; - } + *error_is_read =3D true; goto out; } =20 @@ -403,9 +399,7 @@ static int coroutine_fn block_copy_do_copy(BlockCopySta= te *s, s->write_flags); if (ret < 0) { trace_block_copy_write_fail(s, offset, ret); - if (error_is_read) { - *error_is_read =3D false; - } + *error_is_read =3D false; goto out; } =20 --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548780; cv=none; d=zohomail.com; s=zohoarc; b=FnDyddVX3QTBXqad6iQpndlNhuXURjYlsJSHxhO/yFQSeoP+GPTqxyxuLffqk2UJpRZXY/cmkGiS8RKPINwZss6ScphyZwHyepyXu7jkChemyE7QSwJX33JnQmZdhpnNmdBx45jbyCGZMh+KH6t4KfQTfKavJbY/Lb/sKhTiw+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548780; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rYET/JmmLAnl/WTYWa1apJGjB/2lqVM4zBHV7dXbd7k=; b=XrWBOmebHMloEPzzqkJO1iNiQm8ZjiAqFk1Y4ThaQbbxkLKww7UwG1mAlndtXNJyFgBtUL+O9pROMCGDd0Wa9pqvEuPV/GoI3H5pmhqDpNi78YFOYz67eh/bSvRaviajBnT3b8cwJr3WfdJ2vc+mPy0ZvJgXg3ifOJIMEjKDuYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158954878050360.46125247618727; Fri, 15 May 2020 06:19:40 -0700 (PDT) Received: from localhost ([::1]:34724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaFX-0006PL-5Y for importer@patchew.org; Fri, 15 May 2020 09:19:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjg-0003rP-07 for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:44 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:26980 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjf-0002Un-2g for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-I3ZgNixwMP62oIOJbP119g-1; Fri, 15 May 2020 08:46:39 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65B5E835B40; Fri, 15 May 2020 12:46:38 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E1E52E024; Fri, 15 May 2020 12:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rYET/JmmLAnl/WTYWa1apJGjB/2lqVM4zBHV7dXbd7k=; b=YXfHxPme7g5ks6OfCR185kyj0n1xA+sGre/6Ceuyv0ZTeEK1gPcucFT9SjLxNGmkPg8ZQ9 Ogz4n4Uw8gxO0HeowE5IdsZOr5Fah85JNZ+H605dMYT+F/OrVbLbxiGE7amD+m+2TeDn95 VAhiGQjtxoZ+ZogUlreL0PjW/G1O9N8= X-MC-Unique: I3ZgNixwMP62oIOJbP119g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 49/51] iotests: log messages from notrun() Date: Fri, 15 May 2020 14:45:19 +0200 Message-Id: <20200515124521.335403-50-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 22:56:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: John Snow Shift the logging initialization up to occur prior to validation checks, so that notrun() messages still get printed to console. (Also, remove the "debugging messages active" message, because we don't need to see that hundreds of times per iotest suite run.) Signed-off-by: John Snow Message-Id: <20200514201614.19941-2-jsnow@redhat.com> Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1d7f6fd7cf..f20d90f969 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1168,18 +1168,17 @@ def execute_setup_common(supported_fmts: Sequence[s= tr] =3D (), sys.stderr.write('Please run this test via the "check" script\n') sys.exit(os.EX_USAGE) =20 + debug =3D '-d' in sys.argv + if debug: + sys.argv.remove('-d') + logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) + _verify_image_format(supported_fmts, unsupported_fmts) _verify_protocol(supported_protocols, unsupported_protocols) _verify_platform(supported=3Dsupported_platforms) _verify_cache_mode(supported_cache_modes) _verify_aio_mode(supported_aio_modes) =20 - debug =3D '-d' in sys.argv - if debug: - sys.argv.remove('-d') - logging.basicConfig(level=3D(logging.DEBUG if debug else logging.WARN)) - logger.debug("iotests debugging messages active") - return debug =20 def execute_test(*args, test_function=3DNone, **kwargs): --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548863; cv=none; d=zohomail.com; s=zohoarc; b=lU71Ps4wT6efafwrfzFEduaxfvQHyy14bAm6ZaDVzklMVUf6+0MtJdnfBpm7wUqmqMq/8fAm3R6OyF38fNsKNPmgPbrGXdtg4GabrdLqiNtE1zaZth+ku16TrLaM5f9Py9hctyfqVGMZVUx6ooyIQkyBIHH2qlsGJ8rxFg8mDBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548863; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=k9fpAZ9rPjUPAuSh1dQ8aQhXcuqg8rM81ibln037tcE=; b=Z4PE1zqpSpYYpEEEOTFxOwJFDTyjuRAvJRqnmxbJ6VoiXFQ5eLk7k0V4TZQH7ITzopw8cVvx9OMNnAGtiE1e8mO1GCWg6aOwU+ouL9DCvL9CIOIW9snexiZ2YclbKh8AJEuX+Wp945268FYvJCTm1w+Ki6YwQLsmCuCWk1rsapc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589548863007874.4120530812515; Fri, 15 May 2020 06:21:03 -0700 (PDT) Received: from localhost ([::1]:38110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaGr-0007zL-OW for importer@patchew.org; Fri, 15 May 2020 09:21:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZji-0003uN-MT for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30999 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjh-0002Vv-MQ for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-388-5I93L6TYPYiAlm9pND8fmA-1; Fri, 15 May 2020 08:46:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A859B107ACCD; Fri, 15 May 2020 12:46:39 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEF202E047; Fri, 15 May 2020 12:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k9fpAZ9rPjUPAuSh1dQ8aQhXcuqg8rM81ibln037tcE=; b=hHYZ11HbDaBwhJ6i12L4pMpCCldCehjj+n5nUKfAGOJUktALTiQy6BAk9dzJLsfL0pPQtR Ls8bBelw3Xodo/m+P1w3EAa/Z5Z3ewrOOsoqfDJAeu+QImOeCuJUdrRkSgSfus32jo4MwX sPUsm2No6MfSTOq06yhgPgFH26+x8wA= X-MC-Unique: 5I93L6TYPYiAlm9pND8fmA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 50/51] hw/ide/ahci: Log lost IRQs Date: Fri, 15 May 2020 14:45:20 +0200 Message-Id: <20200515124521.335403-51-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/14 23:27:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) From: Philippe Mathieu-Daud=C3=A9 One might find interesting to look at AHCI IRQs. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200504094858.5975-1-f4bug@amsat.org> Reviewed-by: John Snow Acked-by: John Snow Signed-off-by: Kevin Wolf --- hw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 13d91e109a..fc82cbd5f1 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1509,6 +1509,7 @@ static void ahci_cmd_done(IDEDMA *dma) =20 static void ahci_irq_set(void *opaque, int n, int level) { + qemu_log_mask(LOG_UNIMP, "ahci: IRQ#%d level:%d\n", n, level); } =20 static const IDEDMAOps ahci_dma_ops =3D { --=20 2.25.4 From nobody Thu May 16 03:21:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589548671; cv=none; d=zohomail.com; s=zohoarc; b=Ga746Y0gsHDekPm2Bv4NOBS6UPRgikM2zmRoZIv02xel/x8UqujXnwRgciH+fC3Dgs6f9HAonQGZbOwIzV3WDWU8zCCqxDdE+BAfQb2h7lmXQQy2jfG2lT+6+Hz/npJ1iDAqZ/1OtfQprRLH56pNS5zoLkddGn1SqzC3x6Kohno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589548671; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hwiHccn7lvl/1r6qMKiGeYIvBED9KWcgn7MSl576gJI=; b=VQIHL7s+E7JbKWECwbEIKKRsX8T9WcRo8sfX6lxBXW8IucVsG5T7zMgSm6Yard+haG1KxQEApHmR99jIwV5a2hFnIUNNfOP2a+P89rtvs0lBcOEE97wJieD2VJTUeBw9hGi6y0AwEPxHVxIt8JngB5YO8At5e9kyM98LPu/fTBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158954867171583.44486016680128; Fri, 15 May 2020 06:17:51 -0700 (PDT) Received: from localhost ([::1]:56664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZaDm-0003qC-4m for importer@patchew.org; Fri, 15 May 2020 09:17:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZZjh-0003uI-Se for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:48 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:44225 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jZZjh-0002Vg-1U for qemu-devel@nongnu.org; Fri, 15 May 2020 08:46:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-oheZTiRMO26wnlXoJ7fyCA-1; Fri, 15 May 2020 08:46:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB34F8005AD; Fri, 15 May 2020 12:46:40 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-110.ams2.redhat.com [10.36.113.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id F145A2E024; Fri, 15 May 2020 12:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589546804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hwiHccn7lvl/1r6qMKiGeYIvBED9KWcgn7MSl576gJI=; b=g/XuDCh0UeLmJRYNhwOHjmleUtprOwoz1JCX7Tbt70y1OdvDqs4VYzrJ9qpWtiapuqJBoX i66pp+7ZL75qCEjS2D2wCulbMB31DeVRNzkNA60/eeLftO4IhMnFeS2OI52mS8oJ4ne7pr 8M92H7nXWRJa6EPxNEvtP5wedud0j8M= X-MC-Unique: oheZTiRMO26wnlXoJ7fyCA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 51/51] iotests/030: Reduce run time by unthrottling job earlier Date: Fri, 15 May 2020 14:45:21 +0200 Message-Id: <20200515124521.335403-52-kwolf@redhat.com> In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com> References: <20200515124521.335403-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:39:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" test_overlapping_3() throttles its active commit job so it can be sure the job is still busy when it checks that you can't start a conflicting streaming job. However, it only sets the commit job back to full speed when it is ready, which takes a few seconds while it's throttled. We can already reset the limit after having checked that block-stream returns an error and save these seconds. Signed-off-by: Kevin Wolf Message-Id: <20200513100025.33543-1-kwolf@redhat.com> Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf --- tests/qemu-iotests/030 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 104e3cee1b..1cdd7e2999 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -354,14 +354,14 @@ class TestParallelOps(iotests.QMPTestCase): self.assert_qmp(result, 'error/desc', "Node 'node5' is busy: block device is in use by block job: co= mmit") =20 + result =3D self.vm.qmp('block-job-set-speed', device=3D'commit-dri= ve0', speed=3D0) + self.assert_qmp(result, 'return', {}) + event =3D self.vm.event_wait(name=3D'BLOCK_JOB_READY') self.assert_qmp(event, 'data/device', 'commit-drive0') self.assert_qmp(event, 'data/type', 'commit') self.assert_qmp_absent(event, 'data/error') =20 - result =3D self.vm.qmp('block-job-set-speed', device=3D'commit-dri= ve0', speed=3D0) - self.assert_qmp(result, 'return', {}) - result =3D self.vm.qmp('block-job-complete', device=3D'commit-driv= e0') self.assert_qmp(result, 'return', {}) =20 --=20 2.25.4