mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:51 +00:00
iotests: add Linux loop device image creation test
This qemu-iotests test case is based on the reproducer that Jean-Louis
Dupond <jean-louis@dupond.be> shared in
https://gitlab.com/qemu-project/qemu/-/issues/3127.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20251007141700.71891-4-stefanha@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 59a1cf0cd3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
committed by
Michael Tokarev
parent
df502b9f18
commit
872893185e
59
tests/qemu-iotests/tests/loop-create-file
Executable file
59
tests/qemu-iotests/tests/loop-create-file
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# group: quick
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# Copyright Red Hat, Inc.
|
||||
#
|
||||
# Test Linux loop device image creation
|
||||
#
|
||||
# This test verifies #3127 "qemu-img create fails on loop device with sector size 4096"
|
||||
# https://gitlab.com/qemu-project/qemu/-/issues/3127
|
||||
|
||||
seq="$(basename $0)"
|
||||
echo "QA output created by $seq"
|
||||
|
||||
status=1 # failure is the default!
|
||||
|
||||
_cleanup() {
|
||||
if [ -n "$loopdev" ]; then
|
||||
sudo losetup --detach "$loopdev"
|
||||
fi
|
||||
|
||||
_cleanup_test_img
|
||||
}
|
||||
|
||||
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
|
||||
# get standard environment, filters and checks
|
||||
cd ..
|
||||
. ./common.rc
|
||||
. ./common.filter
|
||||
|
||||
_supported_fmt raw
|
||||
_supported_proto file
|
||||
_supported_os Linux
|
||||
|
||||
if ! sudo -n losetup &>/dev/null; then
|
||||
_notrun "sudo losetup not available"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "=== Create image on a 4 KB sector size loop device ==="
|
||||
echo
|
||||
|
||||
_make_test_img -f $IMGFMT 1M
|
||||
|
||||
loopdev=$(sudo losetup --sector-size 4096 --find --show "$TEST_IMG")
|
||||
if [ -z "$loopdev" ]; then
|
||||
_fail
|
||||
fi
|
||||
|
||||
sudo $QEMU_IMG_PROG create -f raw "$loopdev" 1M | \
|
||||
sed -e "s#/dev/loop[0-9]\\+#LOOPDEV#g"
|
||||
|
||||
# success, all done
|
||||
echo
|
||||
echo '*** done'
|
||||
rm -f $seq.full
|
||||
status=0
|
||||
8
tests/qemu-iotests/tests/loop-create-file.out
Normal file
8
tests/qemu-iotests/tests/loop-create-file.out
Normal file
@@ -0,0 +1,8 @@
|
||||
QA output created by loop-create-file
|
||||
|
||||
=== Create image on a 4 KB sector size loop device ===
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
|
||||
Formatting 'LOOPDEV', fmt=raw size=1048576
|
||||
|
||||
*** done
|
||||
Reference in New Issue
Block a user