From patchwork Fri Oct 14 13:08:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9376839 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 62EF16022E for ; Fri, 14 Oct 2016 13:23:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 552672A6A7 for ; Fri, 14 Oct 2016 13:23:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 497AC2A6AA; Fri, 14 Oct 2016 13:23:53 +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 89FAA2A6A7 for ; Fri, 14 Oct 2016 13:23:47 +0000 (UTC) Received: from localhost ([::1]:47286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv2Sg-0001Dm-Dq for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Oct 2016 09:23:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv2FV-0006oL-2n for qemu-devel@nongnu.org; Fri, 14 Oct 2016 09:10:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bv2FP-0007Ey-4J for qemu-devel@nongnu.org; Fri, 14 Oct 2016 09:10:07 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:62335 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bv2FO-000746-Sy; Fri, 14 Oct 2016 09:10:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AsAgCE2ABY/5tjdVtcHAEFAQsBgz0BAQEBAR2BU400lV4BAQEBAQEFAYEXAZIsgg+CCIYiAoIOOBQBAgEBAQEBAQFeJ4RiAgR5ED8SPBsZiFYBwwUBAQEHKIVyglCMdgWOP3SKU5AAiWmGDJB4HjZEBgiCehyBVm+GCCuCAgEBAQ X-IPAS-Result: A2AsAgCE2ABY/5tjdVtcHAEFAQsBgz0BAQEBAR2BU400lV4BAQEBAQEFAYEXAZIsgg+CCIYiAoIOOBQBAgEBAQEBAQFeJ4RiAgR5ED8SPBsZiFYBwwUBAQEHKIVyglCMdgWOP3SKU5AAiWmGDJB4HjZEBgiCehyBVm+GCCuCAgEBAQ X-IronPort-AV: E=Sophos;i="5.31,493,1473112800"; d="scan'208";a="118727478" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 14 Oct 2016 15:09:19 +0200 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1bv2Eg-0004Qs-CL; Fri, 14 Oct 2016 15:09:18 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bv2E1-0006ke-Vg; Fri, 14 Oct 2016 16:08:37 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 14 Oct 2016 16:08:22 +0300 Message-Id: <810feb3cd4b455bd1f225843e5b9aeec3a962f0c.1476450059.git.berto@igalia.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH v11 10/19] block: Add QMP support for streaming to an intermediate layer 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch makes the 'device' parameter of the 'block-stream' command accept a node name that is not a root node. In addition to that, operation blockers will be checked in all intermediate nodes between the top and the base node. Signed-off-by: Alberto Garcia --- blockdev.c | 15 +++++++++------ qapi/block-core.json | 10 +++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/blockdev.c b/blockdev.c index f13fc69..c01776a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2937,7 +2937,7 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device, bool has_on_error, BlockdevOnError on_error, Error **errp) { - BlockDriverState *bs; + BlockDriverState *bs, *iter; BlockDriverState *base_bs = NULL; AioContext *aio_context; Error *local_err = NULL; @@ -2947,7 +2947,7 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device, on_error = BLOCKDEV_ON_ERROR_REPORT; } - bs = qmp_get_root_bs(device, errp); + bs = bdrv_lookup_bs(device, device, errp); if (!bs) { return; } @@ -2955,10 +2955,6 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device, aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); - if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) { - goto out; - } - if (has_base) { base_bs = bdrv_find_backing_image(bs, base); if (base_bs == NULL) { @@ -2969,6 +2965,13 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device, base_name = base; } + /* Check for op blockers in the whole chain between bs and base */ + for (iter = bs; iter && iter != base_bs; iter = backing_bs(iter)) { + if (bdrv_op_is_blocked(iter, BLOCK_OP_TYPE_STREAM, errp)) { + goto out; + } + } + /* if we are streaming the entire chain, the result will have no backing * file, and specifying one is therefore an error */ if (base_bs == NULL && has_backing_file) { diff --git a/qapi/block-core.json b/qapi/block-core.json index 1b7aa1b..cbbbbb9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1464,6 +1464,10 @@ # with query-block-jobs. The operation can be stopped before it has completed # using the block-job-cancel command. # +# The node that receives the data is called the top image, can be located in +# any part of the chain (but always above the base image; see below) and can be +# specified using its device or node name. +# # If a base file is specified then sectors are not copied from that base file and # its backing chain. When streaming completes the image file will have the base # file as its backing file. This can be used to stream a subset of the backing @@ -1475,12 +1479,12 @@ # @job-id: #optional identifier for the newly-created block job. If # omitted, the device name will be used. (Since 2.7) # -# @device: the device name or node-name of a root node +# @device: the device or node name of the top image # # @base: #optional the common backing file name # -# @backing-file: #optional The backing file string to write into the active -# layer. This filename is not validated. +# @backing-file: #optional The backing file string to write into the top +# image. This filename is not validated. # # If a pathname string is such that it cannot be # resolved by QEMU, that means that subsequent QMP or