From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtxDY-0002M5-I3 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 05:22:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtxDP-0002QB-W6 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 05:22:04 -0500 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:38955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtxDP-0002Q6-PY for qemu-devel@nongnu.org; Fri, 20 Dec 2013 05:21:55 -0500 Received: by mail-wi0-f169.google.com with SMTP id hn6so7764321wib.4 for ; Fri, 20 Dec 2013 02:21:55 -0800 (PST) Date: Fri, 20 Dec 2013 11:21:52 +0100 From: Stefan Hajnoczi Message-ID: <20131220102152.GG27021@stefanha-thinkpad.redhat.com> References: <4f5c56d2ebd81d5ae3333b4894eb785ab98cf2db.1387419339.git.hutao@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4f5c56d2ebd81d5ae3333b4894eb785ab98cf2db.1387419339.git.hutao@cn.fujitsu.com> Subject: Re: [Qemu-devel] [RFC PATCH v3 6/6] qcow2: Add full image preallocation option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: Kevin Wolf , Peter Lieven , Fam Zheng , qemu-devel@nongnu.org On Thu, Dec 19, 2013 at 10:27:41AM +0800, Hu Tao wrote: > -static int preallocate(BlockDriverState *bs) > +static int preallocate(BlockDriverState *bs, enum prealloc_mode mode) > { > uint64_t nb_sectors; > uint64_t offset; > @@ -1395,9 +1395,19 @@ static int preallocate(BlockDriverState *bs) > int ret; > QCowL2Meta *meta; > > + assert(mode != PREALLOC_OFF); > + > nb_sectors = bdrv_getlength(bs) >> 9; > offset = 0; > > + if (mode == PREALLOC_FULL) { > + ret = bdrv_preallocate(bs->file, 0, bdrv_getlength(bs)); This doesn't make sense since it fails to factor in qcow2 metadata and the file layout.