From patchwork Fri Jan 21 22:19:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunqiang Tang X-Patchwork-Id: 79951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CE428B70ED for ; Sat, 22 Jan 2011 09:16:54 +1100 (EST) Received: from localhost ([127.0.0.1]:52007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgPG8-000848-GP for incoming@patchwork.ozlabs.org; Fri, 21 Jan 2011 17:15:08 -0500 Received: from [140.186.70.92] (port=42112 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgPFn-000842-0g for qemu-devel@nongnu.org; Fri, 21 Jan 2011 17:14:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgPFl-0002UI-QF for qemu-devel@nongnu.org; Fri, 21 Jan 2011 17:14:46 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:47342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgPFl-0002U5-Kx for qemu-devel@nongnu.org; Fri, 21 Jan 2011 17:14:45 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e39.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p0LM2UR7004363 for ; Fri, 21 Jan 2011 15:02:30 -0700 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id p0LMEfDc237826 for ; Fri, 21 Jan 2011 15:14:42 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0LMEfOs008646 for ; Fri, 21 Jan 2011 15:14:41 -0700 Received: from localhost.localdomain ([9.59.229.24]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p0LMEfnX008633; Fri, 21 Jan 2011 15:14:41 -0700 From: Chunqiang Tang To: qemu-devel@nongnu.org Date: Fri, 21 Jan 2011 17:19:13 -0500 Message-Id: <1295648355-17359-1-git-send-email-ctang@us.ibm.com> X-Mailer: git-send-email 1.7.0.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Chunqiang Tang Subject: [Qemu-devel] [PATCH 1/3] FVD: Added support for 'qemu-img update' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch is part of the Fast Virtual Disk (FVD) proposal. See the related discussions at http://lists.gnu.org/archive/html/qemu-devel/2011-01/msg00426.html. This patch adds the 'update' command to qemu-img. FVD stores various image-specific configurable parameters in the image header. A user can use 'qemu-img update' to modify those parameters and accordingly controls FVD's runtime behavior. This command may also be leveraged by other block device drivers, e.g., to set the size of the in-memory metadata cache. Currently those parameters are hard-coded in a one-size-fit-all manner. Signed-off-by: Chunqiang Tang --- block_int.h | 1 + qemu-img-cmds.hx | 6 ++++++ qemu-img.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 0 deletions(-) diff --git a/block_int.h b/block_int.h index 12663e8..e98872a 100644 --- a/block_int.h +++ b/block_int.h @@ -98,6 +98,7 @@ struct BlockDriver { int (*bdrv_snapshot_load_tmp)(BlockDriverState *bs, const char *snapshot_name); int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); + int (*bdrv_update)(BlockDriverState *bs, int argc, char **argv); int (*bdrv_save_vmstate)(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size); diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 6c7176f..1ad378b 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -39,6 +39,12 @@ STEXI @item info [-f @var{fmt}] @var{filename} ETEXI +DEF("update", img_update, + "update [-f fmt] filename [attr1=val1 attr2=val2 ...]") +STEXI +@item update [-f @var{fmt}] @var{filename} [@var{attr1=val1 attr2=val2 ...}]") +ETEXI + DEF("snapshot", img_snapshot, "snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename") STEXI diff --git a/qemu-img.c b/qemu-img.c index afd9ed2..5f35c4d 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1054,6 +1054,49 @@ static int img_info(int argc, char **argv) return 0; } +static int img_update(int argc, char **argv) +{ + int c; + const char *filename, *fmt; + BlockDriverState *bs; + + fmt = NULL; + for(;;) { + c = getopt(argc, argv, "f:h"); + if (c == -1) + break; + switch(c) { + case 'h': + help(); + break; + case 'f': + fmt = optarg; + break; + } + } + if (optind >= argc) + help(); + filename = argv[optind++]; + bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING + | BDRV_O_RDWR); + if (!bs) { + return 1; + } + + if (bs->drv->bdrv_update) { + bs->drv->bdrv_update(bs, argc-optind, &argv[optind]); + } + else { + char fmt_name[128]; + bdrv_get_format(bs, fmt_name, sizeof(fmt_name)); + error_report ("The 'update' command is not supported for " + "the '%s' image format.", fmt_name); + } + + bdrv_delete(bs); + return 0; +} + #define SNAPSHOT_LIST 1 #define SNAPSHOT_CREATE 2 #define SNAPSHOT_APPLY 3