]> Git Repo - qemu.git/commitdiff
vhost-net: save & restore vring enable state
authorMarc-André Lureau <[email protected]>
Mon, 6 Jun 2016 16:45:06 +0000 (18:45 +0200)
committerMichael S. Tsirkin <[email protected]>
Fri, 17 Jun 2016 00:28:03 +0000 (03:28 +0300)
A driver may change the vring enable state at run time but vhost-user
backend may not be present (a contrived example is when the backend is
disconnected and the device is reconfigured after driver rebinding)

Restore the vring state when the vhost-user backend is started, so it
can process the ring.

Signed-off-by: Marc-André Lureau <[email protected]>
Tested-by: Yuanhan Liu <[email protected]>
Reviewed-by: Yuanhan Liu <[email protected]>
Reviewed-by: Victor Kaplansky <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
hw/net/vhost_net.c
include/net/net.h

index b28881ffe36a6c2ab9f031b87d0d62db3d847a9b..50f4dcd655279c8e59acfe5e48c7cebca850ef9d 100644 (file)
@@ -329,6 +329,15 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         if (r < 0) {
             goto err_start;
         }
+
+        if (ncs[i].peer->vring_enable) {
+            /* restore vring enable state */
+            r = vhost_set_vring_enable(ncs[i].peer, ncs[i].peer->vring_enable);
+
+            if (r < 0) {
+                goto err_start;
+            }
+        }
     }
 
     return 0;
@@ -422,6 +431,8 @@ int vhost_set_vring_enable(NetClientState *nc, int enable)
     VHostNetState *net = get_vhost_net(nc);
     const VhostOps *vhost_ops;
 
+    nc->vring_enable = enable;
+
     if (!net) {
         return 0;
     }
index a69e382ba7b8dbbf6e1102edbf0d67ff96760111..a5c50951548a7ef64a18e6df07acd57b067a537c 100644 (file)
@@ -99,6 +99,7 @@ struct NetClientState {
     NetClientDestructor *destructor;
     unsigned int queue_index;
     unsigned rxfilter_notify_enabled:1;
+    int vring_enable;
     QTAILQ_HEAD(NetFilterHead, NetFilterState) filters;
 };
 
This page took 0.0315 seconds and 4 git commands to generate.