From nobody Mon Feb 9 23:01:11 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 1529377813005623.872486810089; Mon, 18 Jun 2018 20:10:13 -0700 (PDT) Received: from localhost ([::1]:38915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV724-0001KR-3G for importer@patchew.org; Mon, 18 Jun 2018 23:10:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jM-0002wR-Sk for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jL-0000gw-Ju for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:48 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:46939) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jL-0000fy-D3; Mon, 18 Jun 2018 21:46:47 -0400 Received: by mail-oi0-x232.google.com with SMTP id h79-v6so16687174oig.13; Mon, 18 Jun 2018 18:46:47 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id p8-v6sm7160601oti.66.2018.06.18.18.46.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:45 -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=A2k3Ge2jKD+AUwjKnEqK8a8+3YJqbl+BBY+aCv6m5L4=; b=g8Nq+Vag5R0dkt0lmj4FUkjecLgRMGAGO8h6ro75G08dOJlQ2rws/+/TLqE8QwVRiL NwELNFTfBwPS4z82R3BCbYd0eL27sTxsk2UU+1852enLWN+HWCxN3kfSqjWhRqCLdUOg ZXAjGfzA5uziY72WyG7c3boMX9oje0zPL0PmxBvSh2zbtI0sEE2TvscvzMfzZ9S88cJV 4GewcU/ZpDEadBrFyH0toyL0Ak7sxFzlzgM38dZApnIlrsf92h6oMVanZ6Qz412yKb6y Lj/jBip8GbM8EdarN7ID+A0/L4y8dMUCG1eQfFEozWcGoZoMWybAMgmItM5kDBfc2DdA ND/g== 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=A2k3Ge2jKD+AUwjKnEqK8a8+3YJqbl+BBY+aCv6m5L4=; b=hqSZWqHHGeETSWcUzHizntUKz4kzG7cEMyg7RT89o8xos/eVsRTo9sUZ3nKdrdCMsd AGc+Xbl3EuyQ3zczOK40NaUSns6XYXepx/XMFYyejVJLmabtzkRnnNcIP1IBQcD9El3w gnWXvt6NuNic8yTixuMC6XWajUjafSFPDnpNd2z74FXxx/YIzRjO/tEejJphGFgxOSta 35gCoergV1P473QAOKzcr3Wb+pi4YWvUDLWifvTBl//BDetn5S9urDMnOpII/Pl3crHA BUrUTTASgrVGhONS5nPDHEk6lUGLtrnoo0TCRUKOf6zzSsthX1yNvKMu1nBi69qvrdQ6 nCzw== X-Gm-Message-State: APt69E0FvUjlKu6Xps+Gx5VuPQs7HZIbuo/RSf/NieKu2gcAq4QyzUBd wDJ39nrSl69zqYXgEaR55g6KuDRTSi0= X-Google-Smtp-Source: ADUXVKLHURtLmWBbF9+Eh0t5cRXy8u6jY05HwwUbHRUZfE3tx2aZTg4pfc7o/Kr344CACQ2neVd/7A== X-Received: by 2002:aca:6a4e:: with SMTP id f75-v6mr8745743oic.233.1529372806208; Mon, 18 Jun 2018 18:46:46 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:37 -0500 Message-Id: <20180619014319.28272-72-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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::232 Subject: [Qemu-devel] [PATCH 071/113] 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.11.0