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
>
> [st...@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=1
> sudo sysctl net.link.tap.devfs_cloning=1
> sudo sysctl net.link.tap.up_on_open=1
>
> 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-unsubscr...@freebsd.org"

Hi Steve;

Forgive 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="YES"


*** rc.conf

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

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

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

ext_if="re0"    # replace with actual external interface name i.e., dc0
int_if="bridge0"        # replace with actual internal interface name i.e., dc1
internal_net="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 
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=`ifconfig -a | grep member | grep $1`
if [ "$TEST" == "" ]; 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 = Papi
   workgroup = LOBOS
   hosts allow = 10.1.200. 10.10.10. 127.
   server string = Papi
   guest account = nobody
   log file = /var/log/samba/log.%m
   max log size = 50
   socket options = TCP_NODELAY 
   share modes = yes
   security = share
   interfaces = 10.1.200.254 10.10.10.2 
   local master = no
   domain master = no
   preferred master = no
   domain logons = no
   wins support = no
   dns proxy = no
# Share Definitions ==============================
# 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=/
   read only = yes
   public = yes
   guest ok = yes
   write list = @wheel  

[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. 
Guests have internet, they see ALL the host's files, i can
ssh to the linux guest and remote desktop session with 
the XP guest (I know it is "overheady" but it is doable).

Finally, qemu comand line:

/usr/local/bin/qemu -boot c -m 740 \
-hda '/Vmachines/qemu/sda.img' -hdb '/Vmachines/qemu/sdb.img' \
-cdrom  '/dev/cd0' \
-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=/etc/qemu-ifup \
-localtime -kernel-kqemu &

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

I hope this helps 

-- 
Mario Lobo
http://www.mallavoodoo.com.br
FreeBSD since version 2.2.8 [not Pro-Audio.... YET!!] (99,7% winedows FREE)
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to