Il 13/03/2013 03:26, liu ping fan ha scritto: >>> >> + qemu_net_queue_append(port->nc.peer->send_queue, &port->nc, >>> >> + QEMU_NET_PACKET_FLAG_NONE, buf, len, NULL); >>> >> + event_notifier_set(&port->e); >> > >> > Why are the context and the EventNotifier a property of the port, rather >> > than applicable to the NetClientState? >> > > Yes, embed context into NetClientState is more reasonable, but as for > EventNotifier, considering about if we port tap onto context, the tap > do not have EventNotifier. >
There doesn't even need to be an EventNotifier, instead you can pass the NetClientState's AioContext to the queue and use a bottom half on the AioContext. Furthermore, the bottom half should be completely transparent. Callers can keep using qemu_net_queue_flush, qemu_net_queue_flush schedules the bottom half (perhaps, with an optimization, it only does that if the queue is not empty), the handler actually performs the flush. Paolo