From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFB1x-0007Zq-0a for qemu-devel@nongnu.org; Thu, 29 Aug 2013 18:49:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VFB1r-0004zL-S0 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 18:49:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFB1r-0004yM-L2 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 18:49:27 -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 r7TMnQ0E011537 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 29 Aug 2013 18:49:26 -0400 Message-ID: <521FCFF5.5000409@redhat.com> Date: Thu, 29 Aug 2013 16:49:25 -0600 From: Eric Blake MIME-Version: 1.0 References: <1377784821-29561-1-git-send-email-pbonzini@redhat.com> <1377784821-29561-17-git-send-email-pbonzini@redhat.com> In-Reply-To: <1377784821-29561-17-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GD2N5uOX2wG3ohsIjDwH3lTKNBLnJACvn" Subject: Re: [Qemu-devel] [PATCH v4 16/21] qemu-img: add a "map" subcommand List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GD2N5uOX2wG3ohsIjDwH3lTKNBLnJACvn Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/29/2013 08:00 AM, Paolo Bonzini wrote: > This command dumps the metadata of an entire chain, in either tabular o= r JSON > format. >=20 > Signed-off-by: Paolo Bonzini > --- > qemu-img-cmds.hx | 6 ++ > qemu-img.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 2 files changed, 197 insertions(+) >=20 > +++ b/qemu-img-cmds.hx > @@ -45,6 +45,12 @@ STEXI > @item info [-f @var{fmt}] [--output=3D@var{ofmt}] [--backing-chain] @v= ar{filename} > ETEXI > =20 > +DEF("map", img_map, > + "map [-f fmt] [--output=3Dofmt] filename") > +STEXI > +@item map [-f @var{fmt}] [--output=3D@var{ofmt}] @var{filename} > +ETEXI > + Should the matching changes to qemu.texi (currently in 17/21) be hoisted into this patch? > + case OFORMAT_HUMAN: > + if ((e->flags & BDRV_BLOCK_DATA) && > + !(e->flags & BDRV_BLOCK_OFFSET_VALID)) { > + error_report("File contains external, encrypted or compres= sed clusters."); > + exit(1); > + } > + if ((e->flags & (BDRV_BLOCK_DATA|BDRV_BLOCK_ZERO)) =3D=3D BDRV= _BLOCK_DATA) { > + printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n", printf("%#x", 0) prints 0, not 0x0. The automatic 0x is only for non-zero values; do we really want 0 to look different in the output from all other values? Let's see... > + e->start, e->length, e->offset, e->bs->filename); e->length is always non-zero. For a qcow2 file, e->offset will never be 0 (the first raw cluster is always after the metadata). But for a raw file, the file starts at 0, so e->offset could be 0 there - is your new 'map' subcommand a useful way to probe where the holes are in a sparse raw file? But e->start will cover at most one entry starting at 0 (none if the logical data is unallocated at the start of the file, since the human output elides those blocks); and indeed, your example in 17/21 shows the special casing: +@example +Offset Length Mapped to File +0 0x20000 0x50000 /tmp/overlay.qcow2 +0x100000 0x10000 0x95380000 /tmp/backing.qcow2 I would have written "0x%-16"PRIx64 instead of "%#-16"PRIx64, but I can live with your version. > + case OFORMAT_JSON: > + printf("%s{ \"start\": %"PRId64", \"length\": %"PRId64", \"dep= th\": %d," > + " \"zero\": %s, \"data\": %s", > + (e->start =3D=3D 0 ? "[" : ",\n"), Here, e->start=3D=3D0 will always be present, even when unallocated (sinc= e you don't elide any blocks, and the logical data always starts at 0). > + > + if (output_format =3D=3D OFORMAT_HUMAN) { > + printf("%-16s%-16s%-16s%s\n", "Offset", "Length", "Mapped to",= "File"); Are we ever planning on marking up qemu-img for translation? But this patch need not worry about it. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GD2N5uOX2wG3ohsIjDwH3lTKNBLnJACvn 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.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSH8/1AAoJEKeha0olJ0NqetQH/jQLSQ4m+foX7kOYKhIIS1Ma YjHTtzFI/KC0MUB57Acwg0YqcsKBz1DsSJeOQ/2b3kcHAjaM8umZa7dPYiE3KzcT TtS/mKxD0rVk1X6LHgeS6ISKElM/yP6C/7zci2673dSpMB8daZMskUv0oQYF4vKo LmTLoeosIbj2Zgd1fEYgs1DyGBp5C0JcOznmRcYcgX+yZv/FAPsx8P1gXzalGgZ3 zi2ZALbjSKYnPIzkMuP5HxUfGU1yY3dgZhuU3ZzzeQ2AgrZHHCONqjD90g8NTded G458ZZHmgM9+7TRKrmBj5tqMewunBGKLPMVMLRDP4kutGiS+xqsKkqPDgrz373w= =06zl -----END PGP SIGNATURE----- --GD2N5uOX2wG3ohsIjDwH3lTKNBLnJACvn--