From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4 16/21] qemu-img: add a "map" subcommand
Date: Thu, 29 Aug 2013 16:49:25 -0600 [thread overview]
Message-ID: <521FCFF5.5000409@redhat.com> (raw)
In-Reply-To: <1377784821-29561-17-git-send-email-pbonzini@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3047 bytes --]
On 08/29/2013 08:00 AM, Paolo Bonzini wrote:
> This command dumps the metadata of an entire chain, in either tabular or JSON
> format.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> qemu-img-cmds.hx | 6 ++
> qemu-img.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 197 insertions(+)
>
> +++ b/qemu-img-cmds.hx
> @@ -45,6 +45,12 @@ STEXI
> @item info [-f @var{fmt}] [--output=@var{ofmt}] [--backing-chain] @var{filename}
> ETEXI
>
> +DEF("map", img_map,
> + "map [-f fmt] [--output=ofmt] filename")
> +STEXI
> +@item map [-f @var{fmt}] [--output=@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 compressed clusters.");
> + exit(1);
> + }
> + if ((e->flags & (BDRV_BLOCK_DATA|BDRV_BLOCK_ZERO)) == 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", \"depth\": %d,"
> + " \"zero\": %s, \"data\": %s",
> + (e->start == 0 ? "[" : ",\n"),
Here, e->start==0 will always be present, even when unallocated (since
you don't elide any blocks, and the logical data always starts at 0).
> +
> + if (output_format == 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 <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
next prev parent reply other threads:[~2013-08-29 22:49 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-29 14:00 [Qemu-devel] [PATCH v4 00/21] Add qemu-img subcommand to dump file metadata Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 01/21] cow: make reads go at a decent speed Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 02/21] cow: make writes go at a less indecent speed Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 03/21] cow: do not call bdrv_co_is_allocated Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 04/21] block: keep bs->total_sectors up to date even for growable block devices Paolo Bonzini
2013-08-29 19:51 ` Eric Blake
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 05/21] block: make bdrv_co_is_allocated static Paolo Bonzini
2013-08-29 19:53 ` Eric Blake
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 06/21] block: do not use ->total_sectors in bdrv_co_is_allocated Paolo Bonzini
2013-08-29 19:58 ` Eric Blake
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 07/21] block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 08/21] block: expect errors from bdrv_co_is_allocated Paolo Bonzini
2013-08-29 21:35 ` Eric Blake
2013-08-30 7:18 ` Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 09/21] qemu-img: always probe the input image for allocated sectors Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 10/21] block: make bdrv_has_zero_init return false for copy-on-write-images Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 11/21] block: introduce bdrv_get_block_status API Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 12/21] block: define get_block_status return value Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 13/21] block: return get_block_status data and flags for formats Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 14/21] block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 15/21] block: return BDRV_BLOCK_ZERO past end of backing file Paolo Bonzini
2013-08-29 21:59 ` Eric Blake
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 16/21] qemu-img: add a "map" subcommand Paolo Bonzini
2013-08-29 22:49 ` Eric Blake [this message]
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 17/21] docs, qapi: document qemu-img map Paolo Bonzini
2013-08-29 15:31 ` Eric Blake
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 18/21] raw-posix: return get_block_status data and flags Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 19/21] raw-posix: report unwritten extents as zero Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 20/21] block: add default get_block_status implementation for protocols Paolo Bonzini
2013-08-29 14:00 ` [Qemu-devel] [PATCH v4 21/21] block: look for zero blocks in bs->file Paolo Bonzini
2013-09-04 15:50 ` [Qemu-devel] [PATCH v4 00/21] Add qemu-img subcommand to dump file metadata Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=521FCFF5.5000409@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).