From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxJjA-0002fm-GL for qemu-devel@nongnu.org; Fri, 03 Aug 2012 11:23:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SxJj4-00015B-Pq for qemu-devel@nongnu.org; Fri, 03 Aug 2012 11:23:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxJj4-00014H-Ih for qemu-devel@nongnu.org; Fri, 03 Aug 2012 11:23:42 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q73FNeqO001106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 3 Aug 2012 11:23:41 -0400 Received: from [10.3.113.77] (ovpn-113-77.phx2.redhat.com [10.3.113.77]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q73FNe4Z024298 for ; Fri, 3 Aug 2012 11:23:40 -0400 Message-ID: <501BECF6.4020101@redhat.com> Date: Fri, 03 Aug 2012 09:23:34 -0600 From: Eric Blake MIME-Version: 1.0 References: <1736118218.6697488.1343814369561.JavaMail.root@redhat.com> <490157254.6767622.1343815423950.JavaMail.root@redhat.com> <20120803064520.GA10029@lws.brq.redhat.com> In-Reply-To: <20120803064520.GA10029@lws.brq.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig8A12755FFCCB9F34839FC34D" Subject: Re: [Qemu-devel] [PATCH v2][RFC] Add compare subcommand for qemu-img List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig8A12755FFCCB9F34839FC34D Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 08/03/2012 12:45 AM, Miroslav Rezanina wrote: > This is second version of patch adding compare subcommand that compare= s two > images. Compare has following criteria: > - only data part is compared > - unallocated sectors are not read > - in case of different image size, exceeding part of bigger disk has > to be zeroed/unallocated to compare rest > - qemu-img returns: > - 0 if images are identical > - 1 if images differ > - 2 on error >=20 > v2: > - changed option for second image format to -F > - changed handlig of -f and -F [1] > - added strict mode (-s) > - added quiet mode (-q) > - improved output messages [2] > - rename variables for larger image handling > - added man page content >=20 > [1] Original patch handling was as following: > i) neither -f nor -F - both images probed for type > ii) -f only - both images use specified type > iii) -F only - first image probed, second image use specifi= ed type > iii) -f and -F - first image use -f type, second use -F type >=20 > This patch change behavior in way that case ii) and iii) has same efect= - we > use specified value for both images. I still think orthogonality is better than applying one option to both files. Probing is sometimes useful, and you have left no way to probe one file but not the other. >=20 > [2] When we hit different sector we print its number out. >=20 > Points to dicuss: >=20 > i) Handling -f/-F options. > Currently we have three scenarios - no option > specified - probe all, one of options specified - use it for both, both= option > specified - use each value for related image. This behavior is based on= idea > that we can use format probing for all images or specify format for all= images. > This preserve state when -f fmt specify input image format (compare is = only > subcomand with more than one input image except convert that uses multi= ple > images without possibility to specify different format for each image).= >=20 > However, there's one more behavior to be considered - to use -f/-F for = one > image only - when only one option is provided, only appropriate image u= se specified > format, second one is probed. I would prefer this, as it would let me compare against a file of unknown type. > +++ b/qemu-img-cmds.hx > @@ -27,6 +27,12 @@ STEXI > @item commit [-f @var{fmt}] [-t @var{cache}] @var{filename} > ETEXI > =20 > +DEF("compare", img_compare, > + "compare [-f fmt] [-g fmt] [-p] filename1 filename2") Out of date with the rest of your patch. > +STEXI > +@item compare [-f @var{fmt}] [-F @var{fmt}] [-p] [-q] [-s] @var{filena= me1} @var{filename2} > +ETEXI > + > DEF("convert", img_convert, > "convert [-c] [-p] [-f fmt] [-t cache] [-O output_fmt] [-o options= ] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_f= ilename") > STEXI > diff --git a/qemu-img.c b/qemu-img.c > index 80cfb9b..6722fa0 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -96,7 +96,11 @@ static void help(void) > " '-a' applies a snapshot (revert disk to saved state)\n" > " '-c' creates a snapshot\n" > " '-d' deletes a snapshot\n" > - " '-l' lists all snapshots in the given image\n"; > + " '-l' lists all snapshots in the given image\n" > + "Parameters to compare subcommand:\n" > + " '-F' Second image format (in case it differs from first = image)\n" If you make -f and -F orthogonal, applying to one image each, this might be better worded as: '-F' Second image format (-f applies only to first image)\n or even just '-F' Second image format > +/* > + * Compares two images. Exit codes: > + * > + * 0 - Images are identical > + * 1 - Images differ > + * 2 - Error occured s/occured/occurred/ > +++ b/qemu-img.texi > @@ -67,6 +67,18 @@ deletes a snapshot > lists all snapshots in the given image > @end table > =20 > +Parameters to compare subcommand: > + > +@table @option > + > +@item -F > +Second image format (in case it differs from first image) Another instance of wording to be careful of. > @@ -100,6 +112,27 @@ it doesn't need to be specified separately in this= case. > =20 > Commit the changes recorded in @var{filename} in its base image. > =20 > +@item compare [-f @var{fmt}] [-F @var{fmt}] [-p] [-s] [-q] @var{filena= me1} @var{filename2} > + > +Compare content of two images. You can compare images with different f= ormat or > +settings. > + > +Format is probed unless you specify it by @var{-f} and/or @var{-F} opt= ion. > +If only one of these options is specified, it is used for both images.= > +If both options are specfied, @var{-f} is used for @var{filename1} and= > +@var{-F} for @var{filename2}. > + > +By default, compare evaluate as identical images with different size w= here s/evaluate/evaluates/ > +bigger image contains only unallocated and/or zeroed sectors in area a= bove > +second image size. In addition, if any sector is not allocated in one = image > +and contains only zero bytes in second, it is evaluated as equal. You = can use > +Strict mode by specifying @var{-s} option. When compare runs in Strict= mode, > +it fails in case image size differs or sector is allocated in one imag= e and > +is not allocated in second. > + > +In case you want to suppress any non-error output, you can use Quiet m= ode by > +specifying @var{-q} option. When -q is not in use, what gets output? Is it like cmp(1), where output is silent on the same, and lists the location of the first differing byte on different? --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig8A12755FFCCB9F34839FC34D 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/ iQEcBAEBCAAGBQJQG+z3AAoJEKeha0olJ0NqBQAH/1HpDJcHpcQAqlDO728s8xql EAXa0V3GNXm4vL3HE1mqRqB9EIv+QkiM03Toe+Z7VbnTwjPqNq23loSffbTIC6r0 u4N6satZvVRzF0gTOrMGuna7VSeuWUw1cWGP6wRadQQcc3zgUD51MvyQA5U76dQT PMaBCKEBWx/H88Tkx4H6uMKSZzWrsxoXiSvwYbMYuWmXY3lKZakAcdQLZdzAXj5C lnweWO2VgGCgYCaD9BkyUfg4cGVnJaB+rx9M/3XnbsLXqrI/sGH4S6p8GGC8UkGQ u5vf+25PdFDmu7iJv4sICjVat4P/29SB+9Kiq/a8PltBqOKuwqWKdIJ34hxA/Q8= =Ve0Z -----END PGP SIGNATURE----- --------------enig8A12755FFCCB9F34839FC34D--