Received: from eggs.gnu.org ([2001:4830:134:3::10]:59136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLvZd-0003pu-Me for qemu-devel@nongnu.org; Wed, 20 Jan 2016 11:25:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLvZc-00074R-Gi for qemu-devel@nongnu.org; Wed, 20 Jan 2016 11:25:33 -0500 From: Kevin Wolf Date: Wed, 20 Jan 2016 17:25:02 +0100 Message-Id: <1453307106-28330-14-git-send-email-kwolf@redhat.com> In-Reply-To: <1453307106-28330-1-git-send-email-kwolf@redhat.com> References: <1453307106-28330-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 13/17] qcow2: Fix BDRV_O_INACTIVE handling in 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 What qcow2_invalidate_cache() should do is close the image with BDRV_O_INACTIVE set and reopen it with the flag cleared. In fact, it used to do exactly the opposite: qcow2_close() relied on bs->open_flags, which is already updated to have cleared BDRV_O_INACTIVE at this point, whereas qcow2_open() was called with s->flags, which has the flag still set. Fix this. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/qcow2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index bfc80ea..0f8c485 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1719,7 +1719,7 @@ static void qcow2_close(BlockDriverState *bs) /* else pre-write overlap checks in cache_destroy may crash */ s->l1_table = NULL; - if (!(bs->open_flags & BDRV_O_INACTIVE)) { + if (!(s->flags & BDRV_O_INACTIVE)) { qcow2_inactivate(bs); } @@ -1770,6 +1770,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) memset(s, 0, sizeof(BDRVQcow2State)); options = qdict_clone_shallow(bs->options); + flags &= ~BDRV_O_INACTIVE; ret = qcow2_open(bs, options, flags, &local_err); QDECREF(options); if (local_err) { -- 1.8.3.1