[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/14] iotests: add test for blockdev-del(force=false)
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 14/14] iotests: add test for blockdev-del(force=false) |
Date: |
Mon, 7 Feb 2022 17:37:28 +0100 |
Test for new option: use NBD server killing to simulate failure on file
close.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
.../tests/blockdev-del-close-failure | 54 +++++++++++++++++++
.../tests/blockdev-del-close-failure.out | 4 ++
2 files changed, 58 insertions(+)
create mode 100755 tests/qemu-iotests/tests/blockdev-del-close-failure
create mode 100644 tests/qemu-iotests/tests/blockdev-del-close-failure.out
diff --git a/tests/qemu-iotests/tests/blockdev-del-close-failure
b/tests/qemu-iotests/tests/blockdev-del-close-failure
new file mode 100755
index 0000000000..12b442f43f
--- /dev/null
+++ b/tests/qemu-iotests/tests/blockdev-del-close-failure
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+#
+# Test blockdev-add force=false
+#
+# Copyright (c) 2022 Virtuozzo International GmbH.
+#
+# 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/>.
+#
+
+import iotests
+from iotests import qemu_img_create, qemu_img, qemu_nbd_popen, qemu_img_pipe
+
+iotests.script_initialize(supported_fmts=['qcow2'],
+ unsupported_imgopts=['compat'])
+
+disk, nbd_sock = iotests.file_path('disk', 'nbd-sock')
+size = '1M'
+
+assert qemu_img_create('-f', iotests.imgfmt, disk, size) == 0
+assert qemu_img('bitmap', '--add', disk, 'bitmap0') == 0
+assert 'bitmaps' in qemu_img_pipe('info', disk)
+
+vm = iotests.VM()
+vm.launch()
+
+with qemu_nbd_popen('-k', nbd_sock, '-f', 'raw', disk):
+ result = vm.qmp('blockdev-add', {
+ 'node-name': 'disk0',
+ 'driver': 'qcow2',
+ 'file': {
+ 'driver': 'nbd',
+ 'server': {
+ 'type': 'unix',
+ 'path': nbd_sock
+ }
+ }
+ })
+ assert result == {'return': {}}
+
+# Now bitmap is loaded and marked IN_USE in the image, but connection is lost
+# Bitmap can't be saved and blockdev-del(force=false) should fail
+vm.qmp_log('blockdev-del', node_name='disk0', force=False)
+vm.shutdown()
diff --git a/tests/qemu-iotests/tests/blockdev-del-close-failure.out
b/tests/qemu-iotests/tests/blockdev-del-close-failure.out
new file mode 100644
index 0000000000..4a4776cc98
--- /dev/null
+++ b/tests/qemu-iotests/tests/blockdev-del-close-failure.out
@@ -0,0 +1,4 @@
+Start NBD server
+Kill NBD server
+{"execute": "blockdev-del", "arguments": {"force": false, "node-name":
"disk0"}}
+{"error": {"class": "GenericError", "desc": "Failed to flush node 'disk0'"}}
--
2.31.1
- [PATCH 00/14] block: blockdev-del force=false, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 02/14] block: drop bdrv_detach_child(), Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 01/14] block: refactor bdrv_remove_file_or_backing_child to bdrv_remove_child, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 04/14] block: add bdrv_try_set_aio_context_tran transaction action, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 10/14] qcow2: qcow2_inactivate(): don't call qcow2_mark_clean() when RO, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 14/14] iotests: add test for blockdev-del(force=false),
Vladimir Sementsov-Ogievskiy <=
- [PATCH 06/14] block: bdrv_delete(): drop unnecessary zeroing, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 08/14] qapi/block-core: add 'force' argument to blockdev-del, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 03/14] block: bdrv_refresh_perms(): allow external tran, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 05/14] block: merge bdrv_delete and bdrv_close, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 12/14] qcow2: implement .bdrv_close_safe, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 13/14] block/file-posix: implement .bdrv_close_safe, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 09/14] qcow2: qcow2_inactivate(): use qcow2_flush_caches(), Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 07/14] block: implemet bdrv_try_unref(), Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 11/14] qcow2: refactor qcow2_inactivate, Vladimir Sementsov-Ogievskiy, 2022/02/07