[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Use existing tun/tap network interface
From: |
Thomas Schwinge |
Subject: |
Re: [Qemu-devel] [PATCH] Use existing tun/tap network interface |
Date: |
Sun, 28 Nov 2004 19:26:44 +0100 |
User-agent: |
Mutt/1.4.2.1i |
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