qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

block/mirror: honor ratelimit again

Commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748 ("block/mirror: change
the semantic of 'force' of block-job-cancel") accidentally removed the
ratelimit in the mirror job.

Reintroduce the ratelimit but keep the block-job-cancel force=true
behavior that was added in commit
b76e4458b1eb3c32e9824fe6aa51f67d2b251748.

Note that block_job_sleep_ns() returns immediately when the job is
cancelled. Therefore it's safe to unconditionally call
block_job_sleep_ns() - a cancelled job does not sleep.

This commit fixes the non-deterministic qemu-iotests 185 output. The
test relies on the ratelimit to make the job sleep until the 'quit'
command is processed. Previously the job could complete before the
'quit' command was received since there was no ratelimit.

Cc: Liang Li <liliang.opensource@gmail.com>
Cc: Jeff Cody <jcody@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20180424123527.19168-1-stefanha@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
(cherry picked from commit ddc4115efdfa6619689fe18871aa2d37890b3463)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

authored by

Stefan Hajnoczi and committed by
Michael Roth
9eb3e5a8 05a3e663

+6 -4
+5 -3
block/mirror.c
··· 868 868 } 869 869 870 870 ret = 0; 871 + 872 + if (s->synced && !should_complete) { 873 + delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); 874 + } 871 875 trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); 876 + block_job_sleep_ns(&s->common, delay_ns); 872 877 if (block_job_is_cancelled(&s->common) && s->common.force) { 873 878 break; 874 - } else if (!should_complete) { 875 - delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); 876 - block_job_sleep_ns(&s->common, delay_ns); 877 879 } 878 880 s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); 879 881 }
+1 -1
tests/qemu-iotests/185.out
··· 36 36 {"return": {}} 37 37 Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 38 38 {"return": {}} 39 - {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} 40 39 {"return": {}} 41 40 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} 41 + {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} 42 42 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} 43 43 44 44 === Start backup job and exit qemu ===