From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKru0-0004Iz-Ds for qemu-devel@nongnu.org; Mon, 31 Oct 2011 09:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKrty-0004CN-Tk for qemu-devel@nongnu.org; Mon, 31 Oct 2011 09:27:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKrty-0004C8-KH for qemu-devel@nongnu.org; Mon, 31 Oct 2011 09:27:46 -0400 From: Kevin Wolf Date: Mon, 31 Oct 2011 14:29:49 +0100 Message-Id: <1320067830-12093-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com> References: <1320067830-12093-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 14/55] qemu-io: delete bs instead of leaking it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 Signed-off-by: Kevin Wolf --- 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.6.4