From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQDVQ-0007J4-6b for qemu-devel@nongnu.org; Thu, 11 Apr 2013 05:09:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQDVL-0000id-F1 for qemu-devel@nongnu.org; Thu, 11 Apr 2013 05:09:20 -0400 Received: from mail-ee0-f43.google.com ([74.125.83.43]:56866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQDVL-0000iJ-9a for qemu-devel@nongnu.org; Thu, 11 Apr 2013 05:09:15 -0400 Received: by mail-ee0-f43.google.com with SMTP id e50so632707eek.30 for ; Thu, 11 Apr 2013 02:09:14 -0700 (PDT) Date: Thu, 11 Apr 2013 11:09:11 +0200 From: Stefan Hajnoczi Message-ID: <20130411090911.GC8904@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> <20130408114403.GE12852@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 Tue, Apr 09, 2013 at 01:12:39PM +0800, liu ping fan wrote: > On Mon, Apr 8, 2013 at 7:44 PM, Stefan Hajnoczi wrote: > > 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. > > > OK, see. What about nsrc[0] at the end of struct or **nsrc ? The net core code doesn't need to know about nsrc at all. I think nsrc[] should be dropped completely. The net backends should manage their GSource (if they need one). Stefan