From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CYTvI-0005dr-S0 for qemu-devel@nongnu.org; Sun, 28 Nov 2004 13:37:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CYTvI-0005df-EP for qemu-devel@nongnu.org; Sun, 28 Nov 2004 13:37:24 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYTvI-0005dc-BI for qemu-devel@nongnu.org; Sun, 28 Nov 2004 13:37:24 -0500 Received: from [151.189.20.157] (helo=postman.arcor.de) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CYTlT-0002TE-7W for qemu-devel@nongnu.org; Sun, 28 Nov 2004 13:27:15 -0500 Received: from server.schwinge.homeip.net (c-180-200-94.n.dial.de.ignite.net [62.180.200.94]) (authenticated bits=0) by postman.arcor.de (8.13.0.PreAlpha4/8.13.0.PreAlpha4) with ESMTP id iASIR8Th015405 for ; Sun, 28 Nov 2004 19:27:12 +0100 (MET) Date: Sun, 28 Nov 2004 19:26:44 +0100 From: Thomas Schwinge Subject: Re: [Qemu-devel] [PATCH] Use existing tun/tap network interface Message-ID: <20041128182643.GA3422@bobby.schwinge.homeip.net> References: <20041127105452.GA8263@tuxedo.skovlyporten.dk> <20041128160719.GA3263@bobby.schwinge.homeip.net> <20041128163710.GA2526@tuxedo.skovlyporten.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041128163710.GA2526@tuxedo.skovlyporten.dk> Reply-To: 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 Sun, Nov 28, 2004 at 05:36:48PM +0100, Lars Munch wrote: > On Sun, Nov 28, 2004 at 05:07:20PM +0100, Thomas Schwinge wrote: > > On Sat, Nov 27, 2004 at 11:54:30AM +0100, Lars Munch wrote: > > > The attached patch adds a new option '-tun-if' which will enable you to > > > use preconfigured tun/tap network interfaces as described here: > > > http://user-mode-linux.sourceforge.net/UserModeLinux-HOWTO-6.html#ss6.7 > > > > I've been preparing a patch to achieve the same functionality some days > > ago, but didn't have the time to finish it, yet. > > It is, however, working: 'qemu-net-if.patch' is attached. > > > > Things to be done: > > * Make it possible to use '-net-if ...' and '-tun-fd ...' at the same > > time without interfering with each other - albeit I don't know if > > anybody will use both of them at the same time, ever. > > My patch takes care of that. Good. > > * Disable the invocation of a tap/tun network init script when > > specifying '-net-if ...' or '-tun-fd ...' > > With my patch you can still use a tap/tun network init script for the > NICs not created by '-net-if' or '-tun-fd. Yes, I forgot that the same script is used for all interfaces - you could use that with my patch, too. If every interface had it's own specific script, it would be reasonable to disable it by default when using a preconfigured interface. But since it is not, I'd also just leave that alone. > > > Then start qemu with something like this: > > > > > > # qemu -tun-if qemu0 ..... > > > > I'm adding '-n /bin/true' here. > > I don't have to. Of course I also don't have to, but I don't want to get '/etc/qemu-ifup: could not launch network script' every time running qemu. ;-) > +static int net_if_init(NetDriverState *nd, char *ifname) > +{ > + pstrcpy(nd->ifname, sizeof(nd->ifname), ifname); > + > + nd->fd = tun_open(nd->ifname, sizeof(nd->ifname)); > + if (nd->fd < 0) > + return -1; > + > + nd->send_packet = tun_send_packet; > + nd->add_read_packet = tun_add_read_packet; > + return 0; > +} > + Why do you need this function? (Sorry, I don't have the time to dig through qemu's networking code at the moment.) Is it because I am doing #v+ case QEMU_OPTION_net_if: net_if_type = NET_IF_TUN; if (nb_net_ifs < MAX_NICS) { pstrcpy (nd_table[nb_net_ifs].ifname, sizeof(nd_table[nb_net_ifs].ifname), optarg); nb_net_ifs++; } break; #v- ..., whereas you are putting the devices' names into an array and copy it to the interfaces' structure later? What's the advantage of your approach compared to mine? > + case QEMU_OPTION_tun_if: > + net_if_type = NET_IF_TUN; > + if (nb_tun_fds+nb_tun_ifs < MAX_NICS) { > + pstrcpy(tun_ifs[nb_tun_ifs], sizeof(tun_ifs[0]), optarg); > + nb_tun_ifs++; > + } > + break; > + } else if (i < nb_tun_fds+nb_tun_ifs) { > + if (net_if_init(nd, tun_ifs[i-nb_tun_fds]) < 0) > + net_dummy_init(nd); > } else { > if (net_tun_init(nd) < 0) > net_dummy_init(nd); Regards, Thomas