From nobody Sat May 18 16:18:00 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1658949897; cv=none; d=zohomail.com; s=zohoarc; b=PGUexQxaNSP7QVMPgME9drfX5bdOSjBZXpk0/zA8J2OsR1L5AtWqRvpn46WlxGM2sRhPK3/v4f+k/keUg7Lr817lbUWLePdhqKKDhfsCeRn5Y56WK/0XA1hCJSUBoqi/b06e6PwJH/3pKqGGy3146RZ3J8ToGiBLqmzvsYNSJHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658949897; h=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=ITm4/qIgvcgoWJmSBIq+Z1cbVfBb36dogMDzX7p/ShE=; b=S8tKc359NYJDRJzhVH11z5X5E95xK8atUdabHGgEu8qvSo2CcgnibYSNmZLUugw0zjJi4JY8ap55HrdzxyYRooWE7mWFsrUEJ89fsHAJqOis17QGrOIjfCRl2wxP/2vHptYNn7TZhvHrmY0tod0qvsv40DlRa/wAiSDqhfio7Z4= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165894989722994.94917342223016; Wed, 27 Jul 2022 12:24:57 -0700 (PDT) Received: from localhost ([::1]:44546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGmeO-0000dZ-52 for importer@patchew.org; Wed, 27 Jul 2022 15:24:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGmNH-0008D3-BH; Wed, 27 Jul 2022 15:07:15 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:50376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGmNE-000521-Ai; Wed, 27 Jul 2022 15:07:13 -0400 Received: from iva8-3a65cceff156.qloud-c.yandex.net (iva8-3a65cceff156.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2d80:0:640:3a65:ccef]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 263BA2E0974; Wed, 27 Jul 2022 22:07:02 +0300 (MSK) Received: from localhost.localdomain (172.31.41.131-vpn.dhcp.yndx.net [172.31.41.131]) by iva8-3a65cceff156.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id lEd3EUqO2s-70OOsEgk; Wed, 27 Jul 2022 22:07:01 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1658948821; bh=ITm4/qIgvcgoWJmSBIq+Z1cbVfBb36dogMDzX7p/ShE=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=xhfuKckBEEaDklsv3JIhmG3Lpn2UKT6AGEk+1xRaepR7ihJQ0LJrDQwI1JlA+z/wH 5M6FH3w+iU9VeAKAtHgnfDMNSdH68ejOaeIzCp6qPcGEMdEh622kbj1dgbf8yo4M5q i88LnSni+gqshr8raG9jonNfLBEcFuZ+87arU+mU= Authentication-Results: iva8-3a65cceff156.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, den@openvz.org, stefanha@redhat.com Subject: [PULL 1/2] block/parallels: Fix buffer-based write call Date: Wed, 27 Jul 2022 22:06:34 +0300 Message-Id: <20220727190635.1024863-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220727190635.1024863-1-vsementsov@yandex-team.ru> References: <20220727190635.1024863-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=95.108.205.193; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1o.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1658949898383100001 Content-Type: text/plain; charset="utf-8" From: Hanna Reitz Commit a4072543ccdddbd241d5962d9237b8b41fd006bf has changed the I/O here from working on a local one-element I/O vector to just using the buffer directly (using the bdrv_co_pread()/bdrv_co_pwrite() helper functions introduced shortly before). However, it only changed the bdrv_co_preadv() call to bdrv_co_pread() - the subsequent bdrv_co_pwritev() call stayed this way, and so still expects a QEMUIOVector pointer instead of a plain buffer. We must change that to be a bdrv_co_pwrite() call. Fixes: a4072543ccdddbd241d5962d ("block/parallels: use buffer-based io") Signed-off-by: Hanna Reitz Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220714132801.72464-2-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/parallels.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 8b235b9505..a229c06f25 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -241,8 +241,8 @@ static int64_t allocate_clusters(BlockDriverState *bs, = int64_t sector_num, return ret; } =20 - ret =3D bdrv_co_pwritev(bs->file, s->data_end * BDRV_SECTOR_SIZE, - nb_cow_bytes, buf, 0); + ret =3D bdrv_co_pwrite(bs->file, s->data_end * BDRV_SECTOR_SIZE, + nb_cow_bytes, buf, 0); qemu_vfree(buf); if (ret < 0) { return ret; --=20 2.25.1 From nobody Sat May 18 16:18:00 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1658950140; cv=none; d=zohomail.com; s=zohoarc; b=dmZFGw5znJJkl1RY8pvV+cCUe3DVmSRQU4BPuQXQcN/SGDr1r9rNs8SMXVPR+qFBRd36LT0LjSS3ukasImXmtNANu9mQ0ikZJLZifhPsyKQhbhRKG1qX4ug85ki/PpCfbB7Avc7WJkFSlC8zabbIONuXGxkBqyvEn09HFbTGg6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658950140; h=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=jDJaFix2iJm+jPuI7aRxvWc8zDl/yn66dHKdXW9ez5k=; b=Twuwmva3KhRsi5nh5PjhMgGasiKqkWa9Dd5cncoNdotGOKVqJiNpIOsaG5gb32gqgRtdQHOQh/B1TJA70inVlehVo5r5dENIbax9aqTwWzEwuvpZqWsQZ7+EFDZEeBMovt720XJO2KfF6uFxIatIZpdwzqRrRB7NxOkiQ3xj960= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658950140231701.4694241720504; Wed, 27 Jul 2022 12:29:00 -0700 (PDT) Received: from localhost ([::1]:49234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGmiJ-0003yZ-1B for importer@patchew.org; Wed, 27 Jul 2022 15:28:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGmNH-0008DN-Av; Wed, 27 Jul 2022 15:07:15 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:46374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGmNE-000527-7j; Wed, 27 Jul 2022 15:07:14 -0400 Received: from iva8-3a65cceff156.qloud-c.yandex.net (iva8-3a65cceff156.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:2d80:0:640:3a65:ccef]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 6766E2E20FA; Wed, 27 Jul 2022 22:07:03 +0300 (MSK) Received: from localhost.localdomain (172.31.41.131-vpn.dhcp.yndx.net [172.31.41.131]) by iva8-3a65cceff156.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id lEd3EUqO2s-72OO50p5; Wed, 27 Jul 2022 22:07:02 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1658948822; bh=jDJaFix2iJm+jPuI7aRxvWc8zDl/yn66dHKdXW9ez5k=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=DtbPHTQugVDr5v95smb63oX6PPyI/Cm5w2mTMZJRpQjRShsx7+UokE9JukbfSgZqa ms88Y98auOjQZPtNApLs06wu2WD/Fin9E3cwHbXrz0CIe5gb1bz7EGV9GJJccIwB9H btkJC6I8vfv2681BRQxp9m4ieVb74CVBVNdIAQkc= Authentication-Results: iva8-3a65cceff156.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, den@openvz.org, stefanha@redhat.com Subject: [PULL 2/2] iotests/131: Add parallels regression test Date: Wed, 27 Jul 2022 22:06:35 +0300 Message-Id: <20220727190635.1024863-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220727190635.1024863-1-vsementsov@yandex-team.ru> References: <20220727190635.1024863-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=5.45.199.163; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1j.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1658950142648100001 Content-Type: text/plain; charset="utf-8" From: Hanna Reitz Test an allocating write to a parallels image that has a backing node. Before HEAD^, doing so used to give me a failed assertion (when the backing node contains only `42` bytes; the results varies with the value chosen, for `0` bytes, for example, all I get is EIO). Signed-off-by: Hanna Reitz Reviewed-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220714132801.72464-3-hreitz@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/131 | 35 ++++++++++++++++++++++++++++++++++- tests/qemu-iotests/131.out | 13 +++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/131 b/tests/qemu-iotests/131 index d7456cae5b..a847692b4c 100755 --- a/tests/qemu-iotests/131 +++ b/tests/qemu-iotests/131 @@ -43,7 +43,7 @@ _supported_os Linux =20 inuse_offset=3D$((0x2c)) =20 -size=3D64M +size=3D$((64 * 1024 * 1024)) CLUSTER_SIZE=3D64k IMGFMT=3Dparallels _make_test_img $size @@ -70,6 +70,39 @@ _check_test_img _check_test_img -r all { $QEMU_IO -c "read -P 0x11 64k 64k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io= | _filter_testdir =20 +echo "=3D=3D allocate with backing =3D=3D" +# Verify that allocating clusters works fine even when there is a backing = image. +# Regression test for a bug where we would pass a buffer read from the bac= king +# node as a QEMUIOVector object, which could cause anything from I/O error= s over +# assertion failures to invalid reads from memory. + +# Clear image +_make_test_img $size +# Create base image +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $size + +# Write some data to the base image (which would trigger an assertion fail= ure if +# interpreted as a QEMUIOVector) +$QEMU_IO -c 'write -P 42 0 64k' "$TEST_IMG.base" | _filter_qemu_io + +# Parallels does not seem to support storing a backing filename in the ima= ge +# itself, so we need to build our backing chain on the command line +imgopts=3D"driver=3D$IMGFMT,file.driver=3D$IMGPROTO,file.filename=3D$TEST_= IMG" +imgopts+=3D",backing.driver=3D$IMGFMT" +imgopts+=3D",backing.file.driver=3D$IMGPROTO,backing.file.filename=3D$TEST= _IMG.base" + +# Cause allocation in the top image +QEMU_IO_OPTIONS=3D$QEMU_IO_OPTIONS_NO_FMT \ + $QEMU_IO --image-opts "$imgopts" -c 'write -P 1 0 64' | _filter_qemu_io + +# Verify +QEMU_IO_OPTIONS=3D$QEMU_IO_OPTIONS_NO_FMT \ + $QEMU_IO --image-opts "$imgopts" \ + -c 'read -P 1 0 64' \ + -c "read -P 42 64 $((64 * 1024 - 64))" \ + -c "read -P 0 64k $((size - 64 * 1024))" \ + | _filter_qemu_io + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/131.out b/tests/qemu-iotests/131.out index 70da03dee5..de5ef7a8f5 100644 --- a/tests/qemu-iotests/131.out +++ b/tests/qemu-iotests/131.out @@ -37,4 +37,17 @@ Double checking the fixed image now... No errors were found on the image. read 65536/65536 bytes at offset 65536 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D allocate with backing =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D67108864 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 64/64 bytes at offset 0 +64 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 64/64 bytes at offset 0 +64 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65472/65472 bytes at offset 64 +63.938 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 67043328/67043328 bytes at offset 65536 +63.938 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done --=20 2.25.1