From patchwork Tue Jul 31 16:51:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Wang X-Patchwork-Id: 174288 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 150472C0094 for ; Wed, 1 Aug 2012 02:53:01 +1000 (EST) Received: from localhost ([::1]:33190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwFgp-0002AV-4q for incoming@patchwork.ozlabs.org; Tue, 31 Jul 2012 12:52:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwFgU-0001rw-F5 for qemu-devel@nongnu.org; Tue, 31 Jul 2012 12:52:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwFgR-0004Mn-Ml for qemu-devel@nongnu.org; Tue, 31 Jul 2012 12:52:38 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:51739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwFgR-0004IN-IM for qemu-devel@nongnu.org; Tue, 31 Jul 2012 12:52:35 -0400 Received: by mail-yx0-f173.google.com with SMTP id l1so6109195yen.4 for ; Tue, 31 Jul 2012 09:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=78PN9RZVYckgP+Ez+H43qYcOLLPrKhHm//TYT8hlcOI=; b=ohNXBwYcaBGcaD9zX3L4PwJhjpshZigW0KULfupLTO/s4vyZJHOIVp/YhnaXOC2Iw8 N9bGG03mW55f6g7OEfKdla3K1CJBePYQhGmavHJaoFjyn52Qvlkv3lbCED6HJAhsZJ3y KT1/HlRsCy7G1fIPc6T7HcgeKYSmfpp/6clb5kzqz+nMZ6wmh+LlsKqiYHLrxjly4qQU 4T6bhS1s8JbW+bFdw3yiABPrQWdUflBPMUuFij5+WHhUcMnIMVNCljue4Ulrxlm/r/EW O2S1AYltjaNfi2m5hhS5kjx8ihU1/zyvXE6ynlW3THsjcwzj+uAxifaHvhF4hZfo/z2p Cgww== Received: by 10.50.89.169 with SMTP id bp9mr1289622igb.59.1343753554935; Tue, 31 Jul 2012 09:52:34 -0700 (PDT) Received: from localhost.localdomain ([202.108.130.138]) by mx.google.com with ESMTPS id uq6sm3025753igb.14.2012.07.31.09.52.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 Jul 2012 09:52:34 -0700 (PDT) From: Dong Xu Wang To: qemu-devel@nongnu.org Date: Wed, 1 Aug 2012 00:51:49 +0800 Message-Id: <1343753510-24661-5-git-send-email-wdongxu@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1343753510-24661-1-git-send-email-wdongxu@linux.vnet.ibm.com> References: <1343753510-24661-1-git-send-email-wdongxu@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.173 Cc: kwolf@redhat.com, Dong Xu Wang Subject: [Qemu-devel] [PATCH 5/6 v11] add-cow: hmp and qmp interface 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 add HMP and QMP support for add-cow format. Because add-cow does not work like other image formats, it will use image-file, so we need add add-cow support while doing snapshot. Signed-off-by: Dong Xu Wang --- hmp-commands.hx | 8 ++++++-- hmp.c | 5 ++++- qapi-schema.json | 5 +++-- qmp-commands.hx | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index eea8b32..bd14690 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -908,14 +908,18 @@ ETEXI { .name = "snapshot_blkdev", - .args_type = "reuse:-n,device:B,snapshot-file:s?,format:s?", - .params = "[-n] device [new-image-file] [format]", + .args_type = "reuse:-n,device:B,snapshot-file:s?,format:s?,image-file:s?,image-format:s?", + .params = "[-n] device [new-image-file] [format] [image-file] [image-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" + "If image file is specified, the snapshot file will\n\t\t\t" + "be created using image_file option.\n\t\t\t" + "If image-format is specified, the image file will\n\t\t\t" + "be created in that format. Otherwise will use raw format.\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.", diff --git a/hmp.c b/hmp.c index 6b72a64..4c7026c 100644 --- a/hmp.c +++ b/hmp.c @@ -701,6 +701,8 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) const char *filename = qdict_get_try_str(qdict, "snapshot-file"); const char *format = qdict_get_try_str(qdict, "format"); int reuse = qdict_get_try_bool(qdict, "reuse", 0); + const char *image_filename = qdict_get_try_str(qdict, "image-file"); + const char *image_format = qdict_get_try_str(qdict, "image-format"); enum NewImageMode mode; Error *errp = NULL; @@ -714,7 +716,8 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS; qmp_blockdev_snapshot_sync(device, filename, !!format, format, - true, mode, &errp); + true, mode, !!image_filename, image_filename, + !!image_format, image_format, &errp); hmp_handle_error(mon, &errp); } diff --git a/qapi-schema.json b/qapi-schema.json index bc55ed2..c90fe0d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1204,7 +1204,7 @@ ## { 'type': 'BlockdevSnapshot', 'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str', - '*mode': 'NewImageMode' } } + '*mode': 'NewImageMode', '*image_file': 'str', '*image_format': 'str' } } ## # @BlockdevAction @@ -1269,7 +1269,8 @@ ## { 'command': 'blockdev-snapshot-sync', 'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str', - '*mode': 'NewImageMode'} } + '*mode': 'NewImageMode', '*image-file': 'str', + '*image-format': 'str'} } ## # @human-monitor-command: diff --git a/qmp-commands.hx b/qmp-commands.hx index e3cf3c5..fc776a5 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -789,7 +789,7 @@ EQMP { .name = "blockdev-snapshot-sync", - .args_type = "device:B,snapshot-file:s,format:s?,mode:s?", + .args_type = "device:B,snapshot-file:s,format:s?,mode:s?,image-file:s?,image-format:s?", .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_sync, },