vhost-user: support of live migration with multiqueue
v2 cover vhost-user: support of live migration with multiqueue
Patches serie for vhost-user live migration from Marc-Andre Lureau [PATCH v8 00/27] vhost-user: add migration support
(http://lists.nongnu.org/archive/html/qemu-devel/2015-10/msg02452.html) does not work if multiqueue is set.
This patch correct an issue of queue index when a migration is started with multiqueue
v1->v2:
- call vhost_get_vq_index internally in vhost_virtqueue_set_addr
Thibaut Collet (1):
vhost: set the correct queue index in case of migration with
multiqueue
hw/virtio/vhost.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/1 vhost: set the correct queue index in case of migration with multiqueue
When a live migration is started the log address to mark dirty pages is provided to the vhost backend through the vhost_dev_set_log function.
This function is called for each queue pairs but the queue index provided to the vhost_virtqueue_set_addr function is wrongly set: always set to the first queue pair. Then vhost backend lost descriptor addresses of the queue pairs greater than 1 and behaviour of the vhost backend is unpredictable.
The vhost_dev_set_log is modified to provide the correct queue index to the vhost_virtqueue_set_addr function that calls internally the vhost_get_vq_index to compute the expected vhost_vq_index for vhost kernel and vhost user. This change implies a modification of the vhost_virtqueue_start function to provide the index and not the vhost_vq_index.
--- hw/virtio/vhost.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/virtio/vhost.c +5 -4
@@ -628,8 +628,9 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev,struct vhost_virtqueue *vq, unsigned idx, bool enable_log) { + int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_addr addr = { - .index = idx, + .index = vhost_vq_index, .desc_user_addr = (uint64_t)(unsigned long)vq->desc, .avail_user_addr = (uint64_t)(unsigned long)vq->avail, .used_user_addr = (uint64_t)(unsigned long)vq->used,
@@ -662,7 +663,7 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, dev->vq_index + i, enable_log);if (r <0 ) { goto err_vq;
@@ -671,7 +672,7 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log)return 0 ; err_vq:for (; i >=0 ; --i) { - t =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, dev->vq_index + i, dev->log_enabled);assert (t >=0 ); }
@@ -836,7 +837,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, goto fail_alloc_ring; } - r =vhost_virtqueue_set_addr (dev, vq, vhost_vq_index, dev->log_enabled); + r =vhost_virtqueue_set_addr (dev, vq, idx, dev->log_enabled);if (r <0 ) { r = -errno; goto fail_alloc;
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH v2 1/1] vhost: set the correct queue index in case of migration with multiqueue
Quoted 7 lines · Thibaut Collet
When a live migration is started the log address to mark dirty pages is provided to the vhost backend through the
vhost_dev_set_logfunction.
This function is called for each queue pairs but the queue index provided to thevhost_virtqueue_set_addrfunction is wrongly set: always set to the first queue pair. Then vhost backend lost descriptor addresses of the queue pairs greater than 1 and behaviour of the vhost backend is unpredictable.
Quoted 7 lines
The
vhost_dev_set_logis modified to provide the correct queue index to thevhost_virtqueue_set_addrfunction that calls internally thevhost_get_vq_indexto compute the expectedvhost_vq_indexfor vhost kernel and vhost user. This change implies a modification of thevhost_virtqueue_startfunction to provide the index and not thevhost_vq_index.Signed-off-by Thibaut Collet <[email protected]>
I applied v1 already, please post a patch on top.
Quoted 48 lines
--- hw/virtio/vhost.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)hw/virtio/vhost.c +5
-4@@ -628,8 +628,9 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev,struct vhost_virtqueue *vq, unsigned idx, bool enable_log) { + int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_addr addr = { - .index = idx, + .index = vhost_vq_index, .desc_user_addr = (uint64_t)(unsigned long)vq->desc, .avail_user_addr = (uint64_t)(unsigned long)vq->avail, .used_user_addr = (uint64_t)(unsigned long)vq->used,@@ -662,7 +663,7 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, dev->vq_index + i, enable_log);if (r <0 ) { goto err_vq;@@ -671,7 +672,7 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log)return 0 ; err_vq:for (; i >=0 ; --i) { - t =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, dev->vq_index + i, dev->log_enabled);assert (t >=0 ); }@@ -836,7 +837,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, goto fail_alloc_ring; } - r =vhost_virtqueue_set_addr (dev, vq, vhost_vq_index, dev->log_enabled); + r =vhost_virtqueue_set_addr (dev, vq, idx, dev->log_enabled);if (r <0 ) { r = -errno; goto fail_alloc;Signature · 1 line
2.1.4