qemu-img: Add bitmap sub-command

Include actions for --add, --remove, --clear, --enable, --disable, and
--merge (note that --clear is a bit of fluff, because the same can be
accomplished by removing a bitmap and then adding a new one in its
place, but it matches what QMP commands exist).  Listing is omitted,
because it does not require a bitmap name and because it was already
possible with 'qemu-img info'.  A single command line can play one or
more bitmap commands in sequence on the same bitmap name (although all
added bitmaps share the same granularity, and and all merged bitmaps
come from the same source file).  Merge defaults to other bitmaps in
the primary image, but can also be told to merge bitmaps from a
distinct image.

While this supports --image-opts for the file being modified, I did
not think it worth the extra complexity to support that for the source
file in a cross-file merges.  Likewise, I chose to have --merge only
take a single source rather than following the QMP support for
multiple merges in one go (although you can still use more than one
--merge in the command line); in part because qemu-img is offline and
therefore atomicity is not an issue.

Upcoming patches will add iotest coverage of these commands while
also testing other features.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-7-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
This commit is contained in:
Eric Blake 2020-05-12 20:16:45 -05:00
parent bb4e58c613
commit 3b51ab4bf0
3 changed files with 279 additions and 0 deletions

View file

@ -281,6 +281,30 @@ Command description:
For write tests, by default a buffer filled with zeros is written. This can be
overridden with a pattern byte specified by *PATTERN*.
.. option:: bitmap (--merge SOURCE | --add | --remove | --clear | --enable | --disable)... [-b SOURCE_FILE [-F SOURCE_FMT]] [-g GRANULARITY] [--object OBJECTDEF] [--image-opts | -f FMT] FILENAME BITMAP
Perform one or more modifications of the persistent bitmap *BITMAP*
in the disk image *FILENAME*. The various modifications are:
``--add`` to create *BITMAP*, enabled to record future edits.
``--remove`` to remove *BITMAP*.
``--clear`` to clear *BITMAP*.
``--enable`` to change *BITMAP* to start recording future edits.
``--disable`` to change *BITMAP* to stop recording future edits.
``--merge`` to merge the contents of *SOURCE_BITMAP* into *BITMAP*.
Additional options include ``-g`` which sets a non-default
*GRANULARITY* for ``--add``, and ``-b`` and ``-F`` which select an
alternative source file for all *SOURCE* bitmaps used by
``--merge``.
To see what bitmaps are present in an image, use ``qemu-img info``.
.. option:: check [--object OBJECTDEF] [--image-opts] [-q] [-f FMT] [--output=OFMT] [-r [leaks | all]] [-T SRC_CACHE] [-U] FILENAME
Perform a consistency check on the disk image *FILENAME*. The command can