qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Use existing tun/tap network interface


From: Lars Munch
Subject: Re: [Qemu-devel] [PATCH] Use existing tun/tap network interface
Date: Sun, 28 Nov 2004 17:37:10 +0100
User-agent: Mutt/1.5.6+20040907i

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.

> * 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.

> > To use it, first configure your interface by using for example tunctl
> > from UML:
> > 
> > # tunctl -t qemu0 -u OWNER
> > # ifconfig qemu0 xxx.xxx.xxx.xxx up
> > 
> > Now you will have a network interface called 'qemu0'.
> 
> Wrapping that in other words:
> You configure the network interfaces to be used by qemu in your system's
> network configuration script (or anywhere else) and can use that
> interface later without starting qemu (or a wrapper script) as root.
> 
> > Then start qemu with something like this:
> > 
> > # qemu -tun-if qemu0 .....
> 
> I'm adding '-n /bin/true' here.

I don't have to.

> 
> Regards,
>  Thomas
> diff -Nru qemu-0.o/vl.c qemu-0/vl.c
> --- qemu-0.o/vl.c     2004-11-16 14:16:22.000000000 +0100
> +++ qemu-0/vl.c       2004-11-19 18:42:49.811154272 +0100
> @@ -1596,7 +1596,7 @@
>      }
>      memset(&ifr, 0, sizeof(ifr));
>      ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
> -    pstrcpy(ifr.ifr_name, IFNAMSIZ, "tun%d");
> +    pstrcpy(ifr.ifr_name, IFNAMSIZ, *ifname ? ifname : "tun%d");
>      ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
>      if (ret != 0) {
>          fprintf(stderr, "warning: could not configure /dev/net/tun: no 
> virtual network emulation\n");

I like this part of you patch better than my code, so I have added this
to the attached patch.

Regards
Lars Munch

Attachment: tun-if.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]