qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 14/30] block: fully delete bs->file when closing


From: Kevin Wolf
Subject: [Qemu-devel] [PATCH 14/30] block: fully delete bs->file when closing
Date: Thu, 10 May 2012 13:49:18 +0200

From: Paolo Bonzini <address@hidden>

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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
 block.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 271f109..6154c3f 100644
--- 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);
-- 
1.7.6.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]