[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC] qemu-img: add option -d in convert
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [RFC] qemu-img: add option -d in convert |
Date: |
Thu, 20 Jun 2013 16:59:17 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 |
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
- [Qemu-devel] [RFC] qemu-img: add option -d in convert,
Wenchao Xia <=