From patchwork Wed Apr 9 07:12:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 337774 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5D3EE14008D for ; Wed, 9 Apr 2014 17:15:52 +1000 (EST) Received: from localhost ([::1]:44724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXmje-0000j0-5s for incoming@patchwork.ozlabs.org; Wed, 09 Apr 2014 03:15:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXmiv-0000fd-UV for qemu-devel@nongnu.org; Wed, 09 Apr 2014 03:15:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXmir-00086S-6A for qemu-devel@nongnu.org; Wed, 09 Apr 2014 03:15:05 -0400 Received: from [59.151.112.132] (port=5723 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXmiq-00082D-Nx for qemu-devel@nongnu.org; Wed, 09 Apr 2014 03:15:01 -0400 X-IronPort-AV: E=Sophos;i="4.97,824,1389715200"; d="scan'208";a="29036380" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Apr 2014 15:11:55 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s397EJxb012444; Wed, 9 Apr 2014 15:14:19 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com (10.167.226.102) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Wed, 9 Apr 2014 15:14:31 +0800 From: Hu Tao To: Date: Wed, 9 Apr 2014 15:12:34 +0800 Message-ID: <2a4f67b31254a773cfae24ed750148c37e92e9cd.1397026795.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.2.229.g4448466 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.102] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v8 1/4] qapi: introduce PreallocMode and a new PreallocMode full. 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 This patch prepares for the subsequent patches. Reviewed-by: Fam Zheng Signed-off-by: Hu Tao Reviewed-by: Eric Blake --- block/qcow2.c | 8 ++++---- qapi-schema.json | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index e903d97..3377007 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1592,7 +1592,7 @@ static int preallocate(BlockDriverState *bs) static int qcow2_create2(const char *filename, int64_t total_size, const char *backing_file, const char *backing_format, - int flags, size_t cluster_size, int prealloc, + int flags, size_t cluster_size, PreallocMode prealloc, QEMUOptionParameter *options, int version, Error **errp) { @@ -1769,7 +1769,7 @@ static int qcow2_create(const char *filename, QEMUOptionParameter *options, uint64_t sectors = 0; int flags = 0; size_t cluster_size = DEFAULT_CLUSTER_SIZE; - int prealloc = 0; + PreallocMode prealloc = PREALLOC_MODE_OFF; int version = 3; Error *local_err = NULL; int ret; @@ -1790,9 +1790,9 @@ static int qcow2_create(const char *filename, QEMUOptionParameter *options, } } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) { if (!options->value.s || !strcmp(options->value.s, "off")) { - prealloc = 0; + prealloc = PREALLOC_MODE_OFF; } else if (!strcmp(options->value.s, "metadata")) { - prealloc = 1; + prealloc = PREALLOC_MODE_METADATA; } else { error_setg(errp, "Invalid preallocation mode: '%s'", options->value.s); diff --git a/qapi-schema.json b/qapi-schema.json index 391356f..9e6221a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4689,3 +4689,17 @@ 'btn' : 'InputBtnEvent', 'rel' : 'InputMoveEvent', 'abs' : 'InputMoveEvent' } } + +## +# @PreallocMode +# +# Preallocation mode of QEMU image file +# +# @off: no preallocation +# @metadata: preallocate only for metadata +# @full: preallocate all data, including metadata +# +# Since 2.0 +## +{ 'enum': 'PreallocMode', + 'data': [ 'off', 'metadata', 'full' ] }