[PATCH 09/14] kvm tools: Rename struct disk_image_operations ops name for raw image

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

 



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@xxxxxxxxx>
---
 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(-)

diff --git a/tools/kvm/disk/blk.c b/tools/kvm/disk/blk.c
index ece4d2a..7383967 100644
--- a/tools/kvm/disk/blk.c
+++ b/tools/kvm/disk/blk.c
@@ -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);
 }
diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c
index 956775e..dd11ed97 100644
--- a/tools/kvm/disk/qcow.c
+++ b/tools/kvm/disk/qcow.c
@@ -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)
diff --git a/tools/kvm/disk/raw.c b/tools/kvm/disk/raw.c
index b58837b..7f3f8db 100644
--- a/tools/kvm/disk/raw.c
+++ b/tools/kvm/disk/raw.c
@@ -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);
 }
diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h
index 6531a93..82884fb 100644
--- a/tools/kvm/include/kvm/disk-image.h
+++ b/tools/kvm/include/kvm/disk-image.h
@@ -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 */
-- 
1.7.5.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux