From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuEl7-0007an-MH for qemu-devel@nongnu.org; Thu, 05 Nov 2015 02:14:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuEl3-0002mq-MX for qemu-devel@nongnu.org; Thu, 05 Nov 2015 02:14:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuEl3-0002md-HL for qemu-devel@nongnu.org; Thu, 05 Nov 2015 02:14:53 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id A7AD78E238 for ; Thu, 5 Nov 2015 07:14:52 +0000 (UTC) Date: Thu, 5 Nov 2015 15:14:49 +0800 From: Fam Zheng Message-ID: <20151105071449.GH24893@ad.usersys.redhat.com> References: <20151104163730.GB28428@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151104163730.GB28428@redhat.com> Subject: Re: [Qemu-devel] Should 'qemu-img commit' sparsify the backing file? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: qemu-devel@nongnu.org On Wed, 11/04 16:37, Richard W.M. Jones wrote: > > This doesn't work (I tested both qemu 2.3 and qemu from git). Should it? > > (1) Create a non-sparse guest image: > > $ virt-builder fedora-22 > $ mv fedora-22.img fedora-22.img.sparse > $ cp --sparse=never fedora-22.img.sparse fedora-22.img > $ du -sh fedora-22.img > 6.1G fedora-22.img > > (2) Add a snapshot on top: > > $ qemu-img create -f qcow2 -o compat=1.1 -b fedora-22.img overlay.qcow2 > $ du -sh fedora-22.img overlay.qcow2 > 6.1G fedora-22.img > 196K overlay.qcow2 > > (3) Sparsify the overlay: > > $ virt-sparsify --in-place overlay.qcow2 > $ du -sh fedora-22.img overlay.qcow2 > 6.1G fedora-22.img > 3.2M overlay.qcow2 > > (4) Commit to the backing file: > > $ qemu-img commit overlay.qcow2 > Image committed. > $ du -sh fedora-22.img overlay.qcow2 > 6.1G fedora-22.img <------ > 260K overlay.qcow2 > > Notice that the backing file (fedora-22.img) doesn't get any smaller. > > I'm expecting the backing file to shrink to around 800 MB, which is > does if you run virt-sparsify directly on the backing file. > I don't think this the purpose of "qemu-img commit". Committing "new" data in overlay.qcow2 has little to do with discarding backing image's fragments where there are only explict zeroes. However you can try qemu-img convert fedora-22.img fedora-22.img.1 as the last step, which I think will yield a sparse image. I don't think we have an in-place sparsifier now. Fam