aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-09-09 12:08:52 +0300
committerAvi Kivity <avi@redhat.com>2009-09-09 12:08:52 +0300
commitea571d06d8e39187663f255d62b886bf01371667 (patch)
tree2662790614ecc0e6bdc9541aa2550388f9a7e34e /net.c
parentMerge commit 'fd83e9b9dc7adac8244c613e0a51baa4610bb46d' into upstream-merge (diff)
parentSupport for multiple -monitor devices (diff)
downloadqemu-kvm-ea571d06d8e39187663f255d62b886bf01371667.tar.gz
qemu-kvm-ea571d06d8e39187663f255d62b886bf01371667.tar.bz2
qemu-kvm-ea571d06d8e39187663f255d62b886bf01371667.zip
Merge commit 'ddd9bbd93bb2c12ade72dff1790d6d292aac073f' into upstream-merge
* commit 'ddd9bbd93bb2c12ade72dff1790d6d292aac073f': Support for multiple -monitor devices net: Fix send queue ordering do not issue ioctl from within the io thread Delay sighandler_setup() Remove typedef for bool from eepro100.c add documentation for multi-core features piix3: use new vmstate infrastructure i440fx: use new vmstate infrastructure VMState: Fix sub-structs versioning Update SaveVM versions pci_irq_levels[] belong to PIIX3State Save irq_state into PCII440FXState Conflicts: vl.c Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'net.c')
-rw-r--r--net.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/net.c b/net.c
index e414b349c..4ccf1387e 100644
--- a/net.c
+++ b/net.c
@@ -441,34 +441,29 @@ qemu_deliver_packet(VLANClientState *sender, const uint8_t *buf, int size, int r
void qemu_purge_queued_packets(VLANClientState *vc)
{
- VLANPacket **pp = &vc->vlan->send_queue;
-
- while (*pp != NULL) {
- VLANPacket *packet = *pp;
+ VLANPacket *packet, *next;
+ TAILQ_FOREACH_SAFE(packet, &vc->vlan->send_queue, entry, next) {
if (packet->sender == vc) {
- *pp = packet->next;
+ TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry);
qemu_free(packet);
- } else {
- pp = &packet->next;
}
}
}
void qemu_flush_queued_packets(VLANClientState *vc)
{
- VLANPacket *packet;
-
- while ((packet = vc->vlan->send_queue) != NULL) {
+ while (!TAILQ_EMPTY(&vc->vlan->send_queue)) {
+ VLANPacket *packet;
int ret;
- vc->vlan->send_queue = packet->next;
+ packet = TAILQ_FIRST(&vc->vlan->send_queue);
+ TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry);
ret = qemu_deliver_packet(packet->sender, packet->data,
packet->size, packet->raw);
if (ret == 0 && packet->sent_cb != NULL) {
- packet->next = vc->vlan->send_queue;
- vc->vlan->send_queue = packet;
+ TAILQ_INSERT_HEAD(&vc->vlan->send_queue, packet, entry);
break;
}
@@ -486,13 +481,13 @@ static void qemu_enqueue_packet(VLANClientState *sender,
VLANPacket *packet;
packet = qemu_malloc(sizeof(VLANPacket) + size);
- packet->next = sender->vlan->send_queue;
packet->sender = sender;
packet->size = size;
packet->raw = raw;
packet->sent_cb = sent_cb;
memcpy(packet->data, buf, size);
- sender->vlan->send_queue = packet;
+
+ TAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry);
}
static ssize_t qemu_send_packet_async2(VLANClientState *sender,
@@ -616,7 +611,6 @@ static ssize_t qemu_enqueue_packet_iov(VLANClientState *sender,
max_len = calc_iov_length(iov, iovcnt);
packet = qemu_malloc(sizeof(VLANPacket) + max_len);
- packet->next = sender->vlan->send_queue;
packet->sender = sender;
packet->sent_cb = sent_cb;
packet->size = 0;
@@ -629,7 +623,7 @@ static ssize_t qemu_enqueue_packet_iov(VLANClientState *sender,
packet->size += len;
}
- sender->vlan->send_queue = packet;
+ TAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry);
return packet->size;
}
@@ -2501,6 +2495,7 @@ VLANState *qemu_find_vlan(int id, int allocate)
}
vlan = qemu_mallocz(sizeof(VLANState));
vlan->id = id;
+ TAILQ_INIT(&vlan->send_queue);
vlan->next = NULL;
pvlan = &first_vlan;
while (*pvlan != NULL)