From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV2QC-0001He-0g for qemu-devel@nongnu.org; Thu, 17 May 2012 11:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SV2Q3-0006iU-Ru for qemu-devel@nongnu.org; Thu, 17 May 2012 11:15:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SV2Q3-0006hr-J3 for qemu-devel@nongnu.org; Thu, 17 May 2012 11:15:11 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4HFFAAw004595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 May 2012 11:15:10 -0400 Message-ID: <4FB515FC.3010505@redhat.com> Date: Thu, 17 May 2012 09:15:08 -0600 From: Eric Blake MIME-Version: 1.0 References: <1337266628-3588-1-git-send-email-rjones@redhat.com> In-Reply-To: <1337266628-3588-1-git-send-email-rjones@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigEBCE4BD84238333B8448B8CB" Subject: Re: [Qemu-devel] [PATCH v2] 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) --------------enigEBCE4BD84238333B8448B8CB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/17/2012 08:57 AM, Richard W.M. Jones wrote: > From: "Richard W.M. Jones" >=20 > This produces a qcow2 file which is the difference between > two disk images. ie, if: >=20 > base.img - is a disk image (in any format) > modified.img - is base.img, copied and modified >=20 > then: >=20 > qemu-img diff -b base.img modified.img diff.qcow2 >=20 > creates 'diff.qcow2' which contains the differences between 'base.img' > and 'modified.img'. Note that 'diff.qcow2' has 'base.img' as its > backing file. >=20 > +++ b/qemu-img-cmds.hx > @@ -33,6 +33,12 @@ STEXI > @item convert [-c] [-p] [-f @var{fmt}] [-t @var{cache}] [-O @var{outpu= t_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}= ] @var{filename} [@var{filename2} [...]] @var{output_filename} > ETEXI > =20 > +DEF("diff", img_diff, > + "diff [-F backing_fmt] -b backing_file [-f fmt] [-O output_fmt] [-= o options] filename output_filename") > +STEXI > +@item diff [-F @var{backing_fmt}] -b @var{backing_file} [-f @var{fmt}]= [-O @var{output_fmt}] [-o @var{options}] @var{filename} @var{output_file= name} Why the difference in ordering between -o and -O? > + > + if (argc - optind !=3D 2) { > + error_report("The input and output filenames must be supplied"= ); > + return 1; Error is misleading if argc > optind+2. > + > + if (fmt_out =3D=3D NULL || fmt_out[0] =3D=3D '\0') { > + fmt_out =3D "qcow2"; > + } So output defaults to qcow2, and input (both base and modified) default to probing. Works for me. > + > + bdrv_get_geometry(bs_base, &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; > + } I can live with an initial implementation that is strict, where a later patch relaxes things to allow a modified image that has been enlarged. > + > + /* Output image. */ > + ret =3D bdrv_img_create(out, fmt_out, > + /* base file becomes the new backing file */= > + base, fmt_base, > + options, > + num_sectors * BDRV_SECTOR_SIZE, BDRV_O_FLAGS= ); I still think this should be modified_num_sectors - for now, the two values are equal, but if we relax the error check up above, then you really do want to go with the output file the same size as the modified file. It looks like you did indeed address most of my comments on v1. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigEBCE4BD84238333B8448B8CB 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/ iQEcBAEBCAAGBQJPtRX9AAoJEKeha0olJ0NqIyAIAJAvbnysXbrg6N3SpgbhoIlo +ZaxDvEZZzxk0ypWFztHsVHVxQCY8mqmF8xhSn/IvkuRmh78lwW28HFFSdMjH356 1rSsPPjCa5mwQXtXSjj10/LwtOEoWRamUOffkdhCDdBTe96rBB+wesFMpLpYLYJ7 Zqf4ins7ZpjonpZk4tYq6DH48SmoD+r+qdBB5b5osFqfu5UxzuNPE4mDTEYRKNGf elUJiWc4ImGTfaeB1xIbV9t93wPo3+ngbcoIyA52gNd6A0Eom+GlqBLK16h+9J5n eIJ7Hd1v6t06b/hP+4CxuCTiUU7cqVCvI/SypFIOukKdzl44CmnkAzKvmyGLlMA= =XxWI -----END PGP SIGNATURE----- --------------enigEBCE4BD84238333B8448B8CB--