I have some of this left over from s similar project i was doing a while back, I was setting up router images in a carp setup:
This builds the harness: #!/bin/sh # # stupid script to start multiple qemus on a single box SUDO=/usr/bin/sudo USER=xxxxxx MODE=ENABLE usage() { echo "usage: $0 [-h harnesstype] [-d]" 1>&2 exit 2 } start() { echo MODE: $MODE if [ $MODE = "DISABLE" ]; then echo DeConfiguring ${HARNESS} Harness echo DeConfiguring tun0: echo ${SUDO} ifconfig tun0 destroy ${SUDO} ifconfig tun0 destroy echo DeConfiguring tun1: echo ${SUDO} ifconfig tun1 destroy ${SUDO} ifconfig tun1 destroy echo DeConfiguring tun2: echo ${SUDO} ifconfig tun2 destroy ${SUDO} ifconfig tun2 destroy else # make sure a tun interface is available echo Configuring ${HARNESS} Harness echo Configuring tun0: echo ${SUDO} ifconfig tun0 192.168.254.254 link0 ${SUDO} ifconfig tun0 192.168.254.254 link0 echo Configuring tun1: echo ${SUDO} ifconfig tun1 192.168.1.254 link0 ${SUDO} ifconfig tun1 192.168.1.254 link0 echo Configuring tun2: echo ${SUDO} ifconfig tun2 192.168.253.254 link0 ${SUDO} ifconfig tun2 192.168.253.254 link0 fi } args=`getopt d $*` if [ $? -ne 0 ]; then usage fi set -- $args while [ $# -gt 0 ]; do case "$1" in -d) MODE="DISABLE" echo "Disable Mode" ;; --) shift; break ;; esac shift done if [ $# -ne 1 ]; then usage fi start $1 And this brings up the image 3 times: #!/bin/sh # # stupid script to start multiple qemus on a single box SUDO=/usr/bin/sudo USER=jrecords # qemu args IMAGE=$1 MEMORY=128 FLAGS=" -nographic -serial telnet:127.0.0.1:1010,server,nowait -no-fd-bootchk" NICFLAGS="-net nic,vlan=\$id -net tap,vlan=\$id,ifname=\$id,fd=\$fd" start() { for id in 0 1 2; do fd=$(($id + 3)) tun=tun$(($id)) eval "nics=\"$nics $NICFLAGS\"" fds="$fds $fd<> /dev/$tun" done cmd="${SUDO} -C 5 qemu -m ${MEMORY} -hda ${IMAGE}${FLAGS}$nics$fds" echo Running: ${SUDO} sh -c "$cmd" ${SUDO} sh -c "$cmd" } start $1 You may have to do some tweaking its been months since I looked at this stuff, the telnet won't work, you'll need to change the port that its listening on dynamically, but this should help get you going in the right direction, my intention was to scale this out so I could test 24 or 32 firewalls in a cluster on one box. J On Tue, Feb 2, 2010 at 9:09 AM, Vijay Sankar <vsan...@foretell.ca> wrote: > Matthias Pfeifer wrote: > >> On Tue, 2 Feb 2010 15:10:24 +0100 >> Matthias Pfeifer <cont...@snarfu.de> wrote: >> >> Hello >>> >>> On Tue, 02 Feb 2010 05:35:28 -0600 >>> Vijay Sankar <vsan...@foretell.ca> wrote: >>> >>> Matthias Pfeifer wrote: >>>> >>>>> Hello list >>>>> >>>>> I am trying to get multiple qemu guests on >>>>> host machine running. Host and guests are running >>>>> openbsd 4.6 in sync with the patch brunch. >>>>> >>>>> The Host IP is: 192.168.102.110 >>>>> The guest should have: 192.168.102.111, 192.168.102.112 .. >>>>> and so on. All in the same network, using the same DNS server >>>>> and gateway. >>>>> >>>>> I have read /usr/local/share/doc/qemu/README.OpenBSD >>>>> and tried the samples in the tap section. This works >>>>> fine for one host. >>>>> >>>>> For example, this is working well for one host: >>>>> >>>>> ifconfig tun0 link0 >>>>> ifconfig bridge0 create >>>>> brconfig bridge0 add tun0 add rl0 up >>>>> >>>>> qemu -net nic,macaddr=52:54:00:12:35:10 \ >>>>> -net tap,fd=3 \ >>>>> -name Host1 \ >>>>> -no-fd-bootchk \ >>>>> -hda Host1/system.img 3<>/dev/tun0 >>>>> >>>>> >>>>> Then, I'd like to doing this: >>>>> >>>>> ifconfig tun1 link0 >>>>> ifconfig bridge1 create >>>>> brconfig bridge1 add tun1 add rl0 up >>>>> >>>>> qemu -net nic,macaddr=52:54:00:12:35:11 \ ## MAC changed >>>>> -net tap,fd=4 \ ## fd changed >>>>> -name Host1 \ >>>>> -no-fd-bootchk \ >>>>> -hda Host2/system.img 4<>/dev/tun1 ## tun interface changed >>>>> >>>>> >>>>> But this fails. Is there a way to do something like this >>>>> without adding a real NIC? >>>>> >>>>> >>>>> Thanks in advance! >>>>> >>>>> Matthias >>>>> >>>>> NOTE: sudo calls closefrom(2). In order to have more than one fd >>>> passed >>>> tap interface, a line to sudoers akin to: >>>> >>>> Defaults closefrom_override >>>> >>>> then calling sudo via 'sudo -C 5 -u $USER qemu ..' is required. >>>> See sudoers(5) and sudo(8) for details. >>>> >>>> -- >>>> Vijay Sankar, M.Eng., P.Eng. >>>> ForeTell Technologies Limited >>>> 59 Flamingo Avenue, Winnipeg, MB, Canada R3J 0X6 >>>> Phone: (204) 885-9535, E-Mail: vsan...@foretell.ca >>>> >>> >> Sorry, this is what i mean :) >> >> I have added "Defaults closefrom_override" to /etc/sudoers. >> So i am using the tun0 for the second qemu host: >> >> sudo sh -c " sudo -C 5 -u qemu qemu -net nic,macaddr=52:54:00:12:35:10 \ >> -net tap,fd=3 -name DSB -no-fd-bootchk -hda host1/system.img >> 3<>/dev/tun0" >> >> Working fine. Then the second: >> >> sudo sh -c " sudo -C 5 -u qemu qemu -net nic,macaddr=52:54:00:12:35:11 \ >> -net tap,fd=4 -no-fd-bootchk -hda host2/system.img 4<>/dev/tun0" >> >> >> this gives me a " cannot create /dev/tun0: Device busy " >> >> >> >> -- >> >> -------------------------------------------------------------- >> Matthias Pfeifer <m...@finance-circle.de> >> - Technik - >> >> Finance Circle GmbH >> Burgstrasse 3 >> 31582 Nienburg / Weser >> Tel. 05021-92196-25 // Fax. 05021-92196-99 >> >> HRB 106525 // AG Hamburg //USt.ID: de204840463 >> Geschdftsf|hrer: Axel Schwiersch >> >> > I was running three instances of Windows 2000 Server and one Windows 2003 > server on a Dell 2900 -- two IIS servers, and two SQL Servers for testing > purposes a while ago. Here is some info on how I was doing it at that time > -- > > 9:55AM up 106 days, 23:56, 6 users, load averages: 0.18, 0.17, 0.16 > USER TTY FROM LOGIN@ IDLE WHAT > vsankar C0 - 21Sep09106days xinit /etc/X11/xinit/xinitrc -- > /usr/X11R6/bin/X :0 -auth /home/vsankar/.serverauth.21200 > vsankar p0 :0.0 21Sep09106days qemu -net > nic,vlan=0,model=rtl8139,macaddr=AA:BB:CC:DD:EE:F1 -net tap,vlan=0 -m 448 > -no-fd-bootchk -localtime -hda w2k3.img -nographic > vsankar p2 :0.0 21Sep09106days qemu -net > nic,vlan=0,model=rtl8139,macaddr=AA:BB:CC:DD:EE:F2 -net tap,vlan=0 -m 384 > -no-fd-bootchk -localtime -hda w2k.img -nographic > vsankar p3 :0.0 21Sep09106days qemu -net > nic,vlan=0,model=rtl8139,macaddr=AA:BB:CC:DD:EE:F3 -net tap,vlan=0 -m 384 > -localtime -no-fd-bootchk -nographic -hda appint.img > vsankar p4 :0.0 21Sep09106days qemu -net > nic,vlan=0,model=rtl8139,macaddr=AA:BB:CC:DD:EE:F4 -net tap,vlan=0 -m 384 > -no-fd-bootchk -localtime -hda appext.img -nographic > > Each vm guest was started with a command similar to the following: > > sudo env ETHER=bnx1 qemu \ > -net nic,vlan=0,model=rtl8139,macaddr=AA:BB:CC:DD:EE:XX \ > -net tap,vlan=0 -m 384 -no-fd-bootchk -localtime \ > -hda whatever.img -nographic > > XX was F1, F2, F3, and F4 w2k3, w2k, appint and appext images respectively > > I used nographic because it was easier to use rdesktop and rdp from other > systems to access the vm guests instead of being at the console. > > hope this helps, > > Vijay > -- > Vijay Sankar, M.Eng., P.Eng. > ForeTell Technologies Limited > 59 Flamingo Avenue, Winnipeg, MB, Canada R3J 0X6 > Phone: (204) 885-9535, E-Mail: vsan...@foretell.ca