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

QAPI & interop: Clarify events emitted by 'block-job-cancel'

When you cancel an in-progress 'mirror' job (or "active `block-commit`")
with QMP `block-job-cancel`, it emits the event: BLOCK_JOB_CANCELLED.
However, when `block-job-cancel` is issued *after* `drive-mirror` has
indicated (via the event BLOCK_JOB_READY) that the source and
destination have reached synchronization:

[...] # 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 now 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.)

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

Kashyap Chamarthy and committed by
Kevin Wolf
c117bb14 1878eaff

+36 -16
+30 -16
docs/interop/live-block-operations.rst
··· 506 506 507 507 [A] <-- [B] <-- [C] <-- [D] 508 508 509 - The ``drive-mirror`` (and its newer equivalent ``blockdev-mirror``) allows 510 - you to copy data from the entire chain into a single target image (which 511 - can be located on a different host). 509 + The ``drive-mirror`` (and its newer equivalent ``blockdev-mirror``) 510 + allows you to copy data from the entire chain into a single target image 511 + (which can be located on a different host), [E]. 512 512 513 - Once a 'mirror' job has started, there are two possible actions while a 514 - ``drive-mirror`` job is active: 513 + .. note:: 514 + 515 + When you cancel an in-progress 'mirror' job *before* the source and 516 + target are synchronized, ``block-job-cancel`` will emit the event 517 + ``BLOCK_JOB_CANCELLED``. However, note that if you cancel a 518 + 'mirror' job *after* it has indicated (via the event 519 + ``BLOCK_JOB_READY``) that the source and target have reached 520 + synchronization, then the event emitted by ``block-job-cancel`` 521 + changes to ``BLOCK_JOB_COMPLETED``. 515 522 516 - (1) Issuing the command ``block-job-cancel`` after it emits the event 517 - ``BLOCK_JOB_CANCELLED``: will (after completing synchronization of 518 - the content from the disk image chain to the target image, [E]) 519 - create a point-in-time (which is at the time of *triggering* the 520 - cancel command) copy, contained in image [E], of the the entire disk 523 + Besides the 'mirror' job, the "active ``block-commit``" is the only 524 + other block device job that emits the event ``BLOCK_JOB_READY``. 525 + The rest of the block device jobs ('stream', "non-active 526 + ``block-commit``", and 'backup') end automatically. 527 + 528 + So there are two possible actions to take, after a 'mirror' job has 529 + emitted the event ``BLOCK_JOB_READY``, indicating that the source and 530 + target have reached synchronization: 531 + 532 + (1) Issuing the command ``block-job-cancel`` (after it emits the event 533 + ``BLOCK_JOB_COMPLETED``) will create a point-in-time (which is at 534 + the time of *triggering* the cancel command) copy of the entire disk 521 535 image chain (or only the top-most image, depending on the ``sync`` 522 - mode). 536 + mode), contained in the target image [E]. One use case for this is 537 + live VM migration with non-shared storage. 523 538 524 - (2) Issuing the command ``block-job-complete`` after it emits the event 525 - ``BLOCK_JOB_COMPLETED``: will, after completing synchronization of 526 - the content, adjust the guest device (i.e. live QEMU) to point to 527 - the target image, and, causing all the new writes from this point on 528 - to happen there. One use case for this is live storage migration. 539 + (2) Issuing the command ``block-job-complete`` (after it emits the event 540 + ``BLOCK_JOB_COMPLETED``) will adjust the guest device (i.e. live 541 + QEMU) to point to the target image, [E], causing all the new writes 542 + from this point on to happen there. 529 543 530 544 About synchronization modes: The synchronization mode determines 531 545 *which* part of the disk image chain will be copied to the target.
+6
qapi/block-core.json
··· 2065 2065 # BLOCK_JOB_CANCELLED event. Before that happens the job is still visible when 2066 2066 # enumerated using query-block-jobs. 2067 2067 # 2068 + # Note that if you issue 'block-job-cancel' after 'drive-mirror' has indicated 2069 + # (via the event BLOCK_JOB_READY) that the source and destination are 2070 + # synchronized, then the event triggered by this command changes to 2071 + # BLOCK_JOB_COMPLETED, to indicate that the mirroring has ended and the 2072 + # destination now has a point-in-time copy tied to the time of the cancellation. 2073 + # 2068 2074 # For streaming, the image file retains its backing file unless the streaming 2069 2075 # operation happens to complete just as it is being cancelled. A new streaming 2070 2076 # operation can be started at a later time to finish copying all data from the