1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6_run () {
7  case "$1" in
8  "alix_dsk")
9    ARG="-cpu pentium"
10    ARG="$ARG -hda /usr/obj/nanobsd.alix_dsk/_.disk.full -boot c"
11    ARG="$ARG -hdb /z/scratch/scratch"
12    ARG="$ARG -net nic,model=e1000"
13    ARG="$ARG -net tap,ifname=tap0,script=no,downscript=no"
14    ARG="$ARG -m 1024 -k de -localtime -nographic"
15    break
16    ;;
17  "alix_nfs")
18    ARG="-cpu pentium"
19    ARG="$ARG -hda /usr/obj/nanobsd.alix_nfs/_.disk.full -boot c"
20    ARG="$ARG -hdb /z/scratch/scratch"
21    ARG="$ARG -net nic,model=e1000"
22    ARG="$ARG -net tap,ifname=tap0,script=no,downscript=no"
23    ARG="$ARG -m 1024 -k de -localtime -nographic"
24    break
25    ;;
26
27  esac
28  qemu-system-x86_64 -kernel-kqemu $ARG
29}
30
31_init () {
32  kldstat -n kqemu || kldload kqemu
33  kldstat -n aio || kldload aio
34  kldstat -n if_tap || kldload if_tap
35  kldstat -n if_bridge || kldload if_bridge
36  sysctl net.link.tap.up_on_open=1
37  ifconfig bridge0 down destroy
38  ifconfig tap0 down destroy
39  ifconfig tap0 create up
40  ifconfig bridge0 create
41  ifconfig bridge0 addm nfe0 addm tap0 up
42}
43
44_ifup () {
45  sleep 2;
46  ifconfig bridge0 -learn nfe0
47  ifconfig tap0 up
48  ifconfig bridge0 up
49}
50
51_clear () {
52  ifconfig bridge0 down destroy
53  ifconfig tap0 down destroy
54}
55
56_init
57(_ifup) &
58_run "$1"
59_clear
60