All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prasad Joshi <prasadjoshi124@gmail.com>
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	[thread overview]
Message-ID: <1305713837-18889-2-git-send-email-prasadjoshi124@gmail.com> (raw)
In-Reply-To: <1305713837-18889-1-git-send-email-prasadjoshi124@gmail.com>

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 <prasadjoshi124@gmail.com>
---
 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;
-- 
1.7.4.1


  reply	other threads:[~2011-05-18 10:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18 10:17 [PATCH v1 1/3] kvm tools: Close the disk images after the guest shuts down Prasad Joshi
2011-05-18 10:17 ` Prasad Joshi [this message]
2011-05-18 10:25   ` [PATCH v1 2/3] kvm tools: Release memoty allocated during virtio block initialization Pekka Enberg
2011-05-18 11:11   ` Ingo Molnar
2011-05-18 10:17 ` [PATCH v1 3/3] kvm tools: Add QCOW level2 caching support Prasad Joshi
2011-05-18 10:27   ` Pekka Enberg
2011-05-18 10:41     ` Prasad Joshi
2011-05-18 11:18       ` Pekka Enberg
2011-05-18 11:10     ` Ingo Molnar
2011-05-18 11:27   ` Sasha Levin
2011-05-18 10:31 ` [PATCH v1 1/3] kvm tools: Close the disk images after the guest shuts down Sasha Levin
2011-05-18 10:36   ` Prasad Joshi
2011-05-18 11:15 ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305713837-18889-2-git-send-email-prasadjoshi124@gmail.com \
    --to=prasadjoshi124@gmail.com \
    --cc=ashwini.kulkarni@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=chaitanyakulkarni15@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.