From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJL38-0007dS-2A for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:10:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJL36-0007xD-Nk for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:10:53 -0400 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:50141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJL36-0007x9-FS for qemu-devel@nongnu.org; Thu, 27 Oct 2011 04:10:52 -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 p9R8Apes008435 for ; Thu, 27 Oct 2011 08:10:51 GMT Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9R8ApI82187276 for ; Thu, 27 Oct 2011 09:10:51 +0100 Received: from d06av03.portsmouth.uk.ibm.com (localhost.localdomain [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9R8AkkL018182 for ; Thu, 27 Oct 2011 02:10:47 -0600 From: Stefan Hajnoczi Date: Thu, 27 Oct 2011 08:42:13 +0100 Message-Id: <1319701333-5700-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] 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 | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index e91af37..e8ac704 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -1581,7 +1581,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; } @@ -1610,6 +1610,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; } -- 1.7.7