Skip to contentSkip to conversation

Few fixes I found when building QEMU with Rust

PATCH Applied Martin Kletzander 6 participants 15 messages Aug 1, 2025 – Aug 12, 2025 Rust

lore
Share & tools
lore
#0 lore raw

cover Few fixes I found when building QEMU with Rust

I'm fairly sure the first one is alright, but I must admit I have no idea why is the second patch needed on my system.

For both patches, please take them with a grain of salt and feel free to prove me wrong with anything.

This used to be a bigger series until I rebased on top of Paolo's rust-next branch and basically got half of it for free. That's why these unrelated patches are bundled in a "series".

Martin Kletzander (2):
rust: Add antoher variant for impl_vmstate_struct! macro tests/qemu-iotests: Indent expected error messages

 rust/qemu-api/src/vmstate.rs         | 11 +++++++++++
 rust/qemu-api/tests/vmstate_tests.rs |  1 +
 tests/qemu-iotests/039.out           | 10 +++++-----
 tests/qemu-iotests/061.out           |  4 ++--
 tests/qemu-iotests/137.out           |  2 +-
 5 files changed, 20 insertions(+), 8 deletions(-)
Signature · 1 line
2.50.1
#7 lore raw

PATCH 2/2 tests/qemu-iotests: Indent expected error messages

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

---
 tests/qemu-iotests/039.out | 10 +++++-----
 tests/qemu-iotests/061.out |  4 ++--
 tests/qemu-iotests/137.out |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)
tests/qemu-iotests/039.out +5 -5
index e52484d4be1b..87809c534ba3 100644
@@ -11,7 +11,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -46,7 +46,7 @@ read 512/512 bytes at offset 0
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 Rebuilding refcount structure
@@ -60,7 +60,7 @@ incompatible_features     []
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     []
 No errors were found on the image.
 
@@ -79,7 +79,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -89,7 +89,7 @@ Data may be corrupted, or further writes to the image may corrupt it.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     []
 No errors were found on the image.
 *** done
tests/qemu-iotests/061.out +2 -2
index 24c33add7ce6..ae4c0d37bbbe 100644
@@ -118,7 +118,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
@@ -304,7 +304,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
tests/qemu-iotests/137.out +1 -1
index 86377c80cde6..f3b12fbb04b0 100644
@@ -35,7 +35,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 OK: Dirty bit not set
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off'
Signature · 1 line
2.50.1
#1 lore raw

PATCH 1/2 rust: Add antoher variant for impl_vmstate_struct! macro

In reply to Martin Kletzander

From: Martin Kletzander <[email protected]>

In some cases (e.g. in vmstate_tests.rs) the second argument to impl_vmstate_struct! is actually an existing struct which is then copied (since VMStateDescription implements Copy) when saved into the static VMSD using .get(). That is not a problem because it is part of the data segment and the pointers are not being free'd since they point to static data. But it is a problem when tests rely on comparing the VMState descriptions as pointers rather than contents. And it also wastes space, more or less.

Introduce second variant of the macro which can, instead of the expression, take an identifier or what looks like a reference. This second variant is added before the current variant so that it has preference, and only references the existing static data from it.

This way tests are fixed and space is saved.

And now that the VMStateDescription checking is fixed we can also check for the right value in test_vmstate_struct_varray_uint8_wrapper().

---
I'm not sure whether this is caused by different utility on my system or bash version or whatever, but without this patch these three tests fail for me and this patch fixes it.

 rust/qemu-api/src/vmstate.rs         | 11 +++++++++++
 rust/qemu-api/tests/vmstate_tests.rs |  1 +
 2 files changed, 12 insertions(+)
rust/qemu-api/src/vmstate.rs +11 -0
index b5c6b764fbba..716e52afe740 100644
@@ -449,6 +449,17 @@ macro_rules! vmstate_validate {
 /// description of the struct.
 #[macro_export]
 macro_rules! impl_vmstate_struct {
+    ($type:ty, $(&)?$vmsd:ident) => {
+        unsafe impl $crate::vmstate::VMState for $type {
+            const BASE: $crate::bindings::VMStateField =
+                $crate::bindings::VMStateField {
+                    vmsd: $vmsd.as_ref(),
+                    size: ::core::mem::size_of::<$type>(),
+                    flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
+                    ..$crate::zeroable::Zeroable::ZERO
+                };
+        }
+    };
     ($type:ty, $vmsd:expr) => {
         unsafe impl $crate::vmstate::VMState for $type {
             const BASE: $crate::bindings::VMStateField = {
rust/qemu-api/tests/vmstate_tests.rs +1 -0
index 2c0670ba0eed..7d3180e6c2ea 100644
@@ -320,6 +320,7 @@ fn test_vmstate_struct_varray_uint8_wrapper() {
         b"arr_a_wrap\0"
     );
     assert_eq!(foo_fields[5].num_offset, 228);
+    assert_eq!(foo_fields[5].vmsd, VMSTATE_FOOA.as_ref());
     assert!(unsafe { foo_fields[5].field_exists.unwrap()(foo_b_p, 0) });
 
     // The last VMStateField in VMSTATE_FOOB.
Signature · 1 line
2.50.1
#8 lore raw

Re: [PATCH 2/2] tests/qemu-iotests: Indent expected error messages

In reply to Martin Kletzander
Quoted 5 lines · Martin Kletzander

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

This would break the tests on my system and CI too.

What distro are you seeing this on ?

I'm guessing this is a different in either valgrind or C library ?

Quoted 96 lines
---
 tests/qemu-iotests/039.out | 10 +++++-----
 tests/qemu-iotests/061.out |  4 ++--
 tests/qemu-iotests/137.out |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)
tests/qemu-iotests/039.out +5 -5
index e52484d4be1b..87809c534ba3 100644
@@ -11,7 +11,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -46,7 +46,7 @@ read 512/512 bytes at offset 0
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 Rebuilding refcount structure
@@ -60,7 +60,7 @@ incompatible_features     []
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     []
 No errors were found on the image.
 
@@ -79,7 +79,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -89,7 +89,7 @@ Data may be corrupted, or further writes to the image may corrupt it.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     []
 No errors were found on the image.
 *** done
tests/qemu-iotests/061.out +2 -2
index 24c33add7ce6..ae4c0d37bbbe 100644
@@ -118,7 +118,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
@@ -304,7 +304,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
tests/qemu-iotests/137.out +1 -1
index 86377c80cde6..f3b12fbb04b0 100644
@@ -35,7 +35,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed                     ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 OK: Dirty bit not set
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off'
Signature · 1 line
2.50.1

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#9 lore raw

Re: [PATCH 2/2] tests/qemu-iotests: Indent expected error messages

Quoted 7 lines · Daniel P. Berrangé
Quoted 5 lines · Martin Kletzander

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

Quoted 6 lines

This would break the tests on my system and CI too.

What distro are you seeing this on ?

I'm guessing this is a different in either valgrind or C library ?

It's bash, we have an open issue about it:

https://gitlab.com/qemu-project/qemu/-/issues/3050

#2 lore raw

Re: [PATCH 1/2] rust: Add antoher variant for impl_vmstate_struct! macro

In reply to Martin Kletzander

Il ven 1 ago 2025, 17:00 Martin Kletzander <[email protected]> ha scritto:

Quoted 21 lines

From: Martin Kletzander <[email protected]>

In some cases (e.g. in vmstate_tests.rs) the second argument to impl_vmstate_struct! is actually an existing struct which is then copied (since VMStateDescription implements Copy) when saved into the static VMSD using .get(). That is not a problem because it is part of the data segment and the pointers are not being free'd since they point to static data. But it is a problem when tests rely on comparing the VMState descriptions as pointers rather than contents. And it also wastes space, more or less.

Introduce second variant of the macro which can, instead of the expression, take an identifier or what looks like a reference. This second variant is added before the current variant so that it has preference, and only references the existing static data from it.

This way tests are fixed and space is saved.

And now that the VMStateDescription checking is fixed we can also check for the right value in test_vmstate_struct_varray_uint8_wrapper().

Quoted 8 lines

---
I'm not sure whether this is caused by different utility on my system or bash
version or whatever, but without this patch these three tests fail for me and
this patch fixes it.

I found something similar, though I wasn't sure if it was broken in master as well or only in the rust-next branch.

If that works in master as well, I would remove completely the possibility of using &FOO, and always use .as_ref(). It's more efficient as you said, and there's no reason that I know to use the less efficient one.

Paolo

 rust/qemu-api/src/vmstate.rs         | 11 +++++++++++
Quoted 42 lines
 rust/qemu-api/tests/vmstate_tests.rs |  1 +
 2 files changed, 12 insertions(+)
rust/qemu-api/src/vmstate.rs +11 -0
index b5c6b764fbba..716e52afe740 100644
@@ -449,6 +449,17 @@ macro_rules! vmstate_validate {
 /// description of the struct.
 #[macro_export]
 macro_rules! impl_vmstate_struct {
+    ($type:ty, $(&)?$vmsd:ident) => {
+        unsafe impl $crate::vmstate::VMState for $type {
+            const BASE: $crate::bindings::VMStateField =
+                $crate::bindings::VMStateField {
+                    vmsd: $vmsd.as_ref(),
+                    size: ::core::mem::size_of::<$type>(),
+                    flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
+                    ..$crate::zeroable::Zeroable::ZERO
+                };
+        }
+    };
     ($type:ty, $vmsd:expr) => {
         unsafe impl $crate::vmstate::VMState for $type {
             const BASE: $crate::bindings::VMStateField = {
rust/qemu-api/tests/ renamed from rust/qemu-api/tests/vmstate_tests.rs +0 -0

vmstate_tests.rs
index 2c0670ba0eed..7d3180e6c2ea 100644

rust/qemu-api/tests/vmstate_tests.rs +1 -1
@@ -320,6 +320,7 @@ fn test_vmstate_struct_varray_uint8_wrapper() {
         b"arr_a_wrap\0"
     );
     assert_eq!(foo_fields[5].num_offset, 228);
+    assert_eq!(foo_fields[5].vmsd, VMSTATE_FOOA.as_ref());
     assert!(unsafe { foo_fields[5].field_exists.unwrap()(foo_b_p, 0) });
 
     // The last VMStateField in VMSTATE_FOOB.
--

2.50.1

#10 lore raw

Re: [PATCH 2/2] tests/qemu-iotests: Indent expected error messages

In reply to Fabiano Rosas
Quoted 11 lines · Fabiano Rosas
Quoted 9 lines · Daniel P. Berrangé
Quoted 5 lines · Martin Kletzander

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

This would break the tests on my system and CI too.

Quoted 9 lines
Quoted 4 lines

What distro are you seeing this on ?

I'm guessing this is a different in either valgrind or C library ?

It's bash, we have an open issue about it:

https://gitlab.com/qemu-project/qemu/-/issues/3050

Ah, good to know, thanks. That's what I suspected, but haven't thought of checking gitlab issues. Sorry for the noise.

#3 lore raw

Re: [PATCH 1/2] rust: Add antoher variant for impl_vmstate_struct! macro

In reply to Paolo Bonzini
Quoted 32 lines · Paolo Bonzini

Il ven 1 ago 2025, 17:00 Martin Kletzander <[email protected]> ha scritto:

Quoted 21 lines

From: Martin Kletzander <[email protected]>

In some cases (e.g. in vmstate_tests.rs) the second argument to impl_vmstate_struct! is actually an existing struct which is then copied (since VMStateDescription implements Copy) when saved into the static VMSD using .get(). That is not a problem because it is part of the data segment and the pointers are not being free'd since they point to static data. But it is a problem when tests rely on comparing the VMState descriptions as pointers rather than contents. And it also wastes space, more or less.

Introduce second variant of the macro which can, instead of the expression, take an identifier or what looks like a reference. This second variant is added before the current variant so that it has preference, and only references the existing static data from it.

This way tests are fixed and space is saved.

And now that the VMStateDescription checking is fixed we can also check for the right value in test_vmstate_struct_varray_uint8_wrapper().

Quoted 8 lines

---
I'm not sure whether this is caused by different utility on my system or bash
version or whatever, but without this patch these three tests fail for me and
this patch fixes it.

Quoted 3 lines

I found something similar, though I wasn't sure if it was broken in master as well or only in the rust-next branch.

It is not broken on master, but it *was* broken on rust-next.

Quoted 4 lines

If that works in master as well, I would remove completely the possibility of using &FOO, and always use .as_ref(). It's more efficient as you said, and there's no reason that I know to use the less efficient one.

That would mean that you cannot do what's done in e.g. pl011

impl_vmstate_struct!(

    PL011Registers,
    VMStateDescriptionBuilder::<PL011Registers>::new()
    ...
    .build()

);

requiring you to always do:

static/const VMSTATE_PL011_REGISTERS: VMStateDescription<PL011Registers> =

    VMStateDescriptionBuilder::<PL011Registers>::new()
    ...
    .build();

impl_vmstate_struct!(PL011Registers, VMSTATE_PL011_REGISTERS);

*BUT* of course I had to rebase the patches on top of current rust-next on Friday and there were some of your commits from Thursday which I now see actually fix all what I tried fixing before as well. I tried finding the previous commit on which I saw all the issues and after some rebuilding I could not. So it is now not even broken on rust-next.

This way I completely wasted your time, but at least learned something that's happening in the code. Sorry for that.

Martin

Quoted 45 lines

Paolo

rust/qemu-api/src/vmstate.rs | 11 +++++++++++

Quoted 42 lines
 rust/qemu-api/tests/vmstate_tests.rs |  1 +
 2 files changed, 12 insertions(+)
rust/qemu-api/src/vmstate.rs +11 -0
index b5c6b764fbba..716e52afe740 100644
@@ -449,6 +449,17 @@ macro_rules! vmstate_validate {
 /// description of the struct.
 #[macro_export]
 macro_rules! impl_vmstate_struct {
+    ($type:ty, $(&)?$vmsd:ident) => {
+        unsafe impl $crate::vmstate::VMState for $type {
+            const BASE: $crate::bindings::VMStateField =
+                $crate::bindings::VMStateField {
+                    vmsd: $vmsd.as_ref(),
+                    size: ::core::mem::size_of::<$type>(),
+                    flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
+                    ..$crate::zeroable::Zeroable::ZERO
+                };
+        }
+    };
     ($type:ty, $vmsd:expr) => {
         unsafe impl $crate::vmstate::VMState for $type {
             const BASE: $crate::bindings::VMStateField = {
rust/qemu-api/tests/ renamed from rust/qemu-api/tests/vmstate_tests.rs +0 -0

vmstate_tests.rs
index 2c0670ba0eed..7d3180e6c2ea 100644

rust/qemu-api/tests/vmstate_tests.rs +1 -1
@@ -320,6 +320,7 @@ fn test_vmstate_struct_varray_uint8_wrapper() {
         b"arr_a_wrap\0"
     );
     assert_eq!(foo_fields[5].num_offset, 228);
+    assert_eq!(foo_fields[5].vmsd, VMSTATE_FOOA.as_ref());
     assert!(unsafe { foo_fields[5].field_exists.unwrap()(foo_b_p, 0) });
 
     // The last VMStateField in VMSTATE_FOOB.
--

2.50.1

#4 lore raw

Re: [PATCH 1/2] rust: Add antoher variant for impl_vmstate_struct! macro

Il lun 4 ago 2025, 10:56 Martin Kletzander <[email protected]> ha scritto:

Quoted 9 lines

*BUT* of course I had to rebase the patches on top of current rust-next on Friday and there were some of your commits from Thursday which I now see actually fix all what I tried fixing before as well. I tried finding the previous commit on which I saw all the issues and after some rebuilding I could not. So it is now not even broken on rust-next.

This way I completely wasted your time, but at least learned something that's happening in the code. Sorry for that.

Uh no you didn't. It was broken.

Paolo

Martin

Quoted 50 lines
Quoted 8 lines

Paolo

rust/qemu-api/src/vmstate.rs | 11 +++++++++++

rust/qemu-api/src/

Quoted 4 lines
 rust/qemu-api/tests/vmstate_tests.rs |  1 +
 2 files changed, 12 insertions(+)
rust/qemu-api/src/ renamed from rust/qemu-api/src/vmstate.rs +0 -0

vmstate.rs

Quoted 14 lines
Quoted 14 lines

index b5c6b764fbba..716e52afe740 100644

rust/qemu-api/src/vmstate.rs +7 -0
@@ -449,6 +449,17 @@ macro_rules! vmstate_validate {
 /// description of the struct.
 #[macro_export]
 macro_rules! impl_vmstate_struct {
+    ($type:ty, $(&)?$vmsd:ident) => {
+        unsafe impl $crate::vmstate::VMState for $type {
+            const BASE: $crate::bindings::VMStateField =
+                $crate::bindings::VMStateField {
+                    vmsd: $vmsd.as_ref(),
+                    size: ::core::mem::size_of::<$type>(),
+                    flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
Quoted 8 lines

Review

Quoted 8 lines
rust/qemu-api/src/vmstate.rs +4 -0
+                    ..$crate::zeroable::Zeroable::ZERO
+                };
+        }
+    };
     ($type:ty, $vmsd:expr) => {
         unsafe impl $crate::vmstate::VMState for $type {
             const BASE: $crate::bindings::VMStateField = {
(quoted diff) +0 -0

b/rust/qemu-api/tests/

Quoted 10 lines

rust/qemu-api/tests/vmstate_tests.rs fn test_vmstate_struct_varray_uint8_wrapper() { · line 324

Quoted 10 lines

vmstate_tests.rs
index 2c0670ba0eed..7d3180e6c2ea 100644

rust/qemu-api/tests/vmstate_tests.rs +1 -0
@@ -320,6 +320,7 @@ fn test_vmstate_struct_varray_uint8_wrapper() {
         b"arr_a_wrap\0"
     );
     assert_eq!(foo_fields[5].num_offset, 228);
+    assert_eq!(foo_fields[5].vmsd, VMSTATE_FOOA.as_ref());
     assert!(unsafe { foo_fields[5].field_exists.unwrap()(foo_b_p, 0)

});

Quoted 6 lines
Quoted 6 lines
rust/qemu-api/tests/vmstate_tests.rs +0 -1
     // The last VMStateField in VMSTATE_FOOB.
--

2.50.1

#11 lore raw

Re: [PATCH 2/2] tests/qemu-iotests: Indent expected error messages

In reply to Fabiano Rosas

Am 01.08.2025 um 21:09 hat Fabiano Rosas geschrieben:

Quoted 11 lines
Quoted 9 lines · Daniel P. Berrangé
Quoted 5 lines · Martin Kletzander

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

This would break the tests on my system and CI too.

Quoted 7 lines
Quoted 3 lines

What distro are you seeing this on ?

I'm guessing this is a different in either valgrind or C library ?

It's bash, we have an open issue about it:

https://gitlab.com/qemu-project/qemu/-/issues/3050

I see a patch has been posted to that bug, the most important part of which is this added filtering:

tests/qemu-iotests/common.filter 2025-07-25 11:39:22.419665788 +0000 renamed from tests/qemu-iotests/common.filter +1 -1
@@ -75,7 +75,7 @@ _filter_qemu_io()
     _filter_win32 | \
     gsed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
         -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
-        -e "s/qemu-io> //g"
+        -e "s/qemu-io> //g" -e '/Killed/{ s/ \{2,\}/ /}'
 }
 
 # replace occurrences of QEMU_PROG with "qemu"

This approach makes sense to me, though I would have kept each sed expression on a separate line.

And given that the context line above includes "Aborted" as well, maybe have it here, too, though none of the actual test outputs have an Aborted message any more since commit 3f39447. Or we could have a cleanup patch first that removes the unused "Abort" above, just to keep things consistent.

Either way, please post this as a proper patch on the mailing list.

Kevin

#5 lore raw

Re: [PATCH 1/2] rust: Add antoher variant for impl_vmstate_struct! macro

In reply to Paolo Bonzini
Quoted 8 lines · Paolo Bonzini

Il lun 4 ago 2025, 10:56 Martin Kletzander <[email protected]> ha scritto:

Quoted 6 lines

*BUT* of course I had to rebase the patches on top of current rust-next on Friday and there were some of your commits from Thursday which I now see actually fix all what I tried fixing before as well. I tried finding the previous commit on which I saw all the issues and after some rebuilding I could not. So it is now not even broken on rust-next.

Quoted 6 lines
Quoted 3 lines

This way I completely wasted your time, but at least learned something that's happening in the code. Sorry for that.

Uh no you didn't. It was broken.

But it is not now, neither master, nor rust-next, nor anything I tried from the reflog, which makes me suspicious about what I was developing this on. I distinctly remember the $vmsd.get() call in the macro which I presume was causing the copying due to VMStateDescription automatically implementing the Copy trait due to the bindgen invocation.

But that's nowhere to be found, including git log --walk-reflog and manually searching various history trees. And I doubted that you rewrote the history of the rust-next branch. Neither do I remember changing the macro until I found out that other in code changes did not help to fix it.

After some time I now managed to find it. It was the previous version of a commit 4cb0670e12c4, and that is nowhere to be found in rust-next at the moment, I guess fixes were incorporated while rebasing the branch on current master.

That was a wild ride, but I'm glad it all works (apart from the bash version indentation) on rust-next. I'll try to read up on what's next to help with, if anything.

Have a nice day,
Martin

Quoted 53 lines

Paolo

Martin

Quoted 50 lines
Quoted 8 lines

Paolo

rust/qemu-api/src/vmstate.rs | 11 +++++++++++

rust/qemu-api/src/

Quoted 4 lines
 rust/qemu-api/tests/vmstate_tests.rs |  1 +
 2 files changed, 12 insertions(+)
rust/qemu-api/src/ renamed from rust/qemu-api/src/vmstate.rs +0 -0

vmstate.rs

Quoted 14 lines
Quoted 14 lines

index b5c6b764fbba..716e52afe740 100644

rust/qemu-api/src/vmstate.rs +7 -0
@@ -449,6 +449,17 @@ macro_rules! vmstate_validate {
 /// description of the struct.
 #[macro_export]
 macro_rules! impl_vmstate_struct {
+    ($type:ty, $(&)?$vmsd:ident) => {
+        unsafe impl $crate::vmstate::VMState for $type {
+            const BASE: $crate::bindings::VMStateField =
+                $crate::bindings::VMStateField {
+                    vmsd: $vmsd.as_ref(),
+                    size: ::core::mem::size_of::<$type>(),
+                    flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
Quoted 8 lines

Review

Quoted 8 lines
rust/qemu-api/src/vmstate.rs +4 -0
+                    ..$crate::zeroable::Zeroable::ZERO
+                };
+        }
+    };
     ($type:ty, $vmsd:expr) => {
         unsafe impl $crate::vmstate::VMState for $type {
             const BASE: $crate::bindings::VMStateField = {
(quoted diff) +0 -0

b/rust/qemu-api/tests/

Quoted 10 lines

rust/qemu-api/tests/vmstate_tests.rs fn test_vmstate_struct_varray_uint8_wrapper() { · line 324

Quoted 10 lines

vmstate_tests.rs
index 2c0670ba0eed..7d3180e6c2ea 100644

rust/qemu-api/tests/vmstate_tests.rs +1 -0
@@ -320,6 +320,7 @@ fn test_vmstate_struct_varray_uint8_wrapper() {
         b"arr_a_wrap\0"
     );
     assert_eq!(foo_fields[5].num_offset, 228);
+    assert_eq!(foo_fields[5].vmsd, VMSTATE_FOOA.as_ref());
     assert!(unsafe { foo_fields[5].field_exists.unwrap()(foo_b_p, 0)

});

Quoted 6 lines
Quoted 6 lines
rust/qemu-api/tests/vmstate_tests.rs +0 -1
     // The last VMStateField in VMSTATE_FOOB.
--

2.50.1

#6 lore raw

Re: [PATCH 1/2] rust: Add antoher variant for impl_vmstate_struct! macro

Il lun 4 ago 2025, 14:04 Martin Kletzander <[email protected]> ha scritto:

Quoted 3 lines

But that's nowhere to be found, including git log --walk-reflog and manually searching various history trees. And I doubted that you rewrote the history of the rust-next branch

Yes, rust-next has its history rewritten.

By the way the bug was probably related to some compiler changes, because I am almost certain it worked a couple months ago.

Paolo

#12 lore raw

Re: [PATCH 2/2] tests/qemu-iotests: Indent expected error messages

In reply to Kevin Wolf
Quoted 38 lines · Kevin Wolf

Am 01.08.2025 um 21:09 hat Fabiano Rosas geschrieben:

Quoted 11 lines
Quoted 9 lines · Daniel P. Berrangé
Quoted 5 lines · Martin Kletzander

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

This would break the tests on my system and CI too.

Quoted 7 lines
Quoted 3 lines

What distro are you seeing this on ?

I'm guessing this is a different in either valgrind or C library ?

It's bash, we have an open issue about it:

https://gitlab.com/qemu-project/qemu/-/issues/3050

I see a patch has been posted to that bug, the most important part of which is this added filtering:

tests/qemu-iotests/common.filter 2025-07-25 11:39:22.419665788 +0000 renamed from tests/qemu-iotests/common.filter +1 -1
@@ -75,7 +75,7 @@ _filter_qemu_io()
     _filter_win32 | \
     gsed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
         -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
-        -e "s/qemu-io> //g"
+        -e "s/qemu-io> //g" -e '/Killed/{ s/ \{2,\}/ /}'
 }
 
 # replace occurrences of QEMU_PROG with "qemu"

This approach makes sense to me, though I would have kept each sed expression on a separate line.

Quoted 7 lines

And given that the context line above includes "Aborted" as well, maybe have it here, too, though none of the actual test outputs have an Aborted message any more since commit 3f39447. Or we could have a cleanup patch first that removes the unused "Abort" above, just to keep things consistent.

Either way, please post this as a proper patch on the mailing list.

Just next try in tha attached patch with a fixed version of the sed command.

Werner

Signature · 2 lines
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

From: Werner Fink <[email protected]>
Date: Fri, 08 Aug 06:41:23 +0000
Subject: [PATCH 1/1] Avoid dependency on padding on signal messages

New bash 5.3 uses a different padding for reporting job status.

Resolves: boo#1246830

---
 tests/qemu-iotests/039.out       |   10 +++++-----
 tests/qemu-iotests/061.out       |    4 ++--
 tests/qemu-iotests/137.out       |    2 +-
 tests/qemu-iotests/common.filter |    2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)
tests/qemu-iotests/039.out +5 -5
@@ -11,7 +11,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -46,7 +46,7 @@ read 512/512 bytes at offset 0
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 Rebuilding refcount structure
@@ -60,7 +60,7 @@ incompatible_features     []
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     []
 No errors were found on the image.
 
@@ -79,7 +79,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     [0]
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -89,7 +89,7 @@ Data may be corrupted, or further writes
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 incompatible_features     []
 No errors were found on the image.
 *** done
tests/qemu-iotests/061.out +2 -2
@@ -118,7 +118,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
@@ -304,7 +304,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
tests/qemu-iotests/137.out +1 -1
@@ -35,7 +35,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGF
 qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed                  ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
 OK: Dirty bit not set
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off'
tests/qemu-iotests/common.filter +1 -1
@@ -74,7 +74,7 @@ _filter_qemu_io()
 {
     _filter_win32 | \
     gsed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
-        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
+        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\) \{2,\}/:\1 /" \
         -e "s/qemu-io> //g"
 }
 
author Tested-by
#13 lore raw

Re: [PATCH 2/2] tests/qemu-iotests: Indent expected error messages

Quoted 45 lines · Dr. Werner Fink
Quoted 44 lines · Kevin Wolf

Am 01.08.2025 um 21:09 hat Fabiano Rosas geschrieben:

Quoted 11 lines
Quoted 9 lines · Daniel P. Berrangé
Quoted 5 lines · Martin Kletzander

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

This would break the tests on my system and CI too.

Quoted 7 lines
Quoted 3 lines

What distro are you seeing this on ?

I'm guessing this is a different in either valgrind or C library ?

It's bash, we have an open issue about it:

https://gitlab.com/qemu-project/qemu/-/issues/3050

I see a patch has been posted to that bug, the most important part of which is this added filtering:

tests/qemu-iotests/common.filter 2025-07-25 11:39:22.419665788 +0000 renamed from tests/qemu-iotests/common.filter +1 -1
@@ -75,7 +75,7 @@ _filter_qemu_io()
     _filter_win32 | \
     gsed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
         -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
-        -e "s/qemu-io> //g"
+        -e "s/qemu-io> //g" -e '/Killed/{ s/ \{2,\}/ /}'
 }
 
 # replace occurrences of QEMU_PROG with "qemu"

This approach makes sense to me, though I would have kept each sed expression on a separate line.

And given that the context line above includes "Aborted" as well, maybe have it here, too, though none of the actual test outputs have an Aborted message any more since commit 3f39447. Or we could have a cleanup patch first that removes the unused "Abort" above, just to keep things consistent.

Quoted 18 lines
Quoted 1 line

Either way, please post this as a proper patch on the mailing list.

Just next try in tha attached patch with a fixed version of the sed command.

Werner

Signature · 10 lines
 "Having a smoking section in a restaurant is like having
         a peeing section in a swimming pool." -- Edward Burr

From: Werner Fink <[email protected]>
Date: Fri, 08 Aug 06:41:23 +0000
Subject: [PATCH 1/1] Avoid dependency on padding on signal messages

New bash 5.3 uses a different padding for reporting job status.

Resolves: boo#1246830

Not sure you meant that or
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3050

Quoted 1 line

but, FWIW, if that makes any difference,

Quoted 96 lines

---

tests/qemu-iotests/039.out       |   10 +++++-----
tests/qemu-iotests/061.out       |    4 ++--
tests/qemu-iotests/137.out       |    2 +-
tests/qemu-iotests/common.filter |    2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
tests/qemu-iotests/039.out +0 -0
@@ -11,7 +11,7 @@ No errors were found on the image.

Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
wrote 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
incompatible_features [0]
ERROR cluster 5 refcount=0 reference=1
ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0

tests/qemu-iotests/039.out +0 -0
@@ -46,7 +46,7 @@ read 512/512 bytes at offset 0

Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
wrote 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
incompatible_features [0]
ERROR cluster 5 refcount=0 reference=1
Rebuilding refcount structure

tests/qemu-iotests/039.out +0 -0
@@ -60,7 +60,7 @@ incompatible_features     []

Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
wrote 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
incompatible_features []
No errors were found on the image.

tests/qemu-iotests/039.out +0 -0
@@ -79,7 +79,7 @@ No errors were found on the image.

Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
wrote 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
incompatible_features [0]
ERROR cluster 5 refcount=0 reference=1
ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0

tests/qemu-iotests/039.out +0 -0
@@ -89,7 +89,7 @@ Data may be corrupted, or further writes

Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
wrote 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
incompatible_features []
No errors were found on the image.
*** done

tests/qemu-iotests/061.out +0 -0
@@ -118,7 +118,7 @@ No errors were found on the image.

Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
wrote 131072/131072 bytes at offset 0
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )

magic                     0x514649fb
version                   3
backing_file_offset       0x0
tests/qemu-iotests/061.out +0 -0
@@ -304,7 +304,7 @@ No errors were found on the image.

Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
wrote 131072/131072 bytes at offset 0
128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )

magic                     0x514649fb
version                   3
backing_file_offset       0x0
tests/qemu-iotests/137.out +0 -0
@@ -35,7 +35,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGF

qemu-io: Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all wrote 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
+./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" )
OK: Dirty bit not set
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off'

tests/qemu-iotests/common.filter +1 -1
@@ -74,7 +74,7 @@ _filter_qemu_io()
 {
    _filter_win32 | \
    gsed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
-        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
+        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\) \{2,\}/:\1 /" \
        -e "s/qemu-io> //g"
 }
 
Applied
#14 lore raw

Re: [PATCH 2/2] tests/qemu-iotests: Indent expected error messages

Am 11.08.2025 um 11:05 hat Martin Kletzander geschrieben:

Quoted 61 lines · Dr. Werner Fink
Quoted 60 lines · Kevin Wolf
Quoted 38 lines

Am 01.08.2025 um 21:09 hat Fabiano Rosas geschrieben:

Quoted 11 lines
Quoted 9 lines · Daniel P. Berrangé
Quoted 5 lines · Martin Kletzander

From: Martin Kletzander <[email protected]>

When running all tests the expected "killed" messages are indented differently than the actual ones, by three more spaces. Change it so that the messages match and tests pass.

This would break the tests on my system and CI too.

Quoted 7 lines
Quoted 3 lines

What distro are you seeing this on ?

I'm guessing this is a different in either valgrind or C library ?

It's bash, we have an open issue about it:

https://gitlab.com/qemu-project/qemu/-/issues/3050

I see a patch has been posted to that bug, the most important part of which is this added filtering:

tests/qemu-iotests/common.filter 2025-07-25 11:39:22.419665788 +0000 renamed from tests/qemu-iotests/common.filter +1 -1
@@ -75,7 +75,7 @@ _filter_qemu_io()
     _filter_win32 | \
     gsed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
         -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
-        -e "s/qemu-io> //g"
+        -e "s/qemu-io> //g" -e '/Killed/{ s/ \{2,\}/ /}'
 }
 
 # replace occurrences of QEMU_PROG with "qemu"

This approach makes sense to me, though I would have kept each sed expression on a separate line.

Quoted 7 lines

And given that the context line above includes "Aborted" as well, maybe have it here, too, though none of the actual test outputs have an Aborted message any more since commit 3f39447. Or we could have a cleanup patch first that removes the unused "Abort" above, just to keep things consistent.

Either way, please post this as a proper patch on the mailing list.

Just next try in tha attached patch with a fixed version of the sed command.

Werner

Signature · 6 lines
 "Having a smoking section in a restaurant is like having
         a peeing section in a swimming pool." -- Edward Burr

From: Werner Fink <[email protected]>
Date: Fri, 08 Aug 06:41:23 +0000
Subject: [PATCH 1/1] Avoid dependency on padding on signal messages
Quoted 6 lines
Quoted 3 lines

New bash 5.3 uses a different padding for reporting job status.

Resolves: boo#1246830

Not sure you meant that or
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3050

I just updated the commit message to contain both.

Quoted 5 lines
Quoted 1 line

but, FWIW, if that makes any difference,

Thanks, applied to the block branch.

Kevin