QAPI & interop: Clarify events emitted by 'block-job-cancel'
PATCH v3 1/1 QAPI & interop: Clarify events emitted by 'block-job-cancel'
When you cancel an in-progress live block operation with QMP block-job-cancel, it emits the event: BLOCK_JOB_CANCELLED. However, when block-job-cancel is issued after drive-mirror has indicated (by emitting the event BLOCK_JOB_READY) that the source and destination remain synchronized:
[...] # Snip `drive-mirror` invocation & outputs
{
"execute":"block-job-cancel",
"arguments":{
"device":"virtio0"
}
}
{"return": {}}It (block-job-cancel) will counterintuitively emit the event 'BLOCK_JOB_COMPLETED':
{
"timestamp":{
"seconds":1510678024,
"microseconds":526240
},
"event":"BLOCK_JOB_COMPLETED",
"data":{
"device":"virtio0",
"len":41126400,
"offset":41126400,
"speed":0,
"type":"mirror"
}
}But this is expected behaviour, where the _COMPLETED event indicates that synchronization has successfully ended (and the destination has a point-in-time copy, which is at the time of cancel).
So add a small note to this effect in 'block-core.json'. While at it, also update the "Live disk synchronization -- drive-mirror and blockdev-mirror" section in 'live-block-operations.rst'.
(Thanks: Max Reitz for reminding me of this caveat on IRC.)
---
Changes in v3:
- Fix / rewrite the section "Live disk synchronization -- drive-mirror and blockdev-mirror" to note this gotcha [John Snow]
Changes in v2:
- "Note:" seems to be a special construct in Patchew, my usage caused a build failure. So do: s/Note:/Note that/
- Add the missing 'Signed-off-by'
--- docs/interop/live-block-operations.rst | 50 ++++++++++++++++++++++------------ qapi/block-core.json | 8 ++++++ 2 files changed, 40 insertions(+), 18 deletions(-)
docs/interop/live-block-operations.rst +32 -18
@@ -506,26 +506,40 @@ Again, given our familiar disk image chain:: [A] <-- [B] <-- [C] <-- [D] -The ``drive-mirror`` (and its newer equivalent ``blockdev-mirror``) allows -you to copy data from the entire chain into a single target image (which -can be located on a different host). - -Once a 'mirror' job has started, there are two possible actions while a -``drive-mirror`` job is active: - -(1) Issuing the command ``block-job-cancel`` after it emits the event - ``BLOCK_JOB_CANCELLED``: will (after completing synchronization of - the content from the disk image chain to the target image, [E]) - create a point-in-time (which is at the time of *triggering* the - cancel command) copy, contained in image [E], of the the entire disk +The ``drive-mirror`` (and its newer equivalent ``blockdev-mirror``) +allows you to copy data from the entire chain into a single target image +(which can be located on a different host), [E]. + +.. note:: + + When you cancel an in-progress 'mirror' job *before* the source and + target are synchronized, ``block-job-cancel`` will emit the event + ``BLOCK_JOB_CANCELLED``. However, note that if you cancel a + 'mirror' job *after* it has indicated (by emitting the event + ``BLOCK_JOB_READY``) that the source and target now remain + synchronized, then ``block-job-cancel`` will emit the event + ``BLOCK_JOB_COMPLETED``. + + Besides the 'mirror' job, the "active ``block-commit``" is the only + other block device job that emits the event ``BLOCK_JOB_READY``. + The rest of the block device jobs ('stream', "non-active + ``block-commit``", and 'backup') end automatically. + +So there are two possible actions, after a 'mirror' job has +emitted the event ``BLOCK_JOB_READY``, indicating that source and target +now remain synchronized: + +(1) Issuing the command ``block-job-cancel`` (after it emits the event + ``BLOCK_JOB_COMPLETED``) will create a point-in-time (which is at + the time of *triggering* the cancel command) copy of the entire disk image chain (or only the top-most image, depending on the ``sync`` - mode). + mode), contained in the target image [E]. -(2) Issuing the command ``block-job-complete`` after it emits the event - ``BLOCK_JOB_COMPLETED``: will, after completing synchronization of - the content, adjust the guest device (i.e. live QEMU) to point to - the target image, and, causing all the new writes from this point on - to happen there. One use case for this is live storage migration. +(2) Issuing the command ``block-job-complete`` (after it emits the event + ``BLOCK_JOB_COMPLETED``) will adjust the guest device (i.e. live + QEMU) to point to the target image, [E], causing all the new writes + from this point on to happen there. One use case for this is live + storage migration. About synchronization modes: The synchronization mode determines *which* part of the disk image chain will be copied to the target.
qapi/block-core.json +8 -0
@@ -2065,6 +2065,14 @@ # BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when # enumerated using query-block-jobs. # +# Note that the 'block-job-cancel' command will emit the event +# BLOCK_JOB_COMPLETED if you issue it ('block-job-cancel') after 'drive-mirror' +# has indicated (by emitting the event BLOCK_JOB_READY) that the source and +# destination remain synchronized. In this case, the BLOCK_JOB_COMPLETED +# event indicates that synchronization (from 'drive-mirror') has successfully +# ended and the destination now has a point-in-time copy, which is at the time +# of cancel. +# # For streaming, the image file retains its backing file unless the streaming # operation happens to complete just as it is being cancelled. A new streaming # operation can be started at a later time to finish copying all data from the
Signature · 1 line
2.9.5
Quoted 11 lines · Kashyap Chamarthy
When you cancel an in-progress live block operation with QMP
block-job-cancel, it emits the event:BLOCK_JOB_CANCELLED. However, whenblock-job-cancelis issued afterdrive-mirrorhas indicated (by emitting the eventBLOCK_JOB_READY) that the source and destination remain synchronized:But this is expected behaviour, where the
_COMPLETEDevent indicates that synchronization has successfully ended (and the destination has a point-in-time copy, which is at the time of cancel).
Quoted 5 lines
So add a small note to this effect in 'block-core.json'. While at it, also update the "Live disk synchronization -- drive-mirror and blockdev-mirror" section in '
live-block-operations.rst'.(Thanks: Max Reitz for reminding me of this caveat on IRC.)
Sorry for not wordsmithing on earlier versions:
docs/interop/live-block-operations.rst Again, given our familiar disk image chain:: · line 520
Quoted 12 lines
Signed-off-by Kashyap Chamarthy <[email protected]>---
+.. note::
docs/interop/live-block-operations.rst +7
-0+ + When you cancel an in-progress 'mirror' job *before* the source and + target are synchronized, ``block-job-cancel`` will emit the event + ``BLOCK_JOB_CANCELLED``. However, note that if you cancel a + 'mirror' job *after* it has indicated (by emitting the event + ``BLOCK_JOB_READY``) that the source and target now remain + synchronized, then ``block-job-cancel`` will emit the event
Might read slightly nicer as:
the source and target have reached synchronization,
qapi/block-core.json line 2074
Quoted 12 lines
+++
b/qapi/block-core.jsonqapi/block-core.json +7
-0@@ -2065,6 +2065,14 @@ # BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when # enumerated using query-block-jobs. # +# Note that the 'block-job-cancel' command will emit the event +# BLOCK_JOB_COMPLETED if you issue it ('block-job-cancel') after 'drive-mirror' +# has indicated (by emitting the event BLOCK_JOB_READY) that the source and +# destination remain synchronized. In this case, the BLOCK_JOB_COMPLETED +# event indicates that synchronization (from 'drive-mirror') has successfully +# ended and the destination now has a point-in-time copy, which is at the time +# of cancel.
Accurate, but a bit hard to follow the flow of the sentence. Might read nicer as:
Note that if you issue 'block-job-cancel' after 'drive-mirror' has indicated (via the event BLOCK_JOB_READY) that the source and destination are synchronized, then the event triggered by this command changes to BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the destination now has a point-in-time copy tied to the time of the cancellation.
Documentation is worth of inclusion in 2.11. Whether you keep your wording, or incorporate mine in a v4, you can add:
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 1 line · Eric Blake
On 11/17/2017 10:25 AM, Kashyap Chamarthy wrote:
[...]
Quoted 1 line
Sorry for not wordsmithing on earlier versions:
That's fine. Always appreciate your wordsmithing :-)
Quoted 7 lines
docs/interop/live-block-operations.rst Again, given our familiar disk image chain:: · line 520
Quoted 3 lines
docs/interop/live-block-operations.rst +3
-0+ 'mirror' job *after* it has indicated (by emitting the event + ``BLOCK_JOB_READY``) that the source and target now remain + synchronized, then ``block-job-cancel`` will emit the eventMight read slightly nicer as:
the source and target have reached synchronization,
Ah, that sounds nicer indeed. Will fix.
[...]
Quoted 10 lines
qapi/block-core.json line 2074
Quoted 7 lines
qapi/block-core.json +7
-0+# Note that the 'block-job-cancel' command will emit the event +# BLOCK_JOB_COMPLETED if you issue it ('block-job-cancel') after 'drive-mirror' +# has indicated (by emitting the event BLOCK_JOB_READY) that the source and +# destination remain synchronized. In this case, the BLOCK_JOB_COMPLETED +# event indicates that synchronization (from 'drive-mirror') has successfully +# ended and the destination now has a point-in-time copy, which is at the time +# of cancel.Accurate, but a bit hard to follow the flow of the sentence.
Yeah, I wasn't satisfied with my phrasing too. I sat on it for nearly half an hour, and still it came out super clunky.
Quoted 8 lines
Might read nicer as:
Note that if you issue 'block-job-cancel' after 'drive-mirror' has indicated (via the event
BLOCK_JOB_READY) that the source and destination are synchronized, then the event triggered by this command changes toBLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the destination now has a point-in-time copy tied to the time of the cancellation.
Thanks, yours reads much nicer.
Quoted 3 lines
Documentation is worth of inclusion in 2.11. Whether you keep your wording, or incorporate mine in a v4, you can add:
Reviewed-by Eric Blake <[email protected]>
I'll definitely incorporate in v4.
I'll also make similar wording adjustment in live-block-operations.rst.
Thanks for the quick review.
Signature · 1 line
/kashyap