[tip:tools/kvm] kvm tools: Close the disk images after the guest shuts down

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  e5e4c92e400a634b8e7bbdd1c8ec2ccb26f2b961
Gitweb:     http://git.kernel.org/tip/e5e4c92e400a634b8e7bbdd1c8ec2ccb26f2b961
Author:     Prasad Joshi <prasadjoshi124@xxxxxxxxx>
AuthorDate: Sun, 22 May 2011 17:24:05 +0100
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Sun, 22 May 2011 23:06:31 +0300

kvm tools: Close the disk images after the guest shuts down

Signed-off-by: Prasad Joshi <prasadjoshi124@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/disk/core.c              |    8 ++++++++
 tools/kvm/include/kvm/disk-image.h |    1 +
 tools/kvm/kvm-run.c                |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c
index 37ae5c9..f2b482a 100644
--- a/tools/kvm/disk/core.c
+++ b/tools/kvm/disk/core.c
@@ -115,6 +115,14 @@ int disk_image__close(struct disk_image *disk)
 	return 0;
 }
 
+void disk_image__close_all(struct disk_image **disks, int count)
+{
+	while (count)
+		disk_image__close(disks[--count]);
+
+	free(disks);
+}
+
 /*
  * Fill iov with disk data, starting from sector 'sector'.
  * Return amount of bytes read.
diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h
index bf2bfa9..1363fe1 100644
--- a/tools/kvm/include/kvm/disk-image.h
+++ b/tools/kvm/include/kvm/disk-image.h
@@ -55,6 +55,7 @@ struct disk_image *disk_image__open(const char *filename, bool readonly);
 struct disk_image **disk_image__open_all(const char **filenames, bool *readonly, int count);
 struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops, int mmap);
 int disk_image__close(struct disk_image *disk);
+void disk_image__close_all(struct disk_image **disks, int count);
 int disk_image__flush(struct disk_image *disk);
 ssize_t disk_image__read(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
 ssize_t disk_image__write(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
index bd7691f..8cd003b 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -617,6 +617,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 			exit_code = 1;
 	}
 
+	disk_image__close_all(kvm->disks, image_count);
 	kvm__delete(kvm);
 
 	if (!exit_code)
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux