Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K20nh-0003Jf-1x for qemu-devel@nongnu.org; Fri, 30 May 2008 05:21:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K20nf-0003IY-3x for qemu-devel@nongnu.org; Fri, 30 May 2008 05:21:28 -0400 Received: from [199.232.76.173] (port=55887 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K20ne-0003IN-Os for qemu-devel@nongnu.org; Fri, 30 May 2008 05:21:26 -0400 Received: from main.gmane.org ([80.91.229.2]:41338 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K20ne-0004TC-P2 for qemu-devel@nongnu.org; Fri, 30 May 2008 05:21:27 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1K20nZ-0004dc-SC for qemu-devel@nongnu.org; Fri, 30 May 2008 09:21:21 +0000 Received: from adsl-99-146-176-105.dsl.irvnca.sbcglobal.net ([99.146.176.105]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 May 2008 09:21:21 +0000 Received: from m.bevand by adsl-99-146-176-105.dsl.irvnca.sbcglobal.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 May 2008 09:21:21 +0000 From: Marc Bevand Date: Fri, 30 May 2008 09:21:07 +0000 (UTC) Message-ID: References: <18493.11141.847907.619324@mariner.uk.xensource.com> <18493.11264.309358.483993@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: news Subject: [Qemu-devel] [PATCH] New qemu-img convert -B option to preserve the COW aspect of images and/or re-base them Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.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 gmail.com> Get it from: http://etud.epita.fr/~bevand_m/pub/rebase-cow-disk-image.patch