diff mbox

kvm tool: add a close method for raw_image_ro_mmap_ops

Message ID 1302716181-13730-1-git-send-email-prasadjoshi124@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Prasad Joshi April 13, 2011, 5:36 p.m. UTC
---
 tools/kvm/disk-image.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/disk-image.c b/tools/kvm/disk-image.c
index c666c04..df7dd48 100644
--- a/tools/kvm/disk-image.c
+++ b/tools/kvm/disk-image.c
@@ -92,6 +92,13 @@  static int raw_image__write_sector_ro_mmap(struct disk_image *self, uint64_t sec
 	return 0;
 }
 
+static void raw_image__close_sector_ro_mmap(struct disk_image *self)
+{
+	if (self->priv != MAP_FAILED)
+		munmap(self->priv, self->size);
+}
+
+
 static struct disk_image_operations raw_image_ops = {
 	.read_sector		= raw_image__read_sector,
 	.write_sector		= raw_image__write_sector,
@@ -100,6 +107,7 @@  static struct disk_image_operations raw_image_ops = {
 static struct disk_image_operations raw_image_ro_mmap_ops = {
 	.read_sector		= raw_image__read_sector_ro_mmap,
 	.write_sector		= raw_image__write_sector_ro_mmap,
+	.close			= raw_image__close_sector_ro_mmap,
 };
 
 static struct disk_image *raw_image__probe(int fd, bool readonly)
@@ -140,9 +148,6 @@  void disk_image__close(struct disk_image *self)
 	if (!self)
 		return;
 
-	if (self->priv != MAP_FAILED)
-		munmap(self->priv, self->size);
-
 	if (self->ops->close)
 		self->ops->close(self);