yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From c7c21ebc0dcddd666c616e161b0f9bbb4ade9cf4 Mon Sep 17 00:00:00 2001
9ae3a8
From: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Date: Tue, 11 Feb 2014 16:14:27 +0100
9ae3a8
Subject: [PATCH 21/28] block: update block commit documentation regarding image truncation
9ae3a8
9ae3a8
RH-Author: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Message-id: <d4d68c21d4b8936f3bcdc442abe0425e01352167.1392134912.git.jcody@redhat.com>
9ae3a8
Patchwork-id: 57217
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 3/6] block: update block commit documentation regarding image truncation
9ae3a8
Bugzilla: 1047254
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
This updates the documentation for commiting snapshot images.
9ae3a8
Specifically, this highlights what happens when the base image
9ae3a8
is either smaller or larger than the snapshot image being committed.
9ae3a8
9ae3a8
In the case of the base image being smaller, it is resized to the
9ae3a8
larger size of the snapshot image.  In the case of the base image
9ae3a8
being larger, it is not resized automatically, but once the commit
9ae3a8
has completed it is safe for the user to truncate the base image.
9ae3a8
9ae3a8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9ae3a8
Reviewed-by: Fam Zheng <famz@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 37222900743962e146a82b7077a18c3f39859a19)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	qmp-commands.hx
9ae3a8
9ae3a8
RHEL7 Notes: Conflict is due to 2 things: 1) drive-backup
9ae3a8
             not present in RHEL7, and 2) the block job
9ae3a8
             differentiation #ifdefs.
9ae3a8
---
9ae3a8
 hmp-commands.hx  |  5 +++++
9ae3a8
 qapi-schema.json |  7 +++++++
9ae3a8
 qemu-img.texi    |  7 ++++++-
9ae3a8
 qmp-commands.hx  | 40 ++++++++++++++++++++++++++++++++++++++++
9ae3a8
 4 files changed, 58 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hmp-commands.hx  |    5 +++++
9ae3a8
 qapi-schema.json |    7 +++++++
9ae3a8
 qemu-img.texi    |    7 ++++++-
9ae3a8
 qmp-commands.hx  |   40 ++++++++++++++++++++++++++++++++++++++++
9ae3a8
 4 files changed, 58 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/hmp-commands.hx b/hmp-commands.hx
9ae3a8
index 8e08ebf..467dd70 100644
9ae3a8
--- a/hmp-commands.hx
9ae3a8
+++ b/hmp-commands.hx
9ae3a8
@@ -35,6 +35,11 @@ STEXI
9ae3a8
 @item commit
9ae3a8
 @findex commit
9ae3a8
 Commit changes to the disk images (if -snapshot is used) or backing files.
9ae3a8
+If the backing file is smaller than the snapshot, then the backing file will be
9ae3a8
+resized to be the same size as the snapshot.  If the snapshot is smaller than
9ae3a8
+the backing file, the backing file will not be truncated.  If you want the
9ae3a8
+backing file to match the size of the smaller snapshot, you can safely truncate
9ae3a8
+it yourself once the commit operation successfully completes.
9ae3a8
 ETEXI
9ae3a8
 
9ae3a8
     {
9ae3a8
diff --git a/qapi-schema.json b/qapi-schema.json
9ae3a8
index 8b257e2..017b3b7 100644
9ae3a8
--- a/qapi-schema.json
9ae3a8
+++ b/qapi-schema.json
9ae3a8
@@ -1846,6 +1846,13 @@
9ae3a8
 #                    user needs to complete the job with the block-job-complete
9ae3a8
 #                    command after getting the ready event. (Since 2.0)
9ae3a8
 #
9ae3a8
+#                    If the base image is smaller than top, then the base image
9ae3a8
+#                    will be resized to be the same size as top.  If top is
9ae3a8
+#                    smaller than the base image, the base will not be
9ae3a8
+#                    truncated.  If you want the base image size to match the
9ae3a8
+#                    size of the smaller top, you can safely truncate it
9ae3a8
+#                    yourself once the commit operation successfully completes.
9ae3a8
+#
9ae3a8
 #
9ae3a8
 # @speed:  #optional the maximum speed, in bytes per second
9ae3a8
 #
9ae3a8
diff --git a/qemu-img.texi b/qemu-img.texi
9ae3a8
index 1078791..d75a780 100644
9ae3a8
--- a/qemu-img.texi
9ae3a8
+++ b/qemu-img.texi
9ae3a8
@@ -136,7 +136,12 @@ it doesn't need to be specified separately in this case.
9ae3a8
 
9ae3a8
 @item commit [-f @var{fmt}] [-t @var{cache}] @var{filename}
9ae3a8
 
9ae3a8
-Commit the changes recorded in @var{filename} in its base image.
9ae3a8
+Commit the changes recorded in @var{filename} in its base image or backing file.
9ae3a8
+If the backing file is smaller than the snapshot, then the backing file will be
9ae3a8
+resized to be the same size as the snapshot.  If the snapshot is smaller than
9ae3a8
+the backing file, the backing file will not be truncated.  If you want the
9ae3a8
+backing file to match the size of the smaller snapshot, you can safely truncate
9ae3a8
+it yourself once the commit operation successfully completes.
9ae3a8
 
9ae3a8
 @item compare [-f @var{fmt}] [-F @var{fmt}] [-p] [-s] [-q] @var{filename1} @var{filename2}
9ae3a8
 
9ae3a8
diff --git a/qmp-commands.hx b/qmp-commands.hx
9ae3a8
index 7a1bfd4..08a01ee 100644
9ae3a8
--- a/qmp-commands.hx
9ae3a8
+++ b/qmp-commands.hx
9ae3a8
@@ -1008,6 +1008,46 @@ EQMP
9ae3a8
         .args_type  = "device:B,base:s?,top:s,speed:o?",
9ae3a8
         .mhandler.cmd_new = qmp_marshal_input_block_commit,
9ae3a8
     },
9ae3a8
+
9ae3a8
+SQMP
9ae3a8
+block-commit
9ae3a8
+------------
9ae3a8
+
9ae3a8
+Live commit of data from overlay image nodes into backing nodes - i.e., writes
9ae3a8
+data between 'top' and 'base' into 'base'.
9ae3a8
+
9ae3a8
+Arguments:
9ae3a8
+
9ae3a8
+- "device": The device's ID, must be unique (json-string)
9ae3a8
+- "base": The file name of the backing image to write data into.
9ae3a8
+          If not specified, this is the deepest backing image
9ae3a8
+          (json-string, optional)
9ae3a8
+- "top":  The file name of the backing image within the image chain,
9ae3a8
+          which contains the topmost data to be committed down.
9ae3a8
+
9ae3a8
+          If top == base, that is an error.
9ae3a8
+          If top == active, the job will not be completed by itself,
9ae3a8
+          user needs to complete the job with the block-job-complete
9ae3a8
+          command after getting the ready event. (Since 2.0)
9ae3a8
+
9ae3a8
+          If the base image is smaller than top, then the base image
9ae3a8
+          will be resized to be the same size as top.  If top is
9ae3a8
+          smaller than the base image, the base will not be
9ae3a8
+          truncated.  If you want the base image size to match the
9ae3a8
+          size of the smaller top, you can safely truncate it
9ae3a8
+          yourself once the commit operation successfully completes.
9ae3a8
+          (json-string)
9ae3a8
+- "speed":  the maximum speed, in bytes per second (json-int, optional)
9ae3a8
+
9ae3a8
+
9ae3a8
+Example:
9ae3a8
+
9ae3a8
+-> { "execute": "block-commit", "arguments": { "device": "virtio0",
9ae3a8
+                                              "top": "/tmp/snap1.qcow2" } }
9ae3a8
+<- { "return": {} }
9ae3a8
+
9ae3a8
+EQMP
9ae3a8
+
9ae3a8
 #endif
9ae3a8
 
9ae3a8
     {
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8