qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, quintela@redhat.com,
	stefanha@gmail.com, Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
	lcapitulino@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com
Subject: [Qemu-devel] [PATCH V2 10/10] snapshot: hmp add internal snapshot support for block device
Date: Mon,  7 Jan 2013 15:28:09 +0800	[thread overview]
Message-ID: <1357543689-11415-12-git-send-email-xiawenc@linux.vnet.ibm.com> (raw)
In-Reply-To: <1357543689-11415-1-git-send-email-xiawenc@linux.vnet.ibm.com>

  Now hmp can take snapshot for a single block device.

v2:
  Removed option -n in internal snapshot case.
  Better tips.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 hmp-commands.hx |   28 +++++++++++++++++-----------
 hmp.c           |   25 +++++++++++++++----------
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 010b8c9..bd10349 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -983,17 +983,23 @@ ETEXI
 
     {
         .name       = "snapshot_blkdev",
-        .args_type  = "reuse:-n,device:B,snapshot-file:s?,format:s?",
-        .params     = "[-n] device [new-image-file] [format]",
-        .help       = "initiates a live snapshot\n\t\t\t"
-                      "of device. If a new image file is specified, the\n\t\t\t"
-                      "new image file will become the new root image.\n\t\t\t"
-                      "If format is specified, the snapshot file will\n\t\t\t"
-                      "be created in that format. Otherwise the\n\t\t\t"
-                      "snapshot will be internal! (currently unsupported).\n\t\t\t"
-                      "The default format is qcow2.  The -n flag requests QEMU\n\t\t\t"
-                      "to reuse the image found in new-image-file, instead of\n\t\t\t"
-                      "recreating it from scratch.",
+        .args_type  = "internal:-i,reuse:-n,device:B,name:s?,format:s?",
+        .params     = "[-i] [-n] device [name] [format]",
+        .help       = "initiates a live snapshot of device.\n\t\t\t"
+                      "  The -i flag requests QEMU to create internal snapshot\n\t\t\t"
+                      "instead of external one.\n\t\t\t"
+                      "  The -n flag requests QEMU to reuse the image found in\n\t\t\t"
+                      "in name, instead of recreating it from scratch. Only valid\n\t\t\t"
+                      "for external case.\n\t\t\t"
+                      "  The name is the snapshot's name. In external case\n\t\t\t"
+                      "it is the new image's name which will become the new root\n\t\t\t"
+                      "image and must be specified. In internal case it is the\n\t\t\t"
+                      "record's name and if not specified QEMU will create\n\t\t\t"
+                      "internal snapshot with name generated according to time.\n\t\t\t"
+                      "Any existing internal snapshot with name will be overwritten.\n\t\t\t"
+                      "  The format is the new snapshot image's format. If not\n\t\t\t"
+                      "sepcified, the default format is qcow2. Only valid for external\n\t\t\t"
+                      "case.",
         .mhandler.cmd = hmp_snapshot_blkdev,
     },
 
diff --git a/hmp.c b/hmp.c
index 9e9e624..d78d55f 100644
--- a/hmp.c
+++ b/hmp.c
@@ -804,23 +804,28 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
 void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");
-    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+    const char *name = qdict_get_try_str(qdict, "name");
     const char *format = qdict_get_try_str(qdict, "format");
     int reuse = qdict_get_try_bool(qdict, "reuse", 0);
+    int internal = qdict_get_try_bool(qdict, "internal", 0);
     enum NewImageMode mode;
+
     Error *errp = NULL;
 
-    if (!filename) {
-        /* In the future, if 'snapshot-file' is not specified, the snapshot
-           will be taken internally. Today it's actually required. */
-        error_set(&errp, QERR_MISSING_PARAMETER, "snapshot-file");
-        hmp_handle_error(mon, &errp);
-        return;
+    if (internal) {
+        qmp_blockdev_snapshot_internal_sync(device, !!name, name, &errp);
+    } else {
+        if (!name) {
+            /* Name must be specified for external case */
+            error_set(&errp, QERR_MISSING_PARAMETER, "name");
+            hmp_handle_error(mon, &errp);
+            return;
+        }
+        mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
+        qmp_blockdev_snapshot_sync(device, name, !!format, format,
+                                   true, mode, &errp);
     }
 
-    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
-    qmp_blockdev_snapshot_sync(device, filename, !!format, format,
-                               true, mode, &errp);
     hmp_handle_error(mon, &errp);
 }
 
-- 
1.7.1

  parent reply	other threads:[~2013-01-07  7:30 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07  7:27 [Qemu-devel] [PATCH V2 00/10] snapshot: take block snapshots in unified way Wenchao Xia
2013-01-07  7:27 ` [Qemu-devel] [PATCH V2 01/10] block: export function bdrv_find_snapshot() Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 02/10] block: add function deappend() Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 03/10] error: add function error_set_check() Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 04/10] oslib-win32: add lock for time functions Wenchao Xia
2013-01-07 17:12   ` Stefan Weil
2013-01-08  2:27     ` Wenchao Xia
2013-01-07  7:28 ` Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 05/10] snapshot: design of internal common API to take snapshots Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 06/10] snapshot: implemention " Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 07/10] snapshot: qmp use new internal API for external snapshot transaction Wenchao Xia
2013-01-09 12:44   ` Stefan Hajnoczi
2013-01-10  3:21     ` Wenchao Xia
2013-01-10 12:41       ` Stefan Hajnoczi
2013-01-11  6:22         ` Wenchao Xia
2013-01-11  9:12           ` Stefan Hajnoczi
2013-01-14  2:56             ` Wenchao Xia
2013-01-14 10:06               ` Stefan Hajnoczi
2013-01-15  7:03                 ` Wenchao Xia
2013-03-12  8:30                   ` Wenchao Xia
2013-03-12 15:43                     ` Stefan Hajnoczi
2013-03-13  1:36                       ` Wenchao Xia
2013-03-13  8:42                         ` Stefan Hajnoczi
2013-03-13 10:18                     ` Kevin Wolf
2013-03-14  5:08                       ` Wenchao Xia
2013-03-14  8:22                         ` Kevin Wolf
2013-03-18 10:00                           ` Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 08/10] snapshot: qmp add internal snapshot transaction interface Wenchao Xia
2013-01-07  7:28 ` [Qemu-devel] [PATCH V2 09/10] snapshot: qmp add blockdev-snapshot-internal-sync interface Wenchao Xia
2013-01-07  7:28 ` Wenchao Xia [this message]
2013-01-09 22:34 ` [Qemu-devel] [PATCH V2 00/10] snapshot: take block snapshots in unified way Eric Blake
2013-01-10  6:01   ` Wenchao Xia
2013-01-11 13:56     ` Luiz Capitulino
2013-01-14  2:09       ` Wenchao Xia
2013-01-14 10:08         ` Stefan Hajnoczi

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=1357543689-11415-12-git-send-email-xiawenc@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=dietmar@proxmox.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@gmail.com \
    /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).