diff mbox

kvm tools: Return correct values from disk IOV functions

Message ID 1305390882-18747-1-git-send-email-levinsasha928@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sasha Levin May 14, 2011, 4:34 p.m. UTC
Return correct amount of bytes read/written from _iov functions.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/include/kvm/disk-image.h |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h
index 9d7b572..195270f 100644
--- a/tools/kvm/include/kvm/disk-image.h
+++ b/tools/kvm/include/kvm/disk-image.h
@@ -42,6 +42,8 @@  static inline int disk_image__write_sector(struct disk_image *disk, u64 sector,
 
 static inline ssize_t disk_image__read_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount)
 {
+	u64 first_sector = sector;
+
 	if (disk->ops->read_sector_iov)
 		return disk->ops->read_sector_iov(disk, sector, iov, iovcount);
 
@@ -53,11 +55,13 @@  static inline ssize_t disk_image__read_sector_iov(struct disk_image *disk, u64 s
 		iov++;
 	}
 
-	return sector << SECTOR_SHIFT;
+	return (sector - first_sector) << SECTOR_SHIFT;
 }
 
 static inline ssize_t disk_image__write_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount)
 {
+	u64 first_sector = sector;
+
 	if (disk->ops->write_sector_iov)
 		return disk->ops->write_sector_iov(disk, sector, iov, iovcount);
 
@@ -69,7 +73,7 @@  static inline ssize_t disk_image__write_sector_iov(struct disk_image *disk, u64
 		iov++;
 	}
 
-	return sector << SECTOR_SHIFT;
+	return (sector - first_sector) << SECTOR_SHIFT;
 }
 
 #endif /* KVM__DISK_IMAGE_H */