From: "Michael S. Tsirkin" <mst@redhat.com>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: qemu-devel@nongnu.org
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 [thread overview]
Message-ID: <20151112132323.GA15596@redhat.com> (raw)
In-Reply-To: <1447248281-15227-3-git-send-email-yuanhan.liu@linux.intel.com>
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.liu@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
next prev parent reply other threads:[~2015-11-12 13:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-11 13:24 [Qemu-devel] [PATCH v4 0/5] handle vhost reset/start/stop correctly Yuanhan Liu
2015-11-11 13:24 ` [Qemu-devel] [PATCH v4 1/5] vhost: rename RESET_DEVICE backto RESET_OWNER Yuanhan Liu
2015-11-11 13:24 ` [Qemu-devel] [PATCH v4 2/5] vhost: reset vhost net when virtio_net_reset happens Yuanhan Liu
2015-11-12 13:23 ` Michael S. Tsirkin [this message]
2015-11-11 13:24 ` [Qemu-devel] [PATCH v4 3/5] vhost: introduce vhost_set/get_protocol_features callbacks Yuanhan Liu
2015-11-11 13:24 ` [Qemu-devel] [PATCH v4 4/5] vhost: send SET_PROTOCOL_FEATURES at start Yuanhan Liu
2015-11-11 13:24 ` [Qemu-devel] [PATCH v4 5/5] vhost: send SET_VRING_ENABLE at start/stop Yuanhan Liu
2015-11-12 13:33 ` [Qemu-devel] [PATCH v4 0/5] handle vhost reset/start/stop correctly Michael S. Tsirkin
2015-11-12 14:08 ` Yuanhan Liu
2015-11-12 14:44 ` Michael S. Tsirkin
2015-11-13 2:03 ` Yuanhan Liu
2015-11-13 10:24 ` Michael S. Tsirkin
2015-11-13 15:42 ` Yuanhan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151112132323.GA15596@redhat.com \
--to=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yuanhan.liu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.