From patchwork Mon Jul 23 20:16:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Xul0o68t"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCXc3CVQz9s1x for ; Tue, 24 Jul 2018 06:20:16 +1000 (AEST) Received: from localhost ([::1]:36326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJU-0001oG-DZ for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:20:12 -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) 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) 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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=1 # failure is the default! _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 @@ -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 +echo +echo "=== Test rebase in a subdirectory of the working directory ===" +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="t.$IMGFMT.base_old" +BASE_NEW_OREL="t.$IMGFMT.base_new" + +# Relative to $TEST_DIR (which is going to be our working directory) +OVERLAY_WREL="subdir/t.$IMGFMT" + +BASE_OLD="$TEST_DIR/subdir/$BASE_OLD_OREL" +BASE_NEW="$TEST_DIR/subdir/$BASE_NEW_OREL" +OVERLAY="$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=$BASE_OLD _make_test_img 1M +TEST_IMG=$BASE_NEW _make_test_img 1M +TEST_IMG=$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=$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 + # 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 === 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) + +=== Test rebase in a subdirectory of the working directory === + +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_old', fmt=IMGFMT size=1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_new', fmt=IMGFMT size=1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=t.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.base_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