From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJOQf-0000d1-Jr for qemu-devel@nongnu.org; Wed, 13 Jan 2016 11:37:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJOQd-0001ya-W9 for qemu-devel@nongnu.org; Wed, 13 Jan 2016 11:37:49 -0500 From: Kevin Wolf Date: Wed, 13 Jan 2016 17:37:16 +0100 Message-Id: <1452703036-17999-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1452703036-17999-1-git-send-email-kwolf@redhat.com> References: <1452703036-17999-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 9/9] qcow2: Make image inaccessible after failed qcow2_invalidate_cache() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com If qcow2_invalidate_cache() fails, we are in a state where qcow2_close() has already been completed, but the image hasn't been reopened yet. Calling into any qcow2 function for an image in this state will cause crashes. The real solution would be to get rid of the close/open pair and instead do an atomic reset of the involved data structures, but this isn't trivial, so let's just make the image inaccessible for now. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/qcow2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 1b9c5fc..28d1a4b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1763,6 +1763,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) bdrv_invalidate_cache(bs->file->bs, &local_err); if (local_err) { error_propagate(errp, local_err); + bs->drv = NULL; return; } @@ -1776,9 +1777,11 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) error_setg(errp, "Could not reopen qcow2 layer: %s", error_get_pretty(local_err)); error_free(local_err); + bs->drv = NULL; return; } else if (ret < 0) { error_setg_errno(errp, -ret, "Could not reopen qcow2 layer"); + bs->drv = NULL; return; } -- 1.8.3.1