From nobody Sun Feb 8 14:11:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532377301063756.6318207191775; Mon, 23 Jul 2018 13:21:41 -0700 (PDT) Received: from localhost ([::1]:36335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKu-0003Uz-09 for importer@patchew.org; Mon, 23 Jul 2018 16:21:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIC-0001Md-3r for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIA-0002MI-Ld for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:52 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:37379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIA-0002L7-Ey; Mon, 23 Jul 2018 16:18:50 -0400 Received: by mail-oi0-x236.google.com with SMTP id k81-v6so3469637oib.4; Mon, 23 Jul 2018 13:18:50 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q206-v6sm6591520oih.46.2018.07.23.13.18.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=BVbHtDrZ8RMjc4fpVRy5sDtoxnrkssQJuqlh4EGzN+o=; b=Xul0o68tHxPaSNNl7+uiAADIvTz1bSmAmJweyj0YnFCh4g+k7LG27qOkJBapQaWhaG 60OIH3YlAZzxBvLN8bbpivlYwUWf9hDXgFpD9tUkvXmTQqyqy19OAm5eoqK77rjteq8F SOivH7+Ibdhpp+fbYDHipiIDQt+Z9iHhVsIgRKn5v3mZaEsgn5FZt3zu0yupimYrZGcm HkCdcw/Ua1rpTMMECWmrzInFBPhSPlGuNMXwCq/LjX3bcYpb+ttC/jvvxdZtP2CHuDbK V+ov2iwhLeRDJlJBkiUXK9jsDhS9a9WYh5RyfnDW1q9ZnpOhd2l17UwgiCZkIMV0LlKc 9j8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=BVbHtDrZ8RMjc4fpVRy5sDtoxnrkssQJuqlh4EGzN+o=; b=JOwzx7JMqmJo7O8pE2DcU+sz9cWtvp7UTjSa5F7eqXm/za1KiOhQ4lfUd4sReqjCXu JDT79+taLIh0oSLCanhAUuq/4BrZ7P3ffEJUWAXue8Kv5HhuioCN3aWupIKPLEN+Z4dd Wvb15kqGHojeIv3Tt4voun0M7iYgEoxC6V7Kea7GbW2voPF8sxSGRPhPr1cjxkHe1jI8 1x/xQ/X6CJjXkPgMdnz9CsMp9Ewyt3PLrDjARXn9gp7TkeJxhz8zKXElvLue8ArM3c2g 55TqrepetrjDXL5GFMIlwWVlDNVbpHJIYcq7rJCKw7w8nZZ7VydeeRbyisu/1tFnAVYu JaVg== X-Gm-Message-State: AOUpUlFbU/Wz9qqv4GlhIZJRGTQc7aE/OIpu1TEo0N5XQNkxisJ0Q4zP JbaNL8UHALe7Q/5On20Bxw4Tmv2z90k= X-Google-Smtp-Source: AAOMgpe8cmNx3VtP3meeG9pl4ichGDjQQ8EmUNXaJqc2ED1UsQweK7w9fc8X46LW5sIXdMzNHXI4fg== X-Received: by 2002:aca:d986:: with SMTP id q128-v6mr244939oig.349.1532377129195; Mon, 23 Jul 2018 13:18:49 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:22 -0500 Message-Id: <20180723201748.25573-14-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::236 Subject: [Qemu-devel] [PATCH 13/99] iotests: Add test for rebasing with relative paths X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20180509182002.8044-3-mreitz@redhat.com Signed-off-by: Max Reitz (cherry picked from commit 28036a7f7044fddb79819e3c8fcb4ae5605c60e0) Signed-off-by: Michael Roth --- tests/qemu-iotests/024 | 82 ++++++++++++++++++++++++++++++++++++-- tests/qemu-iotests/024.out | 30 ++++++++++++++ 2 files changed, 109 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024 index e0d77ce2f5..4071ed6093 100755 --- a/tests/qemu-iotests/024 +++ b/tests/qemu-iotests/024 @@ -29,9 +29,14 @@ status=3D1 # failure is the default! =20 _cleanup() { - _cleanup_test_img - rm -f "$TEST_DIR/t.$IMGFMT.base_old" - rm -f "$TEST_DIR/t.$IMGFMT.base_new" + _cleanup_test_img + rm -f "$TEST_DIR/t.$IMGFMT.base_old" + rm -f "$TEST_DIR/t.$IMGFMT.base_new" + + rm -f "$TEST_DIR/subdir/t.$IMGFMT" + rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" + rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" + rmdir "$TEST_DIR/subdir" 2> /dev/null } trap "_cleanup; exit \$status" 0 1 2 3 15 =20 @@ -123,6 +128,77 @@ io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE = 0 1 0x00 io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11 io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00 =20 +echo +echo "=3D=3D=3D Test rebase in a subdirectory of the working directory =3D= =3D=3D" +echo + +# Clean up the old images beforehand so they do not interfere with +# this test +_cleanup + +mkdir "$TEST_DIR/subdir" + +# Relative to the overlay +BASE_OLD_OREL=3D"t.$IMGFMT.base_old" +BASE_NEW_OREL=3D"t.$IMGFMT.base_new" + +# Relative to $TEST_DIR (which is going to be our working directory) +OVERLAY_WREL=3D"subdir/t.$IMGFMT" + +BASE_OLD=3D"$TEST_DIR/subdir/$BASE_OLD_OREL" +BASE_NEW=3D"$TEST_DIR/subdir/$BASE_NEW_OREL" +OVERLAY=3D"$TEST_DIR/$OVERLAY_WREL" + +# Test done here: +# +# Backing (old): 11 11 -- 11 +# Backing (new): -- 22 22 11 +# Overlay: -- -- -- -- +# +# Rebasing works, we have verified that above. Here, we just want to +# see that rebasing is done for the correct target backing file. + +TEST_IMG=3D$BASE_OLD _make_test_img 1M +TEST_IMG=3D$BASE_NEW _make_test_img 1M +TEST_IMG=3D$OVERLAY _make_test_img -b "$BASE_OLD_OREL" 1M + +echo + +$QEMU_IO "$BASE_OLD" \ + -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ + -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \ + | _filter_qemu_io + +$QEMU_IO "$BASE_NEW" \ + -c "write -P 0x22 $((1 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ + -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \ + | _filter_qemu_io + +echo + +pushd "$TEST_DIR" >/dev/null +$QEMU_IMG rebase -f "$IMGFMT" -b "$BASE_NEW_OREL" "$OVERLAY_WREL" +popd >/dev/null + +# Verify the backing path is correct +TEST_IMG=3D$OVERLAY _img_info | grep '^backing file' + +echo + +# Verify the data is correct +$QEMU_IO "$OVERLAY" \ + -c "read -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x11 $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x00 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x11 $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + | _filter_qemu_io + +echo + +# Verify that cluster #3 is not allocated (because it is the same in +# $BASE_OLD and $BASE_NEW) +$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map + =20 # success, all done echo "*** done" diff --git a/tests/qemu-iotests/024.out b/tests/qemu-iotests/024.out index 33cfaf5cfc..024dc786b3 100644 --- a/tests/qemu-iotests/024.out +++ b/tests/qemu-iotests/024.out @@ -141,4 +141,34 @@ read 65536/65536 bytes at offset 917504 =3D=3D=3D IO: pattern 0x00 read 65536/65536 bytes at offset 983040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Test rebase in a subdirectory of the working directory =3D=3D=3D + +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_old', fmt=3DIMGFMT size=3D1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_new', fmt=3DIMGFMT size=3D1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 backing= _file=3Dt.IMGFMT.base_old + +wrote 131072/131072 bytes at offset 0 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 65536 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +backing file: t.IMGFMT.base_new (actual path: TEST_DIR/subdir/t.IMGFMT.bas= e_new) + +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 131072 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Offset Length File +0 0x30000 TEST_DIR/subdir/t.IMGFMT +0x30000 0x10000 TEST_DIR/subdir/t.IMGFMT.base_new *** done --=20 2.17.1