From nobody Tue Nov 11 15:58:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1564404472; cv=none; d=zoho.com; s=zohoarc; b=YNStwA3YFOA6K3RYCz7+VTmYmiIlk/CRigwBjUOwK+CvEcfT/Tn70RpAOiS/UE7IuWt2SXtf3XJhpKZ0QzwCEZV7KT9G5KykmBviTbXY7KLHuMnJLsPE0u8hBO957e/DctKuHgofPuCcMHsCTM3dA3ekDi/TNNVDtFj9lYJC2gM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564404472; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=TYg5ZrtURarnGUXUOOEb9HkOspAVEjH2Orvq4VIyOnM=; b=HQmjU/4Zm7PpaHuaKq+4fjdhdNZnVN46xqN2nbZXGVwg/SqiMp0BltVVX85dX+6kBJPHHanr6txRgp/w1F54EGbiGEo9uncz5ofEZxoDgqke+iT7emvnxR007WqL3UE0CHPJOHZhsizgdhBawVoixOmXE8ZQyj9StN0roYLC6qw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564404472027894.9979331472719; Mon, 29 Jul 2019 05:47:52 -0700 (PDT) Received: from localhost ([::1]:51874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs545-00080d-QG for importer@patchew.org; Mon, 29 Jul 2019 08:47:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36261) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs52j-0007WF-CK for qemu-devel@nongnu.org; Mon, 29 Jul 2019 08:46:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hs52h-0004ST-QF for qemu-devel@nongnu.org; Mon, 29 Jul 2019 08:46:21 -0400 Received: from relay.sw.ru ([185.231.240.75]:56098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hs52h-0004OJ-JE; Mon, 29 Jul 2019 08:46:19 -0400 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hs52Z-0001Ai-5P; Mon, 29 Jul 2019 15:46:11 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 29 Jul 2019 15:46:00 +0300 Message-Id: <1564404360-733987-1-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH] tests: Set read-zeroes on for null-co driver 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, lvivier@redhat.com, thuth@redhat.com, vsementsov@virtuozzo.com, hare@suse.com, armbru@redhat.com, keith.busch@intel.com, andrey.shinkevich@virtuozzo.com, kraxel@redhat.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, fam@euphon.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is to reduce the number of Valgrind report messages about using uninitialized memory with the null-co driver. It helps to filter real memory issues and is the same work done for the iotests with the commit ID a6862418fec4072. Suggested-by: Kevin Wolf Signed-off-by: Andrey Shinkevich Acked-by: Thomas Huth --- tests/drive_del-test.c | 3 ++- tests/libqos/virtio-scsi.c | 3 ++- tests/megasas-test.c | 3 ++- tests/nvme-test.c | 3 ++- tests/qmp-test.c | 2 +- tests/test-blockjob-txn.c | 5 ++++- tests/test-blockjob.c | 5 ++++- tests/usb-hcd-uhci-test.c | 3 ++- tests/usb-hcd-xhci-test.c | 3 ++- tests/virtio-blk-test.c | 6 ++++-- tests/virtio-ccw-test.c | 9 ++++++--- tests/virtio-scsi-test.c | 6 ++++-- 12 files changed, 35 insertions(+), 16 deletions(-) diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index b56b223..5f8839b 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -121,7 +121,8 @@ static void test_drive_del_device_del(void) QTestState *qts; =20 /* Start with a drive used by a device that unplugs instantaneously */ - qts =3D qtest_initf("-drive if=3Dnone,id=3Ddrive0,file=3Dnull-co://,fo= rmat=3Draw" + qts =3D qtest_initf("-drive if=3Dnone,id=3Ddrive0,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw" " -device virtio-scsi-%s" " -device scsi-hd,drive=3Ddrive0,id=3Ddev0", qvirtio_get_dev_type()); diff --git a/tests/libqos/virtio-scsi.c b/tests/libqos/virtio-scsi.c index 94842ec..de739be 100644 --- a/tests/libqos/virtio-scsi.c +++ b/tests/libqos/virtio-scsi.c @@ -95,7 +95,8 @@ static void virtio_scsi_register_nodes(void) }; =20 QOSGraphEdgeOptions opts =3D { - .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ,format=3Draw", + .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw", .after_cmd_line =3D "-device scsi-hd,bus=3Dvs0.0,drive=3Ddrv0", }; =20 diff --git a/tests/megasas-test.c b/tests/megasas-test.c index c3e4ab6..d6796b9 100644 --- a/tests/megasas-test.c +++ b/tests/megasas-test.c @@ -75,7 +75,8 @@ static void megasas_register_nodes(void) { QOSGraphEdgeOptions opts =3D { .extra_device_opts =3D "addr=3D04.0,id=3Dscsi0", - .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ,format=3Draw", + .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw", .after_cmd_line =3D "-device scsi-hd,bus=3Dscsi0.0,drive=3Ddrv0", }; =20 diff --git a/tests/nvme-test.c b/tests/nvme-test.c index 5052993..ff04421 100644 --- a/tests/nvme-test.c +++ b/tests/nvme-test.c @@ -70,7 +70,8 @@ static void nvme_register_nodes(void) { QOSGraphEdgeOptions opts =3D { .extra_device_opts =3D "addr=3D04.0,drive=3Ddrv0,serial=3Dfoo", - .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ,format=3Draw", + .before_cmd_line =3D "-drive id=3Ddrv0,if=3Dnone,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw", }; =20 add_qpci_address(&opts, &(QPCIAddress) { .devfn =3D QPCI_DEVFN(4, 0) }= ); diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 48a4fa7..1b0eb69 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -187,7 +187,7 @@ static void send_cmd_that_blocks(QTestState *s, const c= har *id) " 'arguments': {" " 'driver': 'blkdebug', 'node-name': %s," " 'config': %s," - " 'image': { 'driver': 'null-co' } } }", + " 'image': { 'driver': 'null-co', 'read-zeroes': true }= } }", id, id, fifo_name); } =20 diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index 86606f9..7da9216 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -15,6 +15,7 @@ #include "qemu/main-loop.h" #include "block/blockjob_int.h" #include "sysemu/block-backend.h" +#include "qapi/qmp/qdict.h" =20 typedef struct { BlockJob common; @@ -96,7 +97,9 @@ static BlockJob *test_block_job_start(unsigned int iterat= ions, =20 data =3D g_new0(TestBlockJobCBData, 1); =20 - bs =3D bdrv_open("null-co://", NULL, NULL, 0, &error_abort); + QDict *opt =3D qdict_new(); + qdict_put_str(opt, "file.read-zeroes", "on"); + bs =3D bdrv_open("null-co://", NULL, opt, 0, &error_abort); g_assert_nonnull(bs); =20 snprintf(job_id, sizeof(job_id), "job%u", counter++); diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index b33f899..68a0819 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -15,6 +15,7 @@ #include "qemu/main-loop.h" #include "block/blockjob_int.h" #include "sysemu/block-backend.h" +#include "qapi/qmp/qdict.h" =20 static const BlockJobDriver test_block_job_driver =3D { .job_driver =3D { @@ -71,7 +72,9 @@ static BlockBackend *create_blk(const char *name) BlockBackend *blk =3D blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL); BlockDriverState *bs; =20 - bs =3D bdrv_open("null-co://", NULL, NULL, 0, &error_abort); + QDict *opt =3D qdict_new(); + qdict_put_str(opt, "file.read-zeroes", "on"); + bs =3D bdrv_open("null-co://", NULL, opt, 0, &error_abort); g_assert_nonnull(bs); =20 blk_insert_bs(blk, bs, &error_abort); diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index a119d6d..6d355c2 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -57,7 +57,8 @@ int main(int argc, char **argv) { const char *arch =3D qtest_get_arch(); const char *cmd =3D "-device piix3-usb-uhci,id=3Duhci,addr=3D1d.0" - " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://,for= mat=3Draw" + " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw" " -device usb-tablet,bus=3Duhci.0,port=3D1"; int ret; =20 diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 9eb24b0..b15a511 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -56,7 +56,8 @@ int main(int argc, char **argv) qtest_add_func("/xhci/pci/hotplug/usb-ccid", test_usb_ccid_hotplug); =20 qtest_start("-device nec-usb-xhci,id=3Dxhci" - " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://,format=3D= raw"); + " -drive id=3Ddrive0,if=3Dnone,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw"); ret =3D g_test_run(); qtest_end(); =20 diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index 1b02714..1589ab0 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -753,8 +753,10 @@ static void *virtio_blk_test_setup(GString *cmd_line, = void *arg) char *tmp_path =3D drive_create(); =20 g_string_append_printf(cmd_line, - " -drive if=3Dnone,id=3Ddrive0,file=3D%s,format= =3Draw,auto-read-only=3Doff " - "-drive if=3Dnone,id=3Ddrive1,file=3Dnull-co://= ,format=3Draw ", + " -drive if=3Dnone,id=3Ddrive0,file=3D%s," + "format=3Draw,auto-read-only=3Doff " + "-drive if=3Dnone,id=3Ddrive1,file=3Dnull-co://= ," + "file.read-zeroes=3Don,format=3Draw ", tmp_path); =20 return arg; diff --git a/tests/virtio-ccw-test.c b/tests/virtio-ccw-test.c index 48c714d..6be4e6a 100644 --- a/tests/virtio-ccw-test.c +++ b/tests/virtio-ccw-test.c @@ -53,7 +53,8 @@ static void virtio_serial_hotplug(void) =20 static void virtio_blk_nop(void) { - global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://,format=3Draw " + global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://," + "file.read-zeroes=3Don,format=3Draw " "-device virtio-blk-ccw,drive=3Ddrv0"); qtest_end(); } @@ -78,8 +79,10 @@ static void virtio_scsi_nop(void) =20 static void virtio_scsi_hotplug(void) { - global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://,format=3Draw " - "-drive if=3Dnone,id=3Ddrv1,file=3Dnull-co= ://,format=3Draw " + global_qtest =3D qtest_initf("-drive if=3Dnone,id=3Ddrv0,file=3Dnull-c= o://," + "file.read-zeroes=3Don,format=3Draw " + "-drive if=3Dnone,id=3Ddrv1,file=3Dnull-co= ://," + "file.read-zeroes=3Don,format=3Draw " "-device virtio-scsi-ccw " "-device scsi-hd,drive=3Ddrv0"); qtest_qmp_device_add("scsi-hd", "scsihd", "{'drive': 'drv1'}"); diff --git a/tests/virtio-scsi-test.c b/tests/virtio-scsi-test.c index 1ad9f75..ae6698d 100644 --- a/tests/virtio-scsi-test.c +++ b/tests/virtio-scsi-test.c @@ -239,7 +239,8 @@ fail: static void *virtio_scsi_hotplug_setup(GString *cmd_line, void *arg) { g_string_append(cmd_line, - " -drive id=3Ddrv1,if=3Dnone,file=3Dnull-co://,format= =3Draw"); + " -drive id=3Ddrv1,if=3Dnone,file=3Dnull-co://," + "file.read-zeroes=3Don,format=3Draw"); return arg; } =20 @@ -247,6 +248,7 @@ static void *virtio_scsi_setup(GString *cmd_line, void = *arg) { g_string_append(cmd_line, " -drive file=3Dblkdebug::null-co://," + "file.image.read-zeroes=3Don," "if=3Dnone,id=3Ddr1,format=3Draw,file.align=3D4k " "-device scsi-hd,drive=3Ddr1,lun=3D0,scsi-id=3D1"); return arg; @@ -256,7 +258,7 @@ static void *virtio_scsi_setup_iothread(GString *cmd_li= ne, void *arg) { g_string_append(cmd_line, " -object iothread,id=3Dthread0" - " -blockdev driver=3Dnull-co,node-name=3Dnull0" + " -blockdev driver=3Dnull-co,read-zeroes=3Don,node-nam= e=3Dnull0" " -device scsi-hd,drive=3Dnull0"); return arg; } --=20 1.8.3.1