From patchwork Mon Sep 5 18:13:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9315039 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 57F5F60869 for ; Mon, 5 Sep 2016 18:46:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46F60284B7 for ; Mon, 5 Sep 2016 18:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B9D528ACA; Mon, 5 Sep 2016 18:46:14 +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 A43ED28AC8 for ; Mon, 5 Sep 2016 18:46:13 +0000 (UTC) Received: from localhost ([::1]:56307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgyuK-0004Oa-Ee for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Sep 2016 14:46:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgyPt-0003DJ-Nz for qemu-devel@nongnu.org; Mon, 05 Sep 2016 14:14:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgyPp-00015H-OK for qemu-devel@nongnu.org; Mon, 05 Sep 2016 14:14:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41994) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgyPf-0000yI-J4; Mon, 05 Sep 2016 14:14:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 402CD8E248; Mon, 5 Sep 2016 18:14:31 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u85IDt7p020627; Mon, 5 Sep 2016 14:14:30 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 5 Sep 2016 20:13:39 +0200 Message-Id: <1473099234-10882-28-git-send-email-kwolf@redhat.com> In-Reply-To: <1473099234-10882-1-git-send-email-kwolf@redhat.com> References: <1473099234-10882-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 05 Sep 2016 18:14:31 +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 27/42] blockdev-backup: added support for data compression 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: Pavel Butsykin The idea is simple - backup is "written-once" data. It is written block by block and it is large enough. It would be nice to save storage space and compress it. Signed-off-by: Pavel Butsykin Reviewed-by: Stefan Hajnoczi Signed-off-by: Denis V. Lunev CC: Jeff Cody CC: Markus Armbruster CC: Eric Blake CC: John Snow CC: Stefan Hajnoczi CC: Kevin Wolf Signed-off-by: Kevin Wolf --- blockdev.c | 7 +++++-- qapi/block-core.json | 4 ++++ qmp-commands.hx | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index f5857d0..97062e3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3254,6 +3254,9 @@ void do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, Error **errp) if (!backup->has_job_id) { backup->job_id = NULL; } + if (!backup->has_compress) { + backup->compress = false; + } bs = qmp_get_root_bs(backup->device, errp); if (!bs) { @@ -3280,8 +3283,8 @@ void do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, Error **errp) } } backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync, - NULL, false, backup->on_source_error, backup->on_target_error, - block_job_cb, bs, txn, &local_err); + NULL, backup->compress, backup->on_source_error, + backup->on_target_error, block_job_cb, bs, txn, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); } diff --git a/qapi/block-core.json b/qapi/block-core.json index 300a68b..31f9990 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -939,6 +939,9 @@ # @speed: #optional the maximum speed, in bytes per second. The default is 0, # for unlimited. # +# @compress: #optional true to compress data, if the target format supports it. +# (default: false) (since 2.7) +# # @on-source-error: #optional the action to take on an error on the source, # default 'report'. 'stop' and 'enospc' can only be used # if the block device supports io-status (see BlockInfo). @@ -957,6 +960,7 @@ 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', 'sync': 'MirrorSyncMode', '*speed': 'int', + '*compress': 'bool', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index d1593c9..ba2a916 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1275,7 +1275,7 @@ EQMP { .name = "blockdev-backup", - .args_type = "job-id:s?,sync:s,device:B,target:B,speed:i?," + .args_type = "job-id:s?,sync:s,device:B,target:B,speed:i?,compress:b?," "on-source-error:s?,on-target-error:s?", .mhandler.cmd_new = qmp_marshal_blockdev_backup, }, @@ -1299,6 +1299,8 @@ Arguments: sectors allocated in the topmost image, or "none" to only replicate new I/O (MirrorSyncMode). - "speed": the maximum speed, in bytes per second (json-int, optional) +- "compress": true to compress data, if the target format supports it. + (json-bool, optional, default false) - "on-source-error": the action to take on an error on the source, default 'report'. 'stop' and 'enospc' can only be used if the block device supports io-status.