diff mbox series

[RFC,25/27] vhost: Do not commit vhost used idx on vhost_virtqueue_stop

Message ID 20201120185105.279030-26-eperezma@redhat.com
State New
Headers show
Series vDPA software assisted live migration | expand

Commit Message

Eugenio Perez Martin Nov. 20, 2020, 6:51 p.m. UTC
... if sw lm is enabled

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 hw/virtio/vhost.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Eugenio Perez Martin Nov. 20, 2020, 7:35 p.m. UTC | #1
On Fri, Nov 20, 2020 at 8:12 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> ... if sw lm is enabled
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>  hw/virtio/vhost.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index cb44b9997f..cf000b979f 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1424,17 +1424,22 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,
>      struct vhost_vring_state state = {
>          .index = vhost_vq_index,
>      };
> -    int r;
> +    int r = -1;
>
>      if (virtio_queue_get_desc_addr(vdev, idx) == 0) {
>          /* Don't stop the virtqueue which might have not been started */
>          return;
>      }
>
> -    r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
> -    if (r < 0) {
> -        VHOST_OPS_DEBUG("vhost VQ %u ring restore failed: %d", idx, r);
> -        /* Connection to the backend is broken, so let's sync internal
> +    if (!dev->sw_lm_enabled) {
> +        r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
> +        if (r < 0) {
> +            VHOST_OPS_DEBUG("vhost VQ %u ring restore failed: %d", idx, r);
> +        }
> +    }
> +
> +    if (!dev->sw_lm_enabled || r < 0) {

This test should actually test for `dev->sw_lm_enabled`, not for negation.

> +        /* Connection to the backend is unusable, so let's sync internal
>           * last avail idx to the device used idx.
>           */
>          virtio_queue_restore_last_avail_idx(vdev, idx);
> --
> 2.18.4
>
diff mbox series

Patch

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index cb44b9997f..cf000b979f 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1424,17 +1424,22 @@  static void vhost_virtqueue_stop(struct vhost_dev *dev,
     struct vhost_vring_state state = {
         .index = vhost_vq_index,
     };
-    int r;
+    int r = -1;
 
     if (virtio_queue_get_desc_addr(vdev, idx) == 0) {
         /* Don't stop the virtqueue which might have not been started */
         return;
     }
 
-    r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
-    if (r < 0) {
-        VHOST_OPS_DEBUG("vhost VQ %u ring restore failed: %d", idx, r);
-        /* Connection to the backend is broken, so let's sync internal
+    if (!dev->sw_lm_enabled) {
+        r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
+        if (r < 0) {
+            VHOST_OPS_DEBUG("vhost VQ %u ring restore failed: %d", idx, r);
+        }
+    }
+
+    if (!dev->sw_lm_enabled || r < 0) {
+        /* Connection to the backend is unusable, so let's sync internal
          * last avail idx to the device used idx.
          */
         virtio_queue_restore_last_avail_idx(vdev, idx);