[PATCH] kvm tools: Return correct values from disk IOV functions

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

 



Return correct amount of bytes read/written from _iov functions.

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

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 */
-- 
1.7.5.rc3

--
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