From patchwork Fri Nov 17 16:25:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Chamarthy X-Patchwork-Id: 10062969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 636DF60352 for ; Fri, 17 Nov 2017 16:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 558392ACF6 for ; Fri, 17 Nov 2017 16:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A6C22AD05; Fri, 17 Nov 2017 16:26:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A8ED52ACF6 for ; Fri, 17 Nov 2017 16:26:47 +0000 (UTC) Received: from localhost ([::1]:46716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFjTa-000563-SY for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Nov 2017 11:26:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFjSj-00052s-71 for qemu-devel@nongnu.org; Fri, 17 Nov 2017 11:25:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFjSh-0008Ew-Rw for qemu-devel@nongnu.org; Fri, 17 Nov 2017 11:25:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45988) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eFjSc-00086p-U1; Fri, 17 Nov 2017 11:25:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F40B77E422; Fri, 17 Nov 2017 16:25:45 +0000 (UTC) Received: from eukaryote.localdomain (ovpn-117-192.ams2.redhat.com [10.36.117.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D0525E1A3; Fri, 17 Nov 2017 16:25:41 +0000 (UTC) From: Kashyap Chamarthy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 17 Nov 2017 17:25:36 +0100 Message-Id: <20171117162536.23225-1-kchamart@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 17 Nov 2017 16:25:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3] QAPI & interop: Clarify events emitted by 'block-job-cancel' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kashyap Chamarthy , jsnow@redhat.com, armbru@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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.) Signed-off-by: Kashyap Chamarthy Reviewed-by: Eric Blake --- 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(-) diff --git a/docs/interop/live-block-operations.rst b/docs/interop/live-block-operations.rst index 5f01797..3cb64f6 100644 --- a/docs/interop/live-block-operations.rst +++ b/docs/interop/live-block-operations.rst @@ -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. diff --git a/qapi/block-core.json b/qapi/block-core.json index ab96e34..4ecfd1f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -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