]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Release memory allocated during virtio block initialization
authorPrasad Joshi <prasadjoshi124@gmail.com>
Sun, 22 May 2011 16:24:07 +0000 (17:24 +0100)
committerPekka Enberg <penberg@kernel.org>
Sun, 22 May 2011 20:06:37 +0000 (23:06 +0300)
Add a new function virtio_blk__delete() goes through array of block
devices and releases memory allocated for block device.

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/virtio-blk.h
tools/kvm/kvm-run.c
tools/kvm/virtio/blk.c

index 72f6491066055e87a76ffbc083ca1129527b7108..8c4fb9199177a35463e9303285e5f32f16be0178 100644 (file)
@@ -7,5 +7,6 @@ struct kvm;
 
 void virtio_blk__init(struct kvm *kvm, struct disk_image *disk);
 void virtio_blk__init_all(struct kvm *kvm);
+void virtio_blk__delete_all(struct kvm *kvm);
 
 #endif /* KVM__BLK_VIRTIO_H */
index eacde818b70bdabeaa80a96311f7b2ffdc6a4757..288e1fbe530a37a9f3af47ff09ea20ab03b4fea9 100644 (file)
@@ -617,6 +617,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
                        exit_code = 1;
        }
 
+       virtio_blk__delete_all(kvm);
+
        disk_image__close_all(kvm->disks, image_count);
        kvm__delete(kvm);
 
index 224e14c433b9fbc3f1cdfc5482d8f1ab52e79032..25ce61f8ef5380f73044cdeb097ebb05dcb9262c 100644 (file)
@@ -328,3 +328,11 @@ void virtio_blk__init_all(struct kvm *kvm)
        for (i = 0; i < kvm->nr_disks; i++)
                virtio_blk__init(kvm, kvm->disks[i]);
 }
+
+void virtio_blk__delete_all(struct kvm *kvm)
+{
+       int i;
+
+       for (i = 0; i < kvm->nr_disks; i++)
+               free(bdevs[i]);
+}