From patchwork Wed May 18 10:17:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Joshi X-Patchwork-Id: 793322 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4IAMV8F029441 for ; Wed, 18 May 2011 10:22:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756885Ab1ERKRY (ORCPT ); Wed, 18 May 2011 06:17:24 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:52769 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754788Ab1ERKRV (ORCPT ); Wed, 18 May 2011 06:17:21 -0400 Received: by wwa36 with SMTP id 36so1541182wwa.1 for ; Wed, 18 May 2011 03:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=zFfpE2ZkBS6TnpqDsY0ute4i4BrKd8zgexNlM9tQngM=; b=q5eyimpz0v1YvEDomb8MGhpjPsktPScuod6IgRS1P0vGCDzsRk5ONv0DdqcjMrVEV9 31NTOEpdUFHi7FEZ8hr/zMVjdwJtQ1WEDnaRD9e6TG0JMXJ5GCnMms5cs86J7XtW4NxG AqDyRlhV2jPQTmDN4qv7g8IHZdH4+pvLoJQTs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=BbrZ+8JffyUlAJjvapLoBQ0pClZ79K53dQlmyFnDHfDSmD/Xn/x50RqOlF5DQIkDAH epIwH+4XHciXDzFmWoGZzvd3JYsSIDPqErTPMCSdniz5vjuoPbUnFZCQmYjWdXFM20T7 8YEzh7kfT9KD8SRkGK/hfDAQfR5XZFXKN2ERQ= Received: by 10.227.53.206 with SMTP id n14mr1676857wbg.14.1305713840286; Wed, 18 May 2011 03:17:20 -0700 (PDT) Received: from prasad-kvm.localdomain (pineapple.rdg.ac.uk [134.225.206.123]) by mx.google.com with ESMTPS id ed10sm881028wbb.15.2011.05.18.03.17.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 03:17:19 -0700 (PDT) Received: by prasad-kvm.localdomain (Postfix, from userid 1000) id 505F926E004F; Wed, 18 May 2011 11:17:18 +0100 (BST) From: Prasad Joshi To: prasadjoshi124@gmail.com Cc: mingo@elte.hu, kvm@vger.kernel.org, penberg@kernel.org, asias.hejun@gmail.com, gorcunov@gmail.com, levinsasha928@gmail.com, chaitanyakulkarni15@gmail.com, ashwini.kulkarni@gmail.com Subject: [PATCH v1 2/3] kvm tools: Release memoty allocated during virtio block initialization Date: Wed, 18 May 2011 11:17:16 +0100 Message-Id: <1305713837-18889-2-git-send-email-prasadjoshi124@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1305713837-18889-1-git-send-email-prasadjoshi124@gmail.com> References: <1305713837-18889-1-git-send-email-prasadjoshi124@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 18 May 2011 10:22:31 +0000 (UTC) Add a new function virtio_blk__fini() which goes through array of block devices and releases memory allocated for block device. Signed-off-by: Prasad Joshi --- tools/kvm/include/kvm/virtio-blk.h | 1 + tools/kvm/kvm-run.c | 2 ++ tools/kvm/virtio/blk.c | 9 +++++++++ 3 files changed, 12 insertions(+), 0 deletions(-) diff --git a/tools/kvm/include/kvm/virtio-blk.h b/tools/kvm/include/kvm/virtio-blk.h index 22983e8..61fe404 100644 --- a/tools/kvm/include/kvm/virtio-blk.h +++ b/tools/kvm/include/kvm/virtio-blk.h @@ -6,5 +6,6 @@ struct kvm; void virtio_blk__init(struct kvm *kvm, struct disk_image *disk); +void virtio_blk__fini(struct kvm *kvm); #endif /* KVM__BLK_VIRTIO_H */ diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index ef180e4..1a1eccc 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -585,6 +585,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) exit_code = 1; } + virtio_blk__fini(kvm); + for (i = 0; i < MAX_DISK_IMAGES; i++) { if (image_disks[i]) disk_image__close(image_disks[i]); diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c index 6c9eb19..2e541ef 100644 --- a/tools/kvm/virtio/blk.c +++ b/tools/kvm/virtio/blk.c @@ -262,6 +262,15 @@ static int virtio_blk_find_empty_dev(void) return -1; } + +void virtio_blk__fini(struct kvm *kvm) +{ + int i; + + for (i = 0; i < VIRTIO_BLK_MAX_DEV; i++) + free(bdevs[i]); +} + void virtio_blk__init(struct kvm *kvm, struct disk_image *disk) { u16 blk_dev_base_addr;