From nobody Tue Nov 18 21:13:48 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613053630; cv=none; d=zohomail.com; s=zohoarc; b=Qvdp0ONtuqixYKKr+AN5k24+xenT8+ywx7jCSceVlm639hpZISieh1YH4PN6lC1SSI5SU2RQYNSI10HYhTcahq0RdJ9BvRt0gGs30QhcuAZKruRaW5FNUlpnxrfSLeIOsQ728S0ZBGHz+stzCHx2D6POCxzA7HywyrksHYHUrQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613053630; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5a8SO4z5QCR5zPs+SXEld8SlB6+sW4d79/lzjI58Kxk=; b=Pn6QR0xvpfLdtufBr0JHMQAhyirxFQceK3fm1AptB2zfx5uDm3Supday847HJUHKbJwdCeSd/bf80t4KkF102PL1j3Wbm/AxvzdQcCiSfIQ++ZwY6Pmes/+fGhPghKBnsSK0u2KT8yq2rL3fLaEDJ7gwGA2sf1qhh2ycBFXJ5SA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613053629807187.27336887258537; Thu, 11 Feb 2021 06:27:09 -0800 (PST) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-169-PRnb0MYRM5auKZ3xBzElew-1; Thu, 11 Feb 2021 09:27:06 -0500 Received: by mail-ej1-f72.google.com with SMTP id yh28so4907368ejb.11 for ; Thu, 11 Feb 2021 06:27:06 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id x17sm4076779edd.76.2021.02.11.06.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 06:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613053628; 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=5a8SO4z5QCR5zPs+SXEld8SlB6+sW4d79/lzjI58Kxk=; b=I3vd+080xqEnFq189uUz9wE+gbcyTs13cWY+iphWN7/Rw5OgNok8X48YVqDiThbMoOp0W5 YWnN9O42GGIukA1CsYdRUj157NS8puj95o9WHzbFbm+sxLDx41J69oto2CqWiluu1Ka/nl SA/WXf8zvk2XfO7+6nouAtGpm3TfHxY= X-MC-Unique: PRnb0MYRM5auKZ3xBzElew-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5a8SO4z5QCR5zPs+SXEld8SlB6+sW4d79/lzjI58Kxk=; b=RXnmepSh8xMiUn8LYsLhChW56pDUgaOduK7TkDsx9Az9rVV6or+ei1lfiv5KhU7ccY +LL0qoYTL9iFdxzoZUCJ6bDA632x6iZLx/KwUVeBxJGVieoPSRkHf+huRoQ6r98rMSfm cs1EF30v9Dk1v9TC4vrRg80ZCeqiwNgCOb6zHJtcVXa4ZXhAVLIyI5IASC0LZIP3XEFI bgziOVPQmCK4qWZZ+Vi1k9n/dtFT1/s2VMikw4fSqw8E5JDF83vYKDS2BWE2c6d5PUun vREwtrZYc7Dp6+SxyWFmF+AlaTQO8iexm2E1mtcV6xp3OyIZtg1UG5eyMdQdsdYXPsc9 uo0A== X-Gm-Message-State: AOAM533lYJd1/brV4BRe4rk0c8216zEm6UDbEdie+4QfjCzC8GhfnImL erqnigOLvJeF3U9Bw4rV7Ycx4zqR7xYi8/aUpGTyvGcbKU52GHql5ckyLV7AvrB+ZbnlEWoroyh ZDF8idjcLpVQZSg== X-Received: by 2002:a17:907:210d:: with SMTP id qn13mr8544190ejb.377.1613053625165; Thu, 11 Feb 2021 06:27:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZU2ot3AcD7gHLiwFDkMAf84WtF46QmTQU+bz+iXbQb33ayh32gPqLMFHVE6nCdKCGtQ2HLw== X-Received: by 2002:a17:907:210d:: with SMTP id qn13mr8544165ejb.377.1613053624912; Thu, 11 Feb 2021 06:27:04 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Cleber Rosa , Thomas Huth , Fam Zheng , Paolo Bonzini , Laurent Vivier , Bandan Das , Markus Armbruster , qemu-block@nongnu.org, Max Reitz , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Kevin Wolf , Alexander Bulekov , Wainer dos Santos Moschetta Subject: [PATCH v2 1/2] block: Explicit null-co uses 'read-zeroes=false' Date: Thu, 11 Feb 2021 15:26:55 +0100 Message-Id: <20210211142656.3818078-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210211142656.3818078-1-philmd@redhat.com> References: <20210211142656.3818078-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We are going to switch the 'null-co' default 'read-zeroes' value from FALSE to TRUE in the next commit. First explicit the FALSE value when it is not set. Suggested-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Eric Blake --- - Missing: 056 & 155. I couldn't figure out the proper syntax, any help welcomed... - I'm unsure about 162, this doesn't seem to use the null-co driver but rather testing global syntax. --- docs/devel/testing.rst | 14 +++++++------- tests/qtest/fuzz/generic_fuzz_configs.h | 11 ++++++----- tests/test-bdrv-drain.c | 10 ++++++++-- tests/acceptance/virtio_check_params.py | 2 +- tests/perf/block/qcow2/convert-blockstatus | 6 +++--- tests/qemu-iotests/040 | 2 +- tests/qemu-iotests/041 | 12 ++++++++---- tests/qemu-iotests/051 | 2 +- tests/qemu-iotests/051.out | 2 +- tests/qemu-iotests/051.pc.out | 4 ++-- tests/qemu-iotests/087 | 6 ++++-- tests/qemu-iotests/118 | 2 +- tests/qemu-iotests/133 | 2 +- tests/qemu-iotests/153 | 8 ++++---- tests/qemu-iotests/184 | 2 ++ tests/qemu-iotests/184.out | 10 +++++----- tests/qemu-iotests/218 | 3 +++ tests/qemu-iotests/224 | 3 ++- tests/qemu-iotests/224.out | 8 ++++---- tests/qemu-iotests/225 | 2 +- tests/qemu-iotests/227 | 4 ++-- tests/qemu-iotests/227.out | 4 ++-- tests/qemu-iotests/228 | 2 +- tests/qemu-iotests/235 | 1 + tests/qemu-iotests/245 | 2 +- tests/qemu-iotests/270 | 2 +- tests/qemu-iotests/283 | 3 ++- tests/qemu-iotests/283.out | 4 ++-- tests/qemu-iotests/299 | 1 + tests/qemu-iotests/299.out | 2 +- tests/qemu-iotests/300 | 4 ++-- 31 files changed, 81 insertions(+), 59 deletions(-) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 209f9d8172f..45f1a674384 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -216,13 +216,13 @@ code. Both Python and Bash frameworks in iotests provide helpers to manage test images. They can be used to create and clean up images under the test directory. If no I/O or any protocol specific feature is needed, it is oft= en -more convenient to use the pseudo block driver, ``null-co://``, as the test -image, which doesn't require image creation or cleaning up. Avoid system-w= ide -devices or files whenever possible, such as ``/dev/null`` or ``/dev/zero``. -Otherwise, image locking implications have to be considered. For example, -another application on the host may have locked the file, possibly leading= to a -test failure. If using such devices are explicitly desired, consider addi= ng -``locking=3Doff`` option to disable image locking. +more convenient to use the pseudo block driver, ``null-co://,read-zeroes= =3Doff``, +as the test image, which doesn't require image creation or cleaning up. Av= oid +system-wide devices or files whenever possible, such as ``/dev/null`` or +``/dev/zero``. Otherwise, image locking implications have to be considered. +For example, another application on the host may have locked the file, pos= sibly +leading to a test failure. If using such devices are explicitly desired, +consider adding ``locking=3Doff`` option to disable image locking. =20 Test case groups ---------------- diff --git a/tests/qtest/fuzz/generic_fuzz_configs.h b/tests/qtest/fuzz/gen= eric_fuzz_configs.h index 5d599765c4b..dd5a7aeff0d 100644 --- a/tests/qtest/fuzz/generic_fuzz_configs.h +++ b/tests/qtest/fuzz/generic_fuzz_configs.h @@ -38,13 +38,13 @@ const generic_fuzz_config predefined_configs[] =3D { },{ .name =3D "virtio-blk", .args =3D "-machine q35 -device virtio-blk,drive=3Ddisk0 " - "-drive file=3Dnull-co://,id=3Ddisk0,if=3Dnone,format=3Draw", + "-drive file=3Dnull-co://,file.read-zeroes=3Doff,id=3Ddisk0,if=3Dn= one,format=3Draw", .objects =3D "virtio*", },{ .name =3D "virtio-scsi", .args =3D "-machine q35 -device virtio-scsi,num_queues=3D8 " "-device scsi-hd,drive=3Ddisk0 " - "-drive file=3Dnull-co://,id=3Ddisk0,if=3Dnone,format=3Draw", + "-drive file=3Dnull-co://,file.read-zeroes=3Doff,id=3Ddisk0,if=3Dn= one,format=3Draw", .objects =3D "scsi* virtio*", },{ .name =3D "virtio-gpu", @@ -119,7 +119,7 @@ const generic_fuzz_config predefined_configs[] =3D { },{ .name =3D "ahci-hd", .args =3D "-machine q35 -nodefaults " - "-drive file=3Dnull-co://,if=3Dnone,format=3Draw,id=3Ddisk0 " + "-drive file=3Dnull-co://,file.read-zeroes=3Doff,if=3Dnone,format= =3Draw,id=3Ddisk0 " "-device ide-hd,drive=3Ddisk0", .objects =3D "*ahci*", },{ @@ -137,7 +137,7 @@ const generic_fuzz_config predefined_configs[] =3D { },{ .name =3D "xhci", .args =3D "-machine q35 -nodefaults " - "-drive file=3Dnull-co://,if=3Dnone,format=3Draw,id=3Ddisk0 " + "-drive file=3Dnull-co://,file.read-zeroes=3Doff,if=3Dnone,format= =3Draw,id=3Ddisk0 " "-device qemu-xhci,id=3Dxhci -device usb-tablet,bus=3Dxhci.0 " "-device usb-bot -device usb-storage,drive=3Ddisk0 " "-chardev null,id=3Dcd0 -chardev null,id=3Dcd1 " @@ -182,7 +182,8 @@ const generic_fuzz_config predefined_configs[] =3D { .name =3D "sdhci-v3", .args =3D "-nodefaults -device sdhci-pci,sd-spec-version=3D3 " "-device sd-card,drive=3Dmydrive " - "-drive if=3Dsd,index=3D0,file=3Dnull-co://,format=3Draw,id=3Dmydr= ive -nographic", + "-drive if=3Dsd,index=3D0,file=3Dnull-co://,file.read-zeroes=3Doff= ," + "format=3Draw,id=3Dmydrive -nographic", .objects =3D "sd*" },{ .name =3D "ehci", diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c index 8a29e33e004..a3e7d872d88 100644 --- a/tests/test-bdrv-drain.c +++ b/tests/test-bdrv-drain.c @@ -27,6 +27,7 @@ #include "block/blockjob_int.h" #include "sysemu/block-backend.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" #include "qemu/main-loop.h" #include "iothread.h" =20 @@ -1177,13 +1178,16 @@ static void do_test_delete_by_drain(bool detach_ins= tead_of_delete, BDRVTestTopState *tts; TestCoDeleteByDrainData dbdd; Coroutine *co; + QDict *opt; =20 bs =3D bdrv_new_open_driver(&bdrv_test_top_driver, "top", BDRV_O_RDWR, &error_abort); bs->total_sectors =3D 65536 >> BDRV_SECTOR_BITS; tts =3D bs->opaque; =20 - null_bs =3D bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_P= ROTOCOL, + opt =3D qdict_new(); + qdict_put_str(opt, "read-zeroes", "off"); + null_bs =3D bdrv_open("null-co://", NULL, opt, BDRV_O_RDWR | BDRV_O_PR= OTOCOL, &error_abort); bdrv_attach_child(bs, null_bs, "null-child", &child_of_bds, BDRV_CHILD_DATA, &error_abort); @@ -1201,7 +1205,9 @@ static void do_test_delete_by_drain(bool detach_inste= ad_of_delete, =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, + opt =3D qdict_new(); + qdict_put_str(opt, "read-zeroes", "off"); + null_bs =3D bdrv_open("null-co://", NULL, opt, BDRV_O_RDWR | BDRV_O_PR= OTOCOL, &error_abort); bdrv_attach_child(bs, null_bs, "null-child", &child_of_bds, BDRV_CHILD= _DATA, &error_abort); diff --git a/tests/acceptance/virtio_check_params.py b/tests/acceptance/vir= tio_check_params.py index 87e6c839d14..dee386d26f4 100644 --- a/tests/acceptance/virtio_check_params.py +++ b/tests/acceptance/virtio_check_params.py @@ -38,7 +38,7 @@ 'virtio-blk-pci': ['-device', 'virtio-blk-pci,id=3Dscsi0,drive=3Ddri= ve0', '-drive', - 'driver=3Dnull-co,id=3Ddrive0,if=3Dnon= e']} + 'driver=3Dnull-co,read-zeroes=3Doff,id= =3Ddrive0,if=3Dnone']} =20 =20 class VirtioMaxSegSettingsCheck(Test): diff --git a/tests/perf/block/qcow2/convert-blockstatus b/tests/perf/block/= qcow2/convert-blockstatus index a1a3c1ef438..c7449eb2c38 100755 --- a/tests/perf/block/qcow2/convert-blockstatus +++ b/tests/perf/block/qcow2/convert-blockstatus @@ -46,7 +46,7 @@ done | $QEMU_IO "$src" ) > /dev/null =20 echo -n "plain: " -/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co:// +/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://,read-zeroes=3Do= ff =20 # test-case forward =20 @@ -61,11 +61,11 @@ done | $QEMU_IO "$src" ) > /dev/null =20 echo -n "forward: " -/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co:// +/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://,read-zeroes=3Do= ff =20 # test-case prealloc =20 $QEMU_IMG create -f qcow2 -o preallocation=3Dmetadata "$src" $size > /dev/= null =20 echo -n "prealloc: " -/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co:// +/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://,read-zeroes=3Do= ff diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 7ebc9ed8257..3abc653e599 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -220,7 +220,7 @@ class TestSingleDrive(ImageCommitTestCase): def test_top_node_in_wrong_chain(self): self.assert_no_active_block_jobs() =20 - result =3D self.vm.qmp('blockdev-add', driver=3D'null-co', node_na= me=3D'null') + result =3D self.vm.qmp('blockdev-add', driver=3D'null-co', read_ze= roes=3DFalse, node_name=3D'null') self.assert_qmp(result, 'return', {}) =20 result =3D self.vm.qmp('block-commit', device=3D'drive0', top_node= =3D'null', base_node=3D'base') diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 5cc02b24fc7..74d2bec02a8 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -1159,13 +1159,16 @@ class TestRepairQuorum(iotests.QMPTestCase): class TestOrphanedSource(iotests.QMPTestCase): def setUp(self): blk0 =3D { 'node-name': 'src', - 'driver': 'null-co' } + 'driver': 'null-co', + 'read-zeroes': 'off' } =20 blk1 =3D { 'node-name': 'dest', - 'driver': 'null-co' } + 'driver': 'null-co', + 'read-zeroes': 'off' } =20 blk2 =3D { 'node-name': 'dest-ro', 'driver': 'null-co', + 'read-zeroes': 'off', 'read-only': 'on' } =20 self.vm =3D iotests.VM() @@ -1272,14 +1275,15 @@ class TestReplaces(iotests.QMPTestCase): 'driver': 'copy-on-read', 'node-name': 'filter1', 'file': { - 'driver': 'null-co' + 'driver': 'null-co', + 'read-zeroes': False, } } }) self.assert_qmp(result, 'return', {}) =20 result =3D self.vm.qmp('blockdev-add', - node_name=3D'target', driver=3D'null-co') + node_name=3D'target', driver=3D'null-co', rea= d_zeroes=3DFalse) self.assert_qmp(result, 'return', {}) =20 result =3D self.vm.qmp('blockdev-mirror', job_id=3D'mirror', devic= e=3D'filter0', diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 index 7cbd1415ce7..42e69054f9f 100755 --- a/tests/qemu-iotests/051 +++ b/tests/qemu-iotests/051 @@ -384,7 +384,7 @@ if [ "${VALGRIND_QEMU_VM}" =3D=3D "y" ]; then _casenotrun "Valgrind needs a valid TMPDIR for itself" fi VALGRIND_QEMU_VM=3D \ -TMPDIR=3D/nonexistent run_qemu -drive driver=3Dnull-co,snapshot=3Don +TMPDIR=3D/nonexistent run_qemu -drive driver=3Dnull-co,read-zeroes=3Doff,s= napshot=3Don =20 # Using snapshot=3Don together with read-only=3Don echo "info block" | diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out index de4771bcb36..a4bf0cc4401 100644 --- a/tests/qemu-iotests/051.out +++ b/tests/qemu-iotests/051.out @@ -459,7 +459,7 @@ wrote 4096/4096 bytes at offset 0 read 4096/4096 bytes at offset 0 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Testing: -drive driver=3Dnull-co,snapshot=3Don -QEMU_PROG: -drive driver=3Dnull-co,snapshot=3Don: Could not get temporary = filename: No such file or directory +QEMU_PROG: -drive driver=3Dnull-co,read-zeroes=3Doff,snapshot=3Don: Could = not get temporary filename: No such file or directory =20 Testing: -drive file=3DTEST_DIR/t.qcow2,snapshot=3Don,read-only=3Don,if=3D= none,id=3Ddrive0 QEMU X.Y.Z monitor - type 'help' for more information diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out index f707471fb00..12275015eaf 100644 --- a/tests/qemu-iotests/051.pc.out +++ b/tests/qemu-iotests/051.pc.out @@ -558,8 +558,8 @@ wrote 4096/4096 bytes at offset 0 =20 read 4096/4096 bytes at offset 0 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Testing: -drive driver=3Dnull-co,snapshot=3Don -QEMU_PROG: -drive driver=3Dnull-co,snapshot=3Don: Could not get temporary = filename: No such file or directory +Testing: -drive driver=3Dnull-co,read-zeroes=3Doff,snapshot=3Don +QEMU_PROG: -drive driver=3Dnull-co,read-zeroes=3Doff,snapshot=3Don: Could = not get temporary filename: No such file or directory =20 Testing: -drive file=3DTEST_DIR/t.qcow2,snapshot=3Don,read-only=3Don,if=3D= none,id=3Ddrive0 QEMU X.Y.Z monitor - type 'help' for more information diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index edd43f1a281..93549524277 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -89,7 +89,8 @@ run_qemu -drive driver=3D$IMGFMT,id=3Ddisk,node-name=3Dte= st-node,file=3D"$TEST_IMG" < None: self.vm_a =3D iotests.VM(path_suffix=3D'-a') self.vm_a.add_blockdev(f'node-name=3D{self.src_node_name},' - 'driver=3Dnull-co') + 'driver=3Dnull-co,read-zeroes=3Doff') self.vm_a.launch() =20 self.vm_b =3D iotests.VM(path_suffix=3D'-b') self.vm_b.add_blockdev(f'node-name=3D{self.dst_node_name},' - 'driver=3Dnull-co') + 'driver=3Dnull-co,read-zeroes=3Doff') self.vm_b.add_incoming(f'unix:{mig_sock}') self.vm_b.launch() =20 --=20 2.26.2 From nobody Tue Nov 18 21:13:48 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613053634; cv=none; d=zohomail.com; s=zohoarc; b=dE8nbweoFq78CAdVDLesaCbtKIzcedrjY/JQThunOXwXdXiK55Zh6jyjDde3MPvl8HYeg7SzqF9Vib9/6A5hC6YmvnUoOWy3oibvN7dd5sn+ez3rkhgve1CMho/0zkvxKPuj/srXt4wkYXQLxLp91z4wOEObG2j8Nx4ysWPylMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613053634; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=D4Z11FEsaA36rEKX69D+N+Q14103WaLLz/9eqppF61E=; b=L07d1oh/CoMGlNt7p428cfJ35GKQjTJU3Ckd8Ryo5i/6xykeJzPLDZzghrmTimrkFjwJKgoc7JqAEMO9UCS8CX1anNAdrlYF2OfdyzoVHQ5eOryJk9+cIKENLNrGqzALIejSX54ZnSxiwseYKI2tIHKj49bEpHQaJ7/ZXz7VYuQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613053634288608.3945731740694; Thu, 11 Feb 2021 06:27:14 -0800 (PST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-NkLvrEDJNvGLoA6LMxT7Sg-1; Thu, 11 Feb 2021 09:27:11 -0500 Received: by mail-ej1-f70.google.com with SMTP id jz15so4929117ejc.12 for ; Thu, 11 Feb 2021 06:27:11 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id a1sm4200072edj.6.2021.02.11.06.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 06:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613053633; 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=D4Z11FEsaA36rEKX69D+N+Q14103WaLLz/9eqppF61E=; b=A6DZUW7HbhhEMmZtQRkOdy9WgbmsMGHn6byvhCTiY69gf+sRIdJz/M/miTpK0spZYtkedf qylGUyucFZpjhkLVo8At3CSpVBNKuqPjuP+W7U9tY3wx+KjpZbKTu9sJUtTaUZr5316Dae 6m7OrRdSvjwP/ji0b9nC60aDvQDkdbU= X-MC-Unique: NkLvrEDJNvGLoA6LMxT7Sg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D4Z11FEsaA36rEKX69D+N+Q14103WaLLz/9eqppF61E=; b=qgAWHZJITEc4QWF8O+Y2YdLDTkAL5dsYyxsvHEbPHgun4lLzfZuPgVa+hwfxejf+34 TtxbfSElL/OB1rdVbkR6oKGbRiYFd/SLChZ0W87fSTQ2hTX3ktSQaDQi6x8pAec8IFwg m72Xqxmxc/NHVVugxv4scUu+vpGAlr0bzgdWKRXNPeESnzrayOBT307Oee+i6KKuxiWX w1TQXjdsfkc7T7/aFVbwvR48j+zx4owBXliR1Gqh9r7UHZ5ebBeZzC4+j3D9YOu5IgxD FXSbNOSAWvrhEwK2+txz1+cfMVurQWqjonLUz4ow0QXl3PGqqvsV4CdUwIkDDysecWzv WcIQ== X-Gm-Message-State: AOAM530uFBps7efFxQI0eIhEOZGCEcvEwPZ6+71KEprr1JBWSpo8OXQa H9FigIPrPiR5Z8RkrJ+1gdYIJbACz7Xg+jSe6fz0+tiDaH48COHJeF4S+DgLMMua2RVa2xymW/M YAPHuk/AMru9d1g== X-Received: by 2002:a17:906:408b:: with SMTP id u11mr8523580ejj.299.1613053630416; Thu, 11 Feb 2021 06:27:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxTsxge7qfxvilOLXgRfz6yd/hySRzdzhsu+1Qs/hC1oL61bxA20D36PYGirQR8/XKsUlc6w== X-Received: by 2002:a17:906:408b:: with SMTP id u11mr8523565ejj.299.1613053630258; Thu, 11 Feb 2021 06:27:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Cleber Rosa , Thomas Huth , Fam Zheng , Paolo Bonzini , Laurent Vivier , Bandan Das , Markus Armbruster , qemu-block@nongnu.org, Max Reitz , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Kevin Wolf , Alexander Bulekov , Wainer dos Santos Moschetta Subject: [PATCH v2 2/2] block/null: Enable 'read-zeroes' mode by default Date: Thu, 11 Feb 2021 15:26:56 +0100 Message-Id: <20210211142656.3818078-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210211142656.3818078-1-philmd@redhat.com> References: <20210211142656.3818078-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The null-co driver is meant for (performance) testing. By default, read operation does nothing, the provided buffer is not filled with zero values and its content is unchanged. This performance 'feature' becomes an issue from a security perspective. For example, using the default null-co driver, buf[] is uninitialized, the blk_pread() call succeeds and we then access uninitialized memory: static int guess_disk_lchs(BlockBackend *blk, int *pcylinders, int *pheads, int *psectors) { uint8_t buf[BDRV_SECTOR_SIZE]; ... if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { return -1; } /* test msdos magic */ if (buf[510] !=3D 0x55 || buf[511] !=3D 0xaa) { return -1; } We could audit all the uninitialized buffers and the bdrv_co_preadv() handlers, but it is simpler to change the default of this testing driver. Performance tests will have to adapt and use 'null-co,read-zeroes=3Doff'. Suggested-by: Max Reitz Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/null.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/null.c b/block/null.c index cc9b1d4ea72..f9658fd70ac 100644 --- a/block/null.c +++ b/block/null.c @@ -93,7 +93,7 @@ static int null_file_open(BlockDriverState *bs, QDict *op= tions, int flags, error_setg(errp, "latency-ns is invalid"); ret =3D -EINVAL; } - s->read_zeroes =3D qemu_opt_get_bool(opts, NULL_OPT_ZEROES, false); + s->read_zeroes =3D qemu_opt_get_bool(opts, NULL_OPT_ZEROES, true); qemu_opts_del(opts); bs->supported_write_flags =3D BDRV_REQ_FUA; return ret; --=20 2.26.2