Skip to contentSkip to conversation

qemu-iotests: update 185 output

PATCH Applied Stefan Hajnoczi 6 participants 8 messages Apr 4, 2018 – Apr 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qemu-iotests: update 185 output

Commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()") added a bdrv_drain_all() call. As a side-effect of the drain operation the block job iterates one more time than before. The 185 output no longer matches and the test is failing now.

It may be possible to avoid the superfluous block job iteration, but that type of patch is not suitable late in the QEMU 2.12 release cycle.

This patch simply updates the 185 output file. The new behavior is correct, just not optimal, so make the test pass again.

Fixes 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()")
Cc Kevin Wolf <[email protected]>
Cc QingFeng Hao <[email protected]>
---
 tests/qemu-iotests/185     | 10 ++++++----
 tests/qemu-iotests/185.out | 12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)
tests/qemu-iotests/185 +6 -4
index f5b47e4c1a..298d88d04e 100755
@@ -92,9 +92,8 @@ echo === Start commit job and exit qemu ===
 echo
 
 # Note that the reference output intentionally includes the 'offset' field in
-# BLOCK_JOB_CANCELLED events for all of the following block jobs. They are
-# predictable and any change in the offsets would hint at a bug in the job
-# throttling code.
+# BLOCK_JOB_* events for all of the following block jobs. They are predictable
+# and any change in the offsets would hint at a bug in the job throttling code.
 #
 # In order to achieve these predictable offsets, all of the following tests
 # use speed=65536. Each job will perform exactly one iteration before it has
@@ -102,11 +101,14 @@ echo
 # command to be received (after receiving the command, the rest runs
 # synchronously, so jobs can arbitrarily continue or complete).
 #
+# Jobs present while QEMU is terminating iterate once more due to
+# bdrv_drain_all().
+#
 # The buffer size for commit and streaming is 512k (waiting for 8 seconds after
 # the first request), for active commit and mirror it's large enough to cover
 # the full 4M, and for backup it's the qcow2 cluster size, which we know is
 # 64k. As all of these are at least as large as the speed, we are sure that the
-# offset doesn't advance after the first iteration before qemu exits.
+# offset advances exactly twice before qemu exits.
 
 _send_qemu_cmd $h \
     "{ 'execute': 'block-commit',
tests/qemu-iotests/185.out +7 -5
index 57eaf8d699..2c4b04de73 100644
@@ -20,7 +20,7 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 524288, "speed": 65536, "type": "commit"}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 1048576, "speed": 65536, "type": "commit"}}
 
 === Start active commit job and exit qemu ===
 
@@ -28,16 +28,18 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
 
 === Start mirror job and exit qemu ===
 
 {"return": {}}
 Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16
 {"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}}
 
 === Start backup job and exit qemu ===
 
@@ -46,7 +48,7 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 65536, "speed": 65536, "type": "backup"}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 131072, "speed": 65536, "type": "backup"}}
 
 === Start streaming job and exit qemu ===
 
@@ -54,6 +56,6 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 l
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 524288, "speed": 65536, "type": "stream"}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "disk", "len": 67108864, "offset": 1048576, "speed": 65536, "type": "stream"}}
 No errors were found on the image.
 *** done
Signature · 1 line
2.14.3
Reviewed-by on v2 1/1
#1 lore raw
Quoted 21 lines · Stefan Hajnoczi

Commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()") added a bdrv_drain_all() call. As a side-effect of the drain operation the block job iterates one more time than before. The 185 output no longer matches and the test is failing now.

It may be possible to avoid the superfluous block job iteration, but that type of patch is not suitable late in the QEMU 2.12 release cycle.

This patch simply updates the 185 output file. The new behavior is correct, just not optimal, so make the test pass again.

Fixes 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()")
Cc Kevin Wolf <[email protected]>
Cc QingFeng Hao <[email protected]>
---
 tests/qemu-iotests/185     | 10 ++++++----
 tests/qemu-iotests/185.out | 12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)

tests/qemu-iotests/185 echo · line 105

Quoted 5 lines
tests/qemu-iotests/185 +2 -0
@@ -102,11 +101,14 @@ echo
 # command to be received (after receiving the command, the rest runs
 # synchronously, so jobs can arbitrarily continue or complete).
 #
+# Jobs present while QEMU is terminating iterate once more due to
+# bdrv_drain_all().

Do we want to add something like: "FIXME: removing the bdrv_drain_all() may be desirable in a future patch; and would warrant a change to the expected output."? Either way,

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
In reply to Stefan Hajnoczi
Quoted 11 lines · Stefan Hajnoczi

Commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()") added a bdrv_drain_all() call. As a side-effect of the drain operation the block job iterates one more time than before. The 185 output no longer matches and the test is failing now.

It may be possible to avoid the superfluous block job iteration, but that type of patch is not suitable late in the QEMU 2.12 release cycle.

This patch simply updates the 185 output file. The new behavior is correct, just not optimal, so make the test pass again.

Quoted 8 lines
Fixes 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()")
Cc Kevin Wolf <[email protected]>
Cc QingFeng Hao <[email protected]>
---
 tests/qemu-iotests/185     | 10 ++++++----
 tests/qemu-iotests/185.out | 12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)

On tmpfs, this isn't enough to let the test pass. There, the active commit job finishes before the quit is sent, resulting in this diff:

qemu-iotests/185.out.bad 2018-04-04 18:10:21.045473817 +0200 renamed from qemu-iotests/185.out 2018-04-04 18:10:02.015935435 +0200 +1 -0
@@ -26,9 +26,9 @@
 
 {"return": {}}
 {"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},

"event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP},
"event": "SHUTDOWN", "data": {"guest": false}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP},
"event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len":
4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}

=== Start mirror job and exit qemu ===

This seems to be independent of whether there is actually data on TEST_IMG (the commit source), so something doesn't seem quite right with the block job throttling here...?

Max

Reviewed-by on v2 1/1
#7 lore raw
In reply to Stefan Hajnoczi
Quoted 42 lines · Stefan Hajnoczi

Commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()") added a bdrv_drain_all() call. As a side-effect of the drain operation the block job iterates one more time than before. The 185 output no longer matches and the test is failing now.

It may be possible to avoid the superfluous block job iteration, but that type of patch is not suitable late in the QEMU 2.12 release cycle.

This patch simply updates the 185 output file. The new behavior is correct, just not optimal, so make the test pass again.

Fixes 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()")
Cc Kevin Wolf <[email protected]>
Cc QingFeng Hao <[email protected]>
---
 tests/qemu-iotests/185     | 10 ++++++----
 tests/qemu-iotests/185.out | 12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)
tests/qemu-iotests/185 +4 -3
index f5b47e4c1a..298d88d04e 100755
@@ -92,9 +92,8 @@ echo === Start commit job and exit qemu ===
 echo
 
 # Note that the reference output intentionally includes the 'offset' field in
-# BLOCK_JOB_CANCELLED events for all of the following block jobs. They are
-# predictable and any change in the offsets would hint at a bug in the job
-# throttling code.
+# BLOCK_JOB_* events for all of the following block jobs. They are predictable
+# and any change in the offsets would hint at a bug in the job throttling code.
 #
 # In order to achieve these predictable offsets, all of the following tests
 # use speed=65536. Each job will perform exactly one iteration before it has
@@ -102,11 +101,14 @@ echo
 # command to be received (after receiving the command, the rest runs
 # synchronously, so jobs can arbitrarily continue or complete).
 #
+# Jobs present while QEMU is terminating iterate once more due to
+# bdrv_drain_all().

tests/qemu-iotests/185 echo · line 114

Quoted 10 lines
tests/qemu-iotests/185 +2 -1
+#
 # The buffer size for commit and streaming is 512k (waiting for 8 seconds after
 # the first request), for active commit and mirror it's large enough to cover
 # the full 4M, and for backup it's the qcow2 cluster size, which we know is
 # 64k. As all of these are at least as large as the speed, we are sure that the
-# offset doesn't advance after the first iteration before qemu exits.
+# offset advances exactly twice before qemu exits.
 
 _send_qemu_cmd $h \
     "{ 'execute': 'block-commit',
Quoted 2 lines
tests/qemu-iotests/185.out +0 -0
index 57eaf8d699..2c4b04de73 100644

[...]

Quoted 1 line
Signature · 2 lines
Regards
QingFeng Hao
#3 lore raw
In reply to Max Reitz
Quoted 43 lines · Max Reitz
Quoted 11 lines · Stefan Hajnoczi

Commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()") added a bdrv_drain_all() call. As a side-effect of the drain operation the block job iterates one more time than before. The 185 output no longer matches and the test is failing now.

It may be possible to avoid the superfluous block job iteration, but that type of patch is not suitable late in the QEMU 2.12 release cycle.

This patch simply updates the 185 output file. The new behavior is correct, just not optimal, so make the test pass again.

Quoted 8 lines
Fixes 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268 ("vl: introduce vm_shutdown()")
Cc Kevin Wolf <[email protected]>
Cc QingFeng Hao <[email protected]>
---
 tests/qemu-iotests/185     | 10 ++++++----
 tests/qemu-iotests/185.out | 12 +++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)

On tmpfs, this isn't enough to let the test pass. There, the active commit job finishes before the quit is sent, resulting in this diff:

qemu-iotests/185.out.bad 2018-04-04 18:10:21.045473817 +0200 renamed from qemu-iotests/185.out 2018-04-04 18:10:02.015935435 +0200 +1 -1
@@ -26,9 +26,9 @@
 
 {"return": {}}
 {"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
 "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304,
 "offset": 4194304, "speed": 65536, "type": "commit"}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},
 "event": "SHUTDOWN", "data": {"guest": false}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP},

"event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP},
"event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len":
4194304, "offset": 4194304, "speed": 65536, "type": "commit"}}

Quoted 5 lines

=== Start mirror job and exit qemu ===

This seems to be independent of whether there is actually data on TEST_IMG (the commit source), so something doesn't seem quite right with the block job throttling here...?

That is a race condition. I can reproduce it on XFS too.

Will see if I can figure it out...

Stefan

#4 lore raw
In reply to Max Reitz
Quoted 6 lines · Max Reitz

On 2018-04-04 17:01, Stefan Hajnoczi wrote:
=== Start mirror job and exit qemu ===

This seems to be independent of whether there is actually data on TEST_IMG (the commit source), so something doesn't seem quite right with the block job throttling here...?

I've been playing around with this test failure. Let's leave it broken (!) in QEMU 2.12 because this test has uncovered a block job ratelimit issue that's not a regression. The fix shouldn't be rushed.

block/mirror.c calculates delay_ns but then discards it:

  static void coroutine_fn mirror_run(void *opaque)
  {
      ...
      for (;;) {
          ...delay_ns is calculated based on job speed...

          ret = 0;
          trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
          if (block_job_is_cancelled(&s->common) && s->common.force) {
              break;
          } else if (!should_complete) {
              delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
	        ^--- we discard it!
              block_job_sleep_ns(&s->common, delay_ns);
          }
          s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
      }

      ...

}

This is why the mirror-based tests are completing even though we'd expect them to only reach the "next" iteration due to the job speed.

Increasing the 4 MB write operation in the test to >16 MB (the mirror buffer size) doesn't solve the problem because the next QMP command will race with the job's 0 ns sleep. It would just make the test unreliable.

I'll work on the following for QEMU 2.13:

1. Avoid spurious block_job_enter() from block_job_drain(). This eliminates the extra block job iteration that changed the output in the first place.

2. Honor the job speed in block/mirror.c.

The end result will be that the test output will not require changes.

Stefan

Applied
#5 lore raw

Am 10.04.2018 um 10:11 hat Stefan Hajnoczi geschrieben:

Quoted 11 lines · Max Reitz
Quoted 6 lines · Stefan Hajnoczi

=== Start mirror job and exit qemu ===

This seems to be independent of whether there is actually data on TEST_IMG (the commit source), so something doesn't seem quite right with the block job throttling here...?

I've been playing around with this test failure. Let's leave it broken (!) in QEMU 2.12 because this test has uncovered a block job ratelimit issue that's not a regression. The fix shouldn't be rushed.

Makes sense.

Thanks, applied to the block branch.

Kevin

#6 lore raw
In reply to Stefan Hajnoczi
Quoted 11 lines · Stefan Hajnoczi
Quoted 6 lines · Max Reitz

On 2018-04-04 17:01, Stefan Hajnoczi wrote:
=== Start mirror job and exit qemu ===

This seems to be independent of whether there is actually data on TEST_IMG (the commit source), so something doesn't seem quite right with the block job throttling here...?

I've been playing around with this test failure. Let's leave it broken (!) in QEMU 2.12 because this test has uncovered a block job ratelimit issue that's not a regression. The fix shouldn't be rushed.

OK for me.

Quoted 22 lines

block/mirror.c calculates delay_ns but then discards it:

  static void coroutine_fn mirror_run(void *opaque)
  {
      ...
      for (;;) {
          ...delay_ns is calculated based on job speed...

          ret = 0;
          trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
          if (block_job_is_cancelled(&s->common) && s->common.force) {
              break;
          } else if (!should_complete) {
              delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
	        ^--- we discard it!
              block_job_sleep_ns(&s->common, delay_ns);
          }
          s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
      }

      ...
Quoted 1 line

}

Uh, nice.

Quoted 9 lines

This is why the mirror-based tests are completing even though we'd expect them to only reach the "next" iteration due to the job speed.

Increasing the 4 MB write operation in the test to >16 MB (the mirror buffer size) doesn't solve the problem because the next QMP command will race with the job's 0 ns sleep. It would just make the test unreliable.

I'll work on the following for QEMU 2.13:

Quoted 7 lines

1. Avoid spurious block_job_enter() from block_job_drain(). This eliminates the extra block job iteration that changed the output in the first place.

2. Honor the job speed in block/mirror.c.

The end result will be that the test output will not require changes.

Thanks!

Max