From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPZAr-0001I5-V4 for qemu-devel@nongnu.org; Tue, 09 Apr 2013 10:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPZAn-0007EJ-Hj for qemu-devel@nongnu.org; Tue, 09 Apr 2013 10:05:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPZAn-0007Dv-9r for qemu-devel@nongnu.org; Tue, 09 Apr 2013 10:05:21 -0400 Date: Tue, 9 Apr 2013 16:03:11 +0200 From: Stefan Hajnoczi Message-ID: <20130409140311.GB12456@stefanha-thinkpad.redhat.com> References: <1365399368-26967-1-git-send-email-pingfank@linux.vnet.ibm.com> <1365399368-26967-2-git-send-email-pingfank@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1365399368-26967-2-git-send-email-pingfank@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v3 1/5] net: introduce glib function for network List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Paolo Bonzini , qemu-devel@nongnu.org, Anthony Liguori , mdroth On Mon, Apr 08, 2013 at 01:36:04PM +0800, Liu Ping Fan wrote: > Bind each NetClientState with a GSource(ie,NetClientSource). Currently, > these GSource attached with default context, but in future, after > resolving the race between handlers and the interface exposed by > NetClientInfo and other re-entrant issue, we can run NetClientState > on different threads > > Signed-off-by: Liu Ping Fan > --- > include/net/net.h | 15 +++++++++++++ > net/net.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 76 insertions(+), 0 deletions(-) > > diff --git a/include/net/net.h b/include/net/net.h > index cb049a1..cb2451d 100644 > --- a/include/net/net.h > +++ b/include/net/net.h > @@ -44,6 +44,7 @@ typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int); > typedef void (NetCleanup) (NetClientState *); > typedef void (LinkStatusChanged)(NetClientState *); > typedef void (NetClientDestructor)(NetClientState *); > +typedef void (NetClientBindCtx)(NetClientState *, GMainContext *); > > typedef struct NetClientInfo { > NetClientOptionsKind type; > @@ -55,8 +56,20 @@ typedef struct NetClientInfo { > NetCleanup *cleanup; > LinkStatusChanged *link_status_changed; > NetPoll *poll; > + NetClientBindCtx *bind_ctx; > } NetClientInfo; > > +typedef bool (*Pollable)(void *opaque); > + > +typedef struct NetClientSource { > + GSource source; > + /* fix me, to expand as array in future */ > + GPollFD gfd; > + Pollable readable; > + Pollable writable; > + void *opaque; > +} NetClientSource; This struct has nothing to do with the net subsystem. It is a generic utility for file descriptor read/write monitoring. It should be in a separate file (maybe util/fdsource.c?). NetClient should not know about the GSource at all. It's an implementation detail of the NetClient, just like the actual fd is also an implementation detail that net.h/net.c doesn't know about. Stefan