|
|
5544c1 |
From 7d797af90c5293b518a072da9b23ec14a1a917f7 Mon Sep 17 00:00:00 2001
|
|
|
5544c1 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
5544c1 |
Date: Thu, 9 Aug 2012 16:45:55 +0200
|
|
|
5544c1 |
Subject: [PATCH] net: notify iothread after flushing queue
|
|
|
5544c1 |
|
|
|
5544c1 |
virtio-net has code to flush the queue and notify the iothread
|
|
|
5544c1 |
whenever new receive buffers are added by the guest. That is
|
|
|
5544c1 |
fine, and indeed we need to do the same in all other drivers.
|
|
|
5544c1 |
However, notifying the iothread should be work for the network
|
|
|
5544c1 |
subsystem. And since we are at it we can add a little smartness:
|
|
|
5544c1 |
if some of the queued packets already could not be delivered,
|
|
|
5544c1 |
there is no need to notify the iothread.
|
|
|
5544c1 |
|
|
|
5544c1 |
Reported-by: Luigi Rizzo <rizzo@iet.unipi.it>
|
|
|
5544c1 |
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
|
|
|
5544c1 |
Cc: Jan Kiszka <jan.kiszka@siemens.de>
|
|
|
5544c1 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
5544c1 |
Reviewed-by: Amos Kong <akong@redhat.com>
|
|
|
5544c1 |
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
|
|
|
5544c1 |
(cherry picked from commit 987a9b4800003567b1a47a379255e886a77d57ea)
|
|
|
5544c1 |
|
|
|
5544c1 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
5544c1 |
---
|
|
|
5544c1 |
hw/virtio-net.c | 4 ----
|
|
|
5544c1 |
net.c | 7 ++++++-
|
|
|
5544c1 |
net/queue.c | 5 +++--
|
|
|
5544c1 |
net/queue.h | 2 +-
|
|
|
5544c1 |
4 files changed, 10 insertions(+), 8 deletions(-)
|
|
|
5544c1 |
|
|
|
5544c1 |
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
|
|
|
5544c1 |
index b1998b2..6490743 100644
|
|
|
5544c1 |
--- a/hw/virtio-net.c
|
|
|
5544c1 |
+++ b/hw/virtio-net.c
|
|
|
5544c1 |
@@ -447,10 +447,6 @@ static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
|
|
|
5544c1 |
VirtIONet *n = to_virtio_net(vdev);
|
|
|
5544c1 |
|
|
|
5544c1 |
qemu_flush_queued_packets(&n->nic->nc);
|
|
|
5544c1 |
-
|
|
|
5544c1 |
- /* We now have RX buffers, signal to the IO thread to break out of the
|
|
|
5544c1 |
- * select to re-poll the tap file descriptor */
|
|
|
5544c1 |
- qemu_notify_event();
|
|
|
5544c1 |
}
|
|
|
5544c1 |
|
|
|
5544c1 |
static int virtio_net_can_receive(NetClientState *nc)
|
|
|
5544c1 |
diff --git a/net.c b/net.c
|
|
|
5544c1 |
index 60043dd..76a8336 100644
|
|
|
5544c1 |
--- a/net.c
|
|
|
5544c1 |
+++ b/net.c
|
|
|
5544c1 |
@@ -357,7 +357,12 @@ void qemu_flush_queued_packets(NetClientState *nc)
|
|
|
5544c1 |
{
|
|
|
5544c1 |
nc->receive_disabled = 0;
|
|
|
5544c1 |
|
|
|
5544c1 |
- qemu_net_queue_flush(nc->send_queue);
|
|
|
5544c1 |
+ if (qemu_net_queue_flush(nc->send_queue)) {
|
|
|
5544c1 |
+ /* We emptied the queue successfully, signal to the IO thread to repoll
|
|
|
5544c1 |
+ * the file descriptor (for tap, for example).
|
|
|
5544c1 |
+ */
|
|
|
5544c1 |
+ qemu_notify_event();
|
|
|
5544c1 |
+ }
|
|
|
5544c1 |
}
|
|
|
5544c1 |
|
|
|
5544c1 |
static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
|
|
|
5544c1 |
diff --git a/net/queue.c b/net/queue.c
|
|
|
5544c1 |
index e8030aa..6e64091 100644
|
|
|
5544c1 |
--- a/net/queue.c
|
|
|
5544c1 |
+++ b/net/queue.c
|
|
|
5544c1 |
@@ -228,7 +228,7 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState *from)
|
|
|
5544c1 |
}
|
|
|
5544c1 |
}
|
|
|
5544c1 |
|
|
|
5544c1 |
-void qemu_net_queue_flush(NetQueue *queue)
|
|
|
5544c1 |
+bool qemu_net_queue_flush(NetQueue *queue)
|
|
|
5544c1 |
{
|
|
|
5544c1 |
while (!QTAILQ_EMPTY(&queue->packets)) {
|
|
|
5544c1 |
NetPacket *packet;
|
|
|
5544c1 |
@@ -244,7 +244,7 @@ void qemu_net_queue_flush(NetQueue *queue)
|
|
|
5544c1 |
packet->size);
|
|
|
5544c1 |
if (ret == 0) {
|
|
|
5544c1 |
QTAILQ_INSERT_HEAD(&queue->packets, packet, entry);
|
|
|
5544c1 |
- break;
|
|
|
5544c1 |
+ return false;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
|
|
|
5544c1 |
if (packet->sent_cb) {
|
|
|
5544c1 |
@@ -253,4 +253,5 @@ void qemu_net_queue_flush(NetQueue *queue)
|
|
|
5544c1 |
|
|
|
5544c1 |
g_free(packet);
|
|
|
5544c1 |
}
|
|
|
5544c1 |
+ return true;
|
|
|
5544c1 |
}
|
|
|
5544c1 |
diff --git a/net/queue.h b/net/queue.h
|
|
|
5544c1 |
index 9d44a9b..fc02b33 100644
|
|
|
5544c1 |
--- a/net/queue.h
|
|
|
5544c1 |
+++ b/net/queue.h
|
|
|
5544c1 |
@@ -53,6 +53,6 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
|
|
|
5544c1 |
NetPacketSent *sent_cb);
|
|
|
5544c1 |
|
|
|
5544c1 |
void qemu_net_queue_purge(NetQueue *queue, NetClientState *from);
|
|
|
5544c1 |
-void qemu_net_queue_flush(NetQueue *queue);
|
|
|
5544c1 |
+bool qemu_net_queue_flush(NetQueue *queue);
|
|
|
5544c1 |
|
|
|
5544c1 |
#endif /* QEMU_NET_QUEUE_H */
|
|
|
5544c1 |
--
|
|
|
5544c1 |
1.7.12.1
|
|
|
5544c1 |
|