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

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Prasad Joshi
2015-06-01 16:39:44 +01:00
committed by Will Deacon
parent c1ed214e17
commit 9df47d0069
3 changed files with 10 additions and 0 deletions
+8
View File
@@ -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.
+1
View File
@@ -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);
+1
View File
@@ -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)