aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-07-10 17:28:29 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-07-10 17:28:29 +0100
commit7851f1a70657245fab837615087ceaf4541df71f (patch)
treeb3b4359e4764fdf80a9f29bc6a35b27f8cd29749 /tests
parent0956ee3e4027d9063b08477a1c4f2b719380aac4 (diff)
parentcd47d792d7a27a57f4b621e2ff1ed8f4e83de1e9 (diff)
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - Copy offloading fixes for when the copy increases the image size - Temporary revert of the removal of deprecated -drive options - Fix request serialisation in the image fleecing scenario - Fix copy-on-read crash with unaligned image size - Fix another drain crash # gpg: Signature made Tue 10 Jul 2018 16:37:52 BST # gpg: using RSA key 7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (24 commits) block: Use common write req handling in truncate block: Fix bdrv_co_truncate overlap check block: Use common req handling in copy offloading block: Use common req handling for discard block: Fix handling of image enlarging write block: Extract common write req handling block: Use uint64_t for BdrvTrackedRequest byte fields block: Use BdrvChild to discard block: Add copy offloading trace points block: Prefix file driver trace points with "file_" Revert "block: Remove deprecated -drive geometry options" Revert "block: Remove deprecated -drive option addr" Revert "block: Remove deprecated -drive option serial" Revert "block: Remove dead deprecation warning code" block/blklogwrites: Make sure the log sector size is not too small qapi/block-core.json: Add missing documentation for blklogwrites log-append option block/backup: fix fleecing scheme: use serialized writes block: add BDRV_REQ_SERIALISING flag block: split flags in copy_range block/io: fix copy_range ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/ahci-test.c6
-rw-r--r--tests/hd-geo-test.c37
-rw-r--r--tests/ide-test.c8
-rwxr-xr-xtests/qemu-iotests/1979
-rw-r--r--tests/qemu-iotests/197.out8
-rw-r--r--tests/qemu-iotests/2222
-rw-r--r--tests/test-bdrv-drain.c43
7 files changed, 99 insertions, 14 deletions
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 937ed2f910..1a7b761304 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -180,12 +180,12 @@ static AHCIQState *ahci_boot(const char *cli, ...)
s = ahci_vboot(cli, ap);
va_end(ap);
} else {
- cli = "-drive if=none,id=drive0,file=%s,cache=writeback,format=%s"
+ cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
+ ",format=%s"
" -M q35 "
"-device ide-hd,drive=drive0 "
- "-global ide-hd.serial=%s "
"-global ide-hd.ver=%s";
- s = ahci_boot(cli, tmp_path, imgfmt, "testdisk", "version");
+ s = ahci_boot(cli, tmp_path, "testdisk", imgfmt, "version");
}
return s;
diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c
index ce665f1f83..24870b38f4 100644
--- a/tests/hd-geo-test.c
+++ b/tests/hd-geo-test.c
@@ -201,7 +201,7 @@ static void setup_mbr(int img_idx, MBRcontents mbr)
static int setup_ide(int argc, char *argv[], int argv_sz,
int ide_idx, const char *dev, int img_idx,
- MBRcontents mbr)
+ MBRcontents mbr, const char *opts)
{
char *s1, *s2, *s3;
@@ -216,7 +216,7 @@ static int setup_ide(int argc, char *argv[], int argv_sz,
s3 = g_strdup(",media=cdrom");
}
argc = append_arg(argc, argv, argv_sz,
- g_strdup_printf("%s%s%s", s1, s2, s3));
+ g_strdup_printf("%s%s%s%s", s1, s2, s3, opts));
g_free(s1);
g_free(s2);
g_free(s3);
@@ -260,7 +260,7 @@ static void test_ide_mbr(bool use_device, MBRcontents mbr)
for (i = 0; i < backend_last; i++) {
cur_ide[i] = &hd_chst[i][mbr];
dev = use_device ? (is_hd(cur_ide[i]) ? "ide-hd" : "ide-cd") : NULL;
- argc = setup_ide(argc, argv, ARGV_SIZE, i, dev, i, mbr);
+ argc = setup_ide(argc, argv, ARGV_SIZE, i, dev, i, mbr, "");
}
args = g_strjoinv(" ", argv);
qtest_start(args);
@@ -327,12 +327,16 @@ static void test_ide_drive_user(const char *dev, bool trans)
const CHST expected_chst = { secs / (4 * 32) , 4, 32, trans };
argc = setup_common(argv, ARGV_SIZE);
- opts = g_strdup_printf("%s,%scyls=%d,heads=%d,secs=%d",
- dev, trans ? "bios-chs-trans=lba," : "",
+ opts = g_strdup_printf("%s,%s%scyls=%d,heads=%d,secs=%d",
+ dev ?: "",
+ trans && dev ? "bios-chs-" : "",
+ trans ? "trans=lba," : "",
expected_chst.cyls, expected_chst.heads,
expected_chst.secs);
cur_ide[0] = &expected_chst;
- argc = setup_ide(argc, argv, ARGV_SIZE, 0, opts, backend_small, mbr_chs);
+ argc = setup_ide(argc, argv, ARGV_SIZE,
+ 0, dev ? opts : NULL, backend_small, mbr_chs,
+ dev ? "" : opts);
g_free(opts);
args = g_strjoinv(" ", argv);
qtest_start(args);
@@ -343,6 +347,22 @@ static void test_ide_drive_user(const char *dev, bool trans)
}
/*
+ * Test case: IDE device (if=ide) with explicit CHS
+ */
+static void test_ide_drive_user_chs(void)
+{
+ test_ide_drive_user(NULL, false);
+}
+
+/*
+ * Test case: IDE device (if=ide) with explicit CHS and translation
+ */
+static void test_ide_drive_user_chst(void)
+{
+ test_ide_drive_user(NULL, true);
+}
+
+/*
* Test case: IDE device (if=none) with explicit CHS
*/
static void test_ide_device_user_chs(void)
@@ -372,7 +392,8 @@ static void test_ide_drive_cd_0(void)
for (i = 0; i <= backend_empty; i++) {
ide_idx = backend_empty - i;
cur_ide[ide_idx] = &hd_chst[i][mbr_blank];
- argc = setup_ide(argc, argv, ARGV_SIZE, ide_idx, NULL, i, mbr_blank);
+ argc = setup_ide(argc, argv, ARGV_SIZE,
+ ide_idx, NULL, i, mbr_blank, "");
}
args = g_strjoinv(" ", argv);
qtest_start(args);
@@ -401,6 +422,8 @@ int main(int argc, char **argv)
qtest_add_func("hd-geo/ide/drive/mbr/blank", test_ide_drive_mbr_blank);
qtest_add_func("hd-geo/ide/drive/mbr/lba", test_ide_drive_mbr_lba);
qtest_add_func("hd-geo/ide/drive/mbr/chs", test_ide_drive_mbr_chs);
+ qtest_add_func("hd-geo/ide/drive/user/chs", test_ide_drive_user_chs);
+ qtest_add_func("hd-geo/ide/drive/user/chst", test_ide_drive_user_chst);
qtest_add_func("hd-geo/ide/drive/cd_0", test_ide_drive_cd_0);
qtest_add_func("hd-geo/ide/device/mbr/blank", test_ide_device_mbr_blank);
qtest_add_func("hd-geo/ide/device/mbr/lba", test_ide_device_mbr_lba);
diff --git a/tests/ide-test.c b/tests/ide-test.c
index f39431b1a9..2384c2c3e2 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -529,8 +529,8 @@ static void test_bmdma_no_busmaster(void)
static void test_bmdma_setup(void)
{
ide_test_start(
- "-drive file=%s,if=ide,cache=writeback,format=raw "
- "-global ide-hd.serial=%s -global ide-hd.ver=%s",
+ "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
+ "-global ide-hd.ver=%s",
tmp_path, "testdisk", "version");
qtest_irq_intercept_in(global_qtest, "ioapic");
}
@@ -561,8 +561,8 @@ static void test_identify(void)
int ret;
ide_test_start(
- "-drive file=%s,if=ide,cache=writeback,format=raw "
- "-global ide-hd.serial=%s -global ide-hd.ver=%s",
+ "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
+ "-global ide-hd.ver=%s",
tmp_path, "testdisk", "version");
dev = get_pci_device(&bmdma_bar, &ide_bar);
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
index 3ae4975eec..0369aa5cff 100755
--- a/tests/qemu-iotests/197
+++ b/tests/qemu-iotests/197
@@ -109,6 +109,15 @@ $QEMU_IO -f qcow2 -c map "$TEST_WRAP"
_check_test_img
$QEMU_IMG compare -f $IMGFMT -F qcow2 "$TEST_IMG" "$TEST_WRAP"
+echo
+echo '=== Partial final cluster ==='
+echo
+
+_make_test_img 1024
+$QEMU_IO -f $IMGFMT -C -c 'read 0 1024' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -f $IMGFMT -c map "$TEST_IMG"
+_check_test_img
+
# success, all done
echo '*** done'
status=0
diff --git a/tests/qemu-iotests/197.out b/tests/qemu-iotests/197.out
index 52b4137d7b..8febda5dea 100644
--- a/tests/qemu-iotests/197.out
+++ b/tests/qemu-iotests/197.out
@@ -23,4 +23,12 @@ can't open device TEST_DIR/t.wrap.qcow2: Can't use copy-on-read on read-only dev
1023.938 MiB (0x3fff0000) bytes not allocated at offset 3 GiB (0xc0010000)
No errors were found on the image.
Images are identical.
+
+=== Partial final cluster ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024
+read 1024/1024 bytes at offset 0
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+1 KiB (0x400) bytes allocated at offset 0 bytes (0x0)
+No errors were found on the image.
*** done
diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222
index ff3bfc1470..0ead56d574 100644
--- a/tests/qemu-iotests/222
+++ b/tests/qemu-iotests/222
@@ -25,6 +25,8 @@ import iotests
from iotests import log, qemu_img, qemu_io, qemu_io_silent
iotests.verify_platform(['linux'])
+iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk',
+ 'vhdx', 'raw'])
patterns = [("0x5d", "0", "64k"),
("0xd5", "1M", "64k"),
diff --git a/tests/test-bdrv-drain.c b/tests/test-bdrv-drain.c
index 291a050f86..17bb8508ae 100644
--- a/tests/test-bdrv-drain.c
+++ b/tests/test-bdrv-drain.c
@@ -1250,6 +1250,47 @@ static void test_detach_by_driver_cb(void)
test_detach_indirect(false);
}
+static void test_append_to_drained(void)
+{
+ BlockBackend *blk;
+ BlockDriverState *base, *overlay;
+ BDRVTestState *base_s, *overlay_s;
+
+ blk = blk_new(BLK_PERM_ALL, BLK_PERM_ALL);
+ base = bdrv_new_open_driver(&bdrv_test, "base", BDRV_O_RDWR, &error_abort);
+ base_s = base->opaque;
+ blk_insert_bs(blk, base, &error_abort);
+
+ overlay = bdrv_new_open_driver(&bdrv_test, "overlay", BDRV_O_RDWR,
+ &error_abort);
+ overlay_s = overlay->opaque;
+
+ do_drain_begin(BDRV_DRAIN, base);
+ g_assert_cmpint(base->quiesce_counter, ==, 1);
+ g_assert_cmpint(base_s->drain_count, ==, 1);
+ g_assert_cmpint(base->in_flight, ==, 0);
+
+ /* Takes ownership of overlay, so we don't have to unref it later */
+ bdrv_append(overlay, base, &error_abort);
+ g_assert_cmpint(base->in_flight, ==, 0);
+ g_assert_cmpint(overlay->in_flight, ==, 0);
+
+ g_assert_cmpint(base->quiesce_counter, ==, 1);
+ g_assert_cmpint(base_s->drain_count, ==, 1);
+ g_assert_cmpint(overlay->quiesce_counter, ==, 1);
+ g_assert_cmpint(overlay_s->drain_count, ==, 1);
+
+ do_drain_end(BDRV_DRAIN, base);
+
+ g_assert_cmpint(base->quiesce_counter, ==, 0);
+ g_assert_cmpint(base_s->drain_count, ==, 0);
+ g_assert_cmpint(overlay->quiesce_counter, ==, 0);
+ g_assert_cmpint(overlay_s->drain_count, ==, 0);
+
+ bdrv_unref(base);
+ blk_unref(blk);
+}
+
int main(int argc, char **argv)
{
int ret;
@@ -1308,6 +1349,8 @@ int main(int argc, char **argv)
g_test_add_func("/bdrv-drain/detach/parent_cb", test_detach_by_parent_cb);
g_test_add_func("/bdrv-drain/detach/driver_cb", test_detach_by_driver_cb);
+ g_test_add_func("/bdrv-drain/attach/drain", test_append_to_drained);
+
ret = g_test_run();
qemu_event_destroy(&done_event);
return ret;