vhost-user: support of live migration with multiqueue
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
Thibaut Collet (1):
vhost: set the correct queue index in case of migration with
multiqueue
hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.1.4
PATCH 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 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 queue index is computed by taking account of the vq_index (to retrieve the queue pair index) and calling the vhost_get_vq_index method of the backend.
--- hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/virtio/vhost.c +5 -3
@@ -656,13 +656,14 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log)static int vhost_dev_set_log (struct vhost_dev *dev,bool enable_log) { -int r, t, i; +int r, t, i, idx; r =vhost_dev_set_features (dev, enable_log);if (r <0 ) { goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, enable_log);if (r <0 ) { goto err_vq;
@@ -671,7 +672,8 @@ 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, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, dev->log_enabled);assert (t >=0 ); }
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 1/1] vhost: set the correct queue index in case of migration with multiqueue
Quoted 11 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 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 queue index is computed by taking account of the
vq_index(to retrieve the queue pair index) and calling thevhost_get_vq_indexmethod of the backend.Signed-off-by Thibaut Collet <[email protected]>
This needs some thought to make sure we don't break the kernel vhost.
I queued this temporarily to enable your testing but I think it would be preferable to make vhost_virtqueue_set_addr for vhost_user call vhost_get_vq_index internally.
Quoted 37 lines
--- hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)hw/virtio/vhost.c +5
-3@@ -656,13 +656,14 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log)static int vhost_dev_set_log (struct vhost_dev *dev,bool enable_log) { -int r, t, i; +int r, t, i, idx; r =vhost_dev_set_features (dev, enable_log);if (r <0 ) { goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, enable_log);if (r <0 ) { goto err_vq;@@ -671,7 +672,8 @@ 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, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, dev->log_enabled);assert (t >=0 ); }Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 1/1] vhost: set the correct queue index in case of migration with multiqueue
Quoted 8 lines · Michael S. Tsirkin
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 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 6 lines
Quoted 4 lines
The queue index is computed by taking account of the
vq_index(to retrieve the queue pair index) and calling thevhost_get_vq_indexmethod of the backend.Signed-off-by Thibaut Collet <[email protected]>This needs some thought to make sure we don't break the kernel vhost.
For kernel vhost my patch does nothing has vhost_get_vq_index method for vhost kernel subtract dev->vq_index (that was just added before) and idx is still equal to i.
Quoted 5 lines
I queued this temporarily to enable your testing but I think it would be preferable to make
vhost_virtqueue_set_addrforvhost_usercallvhost_get_vq_indexinternally.
If I call the vhost_get_vq_index internally by vhost_user when vhost_virtqueue_set_addr is called I will break thevhost_virtqueue_start: this function calls the vhost_get_vq_index function for vhost user and vhost kernel to initializes the queue.
Quoted 39 lines
Quoted 39 lines
--- hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)hw/virtio/vhost.c +5
-4@@ -656,13 +656,14 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log)static int vhost_dev_set_log (struct vhost_dev *dev,bool enable_log) { -int r, t, i; +int r, t, i, idx; r =vhost_dev_set_features (dev, enable_log);if (r <0 ) { goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, enable_log);if (r <0 ) { goto err_vq;@@ -671,7 +672,8 @@ 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, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, dev->log_enabled);assert (t >=0 ); } --2.1.4
Re: [Qemu-devel] [PATCH 1/1] vhost: set the correct queue index in case of migration with multiqueue
Quoted 26 lines · Thibaut Collet
Quoted 8 lines · Michael S. Tsirkin
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 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 6 lines
Quoted 4 lines
The queue index is computed by taking account of the
vq_index(to retrieve the queue pair index) and calling thevhost_get_vq_indexmethod of the backend.Signed-off-by Thibaut Collet <[email protected]>This needs some thought to make sure we don't break the kernel vhost.
For kernel vhost my patch does nothing has
vhost_get_vq_indexmethod for vhost kernel subtractdev->vq_index(that was just added before) and idx is still equal to i.Quoted 5 lines
I queued this temporarily to enable your testing but I think it would be preferable to make
vhost_virtqueue_set_addrforvhost_usercallvhost_get_vq_indexinternally.
Quoted 4 lines
If I call the
vhost_get_vq_indexinternally byvhost_userwhenvhost_virtqueue_set_addris called I will break thevhost_virtqueue_start: this function calls thevhost_get_vq_indexfunction for vhost user and vhost kernel to initializes the queue.
So drop vhost_get_vq_index from there as well then?
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
--- hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)hw/virtio/vhost.c +5
-4@@ -656,13 +656,14 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log)static int vhost_dev_set_log (struct vhost_dev *dev,bool enable_log) { -int r, t, i; +int r, t, i, idx; r =vhost_dev_set_features (dev, enable_log);if (r <0 ) { goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, enable_log);if (r <0 ) { goto err_vq;@@ -671,7 +672,8 @@ 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, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, dev->log_enabled);assert (t >=0 ); } --2.1.4
Re: [Qemu-devel] [PATCH 1/1] vhost: set the correct queue index in case of migration with multiqueue
In reply to Thibaut ColletQuoted 11 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 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 queue index is computed by taking account of the
vq_index(to retrieve the queue pair index) and calling thevhost_get_vq_indexmethod of the backend.Signed-off-by Thibaut Collet <[email protected]>
Thanks!
The code in question was added by:
commit a9f98bb5ebe6fb1869321dcc58e72041ae626ad8
Author: Jason Wang <[email protected]>
Date: Wed Jan 30 19:12:35 2013 +0800
vhost: multiqueue support
Jason, could you comment on whether this makes sense please? If yes - this is an old bug, and we need this on stable, do we not?
Maybe we should refactor vhost_virtqueue_set_addr to make it call vhost_get_vq_index internally automatically. All callers do this anyway.
This can be a patch on top.
Quoted 37 lines
--- hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)hw/virtio/vhost.c +5
-3@@ -656,13 +656,14 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log)static int vhost_dev_set_log (struct vhost_dev *dev,bool enable_log) { -int r, t, i; +int r, t, i, idx; r =vhost_dev_set_features (dev, enable_log);if (r <0 ) { goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, enable_log);if (r <0 ) { goto err_vq;@@ -671,7 +672,8 @@ 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, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, dev->log_enabled);assert (t >=0 ); }Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 1/1] vhost: set the correct queue index in case of migration with multiqueue
Quoted 18 lines · Michael S. Tsirkin
Quoted 11 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 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 queue index is computed by taking account of the
vq_index(to retrieve the queue pair index) and calling thevhost_get_vq_indexmethod of the backend.Signed-off-by Thibaut Collet <[email protected]>Thanks!
The code in question was added by:
commita9f98bb5ebe6fb1869321dcc58e72041ae626ad8
Author: Jason Wang <[email protected]>
Date: Wed Jan 30 19:12:35 2013 +0800
Quoted 3 lines
vhost: multiqueue support
Jason, could you comment on whether this makes sense please?
It makes sense.
Quoted 2 lines
If yes - this is an old bug, and we need this on stable, do we not?
But not an old bug, only vhost-user has this issue. So no need for stable.
Quoted 5 lines
Maybe we should refactor
vhost_virtqueue_set_addrto make it callvhost_get_vq_indexinternally automatically. All callers do this anyway.
This can be a patch on top.
Yes, this looks cleaner.
Quoted 38 lines
Quoted 38 lines
--- hw/virtio/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)hw/virtio/vhost.c +5
-3@@ -656,13 +656,14 @@ static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log)static int vhost_dev_set_log (struct vhost_dev *dev,bool enable_log) { -int r, t, i; +int r, t, i, idx; r =vhost_dev_set_features (dev, enable_log);if (r <0 ) { goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { - r =vhost_virtqueue_set_addr (dev, dev->vqs + i, i, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + r =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, enable_log);if (r <0 ) { goto err_vq;@@ -671,7 +672,8 @@ 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, + idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + t =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, dev->log_enabled);assert (t >=0 ); }Signature · 1 line
2.1.4