qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 63/93] block: update block commit documentation regarding image truncation
Date: Fri, 24 Jan 2014 18:21:46 +0100	[thread overview]
Message-ID: <1390584136-24703-64-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1390584136-24703-1-git-send-email-kwolf@redhat.com>

From: Jeff Cody <jcody@redhat.com>

This updates the documentation for commiting snapshot images.
Specifically, this highlights what happens when the base image
is either smaller or larger than the snapshot image being committed.

In the case of the base image being smaller, it is resized to the
larger size of the snapshot image.  In the case of the base image
being larger, it is not resized automatically, but once the commit
has completed it is safe for the user to truncate the base image.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hmp-commands.hx  |  5 +++++
 qapi-schema.json |  7 +++++++
 qemu-img.texi    |  7 ++++++-
 qmp-commands.hx  | 39 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index feca084..f3fc514 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -35,6 +35,11 @@ STEXI
 @item commit
 @findex commit
 Commit changes to the disk images (if -snapshot is used) or backing files.
+If the backing file is smaller than the snapshot, then the backing file will be
+resized to be the same size as the snapshot.  If the snapshot is smaller than
+the backing file, the backing file will not be truncated.  If you want the
+backing file to match the size of the smaller snapshot, you can safely truncate
+it yourself once the commit operation successfully completes.
 ETEXI
 
     {
diff --git a/qapi-schema.json b/qapi-schema.json
index e04949d..1ff607a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1994,6 +1994,13 @@
 #                    user needs to complete the job with the block-job-complete
 #                    command after getting the ready event. (Since 2.0)
 #
+#                    If the base image is smaller than top, then the base image
+#                    will be resized to be the same size as top.  If top is
+#                    smaller than the base image, the base will not be
+#                    truncated.  If you want the base image size to match the
+#                    size of the smaller top, you can safely truncate it
+#                    yourself once the commit operation successfully completes.
+#
 #
 # @speed:  #optional the maximum speed, in bytes per second
 #
diff --git a/qemu-img.texi b/qemu-img.texi
index f86a86d..526d56a 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -142,7 +142,12 @@ it doesn't need to be specified separately in this case.
 
 @item commit [-f @var{fmt}] [-t @var{cache}] @var{filename}
 
-Commit the changes recorded in @var{filename} in its base image.
+Commit the changes recorded in @var{filename} in its base image or backing file.
+If the backing file is smaller than the snapshot, then the backing file will be
+resized to be the same size as the snapshot.  If the snapshot is smaller than
+the backing file, the backing file will not be truncated.  If you want the
+backing file to match the size of the smaller snapshot, you can safely truncate
+it yourself once the commit operation successfully completes.
 
 @item compare [-f @var{fmt}] [-F @var{fmt}] [-p] [-s] [-q] @var{filename1} @var{filename2}
 
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 4f28250..cce6b81 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -966,6 +966,45 @@ EQMP
         .mhandler.cmd_new = qmp_marshal_input_block_commit,
     },
 
+SQMP
+block-commit
+------------
+
+Live commit of data from overlay image nodes into backing nodes - i.e., writes
+data between 'top' and 'base' into 'base'.
+
+Arguments:
+
+- "device": The device's ID, must be unique (json-string)
+- "base": The file name of the backing image to write data into.
+          If not specified, this is the deepest backing image
+          (json-string, optional)
+- "top":  The file name of the backing image within the image chain,
+          which contains the topmost data to be committed down.
+
+          If top == base, that is an error.
+          If top == active, the job will not be completed by itself,
+          user needs to complete the job with the block-job-complete
+          command after getting the ready event. (Since 2.0)
+
+          If the base image is smaller than top, then the base image
+          will be resized to be the same size as top.  If top is
+          smaller than the base image, the base will not be
+          truncated.  If you want the base image size to match the
+          size of the smaller top, you can safely truncate it
+          yourself once the commit operation successfully completes.
+          (json-string)
+- "speed":  the maximum speed, in bytes per second (json-int, optional)
+
+
+Example:
+
+-> { "execute": "block-commit", "arguments": { "device": "virtio0",
+                                              "top": "/tmp/snap1.qcow2" } }
+<- { "return": {} }
+
+EQMP
+
     {
         .name       = "drive-backup",
         .args_type  = "sync:s,device:B,target:s,speed:i?,mode:s?,format:s?,"
-- 
1.8.1.4

  parent reply	other threads:[~2014-01-24 17:25 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24 17:20 [Qemu-devel] [PULL v2 00/93] Block patches Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 01/93] rbd: switch from pipe to QEMUBH completion notification Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 02/93] qemu-iotests: Introduce _unsupported_imgopts Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 03/93] qemu-iotests: Add _unsupported_imgopts for vmdk subformats Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 04/93] qemu-iotests: Clean up all extents for vmdk Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 05/93] block/iscsi: return -ENOMEM if an async call fails immediately Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 06/93] gluster: Convert aio routines into coroutines Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 07/93] gluster: Implement .bdrv_co_write_zeroes for gluster Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 08/93] gluster: Add support for creating zero-filled image Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 09/93] sheepdog: fix clone operation by 'qemu-img create -b' Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 10/93] qtest: Fix the bug about disable vnc causes "make check" fail Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 11/93] docs: qcow2 compat=1.1 is now the default Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 12/93] vmdk: Fix big flat extent IO Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 13/93] readline: decouple readline from the monitor Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 14/93] readline: move readline to a generic location Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 15/93] osdep: add qemu_set_tty_echo() Kevin Wolf
2014-01-24 17:20 ` [Qemu-devel] [PULL 16/93] qemu-io: use readline.c Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 17/93] qemu-io: add command completion Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 18/93] blkdebug: Use errp for read_config() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 19/93] blkdebug: Don't require sophisticated filename Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 20/93] qdict: Add qdict_array_split() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 21/93] qapi: extend qdict_flatten() for QLists Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 22/93] qemu-option: Add qemu_config_parse_qdict() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 23/93] blkdebug: Always call read_config() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 24/93] blkdebug: Use command-line in read_config() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 25/93] block: Allow reference for bdrv_file_open() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 26/93] block: Pass reference to bdrv_file_open() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 27/93] block: Allow block devices without files Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 28/93] block: Add bdrv_open_image() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 29/93] block: Use bdrv_open_image() in bdrv_open() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 30/93] block: Allow recursive "file"s Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 31/93] blockdev: Move "file" to legacy_opts Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 32/93] blkdebug: Allow command-line file configuration Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 33/93] blkverify: Allow command-line configuration Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 34/93] blkverify: Don't require protocol filename Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 35/93] qapi: Add "errno" to the list of polluted words Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 36/93] qapi: QMP interface for blkdebug and blkverify Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 37/93] qemu-io: Make filename optional Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 38/93] tests: Add test for qdict_array_split() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 39/93] tests: Add test for qdict_flatten() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 40/93] iotests: Test new blkdebug/blkverify interface Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 41/93] iotests: Test file format nesting Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 42/93] block: fix backing file segfault Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 43/93] dataplane: fix shadowed return value Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 44/93] qcow2: fix wrong value of L1E_OFFSET_MASK, L2E_OFFSET_MASK and REFT_OFFSET_MASK Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 45/93] vmdk: Check for overhead when opening Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 46/93] qemu-progress: Drop unused include Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 47/93] qemu-progress: Fix progress printing on SIGUSR1 Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 48/93] Documentation: qemu-img: Mention SIGUSR1 progress report Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 49/93] sheepdog: fix 'qemu-img map' Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 50/93] drive mirror:fix memory leak Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 51/93] vmdk: Fix format specific information (create type) for streamOptimized Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 52/93] qapi: Add "backing" to BlockStats Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 53/93] block: Add bs->node_name to hold the name of a bs node of the bs graph Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 54/93] block: Allow the user to define "node-name" option both on command line and QMP Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 55/93] qmp: Add QMP query-named-block-nodes to list the named BlockDriverState nodes Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 56/93] qmp: Allow to change password on named block driver states Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 57/93] block: Create authorizations mechanism for external snapshot and resize Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 58/93] qmp: Allow block_resize to manipulate bs graph nodes Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 59/93] qmp: Allow to take external snapshots on bs graphs node Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 60/93] block/curl: Implement the libcurl timer callback interface Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 61/93] block: resize backing file image during offline commit, if necessary Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 62/93] block: resize backing image during active layer commit, if needed Kevin Wolf
2014-01-24 17:21 ` Kevin Wolf [this message]
2014-01-24 17:21 ` [Qemu-devel] [PULL 64/93] block: Fix bdrv_commit return value Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 65/93] block: Move initialisation of BlockLimits to bdrv_refresh_limits() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 66/93] block: Inherit opt_transfer_length Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 67/93] block: Update BlockLimits when they might have changed Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 68/93] qemu_memalign: Allow small alignments Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 69/93] block: Detect unaligned length in bdrv_qiov_is_aligned() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 70/93] block: Don't use guest sector size for qemu_blockalign() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 71/93] block: rename buffer_alignment to guest_block_size Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 72/93] raw: Probe required direct I/O alignment Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 73/93] block: Introduce bdrv_aligned_preadv() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 74/93] block: Introduce bdrv_co_do_preadv() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 75/93] block: Introduce bdrv_aligned_pwritev() Kevin Wolf
2014-01-24 17:21 ` [Qemu-devel] [PULL 76/93] block: write: Handle COR dependency after I/O throttling Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 77/93] block: Introduce bdrv_co_do_pwritev() Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 78/93] block: Switch BdrvTrackedRequest to byte granularity Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 79/93] block: Allow waiting for overlapping requests between begin/end Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 80/93] block: Make zero-after-EOF work with larger alignment Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 81/93] block: Generalise and optimise COR serialisation Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 82/93] block: Make overlap range for serialisation dynamic Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 83/93] block: Allow wait_serialising_requests() at any point Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 84/93] block: Align requests in bdrv_co_do_pwritev() Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 85/93] block: Assert serialisation assumptions in pwritev Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 86/93] block: Change coroutine wrapper to byte granularity Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 87/93] block: Make bdrv_pread() a bdrv_prwv_co() wrapper Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 88/93] block: Make bdrv_pwrite() " Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 89/93] iscsi: Set bs->request_alignment Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 90/93] blkdebug: Make required alignment configurable Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 91/93] qemu-io: New command 'sleep' Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 92/93] qemu-iotests: Test pwritev RMW logic Kevin Wolf
2014-01-24 17:22 ` [Qemu-devel] [PULL 93/93] block: Switch bdrv_io_limits_intercept() to byte granularity Kevin Wolf

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=1390584136-24703-64-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /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).