On Wed, Nov 11, 2015 at 09:24:38PM +0800, Yuanhan Liu wrote: > When a virtio net driver is unloaded (unbind), virtio_net_reset happens. > For vhost net, we should also send a message (RESET_OWNER) to the backend > to do some proper reset settings. > > Signed-off-by: Yuanhan Liu <yuanhan....@linux.intel.com>
How about we just skip RESET_OWNER completely? After all, modern clients have VRING_ENABLE. > --- > hw/net/vhost_net.c | 20 ++++++++++++++------ > hw/net/virtio-net.c | 14 ++++++++++++++ > include/net/vhost_net.h | 1 + > 3 files changed, 29 insertions(+), 6 deletions(-) > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c > index d91b7b1..387f851 100644 > --- a/hw/net/vhost_net.c > +++ b/hw/net/vhost_net.c > @@ -292,12 +292,6 @@ static void vhost_net_stop_one(struct vhost_net *net, > int r = vhost_ops->vhost_net_set_backend(&net->dev, &file); > assert(r >= 0); > } > - } else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { > - for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { > - const VhostOps *vhost_ops = net->dev.vhost_ops; > - int r = vhost_ops->vhost_reset_device(&net->dev); > - assert(r >= 0); > - } > } > if (net->nc->info->poll) { > net->nc->info->poll(net->nc, true); > @@ -382,6 +376,16 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState > *ncs, > assert(vhost_net_set_vnet_endian(dev, ncs[0].peer, false) >= 0); > } > > +void vhost_net_reset(VirtIODevice *vdev) > +{ > + VirtIONet *n = VIRTIO_NET(vdev); > + struct vhost_net *net = get_vhost_net(n->nic->ncs[0].peer); > + > + if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { > + net->dev.vhost_ops->vhost_reset_device(&net->dev); > + } > +} > + > void vhost_net_cleanup(struct vhost_net *net) > { > vhost_dev_cleanup(&net->dev); > @@ -469,6 +473,10 @@ void vhost_net_stop(VirtIODevice *dev, > { > } > > +void vhost_net_reset(VirtIODevice *vdev) > +{ > +} > + > void vhost_net_cleanup(struct vhost_net *net) > { > } > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c > index a877614..75472ba 100644 > --- a/hw/net/virtio-net.c > +++ b/hw/net/virtio-net.c > @@ -318,10 +318,24 @@ static RxFilterInfo > *virtio_net_query_rxfilter(NetClientState *nc) > return info; > } > > +static void virtio_net_vhost_reset(VirtIONet *n) > +{ > + VirtIODevice *vdev = VIRTIO_DEVICE(n); > + NetClientState *nc = qemu_get_queue(n->nic); > + > + if (!get_vhost_net(nc->peer)) { > + return; > + } > + > + vhost_net_reset(vdev); > +} > + > static void virtio_net_reset(VirtIODevice *vdev) > { > VirtIONet *n = VIRTIO_NET(vdev); > > + virtio_net_vhost_reset(n); > + > /* Reset back to compatibility mode */ > n->promisc = 1; > n->allmulti = 0; > diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h > index 3389b41..d1c1331 100644 > --- a/include/net/vhost_net.h > +++ b/include/net/vhost_net.h > @@ -18,6 +18,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options); > > int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int > total_queues); > void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, int > total_queues); > +void vhost_net_reset(VirtIODevice *dev); > > void vhost_net_cleanup(VHostNetState *net); > > -- > 1.9.0