On Mon, May 21, 2012 at 03:29:22PM +0200, Kevin Wolf wrote:
> Am 17.05.2012 17:34, schrieb Richard W.M. Jones:
> > From: "Richard W.M. Jones" <rjo...@redhat.com>
> > 
> > This produces a qcow2 file which is the difference between
> > two disk images.  ie, if:
> > 
> >   base.img     - is a disk image (in any format)
> >   modified.img - is base.img, copied and modified
> > 
> > then:
> > 
> >   qemu-img diff -b base.img modified.img diff.qcow2
> > 
> > creates 'diff.qcow2' which contains the differences between 'base.img'
> > and 'modified.img'.  Note that 'diff.qcow2' has 'base.img' as its
> > backing file.
> > 
> > Signed-off-by: Richard W.M. Jones <rjo...@redhat.com>
> > Cc: Matthew Booth <mbo...@redhat.com>
> > Cc: Pablo Iranzo Gómez <pablo.ira...@redhat.com>
> > Cc: Tomas Von Veschler <tvv...@redhat.com>
> 
> Hm, I'm wondering... If I have a command line like this:
> 
>   qemu-img diff -b base.img modified.img diff.qcow2
> 
> Would this be equivalent to this sequence?
> 
>   qemu-img create -f qcow2 -b modified.img diff.qcow2
>   qemu-img rebase -b base.img diff.qcow2
> 
> Or is there some detail that I'm missing? If it is equivalent, this
> would suggest that either the new command isn't necessary at all or at
> least that it should reuse the qemu-img rebase code.

Yes.  I tried for a while to work out the sequence of commands that
could make a diff using 'qemu-img rebase', but it wasn't obvious and I
gave up.  It should at least be documented.  How about the attached
patch?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
>From eec7fa864298b5619c52ada1e8fbd32c00b302d9 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjo...@redhat.com>
Date: Mon, 21 May 2012 14:58:05 +0100
Subject: [PATCH] qemu-img: Explain how rebase operation can be used to
 perform a 'diff' operation.

Signed-off-by: Richard W.M. Jones <rjo...@redhat.com>
---
 qemu-img.texi |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/qemu-img.texi b/qemu-img.texi
index b2ca3a5..6fc3c28 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -159,6 +159,24 @@ It can be used without an accessible old backing file, 
i.e. you can use it to
 fix an image whose backing file has already been moved/renamed.
 @end table
 
+You can use @code{rebase} to perform a ``diff'' operation on two
+disk images.  This can be useful when you have copied or cloned
+a guest, and you want to get back to a thin image on top of a
+template or base image.
+
+Say that @code{base.img} has been cloned as @code{modified.img} by
+copying it, and that the @code{modified.img} guest has run so there
+are now some changes compared to @code{base.img}.  To construct a thin
+image called @code{diff.qcow2} that contains just the differences, do:
+
+@example
+qemu-img create -f qcow2 -b modified.img diff.qcow2
+qemu-img rebase -b base.img diff.qcow2
+@end example
+
+At this point, @code{modified.img} can be discarded, since
+@code{base.img + diff.qcow2} contains the same information.
+
 @item resize @var{filename} [+ | -]@var{size}
 
 Change the disk image as if it had been created with @var{size}.
-- 
1.7.10

Reply via email to