From: Jason Wang <jasowang@redhat.com>
To: yuri.benditovich@daynix.com,
"Michael S . Tsirkin" <mst@redhat.com>,
qemu-devel@nongnu.org
Cc: dmitry@daynix.com, yan@daynix.com
Subject: Re: [Qemu-devel] [PATCH 3/3] net: virtio-net discards TX data after link down
Date: Tue, 8 Nov 2016 14:48:34 +0800 [thread overview]
Message-ID: <ad106db6-c028-ded3-a854-25e1b8ed15ed@redhat.com> (raw)
In-Reply-To: <1478506829-9208-4-git-send-email-yuri.benditovich@daynix.com>
On 2016年11月07日 16:20, yuri.benditovich@daynix.com wrote:
> From: Yuri Benditovich <yuri.benditovich@daynix.com>
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1295637
> Upon set_link monitor command or upon netdev deletion
> virtio-net sends link down indication to the guest
> and stops vhost if one is used.
> Guest driver can still submit data for TX until it
> recognizes link loss. If these packets not returned by
> the host, the Windows guest will never be able to finish
> disable/removal/shutdown.
> Now each packet sent by guest after NIC indicated link
> down will be completed immediately.
>
> Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
> ---
> hw/net/virtio-net.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 06bfe4b..6158de0 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -1200,6 +1200,16 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t
> return size;
> }
>
> +static void virtio_net_drop_tx_queue_data(VirtIODevice *vdev, VirtQueue *vq)
> +{
> + VirtQueueElement *elem;
> + while ((elem = virtqueue_pop(vq, sizeof(VirtQueueElement)))) {
> + virtqueue_push(vq, elem, 0);
> + virtio_notify(vdev, vq);
> + g_free(elem);
> + }
> +}
> +
> static int32_t virtio_net_flush_tx(VirtIONetQueue *q);
>
> static void virtio_net_tx_complete(NetClientState *nc, ssize_t len)
> @@ -1345,6 +1355,11 @@ static void virtio_net_handle_tx_bh(VirtIODevice *vdev, VirtQueue *vq)
> VirtIONet *n = VIRTIO_NET(vdev);
> VirtIONetQueue *q = &n->vqs[vq2q(virtio_get_queue_index(vq))];
>
> + if (unlikely((n->status & VIRTIO_NET_S_LINK_UP) == 0)) {
> + virtio_net_drop_tx_queue_data(vdev, vq);
> + return;
> + }
> +
> if (unlikely(q->tx_waiting)) {
> return;
> }
This doesn't work for tx timer, you may want to do the modification on
virtio_net_flush_tx().
What's more, when link_down is true, qemu_send_packet_async() will
return size of iov, can we do some check there?
Thanks
next prev parent reply other threads:[~2016-11-08 6:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 8:20 [Qemu-devel] [PATCH 0/3] virtio-net discards TX data after link down yuri.benditovich
2016-11-07 8:20 ` [Qemu-devel] [PATCH 1/3] net: Add virtio queue interface to update used index from vring state yuri.benditovich
2016-11-07 8:20 ` [Qemu-devel] [PATCH 2/3] net: vhost stop updates virtio queue state yuri.benditovich
2016-11-07 8:20 ` [Qemu-devel] [PATCH 3/3] net: virtio-net discards TX data after link down yuri.benditovich
2016-11-08 6:48 ` Jason Wang [this message]
2016-11-08 8:26 ` Yuri Benditovich
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=ad106db6-c028-ded3-a854-25e1b8ed15ed@redhat.com \
--to=jasowang@redhat.com \
--cc=dmitry@daynix.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yan@daynix.com \
--cc=yuri.benditovich@daynix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).