From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0pSs-0003Is-S7 for qemu-devel@nongnu.org; Fri, 14 Sep 2018 10:52:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0pSq-0003Ru-52 for qemu-devel@nongnu.org; Fri, 14 Sep 2018 10:52:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g0pSp-0003RU-S0 for qemu-devel@nongnu.org; Fri, 14 Sep 2018 10:52:55 -0400 References: <20180912074402.GB11164@lemon.usersys.redhat.com> <20180914060543.GB3653@lemon.usersys.redhat.com> From: Eric Blake Message-ID: Date: Fri, 14 Sep 2018 09:52:51 -0500 MIME-Version: 1.0 In-Reply-To: <20180914060543.GB3653@lemon.usersys.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Can I convert backing file to internal snapshot? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , lampahome Cc: QEMU Developers On 9/14/18 1:05 AM, Fam Zheng wrote: > On Fri, 09/14 12:23, lampahome wrote: >> Can I convert from internap snapshot to external snapshot? >> If there's 3 snapshots in one qcow2, can I convert them all to external >> snapshots? > > Qcow2 doesn't track internal snapshot dependencies like external snapshot, so > there is no direct way to create the "differentiative" or "delta" images in the > same way as would be with external snapshots. In theory it's possible to convert > all internal snapshots to separate full images then create delta by > sector-by-sector comparison. In fact, qemu-img documents that you can do: You can use "rebase" to perform a "diff" operation on two disk images. This can be useful when you have copied or cloned a guest, and you want to get back to a thin image on top of a template or base image. Say that "base.img" has been cloned as "modified.img" by copying it, and that the "modified.img" guest has run so there are now some changes compared to "base.img". To construct a thin image called "diff.qcow2" that contains just the differences, do: qemu-img create -f qcow2 -b modified.img diff.qcow2 qemu-img rebase -b base.img diff.qcow2 At this point, "modified.img" can be discarded, since "base.img + diff.qcow2" contains the same information. So yes, the process is to first use multiple 'qemu-img convert -l' to extract the separate points in time into separate files, and then 'qemu-img rebase' as above to convert those separate points in time back into differential files. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org