From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC1mt-0007Uy-AQ for qemu-devel@nongnu.org; Mon, 06 Jul 2015 04:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC1mp-0001vG-W8 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 04:30:03 -0400 Received: from smtp.sangfor.com.cn ([222.126.229.182]:49646 helo=mail.sangfor.com.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC1mp-0001jA-9V for qemu-devel@nongnu.org; Mon, 06 Jul 2015 04:29:59 -0400 Date: Mon, 6 Jul 2015 16:20:58 +0800 From: vt Mime-Version: 1.0 Message-ID: <201507061620581832887@sangfor.com.cn> Content-Type: multipart/alternative; boundary="----=_001_NextPart261041472731_=----" Subject: [Qemu-devel] Can the backing file of qcow2 points to a snapshot of base file? Reply-To: vt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel , kwolf , stefanha This is a multi-part message in MIME format. ------=_001_NextPart261041472731_=---- Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 DQpIaS4NCg0KSWYgYSBiYXNlIHFjb3cyIGltYWdlIHNuYXBzaG90IGNoYWluIGxpa2UgdGhpczoN Cg0KYmFzZS5xY293MjogW0FdIC0+IFtCXSAtPiBbQ10NCg0KW0NdIGlzIHRoZSBjdXJyZW50IGlt YWdlIHdoZXJlIGd1ZXN0IHJlYWQvd3JpdGUgdG8sdXN1YWxseSB3ZSBjcmVhdGUgYSBuZXcgaW1h Z2UgYmFzZSBvbiB0aGUgYmFzZS5xY293MiBsaWtlIHRoaXMNCg0KcWVtdS1pbWcgY3JlYXRlIC1m IHFjb3cyIC1vIGJhY2tpbmdfZmlsZT0vcGF0aC9iYXNlLnFjb3cyIG5ldy5xY293Mg0KDQpzbyB0 aGUgZGF0YSBvZiBuZXcucWNvdzIgaXMgZnJvbSBbQ10gb2YgYmFzZS5xY293MiwgYXNzdW1pbmcg dGhlIG5ldy5xY293MiBoYXMgbm90IGJlZW4gd3JpdGUgdG8gc2luY2UgY3JlYXRlZC4NCg0KV2hh dCBJIHdhbnQgaXMgdGhhdCB0aGUgZGF0YSBvZiBuZXcucWNvdzIgaXMgZnJvbSBbQl0gb2YgYmFz ZS5xY293MiwgbGlrZSB0aGlzOg0KDQpxZW11LWltZyBjcmVhdGUgLWYgcWNvdzIgLW8gYmFja2lu Z19maWxlPS9wYXRoL2Jhc2UucWNvdzIsYmFja2luZ19zbmFwc2hvdD1CICBuZXcucWNvdzINCg0K Q2FuIHRoZSBxZW11IHN1cHBvcnQgaXQgbm93Pw0KDQpUaGFua3MNCg0KDQoNCnZ0 ------=_001_NextPart261041472731_=---- Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
 
Hi.
 
If a base qcow2 image snapshot chain like this:
 
base.qcow2: [A] -> [B] -> [C]
 
[C] is the current image where guest read/write to,usually we cr= eate a=20 new image base on the base.qcow2 like this
 
qemu-img create -f qcow2 -o backing_file=3D/path/base.qcow2 new.qcow2=
 
so the data of new.qcow2 is from [C] of base.qcow2, assuming the= =20 new.qcow2 has not been write to since created.
 
What I want is that the data of new.qcow2 is from [B] of base.qcow2, = like=20 this:
 
qemu-img create -f qcow2 -o=20 backing_file=3D/path/base.qcow2,backing_snapshot=3DB  new.qcow2
 
Can the qemu support it now?
 
Thanks

vt
------=_001_NextPart261041472731_=------ From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC5D2-0002FA-KD for qemu-devel@nongnu.org; Mon, 06 Jul 2015 08:09:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC5Cx-0007gH-LS for qemu-devel@nongnu.org; Mon, 06 Jul 2015 08:09:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC5Cx-0007ft-Dk for qemu-devel@nongnu.org; Mon, 06 Jul 2015 08:09:11 -0400 References: <201507061620581832887@sangfor.com.cn> From: Max Reitz Message-ID: <559A6FDF.9050101@redhat.com> Date: Mon, 6 Jul 2015 14:09:03 +0200 MIME-Version: 1.0 In-Reply-To: <201507061620581832887@sangfor.com.cn> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Can the backing file of qcow2 points to a snapshot of base file? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: vt , qemu-devel , kwolf , stefanha On 06.07.2015 10:20, vt wrote: > Hi. > If a base qcow2 image snapshot chain like this: > base.qcow2: [A] -> [B] -> [C] > [C] is the current image where guest read/write to,usually we create a > new image base on the base.qcow2 like this > qemu-img create -f qcow2 -o backing_file=3D/path/base.qcow2 new.qcow2 > so the data of new.qcow2 is from [C] of base.qcow2, assuming the > new.qcow2 has not been write to since created. > What I want is that the data of new.qcow2 is from [B] of base.qcow2, > like this: > qemu-img create -f qcow2 -o > backing_file=3D/path/base.qcow2,backing_snapshot=3DB new.qcow2 > Can the qemu support it now? > Thanks > -----------------------------------------------------------------------= - > vt Hi vt, I don't think this is possible. For this to work, the snapshot would=20 have to be loaded temporarily, but the only place I can see in the qemu=20 code base where this is done is inside qemu-img and qemu-nbd, so qemu=20 itself appearently does not support this. What you can do is export the snapshot via qemu-nbd (-l) and then use=20 that NBD server as a backing file with qemu. This is not very nice, but=20 I don't suppose there are many people eager to implement the=20 functionality you'd like to have (although I don't think it would be too=20 difficult, frankly=A1=AD). Max From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCIBb-00034f-I7 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 22:00:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCIBX-0006L0-9b for qemu-devel@nongnu.org; Mon, 06 Jul 2015 22:00:39 -0400 Received: from smtp.sangfor.com.cn ([222.126.229.182]:49389 helo=mail.sangfor.com.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCIBW-0006IW-AA for qemu-devel@nongnu.org; Mon, 06 Jul 2015 22:00:35 -0400 Date: Tue, 7 Jul 2015 10:00:23 +0800 From: vt References: <201507061620581832887@sangfor.com.cn>, <559A6FDF.9050101@redhat.com> Mime-Version: 1.0 Message-ID: <201507071000225814308@sangfor.com.cn> Content-Type: multipart/alternative; boundary="----=_001_NextPart141684286301_=----" Subject: [Qemu-devel] =?gb2312?b?u9i4tDogUmU6ICBDYW4gdGhlIGJhY2tpbmcgZmls?= =?gb2312?b?ZSBvZiBxY293MiBwb2ludHMgdG8gYSBzbmFwc2hvdCBvZiBiYXNl?= =?gb2312?b?IGZpbGU/?= Reply-To: vt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel , kwolf , stefanha This is a multi-part message in MIME format. ------=_001_NextPart141684286301_=---- Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 T24gMjAxNS83LzYgMjA6MDksIE1heCBSZWl0eiB3cm90ZToNCj4gT24gMDYuMDcuMjAxNSAxMDoy MCwgdnQgd3JvdGU6DQo+PiBIaS4NCj4+IElmIGEgYmFzZSBxY293MiBpbWFnZSBzbmFwc2hvdCBj aGFpbiBsaWtlIHRoaXM6DQo+PiBiYXNlLnFjb3cyOiBbQV0gLT4gW0JdIC0+IFtDXQ0KPj4gW0Nd IGlzIHRoZSBjdXJyZW50IGltYWdlIHdoZXJlIGd1ZXN0IHJlYWQvd3JpdGUgdG8sdXN1YWxseSB3 ZSBjcmVhdGUgYQ0KPj4gbmV3I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684286301_=---- Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
On 2015/7/6 20:09, Max Reitz wrote:
> On 06.07.2015 10:20, vt wrote:
>> Hi.
>> If a base qcow2 image snapshot=  chain like this:
>> base.qcow2: [A] -> [B] ->&nbs= p;[C]
>> [C] is the current image where=  guest read/write to,usually we create a
>> new image base on the base.qco= w2 like this
>> qemu-img create -f qcow2 -o ba= cking_file=3D/path/base.qcow2 new.qcow2
>> so the data of new.qcow2 is&nb= sp;from [C] of base.qcow2, assuming the
>> new.qcow2 has not been write t= o since created.
>> What I want is that the d= ata of new.qcow2 is from [B] of base.qc= ow2,
>> like this:
>> qemu-img create -f qcow2 -o
>> backing_file=3D/path/base.qcow2,backing_snapshot=3DB&nb= sp; new.qcow2
>> Can the qemu support it now?
>> Thanks
>> -------------------------------------------------------= -----------------
>> vt 
>
> Hi vt,
>
> I don't think this is possible.&nb= sp;For this to work, the snapshot would = ;have to be loaded temporarily, but the = ;only place I can see in the qemu = code base where this is done is inside&= nbsp;qemu-img and qemu-nbd, so qemu itself a= ppearently does not support this.
>
> What you can do is export the=  snapshot via qemu-nbd (-l) and then us= e that NBD server as a backing file&nbs= p;with qemu. This is not very nice, but=  I don't suppose there are many people&= nbsp;eager to implement the functionality you'd&n= bsp;like to have (although I don't think&nbs= p;it would be too difficult, frankly=A1=AD).
>
> Max
 
Thanks, Max!
 
It seems that I have to implement = the functionality by myself...
 
Here is my plan:
 
1. Pass the snapshot name(id) by -drive=
2. Get the snapshot name(id) in the&nbs= p;bdrv_open_backing_file() -> qcow2_open() and load=  the snapshot header
3. Load BDRVQcowState.l1_table with the snap= shot's l1 table
 
Does it look ok?
 
Thanks
---------------------------------------------------------------------= ---
vt
 
------=_001_NextPart141684286301_=------