summary refs log tree commit diff stats
path: root/qemu-io.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-10-27 10:54:26 +0100
committerKevin Wolf <kwolf@redhat.com>2011-10-28 19:25:49 +0200
commitb46578555c4bce64e3daba4591334aba2d12c156 (patch)
tree59ff501b5747cfcc6645119ff291c7e1051b58c9 /qemu-io.c
parentc95de7e2c40da4235ceda6d134ae069dae80157e (diff)
downloadfocaccia-qemu-b46578555c4bce64e3daba4591334aba2d12c156.tar.gz
focaccia-qemu-b46578555c4bce64e3daba4591334aba2d12c156.zip
qemu-io: delete bs instead of leaking it
Using bdrv_close() is not enough to free a BlockDriverState.  Since we
explicitly create it with bdrv_new(), use bdrv_delete() to close and
delete it.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-io.c')
-rw-r--r--qemu-io.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/qemu-io.c b/qemu-io.c
index c45a4138b2..5af887e057 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1582,7 +1582,7 @@ static const cmdinfo_t map_cmd = {
 
 static int close_f(int argc, char **argv)
 {
-    bdrv_close(bs);
+    bdrv_delete(bs);
     bs = NULL;
     return 0;
 }
@@ -1611,6 +1611,7 @@ static int openfile(char *name, int flags, int growable)
 
         if (bdrv_open(bs, name, flags, NULL) < 0) {
             fprintf(stderr, "%s: can't open device %s\n", progname, name);
+            bdrv_delete(bs);
             bs = NULL;
             return 1;
         }
@@ -1834,7 +1835,7 @@ int main(int argc, char **argv)
     qemu_aio_flush();
 
     if (bs) {
-        bdrv_close(bs);
+        bdrv_delete(bs);
     }
     return 0;
 }