From patchwork Thu Oct 27 09:54:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 122100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 369CC1007D8 for ; Thu, 27 Oct 2011 20:55:00 +1100 (EST) Received: from localhost ([::1]:60324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJMfk-0004dO-Kn for incoming@patchwork.ozlabs.org; Thu, 27 Oct 2011 05:54:52 -0400 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 Received: from localhost (stefanha-thinkpad.manchester-maybrook.uk.ibm.com [9.174.219.31]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p9R9scmK024477; Thu, 27 Oct 2011 10:54:38 +0100 From: Stefan Hajnoczi To: Date: Thu, 27 Oct 2011 10:54:26 +0100 Message-Id: <1319709268-7435-1-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 194.196.100.161 Cc: Kevin Wolf , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/3] qemu-io: delete bs instead of leaking it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }