diff mbox

[v1,2/3] kvm tools: Release memoty allocated during virtio block initialization

Message ID 1305713837-18889-2-git-send-email-prasadjoshi124@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Prasad Joshi May 18, 2011, 10:17 a.m. 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 <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(-)

Comments

Pekka Enberg May 18, 2011, 10:25 a.m. UTC | #1
On Wed, May 18, 2011 at 1:17 PM, Prasad Joshi <prasadjoshi124@gmail.com> wrote:
> 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>
> @@ -6,5 +6,6 @@
>  struct kvm;
>
>  void virtio_blk__init(struct kvm *kvm, struct disk_image *disk);
> +void virtio_blk__fini(struct kvm *kvm);

Please make that virtio_blk__delete() to follow the established convention.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ingo Molnar May 18, 2011, 11:11 a.m. UTC | #2
FYI, since you are re-running this series anyway, there's a typo in the patch 
title.

Thanks,

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;