@@ -3,10 +3,10 @@
/*
* raw image and blk dev are similar, so reuse 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_ro_mmap,
+static struct disk_image_operations raw_image_ops = {
+ .read_sector = raw_image__read_sector,
+ .write_sector = raw_image__write_sector,
+ .close = raw_image__close,
};
struct disk_image *blkdev__probe(const char *filename, struct stat *st)
@@ -26,5 +26,5 @@ struct disk_image *blkdev__probe(const char *filename, struct stat *st)
return NULL;
}
- return disk_image__new(fd, size, &raw_image_ro_mmap_ops, DISK_IMAGE_MMAP);
+ return disk_image__new(fd, size, &raw_image_ops, DISK_IMAGE_MMAP);
}
@@ -351,7 +351,7 @@ static struct disk_image_operations qcow1_disk_readonly_ops = {
static struct disk_image_operations qcow1_disk_ops = {
.read_sector = qcow1_read_sector,
.write_sector = qcow1_write_sector,
- .close = qcow1_disk_close
+ .close = qcow1_disk_close,
};
static int qcow_read_l1_table(struct qcow *q)
@@ -14,7 +14,7 @@ ssize_t raw_image__write_sector_iov(struct disk_image *disk, u64 sector, const s
return pwritev_in_full(disk->fd, iov, iovcount, offset);
}
-ssize_t raw_image__read_sector_ro_mmap(struct disk_image *disk, u64 sector, void *dst, u32 dst_len)
+ssize_t raw_image__read_sector(struct disk_image *disk, u64 sector, void *dst, u32 dst_len)
{
u64 offset = sector << SECTOR_SHIFT;
@@ -26,7 +26,7 @@ ssize_t raw_image__read_sector_ro_mmap(struct disk_image *disk, u64 sector, void
return dst_len;
}
-ssize_t raw_image__write_sector_ro_mmap(struct disk_image *disk, u64 sector, void *src, u32 src_len)
+ssize_t raw_image__write_sector(struct disk_image *disk, u64 sector, void *src, u32 src_len)
{
u64 offset = sector << SECTOR_SHIFT;
@@ -38,7 +38,7 @@ ssize_t raw_image__write_sector_ro_mmap(struct disk_image *disk, u64 sector, voi
return src_len;
}
-int raw_image__close_ro_mmap(struct disk_image *disk)
+int raw_image__close(struct disk_image *disk)
{
int ret = 0;
@@ -48,15 +48,21 @@ int raw_image__close_ro_mmap(struct disk_image *disk)
return ret;
}
-static struct disk_image_operations raw_image_ops = {
+/*
+ * multiple buffer based disk image operations
+ */
+static struct disk_image_operations raw_image_iov_ops = {
.read_sector_iov = raw_image__read_sector_iov,
.write_sector_iov = raw_image__write_sector_iov,
};
-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_ro_mmap,
+/*
+ * single buffer based disk image operations
+ */
+static struct disk_image_operations raw_image_ops = {
+ .read_sector = raw_image__read_sector,
+ .write_sector = raw_image__write_sector,
+ .close = raw_image__close,
};
struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonly)
@@ -67,10 +73,10 @@ struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonly)
* Use mmap's MAP_PRIVATE to implement non-persistent write
* FIXME: This does not work on 32-bit host.
*/
- return disk_image__new(fd, st->st_size, &raw_image_ro_mmap_ops, DISK_IMAGE_MMAP);
+ return disk_image__new(fd, st->st_size, &raw_image_ops, DISK_IMAGE_MMAP);
else
/*
* Use read/write instead of mmap
*/
- return disk_image__new(fd, st->st_size, &raw_image_ops, DISK_IMAGE_NOMMAP);
+ return disk_image__new(fd, st->st_size, &raw_image_iov_ops, DISK_IMAGE_NOMMAP);
}
@@ -69,8 +69,8 @@ struct disk_image *blkdev__probe(const char *filename, struct stat *st);
ssize_t raw_image__read_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
ssize_t raw_image__write_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount);
-ssize_t raw_image__read_sector_ro_mmap(struct disk_image *disk, u64 sector, void *dst, u32 dst_len);
-ssize_t raw_image__write_sector_ro_mmap(struct disk_image *disk, u64 sector, void *src, u32 src_len);
-int raw_image__close_ro_mmap(struct disk_image *disk);
+ssize_t raw_image__read_sector(struct disk_image *disk, u64 sector, void *dst, u32 dst_len);
+ssize_t raw_image__write_sector(struct disk_image *disk, u64 sector, void *src, u32 src_len);
+int raw_image__close(struct disk_image *disk);
#endif /* KVM__DISK_IMAGE_H */
This patch renames: raw_image__read_sector_ro_mmap to raw_image__read_sector raw_image__write_sector_ro_mmap to raw_image__write_sector raw_image__close_ro_mmap to raw_image__close Signed-off-by: Asias He <asias.hejun@gmail.com> --- tools/kvm/disk/blk.c | 10 +++++----- tools/kvm/disk/qcow.c | 2 +- tools/kvm/disk/raw.c | 26 ++++++++++++++++---------- tools/kvm/include/kvm/disk-image.h | 6 +++--- 4 files changed, 25 insertions(+), 19 deletions(-)