From patchwork Fri Jul 8 17:21:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9221587 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 0615E60467 for ; Fri, 8 Jul 2016 17:44:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB4DE26254 for ; Fri, 8 Jul 2016 17:44:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF98927DF9; Fri, 8 Jul 2016 17:44:33 +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 42CC626254 for ; Fri, 8 Jul 2016 17:44:33 +0000 (UTC) Received: from localhost ([::1]:47044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLZpH-0001DR-Tg for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Jul 2016 13:44:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLZTf-0001Gs-Tg for qemu-devel@nongnu.org; Fri, 08 Jul 2016 13:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLZTb-0008NP-Jd for qemu-devel@nongnu.org; Fri, 08 Jul 2016 13:22:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLZTR-0008JQ-Lk; Fri, 08 Jul 2016 13:21:57 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FB63C00F237; Fri, 8 Jul 2016 17:21:57 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-56.ams2.redhat.com [10.36.116.56]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u68HLk2u006858; Fri, 8 Jul 2016 13:21:56 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 8 Jul 2016 19:21:20 +0200 Message-Id: <1467998504-15744-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1467998504-15744-1-git-send-email-kwolf@redhat.com> References: <1467998504-15744-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 08 Jul 2016 17:21:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/32] stream: Add 'job-id' parameter to 'block-stream' 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Alberto Garcia This patch adds a new optional 'job-id' parameter to 'block-stream', allowing the user to specify the ID of the block job to be created. The HMP 'block_stream' command remains unchanged. Signed-off-by: Alberto Garcia Reviewed-by: Kevin Wolf Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- block/stream.c | 12 ++++++------ blockdev.c | 6 +++--- hmp.c | 2 +- include/block/block_int.h | 10 ++++++---- qapi/block-core.json | 8 ++++++-- qmp-commands.hx | 4 +++- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/block/stream.c b/block/stream.c index e4319d3..54c8cd8 100644 --- a/block/stream.c +++ b/block/stream.c @@ -218,15 +218,15 @@ static const BlockJobDriver stream_job_driver = { .set_speed = stream_set_speed, }; -void stream_start(BlockDriverState *bs, BlockDriverState *base, - const char *backing_file_str, int64_t speed, - BlockdevOnError on_error, - BlockCompletionFunc *cb, - void *opaque, Error **errp) +void stream_start(const char *job_id, BlockDriverState *bs, + BlockDriverState *base, const char *backing_file_str, + int64_t speed, BlockdevOnError on_error, + BlockCompletionFunc *cb, void *opaque, Error **errp) { StreamBlockJob *s; - s = block_job_create(NULL, &stream_job_driver, bs, speed, cb, opaque, errp); + s = block_job_create(job_id, &stream_job_driver, bs, speed, + cb, opaque, errp); if (!s) { return; } diff --git a/blockdev.c b/blockdev.c index 920d987..d6f1d4d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3005,7 +3005,7 @@ static void block_job_cb(void *opaque, int ret) } } -void qmp_block_stream(const char *device, +void qmp_block_stream(bool has_job_id, const char *job_id, const char *device, bool has_base, const char *base, bool has_backing_file, const char *backing_file, bool has_speed, int64_t speed, @@ -3064,8 +3064,8 @@ void qmp_block_stream(const char *device, /* backing_file string overrides base bs filename */ base_name = has_backing_file ? backing_file : base_name; - stream_start(bs, base_bs, base_name, has_speed ? speed : 0, - on_error, block_job_cb, bs, &local_err); + stream_start(has_job_id ? job_id : NULL, bs, base_bs, base_name, + has_speed ? speed : 0, on_error, block_job_cb, bs, &local_err); if (local_err) { error_propagate(errp, local_err); goto out; diff --git a/hmp.c b/hmp.c index 62eca70..3ca79c3 100644 --- a/hmp.c +++ b/hmp.c @@ -1485,7 +1485,7 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict) const char *base = qdict_get_try_str(qdict, "base"); int64_t speed = qdict_get_try_int(qdict, "speed", 0); - qmp_block_stream(device, base != NULL, base, false, NULL, + qmp_block_stream(false, NULL, device, base != NULL, base, false, NULL, qdict_haskey(qdict, "speed"), speed, true, BLOCKDEV_ON_ERROR_REPORT, &error); diff --git a/include/block/block_int.h b/include/block/block_int.h index a0b9f92..db364bb 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -639,6 +639,8 @@ int is_windows_drive(const char *filename); /** * stream_start: + * @job_id: The id of the newly-created job, or %NULL to use the + * device name of @bs. * @bs: Block device to operate on. * @base: Block device that will become the new base, or %NULL to * flatten the whole backing file chain onto @bs. @@ -657,10 +659,10 @@ int is_windows_drive(const char *filename); * @backing_file_str in the written image and to @base in the live * BlockDriverState. */ -void stream_start(BlockDriverState *bs, BlockDriverState *base, - const char *backing_file_str, int64_t speed, - BlockdevOnError on_error, BlockCompletionFunc *cb, - void *opaque, Error **errp); +void stream_start(const char *job_id, BlockDriverState *bs, + BlockDriverState *base, const char *backing_file_str, + int64_t speed, BlockdevOnError on_error, + BlockCompletionFunc *cb, void *opaque, Error **errp); /** * commit_start: diff --git a/qapi/block-core.json b/qapi/block-core.json index ee44ce4..94f4733 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1425,6 +1425,9 @@ # On successful completion the image file is updated to drop the backing file # and the BLOCK_JOB_COMPLETED event is emitted. # +# @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 # # @base: #optional the common backing file name @@ -1456,8 +1459,9 @@ # Since: 1.1 ## { 'command': 'block-stream', - 'data': { 'device': 'str', '*base': 'str', '*backing-file': 'str', - '*speed': 'int', '*on-error': 'BlockdevOnError' } } + 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', + '*backing-file': 'str', '*speed': 'int', + '*on-error': 'BlockdevOnError' } } ## # @block-job-set-speed: diff --git a/qmp-commands.hx b/qmp-commands.hx index a032089..d61ea20 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1106,7 +1106,7 @@ EQMP { .name = "block-stream", - .args_type = "device:B,base:s?,speed:o?,backing-file:s?,on-error:s?", + .args_type = "job-id:s?,device:B,base:s?,speed:o?,backing-file:s?,on-error:s?", .mhandler.cmd_new = qmp_marshal_block_stream, }, @@ -1118,6 +1118,8 @@ Copy data from a backing file into a block device. Arguments: +- "job-id": Identifier for the newly-created block job. If omitted, + the device name will be used. (json-string, optional) - "device": The device's ID, must be unique (json-string) - "base": The file name of the backing image above which copying starts (json-string, optional)