From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upain-00027y-Cp for qemu-devel@nongnu.org; Thu, 20 Jun 2013 05:00:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Upaim-0001BX-1S for qemu-devel@nongnu.org; Thu, 20 Jun 2013 05:00:01 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:54962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upail-0001B3-DV for qemu-devel@nongnu.org; Thu, 20 Jun 2013 04:59:59 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Jun 2013 14:23:08 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id B9B5E3940043 for ; Thu, 20 Jun 2013 14:29:53 +0530 (IST) Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5K8xnDG23920644 for ; Thu, 20 Jun 2013 14:29:49 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5K8xq0V020685 for ; Thu, 20 Jun 2013 18:59:53 +1000 Message-ID: <51C2C465.1090701@linux.vnet.ibm.com> Date: Thu, 20 Jun 2013 16:59:17 +0800 From: Wenchao Xia MIME-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC] qemu-img: add option -d in convert List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , Stefan Hajnoczi , Paolo Bonzini , Dietmar Maurer , Anthony Liguori , qemu-devel , Eric Blake Hi, This is a draft design which aimed for internal snapshot convert, hope to get your comments: Internal snapshot is not as easy as external snapshot, to query and convert. This patch will improve convertion side, which helps internal / external snapshot mixed case. With it user can treat internal snapshot as lineraity relationship, use it like external ones with tool qemu-img. An detailed example, If there is a chain as following: imageA(sn0)->imageB(sn0,sn1)->imageC(sn0) The real relationship in it could be: -->imageA.qcow2---->imageB.qcow2--------->imageC.qcow2 |->imageA(sn0) |->imageB(sn0) |->imageC(sn0) |->imageB(sn1) To export it, two steps: 1. duplicate them to get an exactly same tree by: qemu-img convert imageA.qcow2 -O export/imageA.qcow2 -f qcow2 qemu-img convert imageA.qcow2 -s sn0 -O export/imageA_sn0.qcow2 qemu-img convert imageB.qcow2 -O export/imageB.qcow2 -f qcow2 -o backing_file=export/imageA.qcow2 qemu-img convert imageB.qcow2 -s sn0 -O export/imageB.qcow2 -f qcow2 -o backing_file=export/imageB.qcow2 ... result at ./export: -->imageA.qcow2-------->imageB.qcow2--------->imageC.qcow2 |->imageA_sn0.qcow2 |->imageB_sn0.qcow2 |->imageC_sn0.qcow2 |->imageB_sn1.qcow2 2. change the relationship to linearity to save space(or by 3rd party diff tool): qemu-img create imageA_l.qcow2 -f qcow2 -p backing_file=imageA_qcow2 qemu-img rebase imageA_l.qcow2 -b imageA_sn0.qcow2 qemu-img rebase -u imageB.qcow2 -b imageA_l.qcow2 discard imageA.qcow2 ........ result at ./export: imageA_sn0.qcow2-->imageA_l.qcow2-->imageB_sn0.qcow2-->imageB_sn1_l.qcow2- ->imageB_l.qcow2-->imageC_sn0.qcow2-->imageC_l.qcow2 This is a bit complexity, they can be merged into one step, to save disk I/O and make procedure simple, add a parameter: [-d [base_image=IMAGE,]snapshot=SNAPSHOT] qemu-img convert imageA.qcow2 -s sn0 -O export/imageA_sn0.qcow2 -f qcow2 qemu-img convert imageA.qcow2 -d snapshot=sn0 -O export/imageA.qcow2 -f qcow2 -o backing_file=export/imageA_sn0.qcow2 ........... result at ./export: imageA_sn0.qcow2-->imageA.qcow2-->imageB_sn0.qcow2-->imageB_sn1.qcow2- ->imageB.qcow2-->imageC_sn0.qcow2-->imageC.qcow2 parameter base_image allow diff operation taken across image in the backing chain. Note: 1 snapshot query can be added in qemu-nbd easily later. 2 This is actually a work around by qemu-img and qemu-nbd. A better way is to provide user snapshot_read() and snapshot_allocated() interface, typically a library. But that need some adjust in block level, especially thread, coroutine, and emulator cut off, so delay that. -- Best Regards Wenchao Xia