qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Dietmar Maurer <dietmar@proxmox.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Eric Blake <eblake@redhat.com>
Subject: [Qemu-devel]  [RFC] qemu-img: add option -d in convert
Date: Thu, 20 Jun 2013 16:59:17 +0800	[thread overview]
Message-ID: <51C2C465.1090701@linux.vnet.ibm.com> (raw)

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

             reply	other threads:[~2013-06-20  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20  8:59 Wenchao Xia [this message]
2013-06-25  9:13 ` [Qemu-devel] [RFC] qemu-img: add option -d in convert Stefan Hajnoczi
2013-06-25 11:14   ` Wenchao Xia
2013-06-27  9:01     ` Stefan Hajnoczi
2013-06-27 12:30       ` Wenchao Xia
2013-07-02  8:47         ` Stefan Hajnoczi
2013-06-27 12:44       ` Wenchao Xia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C2C465.1090701@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=dietmar@proxmox.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).