qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ian Main <imain@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, rjones@redhat.com,
	Ian Main <imain@redhat.com>,
	stefanha@redhat.com, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH V5 3/4] Add backing drive while performing backup.
Date: Fri, 19 Jul 2013 10:03:30 -0700	[thread overview]
Message-ID: <1374253411-17162-4-git-send-email-imain@redhat.com> (raw)
In-Reply-To: <1374253411-17162-1-git-send-email-imain@redhat.com>

This patch adds the original source drive as a backing drive to our target
image so that the target image will appear complete during backup.  This
is especially useful for SYNC_MODE_NONE as it allows export via NBD to
have a complete point-in-time snapshot available for export.

Signed-off-by: Ian Main <imain@redhat.com>
---
 block/backup.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/block/backup.c b/block/backup.c
index 68abd23..e086e76 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -323,6 +323,10 @@ static void coroutine_fn backup_run(void *opaque)
 
     hbitmap_free(job->bitmap);
 
+    /* Set the target backing drive back to NULL before calling delete or
+     * it will also delete the underlying drive. */
+    target->backing_hd = NULL;
+
     bdrv_iostatus_disable(target);
     bdrv_delete(target);
 
@@ -362,6 +366,15 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
         return;
     }
 
+    /* Manually set the backing hd to be the backup source drive so
+     * that all reads done while we are backing up will be passed
+     * on to the original source drive.  This allows reading from the
+     * image while the backup is in progress, or in the case of
+     * SYNC_MODE_NONE allows a complete image to be present for export.
+     * Note that we do this for all modes including SYNC_MODE_TOP as
+     * even then it allows on-the-fly reading. */
+    target->backing_hd = bs;
+
     job->on_source_error = on_source_error;
     job->on_target_error = on_target_error;
     job->target = target;
-- 
1.8.1.4

  parent reply	other threads:[~2013-07-19 17:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 17:03 [Qemu-devel] [PATCH V5 0/4] Implement sync modes for drive-backup Ian Main
2013-07-19 17:03 ` [Qemu-devel] [PATCH V5 1/4] " Ian Main
2013-07-19 19:41   ` Eric Blake
2013-07-19 21:49     ` Ian Main
2013-07-19 22:11       ` Eric Blake
2013-07-20  3:11         ` Ian Main
2013-07-19 17:03 ` [Qemu-devel] [PATCH V5 2/4] Add tests for sync modes 'TOP' and 'NONE' Ian Main
2013-07-19 17:03 ` Ian Main [this message]
2013-07-19 17:03 ` [Qemu-devel] [PATCH V5 4/4] Change default to qcow2 for sync mode none Ian Main

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=1374253411-17162-4-git-send-email-imain@redhat.com \
    --to=imain@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --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).