thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
9ae3a8
From f7c79aada82c99552499bc075021128f4a8653a6 Mon Sep 17 00:00:00 2001
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Date: Fri, 18 Oct 2013 08:14:43 +0200
9ae3a8
Subject: [PATCH 18/81] docs, qapi: document qemu-img map
9ae3a8
9ae3a8
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Message-id: <1382084091-16636-19-git-send-email-pbonzini@redhat.com>
9ae3a8
Patchwork-id: 55001
9ae3a8
O-Subject: [RHEL 7.0 qemu-kvm PATCH 18/26] docs, qapi: document qemu-img map
9ae3a8
Bugzilla: 989646
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
9ae3a8
Eric Blake also requested including the output in qapi-schema.json,
9ae3a8
so that it is published through the introspection mechanism.
9ae3a8
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
(cherry picked from commit facd6e2b5c0217f9d9eeb2ee497dda28009518bd)
9ae3a8
---
9ae3a8
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
9ae3a8
 qemu-img.texi    | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
9ae3a8
 2 files changed, 84 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 qapi-schema.json |   29 ++++++++++++++++++++++++++++
9ae3a8
 qemu-img.texi    |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
9ae3a8
 2 files changed, 84 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/qapi-schema.json b/qapi-schema.json
9ae3a8
index 780c6fe..b779458 100644
9ae3a8
--- a/qapi-schema.json
9ae3a8
+++ b/qapi-schema.json
9ae3a8
@@ -795,6 +795,35 @@
9ae3a8
 { 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
9ae3a8
 
9ae3a8
 ##
9ae3a8
+# @BlockDeviceMapEntry:
9ae3a8
+#
9ae3a8
+# Entry in the metadata map of the device (returned by "qemu-img map")
9ae3a8
+#
9ae3a8
+# @start: Offset in the image of the first byte described by this entry
9ae3a8
+#         (in bytes)
9ae3a8
+#
9ae3a8
+# @length: Length of the range described by this entry (in bytes)
9ae3a8
+#
9ae3a8
+# @depth: Number of layers (0 = top image, 1 = top image's backing file, etc.)
9ae3a8
+#         before reaching one for which the range is allocated.  The value is
9ae3a8
+#         in the range 0 to the depth of the image chain - 1.
9ae3a8
+#
9ae3a8
+# @zero: the sectors in this range read as zeros
9ae3a8
+#
9ae3a8
+# @data: reading the image will actually read data from a file (in particular,
9ae3a8
+#        if @offset is present this means that the sectors are not simply
9ae3a8
+#        preallocated, but contain actual data in raw format)
9ae3a8
+#
9ae3a8
+# @offset: if present, the image file stores the data for this range in
9ae3a8
+#          raw format at the given offset.
9ae3a8
+#
9ae3a8
+# Since 1.7
9ae3a8
+##
9ae3a8
+{ 'type': 'BlockDeviceMapEntry',
9ae3a8
+  'data': { 'start': 'int', 'length': 'int', 'depth': 'int', 'zero': 'bool',
9ae3a8
+            'data': 'bool', '*offset': 'int' } }
9ae3a8
+
9ae3a8
+##
9ae3a8
 # @BlockDirtyInfo:
9ae3a8
 #
9ae3a8
 # Block dirty bitmap information.
9ae3a8
diff --git a/qemu-img.texi b/qemu-img.texi
9ae3a8
index 69f1bda..8364fa1 100644
9ae3a8
--- a/qemu-img.texi
9ae3a8
+++ b/qemu-img.texi
9ae3a8
@@ -213,6 +213,61 @@ To enumerate information about each disk image in the above chain, starting from
9ae3a8
 qemu-img info --backing-chain snap2.qcow2
9ae3a8
 @end example
9ae3a8
 
9ae3a8
+@item map [-f @var{fmt}] [--output=@var{ofmt}] @var{filename}
9ae3a8
+
9ae3a8
+Dump the metadata of image @var{filename} and its backing file chain.
9ae3a8
+In particular, this commands dumps the allocation state of every sector
9ae3a8
+of @var{filename}, together with the topmost file that allocates it in
9ae3a8
+the backing file chain.
9ae3a8
+
9ae3a8
+Two option formats are possible.  The default format (@code{human})
9ae3a8
+only dumps known-nonzero areas of the file.  Known-zero parts of the
9ae3a8
+file are omitted altogether, and likewise for parts that are not allocated
9ae3a8
+throughout the chain.  @command{qemu-img} output will identify a file
9ae3a8
+from where the data can be read, and the offset in the file.  Each line
9ae3a8
+will include four fields, the first three of which are hexadecimal
9ae3a8
+numbers.  For example the first line of:
9ae3a8
+@example
9ae3a8
+Offset          Length          Mapped to       File
9ae3a8
+0               0x20000         0x50000         /tmp/overlay.qcow2
9ae3a8
+0x100000        0x10000         0x95380000      /tmp/backing.qcow2
9ae3a8
+@end example
9ae3a8
+@noindent
9ae3a8
+means that 0x20000 (131072) bytes starting at offset 0 in the image are
9ae3a8
+available in /tmp/overlay.qcow2 (opened in @code{raw} format) starting
9ae3a8
+at offset 0x50000 (327680).  Data that is compressed, encrypted, or
9ae3a8
+otherwise not available in raw format will cause an error if @code{human}
9ae3a8
+format is in use.  Note that file names can include newlines, thus it is
9ae3a8
+not safe to parse this output format in scripts.
9ae3a8
+
9ae3a8
+The alternative format @code{json} will return an array of dictionaries
9ae3a8
+in JSON format.  It will include similar information in
9ae3a8
+the @code{start}, @code{length}, @code{offset} fields;
9ae3a8
+it will also include other more specific information:
9ae3a8
+@itemize @minus
9ae3a8
+@item
9ae3a8
+whether the sectors contain actual data or not (boolean field @code{data};
9ae3a8
+if false, the sectors are either unallocated or stored as optimized
9ae3a8
+all-zero clusters);
9ae3a8
+
9ae3a8
+@item
9ae3a8
+whether the data is known to read as zero (boolean field @code{zero});
9ae3a8
+
9ae3a8
+@item
9ae3a8
+in order to make the output shorter, the target file is expressed as
9ae3a8
+a @code{depth}; for example, a depth of 2 refers to the backing file
9ae3a8
+of the backing file of @var{filename}.
9ae3a8
+@end itemize
9ae3a8
+
9ae3a8
+In JSON format, the @code{offset} field is optional; it is absent in
9ae3a8
+cases where @code{human} format would omit the entry or exit with an error.
9ae3a8
+If @code{data} is false and the @code{offset} field is present, the
9ae3a8
+corresponding sectors in the file are not yet in use, but they are
9ae3a8
+preallocated.
9ae3a8
+
9ae3a8
+For more information, consult @file{include/block/block.h} in QEMU's
9ae3a8
+source code.
9ae3a8
+
9ae3a8
 @item snapshot [-l | -a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot} ] @var{filename}
9ae3a8
 
9ae3a8
 List, apply, create or delete snapshots in image @var{filename}.
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8