qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Rudy Zhang <rudyflyzhang@gmail.com>
To: qemu-devel@nongnu.org
Cc: Rudy Zhang <rudyflyzhang@gmail.com>,
	famz@redhat.com, qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] hmp: add hmp command for incremental backup
Date: Thu, 21 Jan 2016 19:22:17 +0800	[thread overview]
Message-ID: <1453375338-13508-2-git-send-email-rudyflyzhang@gmail.com> (raw)
In-Reply-To: <1453375338-13508-1-git-send-email-rudyflyzhang@gmail.com>

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 <rudyflyzhang@gmail.com>
---
 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);
 }
-- 
2.6.4

  reply	other threads:[~2016-01-21 11:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 11:22 [Qemu-devel] [PATCH 0/2] block/hmp: add sereval hmp commands for incremental backup Rudy Zhang
2016-01-21 11:22 ` Rudy Zhang [this message]
2016-01-21 16:39   ` [Qemu-devel] [PATCH 1/2] hmp: add hmp command " Eric Blake
2016-01-21 20:47     ` [Qemu-devel] [Qemu-block] " John Snow
2016-01-22  2:04     ` [Qemu-devel] " 张敏
2016-01-22 16:39       ` Eric Blake
2016-01-21 11:22 ` [Qemu-devel] [PATCH 2/2] hmp: add hmp commands dirty bitmap add/clear/remove' Rudy Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453375338-13508-2-git-send-email-rudyflyzhang@gmail.com \
    --to=rudyflyzhang@gmail.com \
    --cc=famz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).