@@ -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 */
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(-)