All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] fix tests on FreeBSD
@ 2026-11-25 19:16 Roman Bogorodskiy
  2026-11-25 19:16 ` [PATCH v2 01/10] iotests: use gsed when necessary Roman Bogorodskiy
                   ` (9 more replies)
  0 siblings, 10 replies; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Roman Bogorodskiy

This series fixes test failures on FreeBSD. Most of the affected tests
happen to be iotests.

This brings full test run from:

Ok:                1253
Fail:              72
Skipped:           669
Timeout:           2

to:

Ok:                1343
Fail:              0
Skipped:           653

thus, a successful run.

Changes since v1:

 - 01/10: use gsed only when necessary, not everywhere
 - 03/10: use more general "status=noxfer" check for dd
 - 04/10: adjust code comment

Roman Bogorodskiy (10):
  iotests: use gsed when necessary
  iotests: fix default QEMU_PROG on FreeBSD amd64
  iotests: fix the dd() wrapper
  tests/qtest: unset socket timeout
  iotests: skip preallocation tests if not supported
  iotests: mark 149 as Linux-only
  iotests: fix test 162
  iotests: fix possible race in 145
  iotests: properly skip tests that require OFD locking support
  iotests: fix test 211

 tests/qemu-iotests/115                        |  2 +-
 tests/qemu-iotests/145                        |  5 ++++-
 tests/qemu-iotests/149                        |  3 ++-
 tests/qemu-iotests/162                        | 14 ++++++++++---
 tests/qemu-iotests/211                        | 19 ++++++++++++++++-
 tests/qemu-iotests/211.out                    |  1 -
 tests/qemu-iotests/296                        |  1 +
 tests/qemu-iotests/298                        | 10 +++++++++
 tests/qemu-iotests/common.filter              |  6 +++---
 tests/qemu-iotests/common.rc                  | 21 +++++++------------
 tests/qemu-iotests/iotests.py                 | 16 ++++++++++++++
 tests/qemu-iotests/testenv.py                 |  2 ++
 .../qemu-iotests/tests/migration-permissions  |  3 +++
 tests/qemu-iotests/tests/mirror-top-perms     |  3 +++
 tests/qtest/libqtest.c                        | 13 ++++++++++++
 15 files changed, 95 insertions(+), 24 deletions(-)

-- 
2.56.0



^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v2 01/10] iotests: use gsed when necessary
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:31   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 02/10] iotests: fix default QEMU_PROG on FreeBSD amd64 Roman Bogorodskiy
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

Some iotests fail on FreeBSD because the tests call sed
directly, and BSD sed is not always compatible with GNU sed.
As common.rc already provides the gsed() wrapper, use it
instead if needed.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/115           | 2 +-
 tests/qemu-iotests/common.filter | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115
index 5c8a12f85a..e3ff91de7a 100755
--- a/tests/qemu-iotests/115
+++ b/tests/qemu-iotests/115
@@ -78,7 +78,7 @@ _make_test_img -o "refcount_bits=64,cluster_size=512,preallocation=metadata" 256
 # qemu-img check for that purpose, too.
 
 $QEMU_IMG check "$TEST_IMG" | \
-    sed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
+    gsed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
         -e '/^Image end offset/d'
 
 # (Note that we cannot use _check_test_img because that function filters out the
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index ce4213cb97..f7211a0a29 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -130,7 +130,7 @@ _filter_actual_image_size()
 # Filename filters for qemu-img create
 _filter_img_create_filenames()
 {
-    sed \
+    gsed \
         -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
         -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
         -e "s#$TEST_DIR#TEST_DIR#g" \
@@ -296,7 +296,7 @@ _filter_qemu_img_map()
         data_file_filter=(-e "s#$data_file_pattern#\\1#")
     fi
 
-    sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
+    gsed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
         -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
         -e 's/Mapped to *//' \
         "${data_file_filter[@]}" \
@@ -310,7 +310,7 @@ _filter_nbd()
     # receive callbacks sometimes, making them unreliable.
     #
     # Filter out the TCP port number since this changes between runs.
-    sed -e '/nbd\/.*\.c:/d' \
+    gsed -e '/nbd\/.*\.c:/d' \
         -e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
         -e 's#localhost:[0-9]*#localhost:PORT#g' \
         -e 's#host=127\.0\.0\.1,port=[0-9]*#host=127.0.0.1,port=PORT#g' \
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 02/10] iotests: fix default QEMU_PROG on FreeBSD amd64
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
  2026-11-25 19:16 ` [PATCH v2 01/10] iotests: use gsed when necessary Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:09   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 03/10] iotests: fix the dd() wrapper Roman Bogorodskiy
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

testenv.py uses 'qemu-system-{arch}' as a default
value for QEMU_PROG and it obtains arch from os.uname().machine.
As FreeBSD reports it as 'amd64', normalize it to 'x86_64'
to use a proper qemu-system binary by default.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/testenv.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index 53c9b5d196..20595e680f 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -171,6 +171,8 @@ def root(*names: str) -> str:
         arch = os.uname().machine
         if 'ppc64' in arch:
             arch = 'ppc64'
+        elif arch == 'amd64':
+            arch = 'x86_64'
 
         self.qemu_prog = os.getenv('QEMU_PROG', root(f'qemu-system-{arch}'))
         if not os.path.exists(self.qemu_prog):
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 03/10] iotests: fix the dd() wrapper
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
  2026-11-25 19:16 ` [PATCH v2 01/10] iotests: use gsed when necessary Roman Bogorodskiy
  2026-11-25 19:16 ` [PATCH v2 02/10] iotests: fix default QEMU_PROG on FreeBSD amd64 Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:10   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 04/10] tests/qtest: unset socket timeout Roman Bogorodskiy
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Brad Smith, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

The dd() wrapper uses status=noxfer on Linux. It's also required on
other systems such as FreeBSD.

Rather than adding OS specific conditions, check whether dd supports
status=noxfer and append it to the command if it does.

Suggested-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/common.rc | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 262fe63da8..a89aa48fb1 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -52,21 +52,16 @@ if ! command -v gsed >/dev/null 2>&1; then
     fi
 fi
 
+if command dd if=/dev/null of=/dev/null status=noxfer >/dev/null 2>&1
+then
+    DD_NOXFER="status=noxfer"
+else
+    DD_NOXFER=""
+fi
+
 dd()
 {
-   if [ "$HOSTOS" == "Linux" ]
-   then
-        command dd --help | grep noxfer > /dev/null 2>&1
-
-        if [ "$?" -eq 0 ]
-            then
-                command dd status=noxfer $@
-            else
-                command dd $@
-            fi
-   else
-        command dd $@
-   fi
+    command dd $DD_NOXFER "$@"
 }
 
 # poke_file 'test.img' 512 '\xff\xfe'
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 04/10] tests/qtest: unset socket timeout
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
                   ` (2 preceding siblings ...)
  2026-11-25 19:16 ` [PATCH v2 03/10] iotests: fix the dd() wrapper Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:12   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 05/10] iotests: skip preallocation tests if not supported Roman Bogorodskiy
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Brad Smith, Fabiano Rosas, Laurent Vivier,
	Paolo Bonzini

The qtest_socket_accept() sets a timeout on a listening
socket. FreeBSD also inherits this timeout for the accepted socket,
which breaks some tests. Explicitly set timeout on the accepted socket
to 0.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Brad Smith <brad@comstyle.com>
---
 tests/qtest/libqtest.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 7f66c1bbb3..8a7989811d 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -151,6 +151,19 @@ static int qtest_socket_accept(QTestState *s, int sock)
     }
     if (ret == -1) {
         fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno));
+    } else {
+        /*
+         * Accepted sockets might inherit listener's timeout on
+         * BSD systems, so set it to 0 explicitly
+         */
+        memset(&timeout, 0, sizeof(timeout));
+        if (setsockopt(ret, SOL_SOCKET, SO_RCVTIMEO,
+                       (void *)&timeout, sizeof(timeout))) {
+            fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n",
+                    __func__, strerror(errno));
+            close(ret);
+            return -1;
+        }
     }
 
     return ret;
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 05/10] iotests: skip preallocation tests if not supported
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
                   ` (3 preceding siblings ...)
  2026-11-25 19:16 ` [PATCH v2 04/10] tests/qtest: unset socket timeout Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:53   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 06/10] iotests: mark 149 as Linux-only Roman Bogorodskiy
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

Skip preallocation tests requiring efficient zero writes if
not supported. Support is detected by probing
"qemu-io write -z -n".

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/298 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298
index f2b94077f4..869bdb3242 100755
--- a/tests/qemu-iotests/298
+++ b/tests/qemu-iotests/298
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+import errno
 import os
 import iotests
 
@@ -32,6 +33,15 @@ drive_opts = f'node-name=disk,driver={iotests.imgfmt},' \
 
 class TestPreallocateBase(iotests.QMPTestCase):
     def setUp(self):
+        with iotests.FilePath('zero-probe.raw') as probe_path:
+            iotests.qemu_img_create('-f', 'raw', probe_path, '1M')
+            ret = iotests.qemu_io('-f', 'raw', '-c', 'write -z -n -q 0 1M',
+                                  probe_path, check=False)
+            if ret.returncode != 0:
+                if os.strerror(errno.ENOTSUP) in ret.stdout:
+                    self.case_skip("File backend does not support "
+                                   "efficient zero writes")
+            self.assertEqual(ret.returncode, 0, ret.stdout)
         iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB))
 
     def tearDown(self):
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 06/10] iotests: mark 149 as Linux-only
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
                   ` (4 preceding siblings ...)
  2026-11-25 19:16 ` [PATCH v2 05/10] iotests: skip preallocation tests if not supported Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:14   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 07/10] iotests: fix test 162 Roman Bogorodskiy
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

Test 149 requires Linux specific dm-crypt and cryptsetup,
so mark it supported only on Linux.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/149 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index 6dff39a28a..7b7afbd539 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -404,7 +404,8 @@ def test_once(config, qemu_img=False):
 
 
 # Obviously we only work with the luks image format
-iotests.script_initialize(supported_fmts=['luks'])
+iotests.script_initialize(supported_fmts=['luks'],
+                          supported_platforms=['linux'])
 
 # We need sudo in order to run cryptsetup to create
 # dm-crypt devices. This is safe to use on any
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 07/10] iotests: fix test 162
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
                   ` (5 preceding siblings ...)
  2026-11-25 19:16 ` [PATCH v2 06/10] iotests: mark 149 as Linux-only Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:20   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 08/10] iotests: fix possible race in 145 Roman Bogorodskiy
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

Test 162 expects Linux error messages. These messages could
be different on other OSes, on FreeBSD for example.
Add a _normalize_errors() helper to normalize these
error messages.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/162 | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
index 4f01611886..73a0c43e2c 100755
--- a/tests/qemu-iotests/162
+++ b/tests/qemu-iotests/162
@@ -33,6 +33,12 @@ _cleanup()
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
+_normalize_errors()
+{
+    sed -e "s/Name does not resolve/Name or service not known/" \
+        -e "s/Can't assign requested address/Connection refused/"
+}
+
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
@@ -45,7 +51,7 @@ echo '=== NBD ==='
 # NBD expects all of its arguments to be strings
 
 # So this should not crash
-$QEMU_IMG info 'json:{"driver": "nbd", "host": -1}'
+$QEMU_IMG info 'json:{"driver": "nbd", "host": -1}' 2>&1 | _normalize_errors
 
 # And this should not treat @port as if it had not been specified
 # (We need to set up a server here, because the error message for "Connection
@@ -78,10 +84,12 @@ echo '=== SSH ==='
 # expected to be an integer
 
 # So "0" should be converted to an integer here (instead of crashing)
-$QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}'
+$QEMU_IMG info \
+    'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}' 2>&1 | \
+        _normalize_errors
 # The same, basically (all values for --image-opts are seen as strings in qemu)
 $QEMU_IMG info --image-opts \
-    driver=ssh,host=localhost,port=0,path=/foo
+    driver=ssh,host=localhost,port=0,path=/foo 2>&1 | _normalize_errors
 
 # This, however, should fail because of the wrong type
 $QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}'
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 08/10] iotests: fix possible race in 145
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
                   ` (6 preceding siblings ...)
  2026-11-25 19:16 ` [PATCH v2 07/10] iotests: fix test 162 Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:21   ` Daniel P. Berrangé
  2026-11-25 19:16 ` [PATCH v2 09/10] iotests: properly skip tests that require OFD locking support Roman Bogorodskiy
  2026-11-25 19:17 ` [PATCH v2 10/10] iotests: fix test 211 Roman Bogorodskiy
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

Test 145 uses "-incoming 'exec:true'" argument for QEMU.
It is possible that it reads the migration input before
processing "quit", so it'll report an error and the test
will fail.

Fix by using a migration socket, similarly to how test 181
already does that.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/145 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/145 b/tests/qemu-iotests/145
index bbc3c34c19..3711250c7d 100755
--- a/tests/qemu-iotests/145
+++ b/tests/qemu-iotests/145
@@ -25,8 +25,11 @@ echo "QA output created by $seq"
 
 status=1	# failure is the default!
 
+MIG_SOCKET="${SOCK_DIR}/migrate"
+
 _cleanup()
 {
+	rm -f "${MIG_SOCKET}"
 	_cleanup_test_img
 	true
 }
@@ -56,7 +59,7 @@ else
 fi
 
 echo quit | $QEMU -nographic $SYSEMU_EXTRA_ARGS -drive $SYSEMU_DRIVE_ARG \
-                  -incoming 'exec:true' -snapshot -serial none -monitor stdio \
+                  -incoming "unix:${MIG_SOCKET}" -snapshot -serial none -monitor stdio \
           | _filter_qemu | _filter_hmp
 
 # success, all done
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 09/10] iotests: properly skip tests that require OFD locking support
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
                   ` (7 preceding siblings ...)
  2026-11-25 19:16 ` [PATCH v2 08/10] iotests: fix possible race in 145 Roman Bogorodskiy
@ 2026-11-25 19:16 ` Roman Bogorodskiy
  2026-11-26  9:23   ` Daniel P. Berrangé
  2026-11-25 19:17 ` [PATCH v2 10/10] iotests: fix test 211 Roman Bogorodskiy
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

Tests 296, qemu-iotests/tests/migration-permissions, and
tests/mirror-top-perms require OFD locking support and fail when
it's not available.

Add the supports_ofd_lock() and verify_ofd_lock() helpers and
use them to skip these tests when necessary.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/296                         |  1 +
 tests/qemu-iotests/iotests.py                  | 16 ++++++++++++++++
 tests/qemu-iotests/tests/migration-permissions |  3 +++
 tests/qemu-iotests/tests/mirror-top-perms      |  3 +++
 4 files changed, 23 insertions(+)

diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296
index 2b63cefff0..84fb8d0d9b 100755
--- a/tests/qemu-iotests/296
+++ b/tests/qemu-iotests/296
@@ -273,6 +273,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase):
 
 
 if __name__ == '__main__':
+    iotests.verify_ofd_lock()
     # support only raw luks since luks encrypted qcow2 is a proper
     # format driver which doesn't allow any sharing
     iotests.activate_logging()
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 7017d2016c..90f25272d4 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -1588,6 +1588,22 @@ def verify_qcow2_zstd_compression():
     if not supports_qcow2_zstd_compression():
         notrun('zstd compression not supported')
 
+def supports_ofd_lock() -> bool:
+    with FilePath('ofdlock.raw') as img_file:
+        qemu_img_create('-f', 'raw', img_file, '1M')
+        res = qemu_img('info', '--image-opts',
+                       f'driver=file,locking=on,filename={img_file}',
+                       check=False)
+        res.check_returncode()
+        if "falling back to POSIX file" in res.stdout:
+            return False
+        else:
+            return True
+
+def verify_ofd_lock():
+    if not supports_ofd_lock():
+        notrun('OFD locking is unavailable')
+
 def qemu_pipe(*args: str) -> str:
     """
     Run qemu with an option to print something and exit (e.g. a help option).
diff --git a/tests/qemu-iotests/tests/migration-permissions b/tests/qemu-iotests/tests/migration-permissions
index 0deaad2d3a..7f943113e9 100755
--- a/tests/qemu-iotests/tests/migration-permissions
+++ b/tests/qemu-iotests/tests/migration-permissions
@@ -30,6 +30,9 @@ mig_sock = os.path.join(iotests.sock_dir, 'mig.sock')
 
 class TestMigrationPermissions(iotests.QMPTestCase):
     def setUp(self):
+        if not iotests.supports_ofd_lock():
+            self.case_skip("OFD locking is unavailable")
+
         qemu_img_create('-f', imgfmt, test_img, '1M')
 
         # Set up two VMs (source and destination) accessing the same raw
diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests/tests/mirror-top-perms
index fab9907e92..653f2e4a6d 100755
--- a/tests/qemu-iotests/tests/mirror-top-perms
+++ b/tests/qemu-iotests/tests/mirror-top-perms
@@ -33,6 +33,9 @@ source = os.path.join(iotests.test_dir, 'source.img')
 
 class TestMirrorTopPerms(iotests.QMPTestCase):
     def setUp(self):
+        if not iotests.supports_ofd_lock():
+            self.case_skip("OFD locking is unavailable")
+
         qemu_img('create', '-f', iotests.imgfmt, source, str(image_size))
         self.vm = iotests.VM()
         self.vm.add_drive(source)
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v2 10/10] iotests: fix test 211
  2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
                   ` (8 preceding siblings ...)
  2026-11-25 19:16 ` [PATCH v2 09/10] iotests: properly skip tests that require OFD locking support Roman Bogorodskiy
@ 2026-11-25 19:17 ` Roman Bogorodskiy
  2026-11-26  9:27   ` Daniel P. Berrangé
  9 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-25 19:17 UTC (permalink / raw)
  To: qemu-devel
  Cc: Roman Bogorodskiy, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

Test 211 compares "qemu-img map" output against a fixed expected layout.
As this layout depends on the host filesystem, the test might fail.

Move away from direct output comparison and ensure correctness by
asserting the essential fields.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/qemu-iotests/211     | 19 ++++++++++++++++++-
 tests/qemu-iotests/211.out |  1 -
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
index 1a3b4596c8..0b1fa7b33d 100755
--- a/tests/qemu-iotests/211
+++ b/tests/qemu-iotests/211
@@ -107,7 +107,24 @@ with iotests.FilePath('t.vdi') as disk_path, \
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
-    iotests.log(iotests.qemu_img_map(disk_path))
+    img_map = iotests.qemu_img_map(disk_path)
+
+    assert len(img_map) > 0
+    assert img_map[0]['start'] == 0
+    mapping_offset = img_map[0]['offset'] - img_map[0]['start']
+    for i, ext in enumerate(img_map):
+        assert ext['length'] > 0
+        assert ext['compressed'] is False
+        assert ext['present'] is True
+        assert ext['data'] is True
+        assert ext['depth'] == 0
+        assert 'offset' in ext
+        if i != 0:
+            assert ext['offset'] - ext['start'] == mapping_offset
+            assert img_map[i - 1]['start'] + img_map[i - 1]['length'] == \
+                    ext['start']
+
+    assert img_map[-1]['start'] + img_map[-1]['length'] == size
 
     #
     # Invalid BlockdevRef
diff --git a/tests/qemu-iotests/211.out b/tests/qemu-iotests/211.out
index ff9f9a6913..caf5caae5e 100644
--- a/tests/qemu-iotests/211.out
+++ b/tests/qemu-iotests/211.out
@@ -53,7 +53,6 @@ file format: IMGFMT
 virtual size: 32 MiB (33554432 bytes)
 cluster_size: 1048576
 
-[{"compressed": false, "data": true, "depth": 0, "length": 3072, "offset": 1024, "present": true, "start": 0, "zero": false}, {"compressed": false, "data": true, "depth": 0, "length": 33551360, "offset": 4096, "present": true, "start": 3072, "zero": true}]
 === Invalid BlockdevRef ===
 
 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vdi", "file": "this doesn't exist", "size": 33554432}}}
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 02/10] iotests: fix default QEMU_PROG on FreeBSD amd64
  2026-11-25 19:16 ` [PATCH v2 02/10] iotests: fix default QEMU_PROG on FreeBSD amd64 Roman Bogorodskiy
@ 2026-11-26  9:09   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:09 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:52PM +0100, Roman Bogorodskiy wrote:
> testenv.py uses 'qemu-system-{arch}' as a default
> value for QEMU_PROG and it obtains arch from os.uname().machine.
> As FreeBSD reports it as 'amd64', normalize it to 'x86_64'
> to use a proper qemu-system binary by default.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/testenv.py | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 03/10] iotests: fix the dd() wrapper
  2026-11-25 19:16 ` [PATCH v2 03/10] iotests: fix the dd() wrapper Roman Bogorodskiy
@ 2026-11-26  9:10   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:10 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Brad Smith, Kevin Wolf, Hanna Reitz,
	open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:53PM +0100, Roman Bogorodskiy wrote:
> The dd() wrapper uses status=noxfer on Linux. It's also required on
> other systems such as FreeBSD.
> 
> Rather than adding OS specific conditions, check whether dd supports
> status=noxfer and append it to the command if it does.
> 
> Suggested-by: Brad Smith <brad@comstyle.com>
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/common.rc | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 04/10] tests/qtest: unset socket timeout
  2026-11-25 19:16 ` [PATCH v2 04/10] tests/qtest: unset socket timeout Roman Bogorodskiy
@ 2026-11-26  9:12   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:12 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Brad Smith, Fabiano Rosas, Laurent Vivier,
	Paolo Bonzini

On Wed, Nov 25, 2026 at 08:16:54PM +0100, Roman Bogorodskiy wrote:
> The qtest_socket_accept() sets a timeout on a listening
> socket. FreeBSD also inherits this timeout for the accepted socket,
> which breaks some tests. Explicitly set timeout on the accepted socket
> to 0.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> Reviewed-by: Brad Smith <brad@comstyle.com>
> ---
>  tests/qtest/libqtest.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> 
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index 7f66c1bbb3..8a7989811d 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -151,6 +151,19 @@ static int qtest_socket_accept(QTestState *s, int sock)
>      }
>      if (ret == -1) {
>          fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno));
> +    } else {
> +        /*
> +         * Accepted sockets might inherit listener's timeout on
> +         * BSD systems, so set it to 0 explicitly
> +         */
> +        memset(&timeout, 0, sizeof(timeout));
> +        if (setsockopt(ret, SOL_SOCKET, SO_RCVTIMEO,
> +                       (void *)&timeout, sizeof(timeout))) {

If I'm nitpicking, I'd check  "setsockopt() < 0", but either
way R-b stands.

> +            fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n",
> +                    __func__, strerror(errno));
> +            close(ret);
> +            return -1;
> +        }
>      }
>  
>      return ret;
> -- 
> 2.56.0
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 06/10] iotests: mark 149 as Linux-only
  2026-11-25 19:16 ` [PATCH v2 06/10] iotests: mark 149 as Linux-only Roman Bogorodskiy
@ 2026-11-26  9:14   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:14 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:56PM +0100, Roman Bogorodskiy wrote:
> Test 149 requires Linux specific dm-crypt and cryptsetup,
> so mark it supported only on Linux.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/149 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 07/10] iotests: fix test 162
  2026-11-25 19:16 ` [PATCH v2 07/10] iotests: fix test 162 Roman Bogorodskiy
@ 2026-11-26  9:20   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:20 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:57PM +0100, Roman Bogorodskiy wrote:
> Test 162 expects Linux error messages. These messages could
> be different on other OSes, on FreeBSD for example.
> Add a _normalize_errors() helper to normalize these
> error messages.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/162 | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162
> index 4f01611886..73a0c43e2c 100755
> --- a/tests/qemu-iotests/162
> +++ b/tests/qemu-iotests/162
> @@ -33,6 +33,12 @@ _cleanup()
>  }
>  trap "_cleanup; exit \$status" 0 1 2 3 15
>  
> +_normalize_errors()
> +{
> +    sed -e "s/Name does not resolve/Name or service not known/" \
> +        -e "s/Can't assign requested address/Connection refused/"
> +}

Rather than attempt to re-map OS dependent messages, I'd be more
inclined to just cull the 'strerror()' strings from the expected
output file.

>  # get standard environment, filters and checks
>  . ./common.rc
>  . ./common.filter
> @@ -45,7 +51,7 @@ echo '=== NBD ==='
>  # NBD expects all of its arguments to be strings
>  
>  # So this should not crash
> -$QEMU_IMG info 'json:{"driver": "nbd", "host": -1}'
> +$QEMU_IMG info 'json:{"driver": "nbd", "host": -1}' 2>&1 | _normalize_errors

   | sed -E 's/(address resolution failed for -1:10809).*$/\1/'

>  
>  # And this should not treat @port as if it had not been specified
>  # (We need to set up a server here, because the error message for "Connection
> @@ -78,10 +84,12 @@ echo '=== SSH ==='
>  # expected to be an integer
>  
>  # So "0" should be converted to an integer here (instead of crashing)
> -$QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}'
> +$QEMU_IMG info \
> +    'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}' 2>&1 | \
> +        _normalize_errors
>  # The same, basically (all values for --image-opts are seen as strings in qemu)
>  $QEMU_IMG info --image-opts \
> -    driver=ssh,host=localhost,port=0,path=/foo
> +    driver=ssh,host=localhost,port=0,path=/foo 2>&1 | _normalize_errors

 | sed -e 's/(Failed to connect to 'localhost:0').*$/\1/'

>  
>  # This, however, should fail because of the wrong type
>  $QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}'
> -- 
> 2.56.0
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 08/10] iotests: fix possible race in 145
  2026-11-25 19:16 ` [PATCH v2 08/10] iotests: fix possible race in 145 Roman Bogorodskiy
@ 2026-11-26  9:21   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:21 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:58PM +0100, Roman Bogorodskiy wrote:
> Test 145 uses "-incoming 'exec:true'" argument for QEMU.
> It is possible that it reads the migration input before
> processing "quit", so it'll report an error and the test
> will fail.
> 
> Fix by using a migration socket, similarly to how test 181
> already does that.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/145 | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 09/10] iotests: properly skip tests that require OFD locking support
  2026-11-25 19:16 ` [PATCH v2 09/10] iotests: properly skip tests that require OFD locking support Roman Bogorodskiy
@ 2026-11-26  9:23   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:23 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:59PM +0100, Roman Bogorodskiy wrote:
> Tests 296, qemu-iotests/tests/migration-permissions, and
> tests/mirror-top-perms require OFD locking support and fail when
> it's not available.
> 
> Add the supports_ofd_lock() and verify_ofd_lock() helpers and
> use them to skip these tests when necessary.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/296                         |  1 +
>  tests/qemu-iotests/iotests.py                  | 16 ++++++++++++++++
>  tests/qemu-iotests/tests/migration-permissions |  3 +++
>  tests/qemu-iotests/tests/mirror-top-perms      |  3 +++
>  4 files changed, 23 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 10/10] iotests: fix test 211
  2026-11-25 19:17 ` [PATCH v2 10/10] iotests: fix test 211 Roman Bogorodskiy
@ 2026-11-26  9:27   ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:27 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:17:00PM +0100, Roman Bogorodskiy wrote:
> Test 211 compares "qemu-img map" output against a fixed expected layout.
> As this layout depends on the host filesystem, the test might fail.
> 
> Move away from direct output comparison and ensure correctness by
> asserting the essential fields.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/211     | 19 ++++++++++++++++++-
>  tests/qemu-iotests/211.out |  1 -
>  2 files changed, 18 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 01/10] iotests: use gsed when necessary
  2026-11-25 19:16 ` [PATCH v2 01/10] iotests: use gsed when necessary Roman Bogorodskiy
@ 2026-11-26  9:31   ` Daniel P. Berrangé
  2026-11-26 18:28     ` Roman Bogorodskiy
  0 siblings, 1 reply; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:31 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:51PM +0100, Roman Bogorodskiy wrote:
> Some iotests fail on FreeBSD because the tests call sed
> directly, and BSD sed is not always compatible with GNU sed.
> As common.rc already provides the gsed() wrapper, use it
> instead if needed.
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/115           | 2 +-
>  tests/qemu-iotests/common.filter | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)


We use plain 'sed' across countless test files, and only call
'gsed' in one test file and common.filter. It feels like a
loosing battle to keep fixing things to use gsed when they
hit an incompatibility.

How about we rename the 'gsed()' wrapper function to simply
'sed()', and thus make GNU sed a mandatory dependency for
all tests.


> 
> diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115
> index 5c8a12f85a..e3ff91de7a 100755
> --- a/tests/qemu-iotests/115
> +++ b/tests/qemu-iotests/115
> @@ -78,7 +78,7 @@ _make_test_img -o "refcount_bits=64,cluster_size=512,preallocation=metadata" 256
>  # qemu-img check for that purpose, too.
>  
>  $QEMU_IMG check "$TEST_IMG" | \
> -    sed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
> +    gsed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
>          -e '/^Image end offset/d'
>  
>  # (Note that we cannot use _check_test_img because that function filters out the
> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> index ce4213cb97..f7211a0a29 100644
> --- a/tests/qemu-iotests/common.filter
> +++ b/tests/qemu-iotests/common.filter
> @@ -130,7 +130,7 @@ _filter_actual_image_size()
>  # Filename filters for qemu-img create
>  _filter_img_create_filenames()
>  {
> -    sed \
> +    gsed \
>          -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
>          -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
>          -e "s#$TEST_DIR#TEST_DIR#g" \
> @@ -296,7 +296,7 @@ _filter_qemu_img_map()
>          data_file_filter=(-e "s#$data_file_pattern#\\1#")
>      fi
>  
> -    sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
> +    gsed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
>          -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
>          -e 's/Mapped to *//' \
>          "${data_file_filter[@]}" \
> @@ -310,7 +310,7 @@ _filter_nbd()
>      # receive callbacks sometimes, making them unreliable.
>      #
>      # Filter out the TCP port number since this changes between runs.
> -    sed -e '/nbd\/.*\.c:/d' \
> +    gsed -e '/nbd\/.*\.c:/d' \
>          -e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
>          -e 's#localhost:[0-9]*#localhost:PORT#g' \
>          -e 's#host=127\.0\.0\.1,port=[0-9]*#host=127.0.0.1,port=PORT#g' \
> -- 
> 2.56.0
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 05/10] iotests: skip preallocation tests if not supported
  2026-11-25 19:16 ` [PATCH v2 05/10] iotests: skip preallocation tests if not supported Roman Bogorodskiy
@ 2026-11-26  9:53   ` Daniel P. Berrangé
  2026-11-26 18:16     ` Roman Bogorodskiy
  0 siblings, 1 reply; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26  9:53 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Wed, Nov 25, 2026 at 08:16:55PM +0100, Roman Bogorodskiy wrote:
> Skip preallocation tests requiring efficient zero writes if
> not supported. Support is detected by probing
> "qemu-io write -z -n".
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/qemu-iotests/298 | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298
> index f2b94077f4..869bdb3242 100755
> --- a/tests/qemu-iotests/298
> +++ b/tests/qemu-iotests/298
> @@ -18,6 +18,7 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  #
>  
> +import errno
>  import os
>  import iotests
>  
> @@ -32,6 +33,15 @@ drive_opts = f'node-name=disk,driver={iotests.imgfmt},' \
>  
>  class TestPreallocateBase(iotests.QMPTestCase):
>      def setUp(self):
> +        with iotests.FilePath('zero-probe.raw') as probe_path:
> +            iotests.qemu_img_create('-f', 'raw', probe_path, '1M')
> +            ret = iotests.qemu_io('-f', 'raw', '-c', 'write -z -n -q 0 1M',
> +                                  probe_path, check=False)
> +            if ret.returncode != 0:
> +                if os.strerror(errno.ENOTSUP) in ret.stdout:
> +                    self.case_skip("File backend does not support "
> +                                   "efficient zero writes")
> +            self.assertEqual(ret.returncode, 0, ret.stdout)

I guess this works, but any idea what the actul underlying missing
feature is ?  Is it something we can check directly instead of
matching on stderr strings ? 

>          iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB))
>  
>      def tearDown(self):
> -- 
> 2.56.0
> 
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 05/10] iotests: skip preallocation tests if not supported
  2026-11-26  9:53   ` Daniel P. Berrangé
@ 2026-11-26 18:16     ` Roman Bogorodskiy
  2026-11-26 18:21       ` Daniel P. Berrangé
  0 siblings, 1 reply; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-26 18:16 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

  Daniel P. Berrangé wrote:

> On Wed, Nov 25, 2026 at 08:16:55PM +0100, Roman Bogorodskiy wrote:
> > Skip preallocation tests requiring efficient zero writes if
> > not supported. Support is detected by probing
> > "qemu-io write -z -n".
> > 
> > Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> > ---
> >  tests/qemu-iotests/298 | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298
> > index f2b94077f4..869bdb3242 100755
> > --- a/tests/qemu-iotests/298
> > +++ b/tests/qemu-iotests/298
> > @@ -18,6 +18,7 @@
> >  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
> >  #
> >  
> > +import errno
> >  import os
> >  import iotests
> >  
> > @@ -32,6 +33,15 @@ drive_opts = f'node-name=disk,driver={iotests.imgfmt},' \
> >  
> >  class TestPreallocateBase(iotests.QMPTestCase):
> >      def setUp(self):
> > +        with iotests.FilePath('zero-probe.raw') as probe_path:
> > +            iotests.qemu_img_create('-f', 'raw', probe_path, '1M')
> > +            ret = iotests.qemu_io('-f', 'raw', '-c', 'write -z -n -q 0 1M',
> > +                                  probe_path, check=False)
> > +            if ret.returncode != 0:
> > +                if os.strerror(errno.ENOTSUP) in ret.stdout:
> > +                    self.case_skip("File backend does not support "
> > +                                   "efficient zero writes")
> > +            self.assertEqual(ret.returncode, 0, ret.stdout)
> 
> I guess this works, but any idea what the actul underlying missing
> feature is ?  Is it something we can check directly instead of
> matching on stderr strings ? 

The actual missing feature is a working handle_aiocb_write_zeroes().
Thus, one of:

  CONFIG_FALLOCATE
  CONFIG_FALLOCATE_ZERO_RANGE
  CONFIG_FALLOCATE_PUNCH_HOLE

and filesystem support.

> >          iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB))
> >  
> >      def tearDown(self):
> > -- 
> > 2.56.0
> > 
> > 
> > 
> 
> With regards,
> Daniel
> -- 
> |: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
> |: https://libvirt.org          ~~          https://entangle-photo.org :|
> |: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
> 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 05/10] iotests: skip preallocation tests if not supported
  2026-11-26 18:16     ` Roman Bogorodskiy
@ 2026-11-26 18:21       ` Daniel P. Berrangé
  0 siblings, 0 replies; 24+ messages in thread
From: Daniel P. Berrangé @ 2026-11-26 18:21 UTC (permalink / raw)
  To: Roman Bogorodskiy
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

On Thu, Nov 26, 2026 at 07:16:36PM +0100, Roman Bogorodskiy wrote:
>   Daniel P. Berrangé wrote:
> 
> > On Wed, Nov 25, 2026 at 08:16:55PM +0100, Roman Bogorodskiy wrote:
> > > Skip preallocation tests requiring efficient zero writes if
> > > not supported. Support is detected by probing
> > > "qemu-io write -z -n".
> > > 
> > > Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> > > ---
> > >  tests/qemu-iotests/298 | 10 ++++++++++
> > >  1 file changed, 10 insertions(+)
> > > 
> > > diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298
> > > index f2b94077f4..869bdb3242 100755
> > > --- a/tests/qemu-iotests/298
> > > +++ b/tests/qemu-iotests/298
> > > @@ -18,6 +18,7 @@
> > >  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
> > >  #
> > >  
> > > +import errno
> > >  import os
> > >  import iotests
> > >  
> > > @@ -32,6 +33,15 @@ drive_opts = f'node-name=disk,driver={iotests.imgfmt},' \
> > >  
> > >  class TestPreallocateBase(iotests.QMPTestCase):
> > >      def setUp(self):
> > > +        with iotests.FilePath('zero-probe.raw') as probe_path:
> > > +            iotests.qemu_img_create('-f', 'raw', probe_path, '1M')
> > > +            ret = iotests.qemu_io('-f', 'raw', '-c', 'write -z -n -q 0 1M',
> > > +                                  probe_path, check=False)
> > > +            if ret.returncode != 0:
> > > +                if os.strerror(errno.ENOTSUP) in ret.stdout:
> > > +                    self.case_skip("File backend does not support "
> > > +                                   "efficient zero writes")
> > > +            self.assertEqual(ret.returncode, 0, ret.stdout)
> > 
> > I guess this works, but any idea what the actul underlying missing
> > feature is ?  Is it something we can check directly instead of
> > matching on stderr strings ? 
> 
> The actual missing feature is a working handle_aiocb_write_zeroes().
> Thus, one of:
> 
>   CONFIG_FALLOCATE
>   CONFIG_FALLOCATE_ZERO_RANGE
>   CONFIG_FALLOCATE_PUNCH_HOLE
> 
> and filesystem support.

Ok, that's a bit too complex to check directly here, so

  Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


> 
> > >          iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB))
> > >  
> > >      def tearDown(self):
> > > -- 
> > > 2.56.0
> > > 
> > > 
> > > 
> > 
> > With regards,
> > Daniel
> > -- 
> > |: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
> > |: https://libvirt.org          ~~          https://entangle-photo.org :|
> > |: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
> > 
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v2 01/10] iotests: use gsed when necessary
  2026-11-26  9:31   ` Daniel P. Berrangé
@ 2026-11-26 18:28     ` Roman Bogorodskiy
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Bogorodskiy @ 2026-11-26 18:28 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: qemu-devel, Kevin Wolf, Hanna Reitz, open list:Block layer core

  Daniel P. Berrangé wrote:

> On Wed, Nov 25, 2026 at 08:16:51PM +0100, Roman Bogorodskiy wrote:
> > Some iotests fail on FreeBSD because the tests call sed
> > directly, and BSD sed is not always compatible with GNU sed.
> > As common.rc already provides the gsed() wrapper, use it
> > instead if needed.
> > 
> > Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> > ---
> >  tests/qemu-iotests/115           | 2 +-
> >  tests/qemu-iotests/common.filter | 6 +++---
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> 
> We use plain 'sed' across countless test files, and only call
> 'gsed' in one test file and common.filter. It feels like a
> loosing battle to keep fixing things to use gsed when they
> hit an incompatibility.
> 
> How about we rename the 'gsed()' wrapper function to simply
> 'sed()', and thus make GNU sed a mandatory dependency for
> all tests.

I'm personally fine with this approach, gsed is easy to install on
FreeBSD and it's a lightweight dependency. It could possibly cause some
inconvenience for people working on other OSes/platforms though.

On the other hand, changing sed to gsed once in a while is not too
cumbersome either.

> 
> > 
> > diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115
> > index 5c8a12f85a..e3ff91de7a 100755
> > --- a/tests/qemu-iotests/115
> > +++ b/tests/qemu-iotests/115
> > @@ -78,7 +78,7 @@ _make_test_img -o "refcount_bits=64,cluster_size=512,preallocation=metadata" 256
> >  # qemu-img check for that purpose, too.
> >  
> >  $QEMU_IMG check "$TEST_IMG" | \
> > -    sed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
> > +    gsed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
> >          -e '/^Image end offset/d'
> >  
> >  # (Note that we cannot use _check_test_img because that function filters out the
> > diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
> > index ce4213cb97..f7211a0a29 100644
> > --- a/tests/qemu-iotests/common.filter
> > +++ b/tests/qemu-iotests/common.filter
> > @@ -130,7 +130,7 @@ _filter_actual_image_size()
> >  # Filename filters for qemu-img create
> >  _filter_img_create_filenames()
> >  {
> > -    sed \
> > +    gsed \
> >          -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
> >          -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
> >          -e "s#$TEST_DIR#TEST_DIR#g" \
> > @@ -296,7 +296,7 @@ _filter_qemu_img_map()
> >          data_file_filter=(-e "s#$data_file_pattern#\\1#")
> >      fi
> >  
> > -    sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
> > +    gsed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
> >          -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
> >          -e 's/Mapped to *//' \
> >          "${data_file_filter[@]}" \
> > @@ -310,7 +310,7 @@ _filter_nbd()
> >      # receive callbacks sometimes, making them unreliable.
> >      #
> >      # Filter out the TCP port number since this changes between runs.
> > -    sed -e '/nbd\/.*\.c:/d' \
> > +    gsed -e '/nbd\/.*\.c:/d' \
> >          -e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \
> >          -e 's#localhost:[0-9]*#localhost:PORT#g' \
> >          -e 's#host=127\.0\.0\.1,port=[0-9]*#host=127.0.0.1,port=PORT#g' \
> > -- 
> > 2.56.0
> > 
> > 
> 
> With regards,
> Daniel
> -- 
> |: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
> |: https://libvirt.org          ~~          https://entangle-photo.org :|
> |: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
> 


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2026-11-26 18:30 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 19:16 [PATCH v2 00/10] fix tests on FreeBSD Roman Bogorodskiy
2026-11-25 19:16 ` [PATCH v2 01/10] iotests: use gsed when necessary Roman Bogorodskiy
2026-11-26  9:31   ` Daniel P. Berrangé
2026-11-26 18:28     ` Roman Bogorodskiy
2026-11-25 19:16 ` [PATCH v2 02/10] iotests: fix default QEMU_PROG on FreeBSD amd64 Roman Bogorodskiy
2026-11-26  9:09   ` Daniel P. Berrangé
2026-11-25 19:16 ` [PATCH v2 03/10] iotests: fix the dd() wrapper Roman Bogorodskiy
2026-11-26  9:10   ` Daniel P. Berrangé
2026-11-25 19:16 ` [PATCH v2 04/10] tests/qtest: unset socket timeout Roman Bogorodskiy
2026-11-26  9:12   ` Daniel P. Berrangé
2026-11-25 19:16 ` [PATCH v2 05/10] iotests: skip preallocation tests if not supported Roman Bogorodskiy
2026-11-26  9:53   ` Daniel P. Berrangé
2026-11-26 18:16     ` Roman Bogorodskiy
2026-11-26 18:21       ` Daniel P. Berrangé
2026-11-25 19:16 ` [PATCH v2 06/10] iotests: mark 149 as Linux-only Roman Bogorodskiy
2026-11-26  9:14   ` Daniel P. Berrangé
2026-11-25 19:16 ` [PATCH v2 07/10] iotests: fix test 162 Roman Bogorodskiy
2026-11-26  9:20   ` Daniel P. Berrangé
2026-11-25 19:16 ` [PATCH v2 08/10] iotests: fix possible race in 145 Roman Bogorodskiy
2026-11-26  9:21   ` Daniel P. Berrangé
2026-11-25 19:16 ` [PATCH v2 09/10] iotests: properly skip tests that require OFD locking support Roman Bogorodskiy
2026-11-26  9:23   ` Daniel P. Berrangé
2026-11-25 19:17 ` [PATCH v2 10/10] iotests: fix test 211 Roman Bogorodskiy
2026-11-26  9:27   ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.