From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJMfc-0004d6-V7 for qemu-devel@nongnu.org; Thu, 27 Oct 2011 05:54:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJMfc-00037N-26 for qemu-devel@nongnu.org; Thu, 27 Oct 2011 05:54:44 -0400 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:54255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJMfb-00036h-N1 for qemu-devel@nongnu.org; Thu, 27 Oct 2011 05:54:43 -0400 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p9R9seMh018795 for ; Thu, 27 Oct 2011 09:54:40 GMT Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9R9sdkE2461860 for ; Thu, 27 Oct 2011 10:54:39 +0100 Received: from d06av08.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9R9sc6r024488 for ; Thu, 27 Oct 2011 10:54:38 +0100 From: Stefan Hajnoczi Date: Thu, 27 Oct 2011 10:54:26 +0100 Message-Id: <1319709268-7435-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/3] qemu-io: delete bs instead of leaking it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi 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 --- qemu-io.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index c45a413..5af887e 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; } -- 1.7.7