From c88876ddab22e053abd5ba976cfc1beb43a23b6e Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 7 May 2012 12:51:55 -0300
Subject: [RHEL6 qemu-kvm PATCH 1/6] block: do not reuse the backing file across bdrv_close/bdrv_open

RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Message-id: <1336395115-4138-3-git-send-email-pbonzini@redhat.com>
Patchwork-id: 39607
O-Subject: [RHEL 6.3 qemu-kvm PATCH] block: do not reuse the backing file across bdrv_close/bdrv_open
Bugzilla: 816471
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>

Bugzilla: 816471

Upstream status: waiting for instructions from Kevin on how to
    best empty my queue...

Brew build: https://brewweb.devel.redhat.com/taskinfo?taskID=4375106

This is another bug caused by not doing a full cleanup of the BDS
across close/open.  This was found with mirroring by Shaolong Hu,
but it can probably be reproduced also with eject or change.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c |    2 ++
 1 file changed, 2 insertions(+)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 block.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index 6df77ac..e05a9c6 100644
--- a/block.c
+++ b/block.c
@@ -706,6 +706,8 @@ void bdrv_close(BlockDriverState *bs)
         bs->opaque = NULL;
         bs->drv = NULL;
         bs->copy_on_read = 0;
+        bs->backing_file[0] = '\0';
+        bs->backing_format[0] = '\0';
 
         if (bs->file != NULL) {
             bdrv_close(bs->file);
-- 
1.7.3.2

