[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 2/5] vhost: reset vhost net when virtio_net_r
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH v4 2/5] vhost: reset vhost net when virtio_net_reset happens |
Date: |
Thu, 12 Nov 2015 15:23:23 +0200 |
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 <address@hidden>
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
- [Qemu-devel] [PATCH v4 0/5] handle vhost reset/start/stop correctly, Yuanhan Liu, 2015/11/11
- [Qemu-devel] [PATCH v4 3/5] vhost: introduce vhost_set/get_protocol_features callbacks, Yuanhan Liu, 2015/11/11
- [Qemu-devel] [PATCH v4 2/5] vhost: reset vhost net when virtio_net_reset happens, Yuanhan Liu, 2015/11/11
- Re: [Qemu-devel] [PATCH v4 2/5] vhost: reset vhost net when virtio_net_reset happens,
Michael S. Tsirkin <=
- [Qemu-devel] [PATCH v4 1/5] vhost: rename RESET_DEVICE backto RESET_OWNER, Yuanhan Liu, 2015/11/11
- [Qemu-devel] [PATCH v4 4/5] vhost: send SET_PROTOCOL_FEATURES at start, Yuanhan Liu, 2015/11/11
- [Qemu-devel] [PATCH v4 5/5] vhost: send SET_VRING_ENABLE at start/stop, Yuanhan Liu, 2015/11/11
- Re: [Qemu-devel] [PATCH v4 0/5] handle vhost reset/start/stop correctly, Michael S. Tsirkin, 2015/11/12