--- tools/kvm/disk-image.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
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); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html