[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.3 58/87] iotests: add test for stream job with an unaligned
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.3 58/87] iotests: add test for stream job with an unaligned prefetch read |
Date: |
Wed, 10 Apr 2024 10:22:31 +0300 |
From: Fiona Ebner <f.ebner@proxmox.com>
Previously, bdrv_pad_request() could not deal with a NULL qiov when
a read needed to be aligned. During prefetch, a stream job will pass a
NULL qiov. Add a test case to cover this scenario.
By accident, also covers a previous race during shutdown, where block
graph changes during iteration in bdrv_flush_all() could lead to
unreferencing the wrong block driver state and an assertion failure
later.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <20240322095009.346989-5-f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 12d7b3bbd3333cededd3b695501d8d247239d769)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/qemu-iotests/tests/stream-unaligned-prefetch
b/tests/qemu-iotests/tests/stream-unaligned-prefetch
new file mode 100755
index 0000000000..546db1d369
--- /dev/null
+++ b/tests/qemu-iotests/tests/stream-unaligned-prefetch
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+# group: rw quick
+#
+# Test what happens when a stream job does an unaligned prefetch read
+# which requires padding while having a NULL qiov.
+#
+# Copyright (C) Proxmox Server Solutions 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 os
+import iotests
+from iotests import imgfmt, qemu_img_create, qemu_io, QMPTestCase
+
+image_size = 1 * 1024 * 1024
+cluster_size = 64 * 1024
+base = os.path.join(iotests.test_dir, 'base.img')
+top = os.path.join(iotests.test_dir, 'top.img')
+
+class TestStreamUnalignedPrefetch(QMPTestCase):
+ def setUp(self) -> None:
+ """
+ Create two images:
+ - base image {base} with {cluster_size // 2} bytes allocated
+ - top image {top} without any data allocated and coarser
+ cluster size
+
+ Attach a compress filter for the top image, because that
+ requires that the request alignment is the top image's cluster
+ size.
+ """
+ qemu_img_create('-f', imgfmt,
+ '-o', 'cluster_size={}'.format(cluster_size // 2),
+ base, str(image_size))
+ qemu_io('-c', f'write 0 {cluster_size // 2}', base)
+ qemu_img_create('-f', imgfmt,
+ '-o', 'cluster_size={}'.format(cluster_size),
+ top, str(image_size))
+
+ self.vm = iotests.VM()
+ self.vm.add_blockdev(self.vm.qmp_to_opts({
+ 'driver': imgfmt,
+ 'node-name': 'base',
+ 'file': {
+ 'driver': 'file',
+ 'filename': base
+ }
+ }))
+ self.vm.add_blockdev(self.vm.qmp_to_opts({
+ 'driver': 'compress',
+ 'node-name': 'compress-top',
+ 'file': {
+ 'driver': imgfmt,
+ 'node-name': 'top',
+ 'file': {
+ 'driver': 'file',
+ 'filename': top
+ },
+ 'backing': 'base'
+ }
+ }))
+ self.vm.launch()
+
+ def tearDown(self) -> None:
+ self.vm.shutdown()
+ os.remove(top)
+ os.remove(base)
+
+ def test_stream_unaligned_prefetch(self) -> None:
+ self.vm.cmd('block-stream', job_id='stream', device='compress-top')
+
+
+if __name__ == '__main__':
+ iotests.main(supported_fmts=['qcow2'], supported_protocols=['file'])
diff --git a/tests/qemu-iotests/tests/stream-unaligned-prefetch.out
b/tests/qemu-iotests/tests/stream-unaligned-prefetch.out
new file mode 100644
index 0000000000..ae1213e6f8
--- /dev/null
+++ b/tests/qemu-iotests/tests/stream-unaligned-prefetch.out
@@ -0,0 +1,5 @@
+.
+----------------------------------------------------------------------
+Ran 1 tests
+
+OK
--
2.39.2
- [Stable-8.2.3 49/87] target/hppa: fix do_stdby_e(), (continued)
- [Stable-8.2.3 49/87] target/hppa: fix do_stdby_e(), Michael Tokarev, 2024/04/10
- [Stable-8.2.3 51/87] docs/conf.py: Remove usage of distutils, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 52/87] target/loongarch: Fix qemu-system-loongarch64 assert failed with the option '-d int', Michael Tokarev, 2024/04/10
- [Stable-8.2.3 54/87] vdpa-dev: Fix initialisation order to restore VDUSE compatibility, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 53/87] target/s390x: Use mutable temporary value for op_ts, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 56/87] block-backend: fix edge case in bdrv_next() where BDS associated to BB changes, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 55/87] block/io: accept NULL qiov in bdrv_pad_request, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 57/87] block-backend: fix edge case in bdrv_next_cleanup() where BDS associated to BB changes, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 59/87] target/i386/tcg: Enable page walking from MMIO memory, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 61/87] monitor/hmp-cmds-target: Append a space in error message in gpa2hva(), Michael Tokarev, 2024/04/10
- [Stable-8.2.3 58/87] iotests: add test for stream job with an unaligned prefetch read,
Michael Tokarev <=
- [Stable-8.2.3 60/87] hw/scsi/scsi-generic: Fix io_timeout property not applying, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 63/87] trans_rvv.c.inc: set vstart = 0 in int scalar move insns, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 62/87] target/riscv/vector_helper.c: set vstart = 0 in GEN_VEXT_VSLIDEUP_VX(), Michael Tokarev, 2024/04/10
- [Stable-8.2.3 65/87] target/riscv: always clear vstart in whole vec move insns, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 66/87] target/riscv/vector_helpers: do early exit when vstart >= vl, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 64/87] target/riscv/vector_helper.c: fix 'vmvr_v' memcpy endianess, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 67/87] target/riscv/vector_helper.c: optimize loops in ldst helpers, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 68/87] hw/intc: Update APLIC IDC after claiming iforce register, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 69/87] target/riscv: rvv: Remove the dependency of Zvfbfmin to Zfbfmin, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 70/87] target/riscv: Fix mode in riscv_tlb_fill, Michael Tokarev, 2024/04/10