diff mbox series

[RFC,03/12] vhost_net: Use ops->vhost_restart_queue in vhost_net_virtqueue_restart

Message ID 20230720181459.607008-4-eperezma@redhat.com
State New
Headers show
Series Prefer to use SVQ to stall dataplane at NIC state restore through CVQ | expand

Commit Message

Eugenio Perez Martin July 20, 2023, 6:14 p.m. UTC
Actually use vhost_restart_queue operation at restart.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 hw/net/vhost_net.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Jason Wang July 25, 2023, 7:07 a.m. UTC | #1
在 2023/7/21 02:14, Eugenio Pérez 写道:
> Actually use vhost_restart_queue operation at restart.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>   hw/net/vhost_net.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index 6b958d6363..416b7d8132 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -608,14 +608,16 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
>           goto err_start;
>       }
>   
> -    if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
> +    if (vhost_ops->vhost_restart_queue) {
> +        r = vhost_ops->vhost_restart_queue(&net->dev, idx);
> +    } else if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
>           file.index = idx;
>           file.fd = net->backend;
>           r = vhost_net_set_backend(&net->dev, &file);


I would introduce a vhost-net specific reset routine and move the above 
logic there.

Thanks


> -        if (r < 0) {
> -            r = -errno;
> -            goto err_start;
> -        }
> +    }
> +    if (r < 0) {
> +        r = -errno;
> +        goto err_start;
>       }
>   
>       return 0;
diff mbox series

Patch

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6b958d6363..416b7d8132 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -608,14 +608,16 @@  int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
         goto err_start;
     }
 
-    if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
+    if (vhost_ops->vhost_restart_queue) {
+        r = vhost_ops->vhost_restart_queue(&net->dev, idx);
+    } else if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
         file.index = idx;
         file.fd = net->backend;
         r = vhost_net_set_backend(&net->dev, &file);
-        if (r < 0) {
-            r = -errno;
-            goto err_start;
-        }
+    }
+    if (r < 0) {
+        r = -errno;
+        goto err_start;
     }
 
     return 0;