qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Fam Zheng <famz@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 0/9] QMP: Introduce incremental drive-backup with in-memory dirty bitmap
Date: Tue, 28 Jan 2014 13:11:32 +0100	[thread overview]
Message-ID: <20140128121132.GF16709@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <20140120025558.GA21516@T430.nay.redhat.com>

On Mon, Jan 20, 2014 at 10:55:58AM +0800, Fam Zheng wrote:
> On Fri, 01/17 17:25, Stefan Hajnoczi wrote:
> > On Mon, Jan 13, 2014 at 06:39:39PM +0800, Fam Zheng wrote:
> > > This implements incremental backup.
> > > 
> > > A few new QMP commands related to dirty bitmap are added:
> > > 
> > >     dirty-bitmap-add *
> > >     dirty-bitmap-disable *
> > >     dirty-bitmap-remove
> > > 
> > >     (*: also supported as transactions)
> > > 
> > > As their name implies, they manipulate a block device's dirty bitmap. This
> > > doesn't interfere with dirty bitmap used for migration, backup, mirror, etc,
> > > which don't have a name and are invisible to user. Only named bitmaps (created
> > > by dirty-bitmap-add) can be disabled/removed by user.
> > > 
> > > They are added to support "user controlled write tracking", so as to determine
> > > the range of date for incremental backup.
> > > 
> > > A new sync mode for drive-backup is introduced:
> > > 
> > >     drive-backup device=.. mode=.. sync=dirty-bitmap bitmap=bitmap0
> > > 
> > > Which will scan dirty bitmap "bitmap0" and only copy all dirty sectors to
> > > target.
> > > 
> > > Now, let's see the usage with a simple example:
> > > 
> > >     # Start the guest
> > >     vm = VM()
> > >     vm.start()
> > > 
> > >     # Fake some guest writes with "qemu-io", this is before creating dirty
> > >     # bitmap, so it won't be copied
> > >     vm.hmp('qemu-io ide0-hd0 "write -P 0xa 512k 1M"')
> > > 
> > >     # Create a dirty bitmap to track writes
> > >     vm.qmp("dirty-bitmap-add", device="ide0-hd0", name="dirty-0")
> > > 
> > >     # Fake some more guest writes with "qemu-io", this will be copied
> > >     vm.hmp('qemu-io ide0-hd0 "write -P 0xa 512M 1M"')
> > > 
> > >     # Now "disable" the first dirty bitmap, do the backup according to it,
> > >     # at meantime continue to track dirty with a new dirty bitmap
> > >     vm.qmp("transaction", actions=[
> > >         {
> > >             'type': 'dirty-bitmap-disable', 'data': {
> > >                 'device': 'ide0-hd0',
> > >                 'name': 'dirty-0'
> > >             }
> > >         }, {
> > >             'type': 'dirty-bitmap-add', 'data': {
> > >                 'device': 'ide0-hd0',
> > >                 'name': 'dirty-1'
> > >                 }
> > >         }, {
> > >             'type': 'drive-backup', 'data': {
> > >                 'device': 'ide0-hd0',
> > >                 'target': '/tmp/incre.qcow2',
> > >                 'bitmap': 'dirty-0',
> > >                 'sync': 'dirty-bitmap'
> > >                 }
> > >             }
> > >         ])
> > > 
> > >     # Once backup job started, the dirty bitmap can be removed (actually only
> > >     # hidden from user since it is still referenced by block job
> > >     vm.qmp("dirty-bitmap-remove", device="ide0-hd0", name="dirty-0")
> > 
> > I'm interested in the lifecycle of a dirty bitmap (but haven't reviewed
> > the patches yet).  In particular, what happens if a bitmap is added to
> > more than one drive?  Is there a more elegant way to handle the disable,
> > drive-backup, remove step (we only need to explicitly disable because we
> > still need the bitmap name for the drive-backup command)?  Also what
> > happens if we add the bitmap again after disabling?
> 
> A same name on that device can't be used again unless it's removed. A bitmap is
> associated to (and only) one device, it can't be shared.
> 
> > 
> > No need to answer all these questions, but it suggests the interface
> > exposes a bit of complexity.  Maybe it's possible to make it simpler and
> > easier to use?
> > 
> 
> At least the user has to explicitly start tracking, that's the dirty-bitmap-add
> step. Alternatively, we can have "disable, drive-backup, remove" step simplified as:
> 
>     drive-backup sync=dirty-bitmap bitmap=dirty0 reset-bitmap=true
> 
> where backup job copy out the dirty bitmap (and clears it, as reset-bitmap is
> true), and backup with it atomically.
> 
> Of course it doesn't have to actually copy the whole bitmap: it just makes the
> old one anonymous, create a new empty one and give it the same name. When
> backup is done, the old bitmap is removed.
> 
> What do you think?

That simplifies usage.  I can think of two options:
1. We want to continue incremental backup so drive-backup should
   atomically swap the bitmap with a new one of the same name (as you
   described).
2. We want to end incremental backup so the drive-backup command should
   consume the bitmap and not create a new one.

Then users just need to add a new bitmap and later use drive-backup.
They don't need to manually manage the bitmap's lifecycle.

Stefan

      reply	other threads:[~2014-01-28 12:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 10:39 [Qemu-devel] [PATCH 0/9] QMP: Introduce incremental drive-backup with in-memory dirty bitmap Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 1/9] block: Introduce reference count for dirty bitmaps Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 2/9] qapi: Add optional field "name" to block dirty bitmap Fam Zheng
2014-01-17 10:22   ` Stefan Hajnoczi
2014-01-13 10:39 ` [Qemu-devel] [PATCH 3/9] block: Add bdrv_dirty_bitmap_make_anon Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 4/9] qmp: Add dirty-bitmap-add and dirty-bitmap-remove Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 5/9] block: Handle error of bdrv_getlength in bdrv_create_dirty_bitmap Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 6/9] block: Introduce bdrv_dirty_bitmap_granularity() Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 7/9] block: Add support of "dirty-bitmap" sync mode Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 8/9] qmp: Add dirty-bitmap-disable command Fam Zheng
2014-01-13 10:39 ` [Qemu-devel] [PATCH 9/9] qapi: Add transaction support to dirty-bitmap-{add, disable} Fam Zheng
2014-01-17  9:25 ` [Qemu-devel] [PATCH 0/9] QMP: Introduce incremental drive-backup with in-memory dirty bitmap Stefan Hajnoczi
2014-01-20  2:55   ` Fam Zheng
2014-01-28 12:11     ` Stefan Hajnoczi [this message]

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=20140128121132.GF16709@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).