From patchwork Mon Jul 22 22:09:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Main X-Patchwork-Id: 260826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CADDC2C00A3 for ; Tue, 23 Jul 2013 08:11:29 +1000 (EST) Received: from localhost ([::1]:37430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1OKF-00070e-Ge for incoming@patchwork.ozlabs.org; Mon, 22 Jul 2013 18:11:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1OIg-0005K6-52 for qemu-devel@nongnu.org; Mon, 22 Jul 2013 18:09:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1OId-0006AA-8B for qemu-devel@nongnu.org; Mon, 22 Jul 2013 18:09:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1OIc-00069z-Vm for qemu-devel@nongnu.org; Mon, 22 Jul 2013 18:09:47 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6MM9kK6022977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 22 Jul 2013 18:09:46 -0400 Received: from arnold.mains.com (ovpn-113-70.phx2.redhat.com [10.3.113.70]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r6MM9aMC011970; Mon, 22 Jul 2013 18:09:45 -0400 From: Ian Main To: qemu-devel@nongnu.org Date: Mon, 22 Jul 2013 15:09:20 -0700 Message-Id: <1374530960-22031-4-git-send-email-imain@redhat.com> In-Reply-To: <1374530960-22031-1-git-send-email-imain@redhat.com> References: <1374530960-22031-1-git-send-email-imain@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, famz@redhat.com, rjones@redhat.com, Ian Main , stefanha@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH V6 3/3] Add backing drive while performing backup. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- block/backup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/block/backup.c b/block/backup.c index 68abd23..d32b3b7 100644 --- a/block/backup.c +++ b/block/backup.c @@ -323,6 +323,11 @@ 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_set_in_use(target, 0); + bdrv_iostatus_disable(target); bdrv_delete(target); @@ -362,6 +367,17 @@ 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; + /* Set in use so it can only be exported by NBD. */ + bdrv_set_in_use(target, 1); + job->on_source_error = on_source_error; job->on_target_error = on_target_error; job->target = target;