[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 28/41] net: virtio-net discards TX data after link do
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 28/41] net: virtio-net discards TX data after link down |
Date: |
Tue, 10 Jan 2017 07:40:30 +0200 |
From: Yuri Benditovich <address@hidden>
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 <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/net/virtio-net.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5009533..6f98eab 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -218,6 +218,14 @@ static void virtio_net_vnet_endian_status(VirtIONet *n,
uint8_t status)
}
}
+static void virtio_net_drop_tx_queue_data(VirtIODevice *vdev, VirtQueue *vq)
+{
+ unsigned int dropped = virtqueue_drop_all(vq);
+ if (dropped) {
+ virtio_notify(vdev, vq);
+ }
+}
+
static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status)
{
VirtIONet *n = VIRTIO_NET(vdev);
@@ -262,6 +270,14 @@ static void virtio_net_set_status(struct VirtIODevice
*vdev, uint8_t status)
} else {
qemu_bh_cancel(q->tx_bh);
}
+ if ((n->status & VIRTIO_NET_S_LINK_UP) == 0 &&
+ (queue_status & VIRTIO_CONFIG_S_DRIVER_OK)) {
+ /* if tx is waiting we are likely have some packets in tx queue
+ * and disabled notification */
+ q->tx_waiting = 0;
+ virtio_queue_set_notification(q->tx_vq, 1);
+ virtio_net_drop_tx_queue_data(vdev, q->tx_vq);
+ }
}
}
}
@@ -1323,6 +1339,11 @@ static void virtio_net_handle_tx_timer(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;
+ }
+
/* This happens when device was stopped but VCPU wasn't. */
if (!vdev->vm_running) {
q->tx_waiting = 1;
@@ -1349,6 +1370,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;
}
--
MST
- [Qemu-devel] [PULL 18/41] virtio-crypto: avoid one cryptodev device is used by multiple virtio crypto devices, (continued)
- [Qemu-devel] [PULL 18/41] virtio-crypto: avoid one cryptodev device is used by multiple virtio crypto devices, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 19/41] virtio-crypto-pci: tag virtio-crypto device hot pluggable, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 20/41] virtio-crypto: zeroize the key material before free, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 21/41] pcie_aer: Convert pcie_aer_init to Error, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 23/41] virtio: fix vq->inuse recalc after migr, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 22/41] pcie_aer: support configurable AER capa version, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 24/41] balloon: Don't balloon roms, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 25/41] net: Add virtio queue interface to update used index from vring state, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 27/41] virtio: Introduce virtqueue_drop_all procedure, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 26/41] net: vhost stop updates virtio queue state, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 28/41] net: virtio-net discards TX data after link down,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 29/41] vhost-user: Add MTU protocol feature and op, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 30/41] vhost-net: Notify the backend about the host MTU, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 31/41] virtio-net: Add MTU feature support, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 32/41] tests: pc: add memory hotplug acpi tables tests, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 34/41] memhp: move build_memory_devices() into memory_hotplug.c, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 35/41] memhp: consolidate scattered MHPD device declaration, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 33/41] memhp: move build_memory_hotplug_aml() into memory_hotplug.c, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 36/41] memhp: merge build_memory_devices() into build_memory_hotplug_aml(), Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 38/41] memhp: move memory hotplug only defines to memory_hotplug.c, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 37/41] memhp: move GPE handler_E03 into build_memory_hotplug_aml(), Michael S. Tsirkin, 2017/01/10