aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-03-06 17:15:35 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-03-06 17:15:36 +0000
commit67f17e23baca5dd545fe98b01169cc351a70fe35 (patch)
treefaab89fb46541f6d2d79d27e95fa9ce1720091a3 /tests
parentc2058285790fd305c06847b1bb9685c4302a0aec (diff)
parent1de6b45fb5c1489b450df7d1a4c692bba9678ce6 (diff)
downloadqemu-67f17e23baca5dd545fe98b01169cc351a70fe35.zip
qemu-67f17e23baca5dd545fe98b01169cc351a70fe35.tar.gz
qemu-67f17e23baca5dd545fe98b01169cc351a70fe35.tar.bz2
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - Add qemu-storage-daemon (still experimental) - rbd: Add support for ceph namespaces - Fix bdrv_reopen() with backing file in different AioContext - qcow2: Fix read-write reopen with persistent dirty bitmaps - qcow2: Fix alloc_cluster_abort() for pre-existing clusters # gpg: Signature made Fri 06 Mar 2020 17:12:31 GMT # gpg: using RSA key 7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (29 commits) block: bdrv_reopen() with backing file in different AioContext iotests: Refactor blockdev-reopen test for iothreads block/rbd: Add support for ceph namespaces qemu-storage-daemon: Add --monitor option monitor: Add allow_hmp parameter to monitor_init() hmp: Fail gracefully if chardev is already in use qmp: Fail gracefully if chardev is already in use monitor: Create QAPIfied monitor_init() qapi: Create 'pragma' module stubs: Update monitor stubs for qemu-storage-daemon qemu-storage-daemon: Add --chardev option qemu-storage-daemon: Add main loop qemu-storage-daemon: Add --export option blockdev-nbd: Boxed argument type for nbd-server-add qemu-storage-daemon: Add --nbd-server option qemu-storage-daemon: Add --object option qapi: Flatten object-add qemu-storage-daemon: Add --blockdev option block: Move sysemu QMP commands to QAPI block module block: Move common QMP commands to block-core QAPI module ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/qemu-iotests/02653
-rw-r--r--tests/qemu-iotests/026.out16
-rw-r--r--tests/qemu-iotests/026.out.nocache16
-rwxr-xr-xtests/qemu-iotests/24545
-rw-r--r--tests/qemu-iotests/245.out4
-rw-r--r--tests/test-util-sockets.c4
6 files changed, 124 insertions, 14 deletions
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
index a4aa747..b05a469 100755
--- a/tests/qemu-iotests/026
+++ b/tests/qemu-iotests/026
@@ -30,6 +30,7 @@ _cleanup()
{
_cleanup_test_img
rm "$TEST_DIR/blkdebug.conf"
+ rm -f "$TEST_IMG.data_file"
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -218,6 +219,58 @@ _make_test_img 64M
$QEMU_IO -c "write 0 1M" -c "write 0 1M" "$BLKDBG_TEST_IMG" | _filter_qemu_io
_check_test_img
+echo
+echo === Avoid freeing preallocated zero clusters on failure ===
+echo
+
+cat > "$TEST_DIR/blkdebug.conf" <<EOF
+[inject-error]
+event = "write_aio"
+errno = "5"
+once = "on"
+EOF
+
+_make_test_img $CLUSTER_SIZE
+# Create a preallocated zero cluster
+$QEMU_IO -c "write 0 $CLUSTER_SIZE" -c "write -z 0 $CLUSTER_SIZE" "$TEST_IMG" \
+ | _filter_qemu_io
+# Try to overwrite it (prompting an I/O error from blkdebug), thus
+# triggering the alloc abort code
+$QEMU_IO -c "write 0 $CLUSTER_SIZE" "$BLKDBG_TEST_IMG" | _filter_qemu_io
+
+_check_test_img
+
+echo
+echo === Avoid freeing external data clusters on failure ===
+echo
+
+# Similar test as the last one, except we test what happens when there
+# is an error when writing to an external data file instead of when
+# writing to a preallocated zero cluster
+_make_test_img -o "data_file=$TEST_IMG.data_file" $CLUSTER_SIZE
+
+# Put blkdebug above the data-file, and a raw node on top of that so
+# that blkdebug will see a write_aio event and emit an error
+$QEMU_IO -c "write 0 $CLUSTER_SIZE" \
+ "json:{
+ 'driver': 'qcow2',
+ 'file': { 'driver': 'file', 'filename': '$TEST_IMG' },
+ 'data-file': {
+ 'driver': 'raw',
+ 'file': {
+ 'driver': 'blkdebug',
+ 'config': '$TEST_DIR/blkdebug.conf',
+ 'image': {
+ 'driver': 'file',
+ 'filename': '$TEST_IMG.data_file'
+ }
+ }
+ }
+ }" \
+ | _filter_qemu_io
+
+_check_test_img
+
# success, all done
echo "*** done"
rm -f $seq.full
diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out
index ff0817b..c1b3b58 100644
--- a/tests/qemu-iotests/026.out
+++ b/tests/qemu-iotests/026.out
@@ -643,4 +643,20 @@ write failed: Input/output error
wrote 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
No errors were found on the image.
+
+=== Avoid freeing preallocated zero clusters on failure ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024
+wrote 1024/1024 bytes at offset 0
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1024/1024 bytes at offset 0
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+write failed: Input/output error
+No errors were found on the image.
+
+=== Avoid freeing external data clusters on failure ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file
+write failed: Input/output error
+No errors were found on the image.
*** done
diff --git a/tests/qemu-iotests/026.out.nocache b/tests/qemu-iotests/026.out.nocache
index 495d013..8d50016 100644
--- a/tests/qemu-iotests/026.out.nocache
+++ b/tests/qemu-iotests/026.out.nocache
@@ -651,4 +651,20 @@ write failed: Input/output error
wrote 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
No errors were found on the image.
+
+=== Avoid freeing preallocated zero clusters on failure ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024
+wrote 1024/1024 bytes at offset 0
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 1024/1024 bytes at offset 0
+1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+write failed: Input/output error
+No errors were found on the image.
+
+=== Avoid freeing external data clusters on failure ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file
+write failed: Input/output error
+No errors were found on the image.
*** done
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
index 489bf78..1001275 100755
--- a/tests/qemu-iotests/245
+++ b/tests/qemu-iotests/245
@@ -970,8 +970,7 @@ class TestBlockdevReopen(iotests.QMPTestCase):
self.assertEqual(self.get_node('hd1'), None)
self.assert_qmp(self.get_node('hd2'), 'ro', True)
- # We don't allow setting a backing file that uses a different AioContext
- def test_iothreads(self):
+ def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None):
opts = hd_opts(0)
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
self.assert_qmp(result, 'return', {})
@@ -986,20 +985,46 @@ class TestBlockdevReopen(iotests.QMPTestCase):
result = self.vm.qmp('object-add', qom_type='iothread', id='iothread1')
self.assert_qmp(result, 'return', {})
- result = self.vm.qmp('x-blockdev-set-iothread', node_name='hd0', iothread='iothread0')
+ result = self.vm.qmp('device_add', driver='virtio-scsi', id='scsi0',
+ iothread=iothread_a)
self.assert_qmp(result, 'return', {})
- self.reopen(opts, {'backing': 'hd2'}, "Cannot use a new backing file with a different AioContext")
-
- result = self.vm.qmp('x-blockdev-set-iothread', node_name='hd2', iothread='iothread1')
+ result = self.vm.qmp('device_add', driver='virtio-scsi', id='scsi1',
+ iothread=iothread_b)
self.assert_qmp(result, 'return', {})
- self.reopen(opts, {'backing': 'hd2'}, "Cannot use a new backing file with a different AioContext")
+ if iothread_a:
+ result = self.vm.qmp('device_add', driver='scsi-hd', drive='hd0',
+ share_rw=True, bus="scsi0.0")
+ self.assert_qmp(result, 'return', {})
- result = self.vm.qmp('x-blockdev-set-iothread', node_name='hd2', iothread='iothread0')
- self.assert_qmp(result, 'return', {})
+ if iothread_b:
+ result = self.vm.qmp('device_add', driver='scsi-hd', drive='hd2',
+ share_rw=True, bus="scsi1.0")
+ self.assert_qmp(result, 'return', {})
- self.reopen(opts, {'backing': 'hd2'})
+ # Attaching the backing file may or may not work
+ self.reopen(opts, {'backing': 'hd2'}, errmsg)
+
+ # But removing the backing file should always work
+ self.reopen(opts, {'backing': None})
+
+ self.vm.shutdown()
+
+ # We don't allow setting a backing file that uses a different AioContext if
+ # neither of them can switch to the other AioContext
+ def test_iothreads_error(self):
+ self.run_test_iothreads('iothread0', 'iothread1',
+ "Cannot change iothread of active block backend")
+
+ def test_iothreads_compatible_users(self):
+ self.run_test_iothreads('iothread0', 'iothread0')
+
+ def test_iothreads_switch_backing(self):
+ self.run_test_iothreads('iothread0', None)
+
+ def test_iothreads_switch_overlay(self):
+ self.run_test_iothreads(None, 'iothread0')
if __name__ == '__main__':
iotests.main(supported_fmts=["qcow2"],
diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out
index a19de52..682b933 100644
--- a/tests/qemu-iotests/245.out
+++ b/tests/qemu-iotests/245.out
@@ -1,6 +1,6 @@
-..................
+.....................
----------------------------------------------------------------------
-Ran 18 tests
+Ran 21 tests
OK
{"execute": "job-finalize", "arguments": {"id": "commit0"}}
diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
index 8ce55ef..5fd947c 100644
--- a/tests/test-util-sockets.c
+++ b/tests/test-util-sockets.c
@@ -71,8 +71,8 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
*/
__thread Monitor *cur_mon;
int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); }
-void monitor_init_qmp(Chardev *chr, bool pretty) {}
-void monitor_init_hmp(Chardev *chr, bool use_readline) {}
+void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp) {}
+void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp) {}
static void test_socket_fd_pass_name_good(void)