From patchwork Wed Jun 26 03:59:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 254564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 678902C0085 for ; Wed, 26 Jun 2013 14:05:30 +1000 (EST) Received: from localhost ([::1]:44781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Urgz1-0004ht-Uc for incoming@patchwork.ozlabs.org; Wed, 26 Jun 2013 00:05:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrgyY-0004a3-Pu for qemu-devel@nongnu.org; Wed, 26 Jun 2013 00:05:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UrgyW-00035n-1F for qemu-devel@nongnu.org; Wed, 26 Jun 2013 00:04:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrgyV-00035j-PW for qemu-devel@nongnu.org; Wed, 26 Jun 2013 00:04:55 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5Q44s1L017825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 26 Jun 2013 00:04:55 -0400 Received: from t430s.nay.redhat.com ([10.66.7.14]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5Q44bbR003751; Wed, 26 Jun 2013 00:04:48 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 26 Jun 2013 11:59:19 +0800 Message-Id: <1372219161-12209-2-git-send-email-famz@redhat.com> In-Reply-To: <1372219161-12209-1-git-send-email-famz@redhat.com> References: <1372219161-12209-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, obarenbo@redhat.com, roliveri@redhat.com, hbrock@redhat.com, rjones@redhat.com, armbru@redhat.com, pmyers@redhat.com, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [RFC PATCH 1/3] block: add target-id option to drive-backup QMP command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add target-id (optional) to drive-backup command, to make the target bs a named drive so that we can operate on it (e.g. export with NBD). Signed-off-by: Fam Zheng --- blockdev.c | 4 +++- qapi-schema.json | 7 +++++-- qmp-commands.hx | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index b3a57e0..5e694f3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -935,6 +935,7 @@ static void drive_backup_prepare(BlkTransactionState *common, Error **errp) backup = common->action->drive_backup; qmp_drive_backup(backup->device, backup->target, + backup->has_target_id, backup->target_id, backup->has_format, backup->format, backup->has_mode, backup->mode, backup->has_speed, backup->speed, @@ -1420,6 +1421,7 @@ void qmp_block_commit(const char *device, } void qmp_drive_backup(const char *device, const char *target, + bool has_target_id, const char *target_id, bool has_format, const char *format, bool has_mode, enum NewImageMode mode, bool has_speed, int64_t speed, @@ -1494,7 +1496,7 @@ void qmp_drive_backup(const char *device, const char *target, return; } - target_bs = bdrv_new(""); + target_bs = bdrv_new(has_target_id ? target_id : ""); ret = bdrv_open(target_bs, target, NULL, flags, drv); if (ret < 0) { bdrv_delete(target_bs); diff --git a/qapi-schema.json b/qapi-schema.json index 30b1edb..abd29c3 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1646,7 +1646,8 @@ # Since: 1.6 ## { 'type': 'DriveBackup', - 'data': { 'device': 'str', 'target': 'str', '*format': 'str', + 'data': { 'device': 'str', 'target': 'str', + '*target-id': 'str', '*format': 'str', '*mode': 'NewImageMode', '*speed': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError' } } @@ -1799,6 +1800,7 @@ # is a device, the existing file/device will be used as the new # destination. If it does not exist, a new file will be created. # +# @target-id: #optional the drive id of the target. # @format: #optional the format of the new destination, default is to # probe if @mode is 'existing', else the format of the source # @@ -1825,7 +1827,8 @@ # Since 1.6 ## { 'command': 'drive-backup', - 'data': { 'device': 'str', 'target': 'str', '*format': 'str', + 'data': { 'device': 'str', 'target': 'str', + '*target-id': 'str', '*format': 'str', '*mode': 'NewImageMode', '*speed': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 362f0e1..c90e132 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -913,7 +913,7 @@ EQMP { .name = "drive-backup", - .args_type = "device:B,target:s,speed:i?,mode:s?,format:s?," + .args_type = "device:B,target:s,target-id:s?,speed:i?,mode:s?,format:s?," "on-source-error:s?,on-target-error:s?", .mhandler.cmd_new = qmp_marshal_input_drive_backup, }, @@ -936,6 +936,7 @@ Arguments: device, the existing file/device will be used as the new destination. If it does not exist, a new file will be created. (json-string) +- "target_id": the drive id of the target image. - "format": the format of the new destination, default is to probe if 'mode' is 'existing', else the format of the source (json-string, optional)