From patchwork Thu Aug 5 11:06:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 60997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 57401B6F0E for ; Fri, 6 Aug 2010 01:29:44 +1000 (EST) Received: from localhost ([127.0.0.1]:46445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oh2O5-0000Ip-CS for incoming@patchwork.ozlabs.org; Thu, 05 Aug 2010 11:29:41 -0400 Received: from [140.186.70.92] (port=51537 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oh23m-0004pe-HE for qemu-devel@nongnu.org; Thu, 05 Aug 2010 11:09:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oh23X-0004Xf-2o for qemu-devel@nongnu.org; Thu, 05 Aug 2010 11:08:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55866) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oh23W-0004Us-SN for qemu-devel@nongnu.org; Thu, 05 Aug 2010 11:08:27 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o75B6tMT016355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 5 Aug 2010 07:06:55 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o75B6r2H014694; Thu, 5 Aug 2010 07:06:54 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Thu, 5 Aug 2010 13:06:59 +0200 Message-Id: <1281006419-5196-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] block: Fix image re-open in bdrv_commit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Arguably we should re-open the backing file with the backing file format and not with the format of the snapshot image. Signed-off-by: Kevin Wolf --- block.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index da70f29..a5514e3 100644 --- a/block.c +++ b/block.c @@ -745,6 +745,7 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res) int bdrv_commit(BlockDriverState *bs) { BlockDriver *drv = bs->drv; + BlockDriver *backing_drv; int64_t sector, total_sectors; int n, ro, open_flags; int ret = 0, rw_ret = 0; @@ -762,7 +763,8 @@ int bdrv_commit(BlockDriverState *bs) if (bs->backing_hd->keep_read_only) { return -EACCES; } - + + backing_drv = bs->backing_hd->drv; ro = bs->backing_hd->read_only; strncpy(filename, bs->backing_hd->filename, sizeof(filename)); open_flags = bs->backing_hd->open_flags; @@ -772,12 +774,14 @@ int bdrv_commit(BlockDriverState *bs) bdrv_delete(bs->backing_hd); bs->backing_hd = NULL; bs_rw = bdrv_new(""); - rw_ret = bdrv_open(bs_rw, filename, open_flags | BDRV_O_RDWR, drv); + rw_ret = bdrv_open(bs_rw, filename, open_flags | BDRV_O_RDWR, + backing_drv); if (rw_ret < 0) { bdrv_delete(bs_rw); /* try to re-open read-only */ bs_ro = bdrv_new(""); - ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, drv); + ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, + backing_drv); if (ret < 0) { bdrv_delete(bs_ro); /* drive not functional anymore */ @@ -828,7 +832,8 @@ ro_cleanup: bdrv_delete(bs->backing_hd); bs->backing_hd = NULL; bs_ro = bdrv_new(""); - ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, drv); + ret = bdrv_open(bs_ro, filename, open_flags & ~BDRV_O_RDWR, + backing_drv); if (ret < 0) { bdrv_delete(bs_ro); /* drive not functional anymore */