From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu145-0002OJ-DQ for qemu-devel@nongnu.org; Wed, 04 Nov 2015 11:37:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zu140-00080W-KI for qemu-devel@nongnu.org; Wed, 04 Nov 2015 11:37:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu140-0007zy-Ea for qemu-devel@nongnu.org; Wed, 04 Nov 2015 11:37:32 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8DF97A380B for ; Wed, 4 Nov 2015 16:37:31 +0000 (UTC) Received: from localhost (vpn1-7-72.ams2.redhat.com [10.36.7.72]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA4GbUb5026479 for ; Wed, 4 Nov 2015 11:37:31 -0500 Date: Wed, 4 Nov 2015 16:37:30 +0000 From: "Richard W.M. Jones" Message-ID: <20151104163730.GB28428@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] Should 'qemu-img commit' sparsify the backing file? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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. For background, `virt-sparsify --in-place' mounts each filesystem (using a small Linux/qemu appliance), and runs fstrim on each one. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW