[fedora-virt] [PATCH 5/7] vhost: fix used logging size math
Michael S. Tsirkin
mst at redhat.com
Wed Feb 24 19:09:58 UTC 2010
Must include used header as well, not only ring
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
---
hw/vhost.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/hw/vhost.c b/hw/vhost.c
index 48034ba..7391bd1 100644
--- a/hw/vhost.c
+++ b/hw/vhost.c
@@ -62,7 +62,8 @@ static int vhost_client_sync_dirty_bitmap(struct CPUPhysMemoryClient *client,
}
for (i = 0; i < dev->nvqs; ++i) {
struct vhost_virtqueue *vq = dev->vqs + i;
- unsigned size = sizeof(struct vring_used_elem) * vq->num;
+ unsigned size = offsetof(struct vring_used, ring) +
+ sizeof(struct vring_used_elem) * vq->num;
vhost_dev_sync_region(dev, start_addr, end_addr, vq->used_phys,
range_get_last(vq->used_phys, size));
}
@@ -230,6 +231,7 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev)
for (i = 0; i < dev->nvqs; ++i) {
struct vhost_virtqueue *vq = dev->vqs + i;
uint64_t last = vq->used_phys +
+ offsetof(struct vring_used, ring) +
sizeof(struct vring_used_elem) * vq->num - 1;
log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1);
}
--
1.7.0.18.g0d53a5
More information about the virt
mailing list