From: Thomas Schwinge <schwinge-qemu-devel@nic-nac-project.de>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Use existing tun/tap network interface
Date: Sun, 28 Nov 2004 19:26:44 +0100 [thread overview]
Message-ID: <20041128182643.GA3422@bobby.schwinge.homeip.net> (raw)
In-Reply-To: <20041128163710.GA2526@tuxedo.skovlyporten.dk>
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
next prev parent reply other threads:[~2004-11-28 18:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-27 10:54 [Qemu-devel] [PATCH] Use existing tun/tap network interface Lars Munch
2004-11-28 16:07 ` Thomas Schwinge
2004-11-28 16:37 ` Lars Munch
2004-11-28 18:26 ` Thomas Schwinge [this message]
2004-11-28 19:37 ` Lars Munch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041128182643.GA3422@bobby.schwinge.homeip.net \
--to=schwinge-qemu-devel@nic-nac-project.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).