qemu_net_client_setup() is the only user of qemu_new_net_queue(), which will pass in NetClientState. By forcing it be a NetClientState, we can ref/unref NetQueue's owner
Signed-off-by: Liu Ping Fan <pingf...@linux.vnet.ibm.com> --- include/net/queue.h | 2 +- net/queue.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/net/queue.h b/include/net/queue.h index fc02b33..1d9e4c3 100644 --- a/include/net/queue.h +++ b/include/net/queue.h @@ -34,7 +34,7 @@ typedef void (NetPacketSent) (NetClientState *sender, ssize_t ret); #define QEMU_NET_PACKET_FLAG_NONE 0 #define QEMU_NET_PACKET_FLAG_RAW (1<<0) -NetQueue *qemu_new_net_queue(void *opaque); +NetQueue *qemu_new_net_queue(NetClientState *nc); void qemu_del_net_queue(NetQueue *queue); diff --git a/net/queue.c b/net/queue.c index 859d02a..1937345 100644 --- a/net/queue.c +++ b/net/queue.c @@ -49,7 +49,7 @@ struct NetPacket { }; struct NetQueue { - void *opaque; + NetClientState *nc; uint32_t nq_maxlen; uint32_t nq_count; @@ -58,13 +58,13 @@ struct NetQueue { unsigned delivering : 1; }; -NetQueue *qemu_new_net_queue(void *opaque) +NetQueue *qemu_new_net_queue(NetClientState *nc) { NetQueue *queue; queue = g_malloc0(sizeof(NetQueue)); - queue->opaque = opaque; + queue->nc = nc; queue->nq_maxlen = 10000; queue->nq_count = 0; @@ -154,7 +154,7 @@ static ssize_t qemu_net_queue_deliver(NetQueue *queue, ssize_t ret = -1; queue->delivering = 1; - ret = qemu_deliver_packet(sender, flags, data, size, queue->opaque); + ret = qemu_deliver_packet(sender, flags, data, size, queue->nc); queue->delivering = 0; return ret; @@ -169,7 +169,7 @@ static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue, ssize_t ret = -1; queue->delivering = 1; - ret = qemu_deliver_packet_iov(sender, flags, iov, iovcnt, queue->opaque); + ret = qemu_deliver_packet_iov(sender, flags, iov, iovcnt, queue->nc); queue->delivering = 0; return ret; -- 1.8.1.4