From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV1D3-0002JP-T0 for qemu-devel@nongnu.org; Thu, 17 May 2012 09:57:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SV1Cx-0003Ub-8X for qemu-devel@nongnu.org; Thu, 17 May 2012 09:57:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV1Cx-0003Tn-0G for qemu-devel@nongnu.org; Thu, 17 May 2012 09:57:35 -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 q4HDvXEp019588 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 May 2012 09:57:33 -0400 Message-ID: <4FB503CB.60609@redhat.com> Date: Thu, 17 May 2012 07:57:31 -0600 From: Eric Blake MIME-Version: 1.0 References: <1337262266-32227-1-git-send-email-rjones@redhat.com> In-Reply-To: <1337262266-32227-1-git-send-email-rjones@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1FB5235DDC4DD3E056B9D55A" Subject: Re: [Qemu-devel] [PATCH] qemu-img: Implement 'diff' operation. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Richard W.M. Jones" Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1FB5235DDC4DD3E056B9D55A Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/17/2012 07:44 AM, Richard W.M. Jones wrote: > From: "Richard W.M. Jones" >=20 > This produces a qcow2 file which is the different between > two disk images. ie, if: >=20 > original.img - is a disk image (in any format) > modified.img - is a modified version of original.img >=20 > then: >=20 > qemu-img diff -b original.img modified.img diff.qcow2 >=20 > creates 'diff.qcow2' which contains just the differences. Note that > 'diff.qcow2' has 'original.img' set as the backing file. Sounds useful! > =20 > +DEF("diff", img_diff, > + "diff [-f fmt] [-F backing_fmt] [-O output_fmt] -b backing_file fi= lename output_filename") Just so I'm clear: -f is for filename (the file with the modifications being extracted), -F is for backing_file (the file that serves as the base of the diff), and -O is for output_filename. > +STEXI > +@item rebase [-f @var{fmt}] [-F @var{backing_fmt}] [-O @var{output_fmt= }] -b @var{backing_file} @var{filename} @var{output_filename} s/rebase/diff/ We also need to support -o options for the output_filename, so that we can expose other qcow2 attributes while creating the diff. For example, encryption, cluster_size, and preacllocation all come to mind. > + > + bdrv_get_geometry(bs_original, &num_sectors); > + bdrv_get_geometry(bs_modified, &modified_num_sectors); > + if (num_sectors !=3D modified_num_sectors) { > + error_report("Number of sectors in backing and source must be = the same"); > + goto out2; > + } Why are you requiring equality? I can see the usefulness of doing a diff where the modified file is larger than the original (basically, the diff was created by extending the original file to something larger). Prohibiting a modified file smaller than the original makes sense, so I think this should be >, not !=3D. > + > + /* Output image. */ > + if (fmt_out =3D=3D NULL || fmt_out[0] =3D=3D '\0') { > + fmt_out =3D "qcow2"; > + } > + ret =3D bdrv_img_create(out, fmt_out, > + /* original file becomes the new backing fil= e */ > + original, fmt_original, > + NULL, num_sectors * BDRV_SECTOR_SIZE, BDRV_O= _FLAGS); If you allow a modified larger than backing, then this should be modified_num_sectors, not num_sectors. > +++ b/qemu-img.texi > @@ -114,6 +114,23 @@ created as a copy on write image of the specified = base image; the > @var{backing_file} should have the same content as the input's base im= age, > however the path, image format, etc may differ. > =20 > +@item diff [-f @var{fmt}] [-F @var{backing_fmt}] [-O @var{output_fmt}]= -b @var{backing_file} @var{filename} @var{output_filename} > + > +Create a new file (@var{output_filename}) which contains the > +differences between @var{backing_file} and @var{filename}. > + > +The @var{backing_file} and @var{filename} must have the same > +virtual disk size, but may be in different formats. Again, I think this is overly tight. > + > +@var{output_file} will have @var{backing_file} set as its backing > +file. The format of @var{output_file} must be one that supports > +backing files (currently @code{qcow2} is the default and only > +permitted output format). Why doesn't qed just work out of the box? --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig1FB5235DDC4DD3E056B9D55A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPtQPMAAoJEKeha0olJ0Nq8ukH/3e1EFeHUgT7H6w5kxszIpY3 uiJw7mvTsp8dJyjbFDAg7AkgqJWPg77e5Hh/5Rsy10MGSc37zj1n3PLamALqpevc iZIMyfj9nWtvMYeZFFjpGZLSKvFFVRIlv0xHm1EU2vaQSO6QXLm9MwlgBUVHwETW dSp1uDKRrFfUHhS6gQdJzNt3BOKukYF0XLKRcRh8vCINV27YpyVNWLwpHsFLOD9y Ao/O3VCLMllymoPpkKM7Zz2ok0vQbWKp7/SPtid1RaON1xX9q3g6qW/NprHumibE sf4YmyCf8K3D4Wprt1TEpU6HdlqhnNWW0uShRcrznxPfRC41bMCvA9Bi097Ht7k= =bfkF -----END PGP SIGNATURE----- --------------enig1FB5235DDC4DD3E056B9D55A--