Received: from eggs.gnu.org ([208.118.235.92]:50030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAUd-0001eB-0p for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:44:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPAUZ-00039W-Fk for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:44:10 -0400 Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:34580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPAUZ-000399-9w for qemu-devel@nongnu.org; Mon, 08 Apr 2013 07:44:07 -0400 Received: by mail-we0-f173.google.com with SMTP id t57so4380926wey.18 for ; Mon, 08 Apr 2013 04:44:06 -0700 (PDT) Date: Mon, 8 Apr 2013 13:44:03 +0200 From: Stefan Hajnoczi Message-ID: <20130408114403.GE12852@stefanha-thinkpad.redhat.com> References: <1364457355-4119-1-git-send-email-qemulist@gmail.com> <1364457355-4119-2-git-send-email-qemulist@gmail.com> <20130328143218.GH22865@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [RFC PATCH v2 1/4] net: port tap onto glib List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liu ping fan Cc: Paolo Bonzini , Anthony Liguori , qemu-devel@nongnu.org, mdroth On Wed, Apr 03, 2013 at 05:28:39PM +0800, liu ping fan wrote: > On Thu, Mar 28, 2013 at 10:32 PM, Stefan Hajnoczi wrote: > > On Thu, Mar 28, 2013 at 03:55:52PM +0800, Liu Ping Fan wrote: > >> From: Liu Ping Fan > >> > >> 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 | 27 +++++++++++++++ > >> net/net.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > >> net/tap.c | 57 +++++++++++++++++++++++++------ > >> 3 files changed, 169 insertions(+), 11 deletions(-) > > > > Please split this into two patches: > > > > 1. NetClientSource > > 2. Convert tap to NetClientSource > > > > Once you do that it turns out that NetClientSource has nothing to do > > with the net subsystem, it's a generic file descriptor GSource (weird > > that glib doesn't already provide this abstraction). > > > > Each net client needs to reimplement .bind_ctx() anyway, so I don't see > > much point in having NetClientSource.nsrc[]. We might as well let net > > clients have that field themselves and destroy the GSource in their > > destructor function. > > > The only way to detach the GSource from GMainContext is > g_source_destroy, so if we want to re-bind nc from threadA to threadB, > we should destroy the old one and create a new. Is that meaningful? I guess that can be done. What I was really thinking when I suggested getting rid of nsrc[] is that it's a little ugly to have the array with 2 GSources. Different net clients have different numbers of GSources - 0 for NICs, 1 for most backends, 2 for ioeventfd for virtio-net data plane with separate rx/tx. So my thought was to leave the number of GSources in the layer that uses them - each specific net client. Stefan