qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Should 'qemu-img commit' sparsify the backing file?
@ 2015-11-04 16:37 Richard W.M. Jones
  2015-11-05  7:14 ` Fam Zheng
  0 siblings, 1 reply; 6+ messages in thread
From: Richard W.M. Jones @ 2015-11-04 16:37 UTC (permalink / raw)
  To: qemu-devel


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-09 16:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 16:37 [Qemu-devel] Should 'qemu-img commit' sparsify the backing file? Richard W.M. Jones
2015-11-05  7:14 ` Fam Zheng
2015-11-05  8:56   ` Richard W.M. Jones
2015-11-05  9:46     ` Fam Zheng
2015-11-05 12:18       ` Richard W.M. Jones
2015-11-09 16:03       ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).