Received: from eggs.gnu.org ([208.118.235.92]:42031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV1Gz-0004u1-FE for qemu-devel@nongnu.org; Thu, 17 May 2012 10:01:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SV1Gu-0005Oq-9W for qemu-devel@nongnu.org; Thu, 17 May 2012 10:01:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV1Gu-0005OU-1g for qemu-devel@nongnu.org; Thu, 17 May 2012 10:01:40 -0400 Date: Thu, 17 May 2012 15:01:36 +0100 From: "Richard W.M. Jones" Message-ID: <20120517140136.GD15276@amd.home.annexia.org> References: <1337262266-32227-1-git-send-email-rjones@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qemu-img: Implement 'diff' operation. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org On Thu, May 17, 2012 at 02:52:56PM +0100, Peter Maydell wrote: > On 17 May 2012 14:44, Richard W.M. Jones wrote: > > From: "Richard W.M. Jones" > > > > This produces a qcow2 file which is the different between > > two disk images. =A0ie, if: > > > > =A0original.img - is a disk image (in any format) > > =A0modified.img - is a modified version of original.img > > > > then: > > > > =A0qemu-img diff -b original.img modified.img diff.qcow2 > > > > creates 'diff.qcow2' which contains just the differences. =A0Note tha= t > > 'diff.qcow2' has 'original.img' set as the backing file. >=20 > Any chance of some more detailed explanation in the docs patch > about what this actually means and why it's useful? I spent > several minutes going "huh, does it even mean anything to > calculate the difference between two binary disk images?" > before realising that it's the presence of the backing file > that makes it actually make sense... Well I'll say first of all that I was asked to implement this by a colleague. Personally, I'm far more organized than this, and I always use snapshots and backing files if I want to create an efficient COW from a base template :-) However my colleague has got himself into a situation where he has copied (ie. "cp" or equivalent) a guest several times from a template, and these guests have been running independently. He now wants to conserve disk space by turning this situation back into one where he has one backing file + several COW copies. To do this, he can (with this patch) do: qemu-img diff -b base.img the_copied_guest.img guest.qcow2 rm the_copied_guest.img 'guest.qcow2' will (in theory at least) be much smaller than the copied guests he has right now. Does that make sense? [BTW I'm still working on this. There are a few spelling mistakes and it needs a lot more testing. This patch is just for comment at the moment.] Rich. --=20 Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rj= ones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org