qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/6] qemu-img: add compression option to rebase subcommand


From: Hanna Czenczek
Subject: Re: [PATCH 5/6] qemu-img: add compression option to rebase subcommand
Date: Fri, 25 Aug 2023 17:14:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 01.06.23 21:28, Andrey Drobyshev via wrote:
If we rebase an image whose backing file has compressed clusters, we
might end up wasting disk space since the copied clusters are now
uncompressed.  In order to have better control over this, let's add
"--compress" option to the "qemu-img rebase" command.

Note that this option affects only the clusters which are actually being
copied from the original backing file.  The clusters which were
uncompressed in the target image will remain so.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
  docs/tools/qemu-img.rst |  6 ++++--
  qemu-img-cmds.hx        |  4 ++--
  qemu-img.c              | 19 +++++++++++++++++--
  3 files changed, 23 insertions(+), 6 deletions(-)

Interesting.  I was about to protest because we only really support writing compressed clusters to new and empty images, so the qcow2 driver does not allow overwriting existing clusters with compressed data.  But by design we skip all clusters that are anything but unallocated in the top image (i.e. the one we are going to write to), so this should indeed work out well.

Reviewed-by: Hanna Czenczek <hreitz@redhat.com>

diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
index 15aeddc6d8..973a912dec 100644
--- a/docs/tools/qemu-img.rst
+++ b/docs/tools/qemu-img.rst
@@ -663,7 +663,7 @@ Command description:
List, apply, create or delete snapshots in image *FILENAME*. -.. option:: rebase [--object OBJECTDEF] [--image-opts] [-U] [-q] [-f FMT] [-t CACHE] [-T SRC_CACHE] [-p] [-u] -b BACKING_FILE [-F BACKING_FMT] FILENAME
+.. option:: rebase [--object OBJECTDEF] [--image-opts] [-U] [-q] [-f FMT] [-t 
CACHE] [-T SRC_CACHE] [-p] [-u] [-c] -b BACKING_FILE [-F BACKING_FMT] FILENAME
Changes the backing file of an image. Only the formats ``qcow2`` and
    ``qed`` support changing the backing file.
@@ -690,7 +690,9 @@ Command description:
In order to achieve this, any clusters that differ between
      *BACKING_FILE* and the old backing file of *FILENAME* are merged
-    into *FILENAME* before actually changing the backing file.
+    into *FILENAME* before actually changing the backing file. With ``-c``

“With the ``-c`` option specified, [...]”

+    option specified, the clusters which are being merged (but not the
+    entire *FILENAME* image) are written in the compressed mode.

“[...] are compressed when written.”

      Note that the safe mode is an expensive operation, comparable to
      converting an image. It only works if the old backing file still




reply via email to

[Prev in Thread] Current Thread [Next in Thread]