Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 2009 19:31:30 -0300
From:      Mario Lobo <mlobo@digiart.art.br>
To:        freebsd-questions@freebsd.org
Subject:   Re: qemu only talks to network on second boot
Message-ID:  <200903301931.31031.mlobo@digiart.art.br>
In-Reply-To: <539c60b90903301429o7fcd9edfhe9c995dcb5cb8430@mail.gmail.com>
References:  <539c60b90903301429o7fcd9edfhe9c995dcb5cb8430@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 30 March 2009 18:29:20 Steve Franks wrote:
> Got win2k on qemu for a couple years now.  Funny thing is, it never
> sees the network or the samba shares on my host the second time I
> "boot" qemu on any given day.  First time always times out.  I get no
> console output.  My win2k.sh file looks something like this.  All the
> tap entries since my system seems to have some issue with naming tap.
> Maybe that's the issue, but I'll be darned if I could fix it.  tap0
> and nothing else would be just fine with me.  When I just had tap0, it
> would make tap1 (then tap2, etc, etc.), but this seems always to wind
> up on tap9 and work (the second time I run qemu)....
>
> Goofy.
>
> Best,
> Steve
>
> [steve@dynstant /usr/ports/emulators/wine]$ cat ~/bin/win2k
> #!/bin/sh
> sudo kldload kqemu if_tap if_bridge aio
>
> sudo sysctl net.link.tap.user_open=3D1
> sudo sysctl net.link.tap.devfs_cloning=3D1
> sudo sysctl net.link.tap.up_on_open=3D1
>
> sudo ifconfig bridge0 create
> sudo ifconfig bridge0 addm vr0
> sudo ifconfig bridge0 addm tap0
> sudo ifconfig bridge0 addm tap1
> sudo ifconfig bridge0 addm tap2
> sudo ifconfig bridge0 addm tap3
> sudo ifconfig bridge0 addm tap4
> sudo ifconfig bridge0 addm tap5
> sudo ifconfig bridge0 addm tap6
> sudo ifconfig bridge0 addm tap7
> sudo ifconfig bridge0 addm tap8
> sudo ifconfig bridge0 addm tap9
> sudo ifconfig bridge0 up
> sudo ifconfig vr0 up
> sudo ifconfig tap0 up
> sudo ifconfig tap1 up
> sudo ifconfig tap2 up
> sudo ifconfig tap3 up
> sudo ifconfig tap4 up
> sudo ifconfig tap5 up
> sudo ifconfig tap6 up
> sudo ifconfig tap7 up
> sudo ifconfig tap8 up
> sudo ifconfig tap9 up
> sudo dhclient bridge0
>
> sudo /etc/rc.d/devfs restart
> sudo /etc/rc.d/sysctl restart
>
> qemu -m 384 -net nic -net tap -hda ~/bin/drivec.img -usb -usbdevice
> tablet -serial /dev/cuaU0 &
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@freebsd.org"

Hi Steve;

=46orgive the long post but
here is what I've got working for me:

[BEGIN] ------------------------------------

*** loader.conf

# if_tap is compiled into the kernel
# but loading if_tap does it also
if_bridge_load=3D"YES"


*** rc.conf

##################################
## network stuff
# =A0 =A0 =A0FBSD HOST(7.1-PRERELEASE)
#=A0 =A0 =A0 +-----------------+
#=A0 =A0 =A0 | =A0 =A010.10.10.1 =A0 |=20
#=A0LAN -+----- re0 =A0 =A0 =A0 =A0|=20
#=A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |=20
#=A0 =A0 =A0 | =A0 =A0+-----+ =A0 =A0 =A0|
#=A0 +---+----+tap0 | =A0 =A0 =A0| =A0
#=A0 | =A0++----+tap1 | =A0 =A0 =A0|=20
#=A0 | =A0|| =A0 =A0+-----+ =A0 =A0 =A0| =A0
#=A0 | =A0|| =A0 =A0bridge0 =A0 =A0 =A0| =A0(if_bridge)
#=A0 | =A0||  10.1.200.254   | =A0
#=A0 | =A0|+-----------------+
#=A0 | =A0|
#=A0 | =A0| =A0 =A0 =A0QEMU GUEST 1 (linux Fedora core 5)
#=A0 | =A0| =A0 +-----------------+
#=A0 | =A0| =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
#=A0 | =A0+---+---- eth0 =A0 =A0 =A0 =A0|=20
#=A0 | =A0 =A0 =A0|   10.1.200.1  =A0 |=20
#=A0 | =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |=20
#=A0 | =A0 =A0 =A0+-----------------+=20
#=A0 | =A0 =A0 =A0 =A0 QEMU GUEST 2 =A0(windows XP)
#=A0 | =A0 =A0 =A0+-----------------+
#=A0 | =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
#=A0 +------+--- realtek =A0 =A0 =A0|=20
#=A0 =A0 =A0 =A0 =A0|   10.1.200.2  =A0 |=20
#=A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |=20
#=A0 =A0 =A0 =A0 =A0+-----------------+=20
#
# The bridge IP is the default gateway
# for the guests and the LAN dns is=20
# guests' DNS server
##################################
gateway_enable=3D"YES"
# don't know why but WITHOUT -promisc- here, it doesnt work !
ifconfig_re0=3D"inet 10.10.10.2  netmask 255.255.255.0 promisc"
autobridge_interfaces=3D"bridge0"
autobridge_bridge0=3D"tap0 tap1"=20
cloned_interfaces=3D"bridge0"
ifconfig_bridge0=3D"inet 10.1.200.254 netmask 255.255.255.0 up"

pf_enable=3D"YES"
samba_enable=3D"NO"
smbd_enable=3D"YES"
kqemu_enable=3D"YES"

*** pf.conf (totally open - needed for NAT)

ext_if=3D"re0"	# replace with actual external interface name i.e., dc0
int_if=3D"bridge0"	# replace with actual internal interface name i.e., dc1
internal_net=3D"10.1.200.0/24"
set loginterface $ext_if
set block-policy drop
set fingerprints "/etc/pf.os"
scrub in all
nat on $ext_if from $internal_net to any -> ($ext_if)
no rdr on { lo0, lo1 } from any to any
# pass traffic=20
pass quick on lo0 all
pass quick on re0 all
pass quick on bridge0 all

# maybe these are redundant but i left them here anyway
pass  in  on $ext_if proto { tcp, udp } from any to any keep state
pass  in  on $int_if from $internal_net to any keep state
pass  out on $int_if from any to $internal_net keep state
pass out on $ext_if proto { tcp, udp, icmp, gre } all keep state


*** qemu-ifup.sh

#!/usr/local/bin/bash
/sbin/ifconfig $1 up
TEST=3D`ifconfig -a | grep member | grep $1`
if [ "$TEST" =3D=3D "" ]; then
   /sbin/ifconfig bridge0 addm $1
fi

*** qemu-ifdown (has to have this name !)

#!/usr/local/bin/bash
/sbin/ifconfig bridge0 deletem $1
/sbin/ifconfig $1 down

*** smb.conf

[global]

   netbios name =3D Papi
   workgroup =3D LOBOS
   hosts allow =3D 10.1.200. 10.10.10. 127.
   server string =3D Papi
   guest account =3D nobody
   log file =3D /var/log/samba/log.%m
   max log size =3D 50
   socket options =3D TCP_NODELAY=20
   share modes =3D yes
   security =3D share
   interfaces =3D 10.1.200.254 10.10.10.2=20
   local master =3D no
   domain master =3D no
   preferred master =3D no
   domain logons =3D no
   wins support =3D no
   dns proxy =3D no
# Share Definitions =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
# I did this here because I wanted the qemu guests
# to see everything but you can be more selective
# you can also set a RW directory so the guests can
# copy files to the host

[qemu]
   path=3D/
   read only =3D yes
   public =3D yes
   guest ok =3D yes
   write list =3D @wheel=09

[END] ------------------------------------

Turned my desktop into a gateway.

No need to fiddle with sysctl at all !

The qemu-ifup script does everything that's needed.

With these configs, EVERYTHING works like a charm here.=20
Guests have internet, they see ALL the host's files, i can
ssh to the linux guest and remote desktop session with=20
the XP guest (I know it is "overheady" but it is doable).

=46inally, qemu comand line:

/usr/local/bin/qemu -boot c -m 740 \
=2Dhda '/Vmachines/qemu/sda.img' -hdb '/Vmachines/qemu/sdb.img' \
=2Dcdrom  '/dev/cd0' \
=2Dnet nic,vlan=3D0 -net tap,vlan=3D0,ifname=3Dtap0,script=3D/etc/qemu-ifup=
 \
=2Dlocaltime -kernel-kqemu &

As you can see, I set aside specific tap names for each guest:
linux -> tap0
XP -> tap1=20
and so on...

I hope this helps=20

=2D-=20
Mario Lobo
http://www.mallavoodoo.com.br
=46reeBSD since version 2.2.8 [not Pro-Audio.... YET!!] (99,7% winedows FRE=
E)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903301931.31031.mlobo>