From patchwork Thu Jan 21 11:22:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rudy Zhang X-Patchwork-Id: 8081471 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 80A5EBEEE5 for ; Thu, 21 Jan 2016 14:01:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B277620502 for ; Thu, 21 Jan 2016 14:01:52 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 25DC120462 for ; Thu, 21 Jan 2016 14:01:45 +0000 (UTC) Received: from localhost ([::1]:47753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMFnz-00069i-Mf for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Jan 2016 09:01:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMDK7-000534-PU for qemu-devel@nongnu.org; Thu, 21 Jan 2016 06:22:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMDK6-0008JT-Pi for qemu-devel@nongnu.org; Thu, 21 Jan 2016 06:22:43 -0500 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]:36465) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMDK6-0008JL-Fb; Thu, 21 Jan 2016 06:22:42 -0500 Received: by mail-pa0-x241.google.com with SMTP id a20so1620618pag.3; Thu, 21 Jan 2016 03:22:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hMgGWdsOK491vYNaTaz008BN619BZVhpdJKYa0gdv4Y=; b=drGXAXSCJrpiAm58V9EzTaSUPkYOLiOjocZ/IgS01juwkRguOSrpFocOiFLyE9DUiw bVRrHDKVZWAuPhpRRjUUob/vE4lrwFkdXjlBvJbB5bUPBdzpLP8PTX3SndVh/ZThOLYO LkQ+IJt3xF0GL78rbOO8AtoH67VU689u/sX0TWbXVCLYXlMPaxDkaggJywEX2JDaBcZA VP2o/nzA2tQAsMC+qwkbZ5qR3w6CUVETbvlH9AfiZUyATlEijBvfpovLMPYkcF0AQs6+ GpYklpDVbQRDwOmKV4+GG7szKYz9I9Y0AQxtgfxXdE+tZS3unmvJxdpSWXJUO07z7zN1 WXwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hMgGWdsOK491vYNaTaz008BN619BZVhpdJKYa0gdv4Y=; b=k43uTe3ctI3vd3kcyXpbxX4EDT1TwRTnxgI0iSJTZj73kGlHtry+P3HsoImTR54Jhd mFuIDjLOCpBffFE9wiZBCl0gA2Kd+60VN+nw7ZTnqCGXAZp9cNvrbTnQyXO1eTgADFRE R3YqOUiD0IRaTPyE2Oqo0fmjgqJg7sTA1Ur0jwIfFTtYUDkWC8bP1ZTHnmuwV5fFyqRL YXBJ3iA0triLsHIJOYngOvdeKDbyw+Fh5G5nQDA+fhDuZhGqsOjHcQBjx14BuA+FG7Py O4n+5kj4YDQwVC2jPI+W9v1batqZXdtgRdqzJzOiHhNjhcORTVFecsqzejNmQDZQEZ3C DMcw== X-Gm-Message-State: AG10YOThnav6VOGABnzvF5+k2ouSiCcE8EJifdrIn1xIMEyVTJKlhNckkNOkR2i4rRD9uA== X-Received: by 10.66.122.8 with SMTP id lo8mr28014629pab.35.1453375361729; Thu, 21 Jan 2016 03:22:41 -0800 (PST) Received: from localhost.localdomain ([207.226.142.175]) by smtp.gmail.com with ESMTPSA id u21sm2000465pfi.15.2016.01.21.03.22.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jan 2016 03:22:41 -0800 (PST) From: Rudy Zhang To: qemu-devel@nongnu.org Date: Thu, 21 Jan 2016 19:22:17 +0800 Message-Id: <1453375338-13508-2-git-send-email-rudyflyzhang@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1453375338-13508-1-git-send-email-rudyflyzhang@gmail.com> References: <1453375338-13508-1-git-send-email-rudyflyzhang@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::241 X-Mailman-Approved-At: Thu, 21 Jan 2016 09:01:35 -0500 Cc: Rudy Zhang , famz@redhat.com, qemu-block@nongnu.org Subject: [Qemu-devel] [PATCH 1/2] hmp: add hmp command for incremental backup 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add hmp command for incremental backup in drive-backup. It need a bitmap to backup data from drive-image to incremental image, so before it need add bitmap for this device to track io. Usage: drive_backup [-n] [-f] device target [bitmap] [format] Signed-off-by: Rudy Zhang --- hmp-commands.hx | 5 +++-- hmp.c | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index bb52e4d..7378aaa 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1180,12 +1180,13 @@ ETEXI { .name = "drive_backup", - .args_type = "reuse:-n,full:-f,device:B,target:s,format:s?", - .params = "[-n] [-f] device target [format]", + .args_type = "reuse:-n,full:-f,device:B,target:s,bitmap:s?,format:s?", + .params = "[-n] [-f] device target [bitmap] [format]", .help = "initiates a point-in-time\n\t\t\t" "copy for a device. The device's contents are\n\t\t\t" "copied to the new image file, excluding data that\n\t\t\t" "is written after the command is started.\n\t\t\t" + "With bitmap will start incremental backup.\n\t\t\t" "The -n flag requests QEMU to reuse the image found\n\t\t\t" "in new-image-file, instead of recreating it from scratch.\n\t\t\t" "The -f flag requests QEMU to copy the whole disk,\n\t\t\t" diff --git a/hmp.c b/hmp.c index 54f2620..f8c33cd 100644 --- a/hmp.c +++ b/hmp.c @@ -1086,11 +1086,13 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); const char *filename = qdict_get_str(qdict, "target"); + const char *bitmap = qdict_get_try_str(qdict, "bitmap"); const char *format = qdict_get_try_str(qdict, "format"); bool reuse = qdict_get_try_bool(qdict, "reuse", false); bool full = qdict_get_try_bool(qdict, "full", false); enum NewImageMode mode; Error *err = NULL; + enum MirrorSyncMode sync; if (!filename) { error_setg(&err, QERR_MISSING_PARAMETER, "target"); @@ -1098,6 +1100,17 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) return; } + if (full && bitmap) { + error_setg(&err, "Parameter 'bitmap' if conflict with '-f'"); + hmp_handle_error(mon, &err); + return; + } else if (full) + sync = MIRROR_SYNC_MODE_FULL; + else if (bitmap) + sync = MIRROR_SYNC_MODE_INCREMENTAL; + else + sync = MIRROR_SYNC_MODE_TOP; + if (reuse) { mode = NEW_IMAGE_MODE_EXISTING; } else { @@ -1105,8 +1118,7 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) } qmp_drive_backup(device, filename, !!format, format, - full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, - true, mode, false, 0, false, NULL, + sync, true, mode, false, 0, !!bitmap, bitmap, false, 0, false, 0, &err); hmp_handle_error(mon, &err); }