From patchwork Mon May 21 13:59:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Richard W.M. Jones" X-Patchwork-Id: 160366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A1132B7008 for ; Mon, 21 May 2012 23:59:41 +1000 (EST) Received: from localhost ([::1]:55612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWT99-0006bD-Jb for incoming@patchwork.ozlabs.org; Mon, 21 May 2012 09:59:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWT91-0006aq-R5 for qemu-devel@nongnu.org; Mon, 21 May 2012 09:59:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWT8z-0003ZD-PT for qemu-devel@nongnu.org; Mon, 21 May 2012 09:59:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWT8z-0003Yw-Gs for qemu-devel@nongnu.org; Mon, 21 May 2012 09:59:29 -0400 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 (8.14.4/8.14.4) with ESMTP id q4LDxR0k009719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 May 2012 09:59:27 -0400 Received: from localhost (vpn1-7-234.ams2.redhat.com [10.36.7.234]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4LDxQDT018855; Mon, 21 May 2012 09:59:27 -0400 Date: Mon, 21 May 2012 14:59:26 +0100 From: "Richard W.M. Jones" To: Kevin Wolf Message-ID: <20120521135926.GM15276@amd.home.annexia.org> References: <1337268840-4779-1-git-send-email-rjones@redhat.com> <4FBA4332.6050201@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4FBA4332.6050201@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH v3] qemu-img: Implement 'diff' operation. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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" > > > > 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 > > Cc: Matthew Booth > > Cc: Pablo Iranzo Gómez > > Cc: Tomas Von Veschler > > 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. 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}.