From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lu50G-0005jg-2V for qemu-devel@nongnu.org; Wed, 15 Apr 2009 09:18:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lu50B-0005h6-Bb for qemu-devel@nongnu.org; Wed, 15 Apr 2009 09:18:11 -0400 Received: from [199.232.76.173] (port=44434 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lu50B-0005h2-57 for qemu-devel@nongnu.org; Wed, 15 Apr 2009 09:18:07 -0400 Received: from mx2.redhat.com ([66.187.237.31]:56872) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lu50A-0007eB-Nj for qemu-devel@nongnu.org; Wed, 15 Apr 2009 09:18:07 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n3FDI6Xh029356 for ; Wed, 15 Apr 2009 09:18:06 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3FDI5ME005648 for ; Wed, 15 Apr 2009 09:18:05 -0400 Received: from [127.0.0.1] (file.rdu.redhat.com [10.11.255.147]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n3FDI4pw008227 for ; Wed, 15 Apr 2009 09:18:04 -0400 Subject: Re: [Qemu-devel] [PATCH 4/7] net: Prevent multiple slirp instances From: Mark McLoughlin In-Reply-To: <20090414172954.15035.41102.stgit@mchn012c.ww002.siemens.net> References: <20090414172954.15035.73053.stgit@mchn012c.ww002.siemens.net> <20090414172954.15035.41102.stgit@mchn012c.ww002.siemens.net> Content-Type: text/plain Date: Wed, 15 Apr 2009 14:09:52 +0100 Message-Id: <1239800992.4431.130.camel@blaa> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Reply-To: Mark McLoughlin , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Tue, 2009-04-14 at 19:29 +0200, Jan Kiszka wrote: > The slirp stack is full of global variables which prevents instantiating > it more than once. Catch this during net_slirp_init to prevent more harm > later on. > > Signed-off-by: Jan Kiszka > --- > > net.c | 14 +++++++++++++- > 1 files changed, 13 insertions(+), 1 deletions(-) > > diff --git a/net.c b/net.c > index 787f249..0486f7c 100644 > --- a/net.c > +++ b/net.c > @@ -519,15 +519,27 @@ static void slirp_receive(void *opaque, const uint8_t *buf, int size) > slirp_input(buf, size); > } > > +static int slirp_in_use; > + > +static void net_slirp_cleanup(void *opaque) > +{ > + slirp_in_use = 0; > +} > + > static int net_slirp_init(VLANState *vlan, const char *model, const char *name) > { > + if (slirp_in_use) { > + /* slirp only supports a single instance so far */ > + return -1; > + } > if (!slirp_inited) { > slirp_inited = 1; > slirp_init(slirp_restrict, slirp_ip); > } > slirp_vc = qemu_new_vlan_client(vlan, model, name, > - slirp_receive, NULL, NULL, NULL); > + slirp_receive, NULL, net_slirp_cleanup, NULL); > slirp_vc->info_str[0] = '\0'; > + slirp_in_use = 1; > return 0; Yeah, it's ugly but probably the best we can do right now. Acked-by: Mark McLoughlin Cheers, Mark.