From patchwork Mon Jan 7 07:28:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 209878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AB7772C008D for ; Mon, 7 Jan 2013 19:24:25 +1100 (EST) Received: from localhost ([::1]:36075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ts7Al-0005TN-Vd for incoming@patchwork.ozlabs.org; Mon, 07 Jan 2013 02:31:03 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ts7AW-00053Y-E2 for qemu-devel@nongnu.org; Mon, 07 Jan 2013 02:30:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ts7AU-0005bi-8r for qemu-devel@nongnu.org; Mon, 07 Jan 2013 02:30:48 -0500 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:36459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ts7AT-0005aW-7L for qemu-devel@nongnu.org; Mon, 07 Jan 2013 02:30:46 -0500 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Jan 2013 17:25:57 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 Jan 2013 17:25:55 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 7A27A357804E for ; Mon, 7 Jan 2013 18:30:41 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r077JETw53018862 for ; Mon, 7 Jan 2013 18:19:14 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r077Uev0023910 for ; Mon, 7 Jan 2013 18:30:41 +1100 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.237]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r077Rp6f018491; Mon, 7 Jan 2013 18:30:38 +1100 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Mon, 7 Jan 2013 15:28:09 +0800 Message-Id: <1357543689-11415-12-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1357543689-11415-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1357543689-11415-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13010707-6102-0000-0000-000002CFFC8B X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.145 Cc: kwolf@redhat.com, aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com, Wenchao Xia , 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 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 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 --- 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); }