[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] New qemu-img convert -B option to preserve the COW
From: |
Marc Bevand |
Subject: |
[Qemu-devel] [PATCH] New qemu-img convert -B option to preserve the COW aspect of images and/or re-base them |
Date: |
Fri, 30 May 2008 09:21:07 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
(Ignore my first email, the patch has been mangled. Get it from:
http://etud.epita.fr/~bevand_m/pub/rebase-cow-disk-image.patch )
If a disk image hd_a is a copy-on-write image based on the backing
file hd_base, it is currently impossible to use qemu-img to convert
hd_a to hd_b (possibly using another disk image format) while keeping
hd_b a copy-on-write image of hd_base. qemu-img also doesn't provide a
feature that would let an enduser re-base a image, for example: adjust
hd_a's backing file name from hd_base to hd_base2 if it had to change
for some reason.
This patch solves the 2 above problems by adding a new qemu-img
convert -B option which works as described below. This is a generic
feature that should work with ANY disk image format supporting backing
files:
-B output_base_image
forces the output image to be created as a copy on write image of
the specified base image; 'output_base_image' should have the
same content as the input's base image, however the path, image
format, etc may differ
Examples:
$ qemu-img info hd_a
image: hd_a
file format: qcow
virtual size: 6.0G (6442450944 bytes)
disk size: 28K
cluster_size: 512
backing file: hd_base (actual path: hd_base)
Converting hd_a (qcow) to hd_b (qcow2) while preserving the
copy-on-write aspect of the image:
$ qemu-img convert hd_a -O qcow2 -B hd_base hd_b
$ qemu-img info hd_b
image: hd_b
file format: qcow2
virtual size: 6.0G (6442450944 bytes)
disk size: 36K
cluster_size: 4096
backing file: hd_base (actual path: hd_base)
Renaming the backing file without losing hd_a:
$ ln hd_base hd_base2
$ qemu-img convert hd_a -O qcow -B hd_base2 hd_a2
$ mv hd_a2 hd_a
$ rm hd_base
$ qemu-img info hd_a
image: hd_a
file format: qcow
virtual size: 6.0G (6442450944 bytes)
disk size: 28K
cluster_size: 512
backing file: hd_base2 (actual path: hd_base2)
Patch made against SVN's rev 4622.
Signed-off-by: Marc Bevand <m.bevand <at> gmail.com>
Get it from: http://etud.epita.fr/~bevand_m/pub/rebase-cow-disk-image.patch