]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
block: fully delete bs->file when closing
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 May 2012 14:51:44 +0000 (16:51 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 10 May 2012 08:32:12 +0000 (10:32 +0200)
We are reusing bs->file across close/open, which may not cause any
known bugs but is a recipe for trouble.  Prefer bdrv_delete, and
enjoy the new invariant in the implementation of bdrv_delete.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c

diff --git a/block.c b/block.c
index 271f109cbe5d6eacf6b3619c875d6d15dbfea4ed..6154c3fec08abb5e02cef478a32e5245f5507fdb 100644 (file)
--- a/block.c
+++ b/block.c
@@ -882,7 +882,8 @@ void bdrv_close(BlockDriverState *bs)
         bs->backing_format[0] = '\0';
 
         if (bs->file != NULL) {
-            bdrv_close(bs->file);
+            bdrv_delete(bs->file);
+            bs->file = NULL;
         }
 
         bdrv_dev_change_media_cb(bs, false);
@@ -1062,9 +1063,6 @@ void bdrv_delete(BlockDriverState *bs)
     bdrv_make_anon(bs);
 
     bdrv_close(bs);
-    if (bs->file != NULL) {
-        bdrv_delete(bs->file);
-    }
 
     assert(bs != bs_snapshots);
     g_free(bs);