2019-03-07 17:58:38 +03:00
|
|
|
#!/usr/bin/env bash
|
2021-01-16 16:44:19 +03:00
|
|
|
# group: rw backing auto quick
|
2010-01-17 14:23:15 +03:00
|
|
|
#
|
|
|
|
# Rebasing COW images
|
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
# creator
|
|
|
|
owner=kwolf@redhat.com
|
|
|
|
|
|
|
|
seq=`basename $0`
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
{
|
2018-05-09 21:20:02 +03:00
|
|
|
_cleanup_test_img
|
2019-11-07 19:37:01 +03:00
|
|
|
_rm_test_img "$TEST_DIR/t.$IMGFMT.base_old"
|
|
|
|
_rm_test_img "$TEST_DIR/t.$IMGFMT.base_new"
|
2018-05-09 21:20:02 +03:00
|
|
|
|
2019-11-07 19:37:01 +03:00
|
|
|
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT"
|
|
|
|
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old"
|
|
|
|
_rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new"
|
2018-05-09 21:20:02 +03:00
|
|
|
rmdir "$TEST_DIR/subdir" 2> /dev/null
|
2010-01-17 14:23:15 +03:00
|
|
|
}
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
. ./common.rc
|
|
|
|
. ./common.filter
|
|
|
|
. ./common.pattern
|
|
|
|
|
2010-10-31 23:10:20 +03:00
|
|
|
# Currently only qcow2 and qed support rebasing
|
|
|
|
_supported_fmt qcow2 qed
|
2014-02-03 13:26:14 +04:00
|
|
|
_supported_proto file
|
2010-01-17 14:23:15 +03:00
|
|
|
_supported_os Linux
|
|
|
|
|
|
|
|
CLUSTER_SIZE=65536
|
|
|
|
|
|
|
|
# Cluster allocations to be tested:
|
|
|
|
#
|
|
|
|
# Backing (old) 11 -- 11 -- 11 -- 11 --
|
|
|
|
# Backing (new) 22 22 -- -- 22 22 -- --
|
|
|
|
# COW image 33 33 33 33 -- -- -- --
|
2010-05-04 20:59:26 +04:00
|
|
|
#
|
|
|
|
# The pattern is written twice to have both an alloc -> non-alloc and a
|
|
|
|
# non-alloc -> alloc transition in the COW image.
|
2010-01-17 14:23:15 +03:00
|
|
|
|
|
|
|
echo "Creating backing file"
|
|
|
|
echo
|
|
|
|
|
2015-12-22 05:49:14 +03:00
|
|
|
TEST_IMG_SAVE="$TEST_IMG"
|
|
|
|
TEST_IMG="$TEST_IMG.base_old"
|
|
|
|
|
2010-01-17 14:23:15 +03:00
|
|
|
_make_test_img 1G
|
qemu-iotests: Use zero-based offsets for IO patterns
The io_pattern style functions have the following loop:
for i in `seq 1 $count`; do
echo ... $(( start + i * step )) ...
done
Offsets are 1-based so start=1024, step=512, count=4 yields:
1536, 2048, 2560, 3072
Normally we expect:
1024, 1536, 2048, 2560
Most tests ignore this detail, which means that they perform I/O to a
slightly different range than expected by the test author.
Later on things got less innocent and tests started trying to compensate
for the 1-based indexing. This included negative start values in test
024 and my own attempt with count-1 in test 028!
The end result is that tests that use io_pattern are hard to reason
about and don't work the way you'd expect. It's time to clean this mess
up.
This patch switches io_pattern to 0-based offsets. This requires
adjusting the golden outputs since I/O ranges are now shifted and output
differs.
Verifying these output diffs is easy, however. Each diff hunk moves one
I/O from beyond the end of the pattern range to the beginning.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2011-02-04 15:55:02 +03:00
|
|
|
io_pattern writev 0 $CLUSTER_SIZE $((2 * CLUSTER_SIZE)) 8 0x11
|
2015-12-22 05:49:14 +03:00
|
|
|
|
|
|
|
TEST_IMG="$TEST_IMG_SAVE.base_new"
|
2010-01-17 14:23:15 +03:00
|
|
|
|
|
|
|
echo "Creating new backing file"
|
|
|
|
echo
|
|
|
|
|
|
|
|
_make_test_img 1G
|
qemu-iotests: Use zero-based offsets for IO patterns
The io_pattern style functions have the following loop:
for i in `seq 1 $count`; do
echo ... $(( start + i * step )) ...
done
Offsets are 1-based so start=1024, step=512, count=4 yields:
1536, 2048, 2560, 3072
Normally we expect:
1024, 1536, 2048, 2560
Most tests ignore this detail, which means that they perform I/O to a
slightly different range than expected by the test author.
Later on things got less innocent and tests started trying to compensate
for the 1-based indexing. This included negative start values in test
024 and my own attempt with count-1 in test 028!
The end result is that tests that use io_pattern are hard to reason
about and don't work the way you'd expect. It's time to clean this mess
up.
This patch switches io_pattern to 0-based offsets. This requires
adjusting the golden outputs since I/O ranges are now shifted and output
differs.
Verifying these output diffs is easy, however. Each diff hunk moves one
I/O from beyond the end of the pattern range to the beginning.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2011-02-04 15:55:02 +03:00
|
|
|
io_pattern writev 0 $((2 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 4 0x22
|
2015-12-22 05:49:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
TEST_IMG="$TEST_IMG_SAVE"
|
2010-01-17 14:23:15 +03:00
|
|
|
|
|
|
|
echo "Creating COW image"
|
|
|
|
echo
|
|
|
|
|
iotests: Specify explicit backing format where sensible
There are many existing qcow2 images that specify a backing file but
no format. This has been the source of CVEs in the past, but has
become more prominent of a problem now that libvirt has switched to
-blockdev. With older -drive, at least the probing was always done by
qemu (so the only risk of a changed format between successive boots of
a guest was if qemu was upgraded and probed differently). But with
newer -blockdev, libvirt must specify a format; if libvirt guesses raw
where the image was formatted, this results in data corruption visible
to the guest; conversely, if libvirt guesses qcow2 where qemu was
using raw, this can result in potential security holes, so modern
libvirt instead refuses to use images without explicit backing format.
The change in libvirt to reject images without explicit backing format
has pointed out that a number of tools have been far too reliant on
probing in the past. It's time to set a better example in our own
iotests of properly setting this parameter.
iotest calls to create, rebase, and convert are all impacted to some
degree. It's a bit annoying that we are inconsistent on command line
- while all of those accept -o backing_file=...,backing_fmt=..., the
shortcuts are different: create and rebase have -b and -F, while
convert has -B but no -F. (amend has no shortcuts, but the previous
patch just deprecated the use of amend to change backing chains).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200706203954.341758-9-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-07-06 23:39:52 +03:00
|
|
|
_make_test_img -b "$TEST_IMG.base_old" -F $IMGFMT 1G
|
2010-01-17 14:23:15 +03:00
|
|
|
io_pattern writev 0 $((4 * CLUSTER_SIZE)) 0 1 0x33
|
2010-05-04 20:59:26 +04:00
|
|
|
io_pattern writev $((8 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 0 1 0x33
|
2010-01-17 14:23:15 +03:00
|
|
|
|
|
|
|
echo "Read before the rebase to make sure everything is set up correctly"
|
|
|
|
echo
|
|
|
|
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
|
|
|
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
2010-05-04 20:59:26 +04:00
|
|
|
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
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
|
2010-01-17 14:23:15 +03:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo Rebase and test again
|
|
|
|
echo
|
iotests: Specify explicit backing format where sensible
There are many existing qcow2 images that specify a backing file but
no format. This has been the source of CVEs in the past, but has
become more prominent of a problem now that libvirt has switched to
-blockdev. With older -drive, at least the probing was always done by
qemu (so the only risk of a changed format between successive boots of
a guest was if qemu was upgraded and probed differently). But with
newer -blockdev, libvirt must specify a format; if libvirt guesses raw
where the image was formatted, this results in data corruption visible
to the guest; conversely, if libvirt guesses qcow2 where qemu was
using raw, this can result in potential security holes, so modern
libvirt instead refuses to use images without explicit backing format.
The change in libvirt to reject images without explicit backing format
has pointed out that a number of tools have been far too reliant on
probing in the past. It's time to set a better example in our own
iotests of properly setting this parameter.
iotest calls to create, rebase, and convert are all impacted to some
degree. It's a bit annoying that we are inconsistent on command line
- while all of those accept -o backing_file=...,backing_fmt=..., the
shortcuts are different: create and rebase have -b and -F, while
convert has -B but no -F. (amend has no shortcuts, but the previous
patch just deprecated the use of amend to change backing chains).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200706203954.341758-9-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-07-06 23:39:52 +03:00
|
|
|
$QEMU_IMG rebase -b "$TEST_IMG.base_new" -F $IMGFMT "$TEST_IMG"
|
2010-01-17 14:23:15 +03:00
|
|
|
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
|
|
|
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
2010-05-04 20:59:26 +04:00
|
|
|
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
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
|
2010-01-17 14:23:15 +03:00
|
|
|
|
2018-05-09 21:20:02 +03:00
|
|
|
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
|
iotests: Specify explicit backing format where sensible
There are many existing qcow2 images that specify a backing file but
no format. This has been the source of CVEs in the past, but has
become more prominent of a problem now that libvirt has switched to
-blockdev. With older -drive, at least the probing was always done by
qemu (so the only risk of a changed format between successive boots of
a guest was if qemu was upgraded and probed differently). But with
newer -blockdev, libvirt must specify a format; if libvirt guesses raw
where the image was formatted, this results in data corruption visible
to the guest; conversely, if libvirt guesses qcow2 where qemu was
using raw, this can result in potential security holes, so modern
libvirt instead refuses to use images without explicit backing format.
The change in libvirt to reject images without explicit backing format
has pointed out that a number of tools have been far too reliant on
probing in the past. It's time to set a better example in our own
iotests of properly setting this parameter.
iotest calls to create, rebase, and convert are all impacted to some
degree. It's a bit annoying that we are inconsistent on command line
- while all of those accept -o backing_file=...,backing_fmt=..., the
shortcuts are different: create and rebase have -b and -F, while
convert has -B but no -F. (amend has no shortcuts, but the previous
patch just deprecated the use of amend to change backing chains).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200706203954.341758-9-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-07-06 23:39:52 +03:00
|
|
|
TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD_OREL" -F $IMGFMT 1M
|
2018-05-09 21:20:02 +03:00
|
|
|
|
|
|
|
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
|
iotests: Specify explicit backing format where sensible
There are many existing qcow2 images that specify a backing file but
no format. This has been the source of CVEs in the past, but has
become more prominent of a problem now that libvirt has switched to
-blockdev. With older -drive, at least the probing was always done by
qemu (so the only risk of a changed format between successive boots of
a guest was if qemu was upgraded and probed differently). But with
newer -blockdev, libvirt must specify a format; if libvirt guesses raw
where the image was formatted, this results in data corruption visible
to the guest; conversely, if libvirt guesses qcow2 where qemu was
using raw, this can result in potential security holes, so modern
libvirt instead refuses to use images without explicit backing format.
The change in libvirt to reject images without explicit backing format
has pointed out that a number of tools have been far too reliant on
probing in the past. It's time to set a better example in our own
iotests of properly setting this parameter.
iotest calls to create, rebase, and convert are all impacted to some
degree. It's a bit annoying that we are inconsistent on command line
- while all of those accept -o backing_file=...,backing_fmt=..., the
shortcuts are different: create and rebase have -b and -F, while
convert has -B but no -F. (amend has no shortcuts, but the previous
patch just deprecated the use of amend to change backing chains).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200706203954.341758-9-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-07-06 23:39:52 +03:00
|
|
|
$QEMU_IMG rebase -f "$IMGFMT" -b "$BASE_NEW_OREL" -F $IMGFMT "$OVERLAY_WREL"
|
2018-05-09 21:20:02 +03:00
|
|
|
popd >/dev/null
|
|
|
|
|
|
|
|
# Verify the backing path is correct
|
iotests: Specify explicit backing format where sensible
There are many existing qcow2 images that specify a backing file but
no format. This has been the source of CVEs in the past, but has
become more prominent of a problem now that libvirt has switched to
-blockdev. With older -drive, at least the probing was always done by
qemu (so the only risk of a changed format between successive boots of
a guest was if qemu was upgraded and probed differently). But with
newer -blockdev, libvirt must specify a format; if libvirt guesses raw
where the image was formatted, this results in data corruption visible
to the guest; conversely, if libvirt guesses qcow2 where qemu was
using raw, this can result in potential security holes, so modern
libvirt instead refuses to use images without explicit backing format.
The change in libvirt to reject images without explicit backing format
has pointed out that a number of tools have been far too reliant on
probing in the past. It's time to set a better example in our own
iotests of properly setting this parameter.
iotest calls to create, rebase, and convert are all impacted to some
degree. It's a bit annoying that we are inconsistent on command line
- while all of those accept -o backing_file=...,backing_fmt=..., the
shortcuts are different: create and rebase have -b and -F, while
convert has -B but no -F. (amend has no shortcuts, but the previous
patch just deprecated the use of amend to change backing chains).
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200706203954.341758-9-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2020-07-06 23:39:52 +03:00
|
|
|
TEST_IMG=$OVERLAY _img_info | grep '^backing file:'
|
2018-05-09 21:20:02 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-09-19 19:57:58 +03:00
|
|
|
# Check that rebase within the chain is working when
|
|
|
|
# overlay_size > old_backing_size
|
|
|
|
#
|
|
|
|
# base_new <-- base_old <-- overlay
|
|
|
|
#
|
|
|
|
# Backing (new): 11 11 11 11 11
|
|
|
|
# Backing (old): 22 22 22 22
|
|
|
|
# Overlay: -- -- -- -- --
|
|
|
|
#
|
|
|
|
# As a result, overlay should contain data identical to base_old, with the
|
|
|
|
# last cluster remaining unallocated.
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "=== Test rebase within one backing chain ==="
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo "Creating backing chain"
|
|
|
|
echo
|
|
|
|
|
|
|
|
TEST_IMG=$BASE_NEW _make_test_img $(( CLUSTER_SIZE * 5 ))
|
|
|
|
TEST_IMG=$BASE_OLD _make_test_img -b "$BASE_NEW" -F $IMGFMT \
|
|
|
|
$(( CLUSTER_SIZE * 4 ))
|
|
|
|
TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD" -F $IMGFMT \
|
|
|
|
$(( CLUSTER_SIZE * 5 ))
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Fill backing files with data"
|
|
|
|
echo
|
|
|
|
|
|
|
|
$QEMU_IO "$BASE_NEW" -c "write -P 0x11 0 $(( CLUSTER_SIZE * 5 ))" \
|
|
|
|
| _filter_qemu_io
|
|
|
|
$QEMU_IO "$BASE_OLD" -c "write -P 0x22 0 $(( CLUSTER_SIZE * 4 ))" \
|
|
|
|
| _filter_qemu_io
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Check the last cluster is zeroed in overlay before the rebase"
|
|
|
|
echo
|
|
|
|
$QEMU_IO "$OVERLAY" -c "read -P 0x00 $(( CLUSTER_SIZE * 4 )) $CLUSTER_SIZE" \
|
|
|
|
| _filter_qemu_io
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Rebase onto another image in the same chain"
|
|
|
|
echo
|
|
|
|
|
|
|
|
$QEMU_IMG rebase -b "$BASE_NEW" -F $IMGFMT "$OVERLAY"
|
|
|
|
|
|
|
|
echo "Verify that data is read the same before and after rebase"
|
|
|
|
echo
|
|
|
|
|
|
|
|
# Verify the first 4 clusters are still read the same as in the old base
|
|
|
|
$QEMU_IO "$OVERLAY" -c "read -P 0x22 0 $(( CLUSTER_SIZE * 4 ))" \
|
|
|
|
| _filter_qemu_io
|
|
|
|
# Verify the last cluster still reads as zeroes
|
|
|
|
$QEMU_IO "$OVERLAY" -c "read -P 0x00 $(( CLUSTER_SIZE * 4 )) $CLUSTER_SIZE" \
|
|
|
|
| _filter_qemu_io
|
|
|
|
|
|
|
|
echo
|
2010-01-17 14:23:15 +03:00
|
|
|
|
2023-09-19 19:58:02 +03:00
|
|
|
# Check that rebase within the chain is working when
|
|
|
|
# overlay cluster size > backings cluster size
|
|
|
|
# (here overlay cluster size == 2 * backings cluster size)
|
|
|
|
#
|
|
|
|
# base_new <-- base_old <-- overlay
|
|
|
|
#
|
|
|
|
# Backing (new): -- -- -- -- -- --
|
|
|
|
# Backing (old): -- 11 -- -- 22 --
|
|
|
|
# Overlay: |-- --|-- --|-- --|
|
|
|
|
#
|
|
|
|
# We should end up having 1st and 3rd cluster allocated, and their halves
|
|
|
|
# being read as zeroes.
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "=== Test rebase with different cluster sizes ==="
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo "Creating backing chain"
|
|
|
|
echo
|
|
|
|
|
|
|
|
TEST_IMG=$BASE_NEW _make_test_img $(( CLUSTER_SIZE * 6 ))
|
|
|
|
TEST_IMG=$BASE_OLD _make_test_img -b "$BASE_NEW" -F $IMGFMT \
|
|
|
|
$(( CLUSTER_SIZE * 6 ))
|
|
|
|
CLUSTER_SIZE=$(( CLUSTER_SIZE * 2 )) TEST_IMG=$OVERLAY \
|
|
|
|
_make_test_img -b "$BASE_OLD" -F $IMGFMT $(( CLUSTER_SIZE * 6 ))
|
|
|
|
|
|
|
|
TEST_IMG=$OVERLAY _img_info
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Fill backing files with data"
|
|
|
|
echo
|
|
|
|
|
|
|
|
$QEMU_IO "$BASE_OLD" -c "write -P 0x11 $CLUSTER_SIZE $CLUSTER_SIZE" \
|
|
|
|
-c "write -P 0x22 $(( CLUSTER_SIZE * 4 )) $CLUSTER_SIZE" \
|
|
|
|
| _filter_qemu_io
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Rebase onto another image in the same chain"
|
|
|
|
echo
|
|
|
|
|
|
|
|
$QEMU_IMG rebase -b "$BASE_NEW" -F $IMGFMT "$OVERLAY"
|
|
|
|
|
|
|
|
echo "Verify that data is read the same before and after rebase"
|
|
|
|
echo
|
|
|
|
|
|
|
|
$QEMU_IO "$OVERLAY" -c "read -P 0x00 0 $CLUSTER_SIZE" \
|
|
|
|
-c "read -P 0x11 $CLUSTER_SIZE $CLUSTER_SIZE" \
|
|
|
|
-c "read -P 0x00 $(( CLUSTER_SIZE * 2 )) $(( CLUSTER_SIZE * 2 ))" \
|
|
|
|
-c "read -P 0x22 $(( CLUSTER_SIZE * 4 )) $CLUSTER_SIZE" \
|
|
|
|
-c "read -P 0x00 $(( CLUSTER_SIZE * 5 )) $CLUSTER_SIZE" \
|
|
|
|
| _filter_qemu_io
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Verify that untouched cluster remains unallocated"
|
|
|
|
echo
|
|
|
|
|
|
|
|
$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
2010-01-17 14:23:15 +03:00
|
|
|
# success, all done
|
|
|
|
echo "*** done"
|
|
|
|
rm -f $seq.full
|
|
|
|
status=0
|