From owner-freebsd-emulation@FreeBSD.ORG Sun Mar 9 11:46:26 2008 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 404E2106566B for ; Sun, 9 Mar 2008 11:46:26 +0000 (UTC) (envelope-from per@hedeland.org) Received: from pluto.hedeland.org (1-1-1-13a.mal.sth.bostream.se [82.182.84.27]) by mx1.freebsd.org (Postfix) with ESMTP id 8E7528FC14 for ; Sun, 9 Mar 2008 11:46:25 +0000 (UTC) (envelope-from per@hedeland.org) Received: from pluto.hedeland.org (localhost [127.0.0.1]) by pluto.hedeland.org (8.13.6/8.13.1) with ESMTP id m29BkNSs078446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 9 Mar 2008 12:46:23 +0100 (CET) (envelope-from per@pluto.hedeland.org) Received: (from per@localhost) by pluto.hedeland.org (8.13.6/8.13.1/Submit) id m29BkNhk078445; Sun, 9 Mar 2008 12:46:23 +0100 (CET) (envelope-from per) Date: Sun, 9 Mar 2008 12:46:23 +0100 (CET) From: Per Hedeland Message-Id: <200803091146.m29BkNhk078445@pluto.hedeland.org> To: sfourman@gmail.com In-Reply-To: <11167f520803090103j1dc61e7ap89eb21347e22557e@mail.gmail.com> X-Scanned-By: MIMEDefang 2.48 on 10.1.1.1 Cc: freebsd-emulation@freebsd.org Subject: Re: Qemu: bridging on FreeBSD 7.0-STABLE X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Mar 2008 11:46:26 -0000 "Sam Fourman Jr." wrote: > >I am confused a bit, > >so what would I have to put in /etc/sysctl.conf so that qemu would >have bridging for a user, automatically on bootup > >would I have to have a shell script of some sort? and would it not >have to test if there already is a tap0? > >I have been trying to get this to work for awhile, if anyone has >config files they could post I would very much appreciate it. > >esp if you could get multiple qemu's to bridge at once Here's the setup I use: 0. In /boot/loader.conf: if_tap_load="YES" This may actually be redundant though, I haven't tried w/o it. 1. In /etc/sysctl.conf: # Allow user open of tap device for qemu networking net.link.tap.user_open=1 2. In /etc/devfs.rules: [localrules=10] # devfs starts before NIS, so need numerical uid here (if you use NIS) add path 'tap*' user 1016 3. In /etc/rc.conf: devfs_system_ruleset="localrules" cloned_interfaces="bridge0" ifconfig_bridge0="addm bge0 up" I.e. this is one-time stuff, you can of course do it manually instead when testing: ifconfig bridge0 create ifconfig bridge0 addm bge0 up Use the name of your physical ethernet interface instead of "bge0", of course. 4. /etc/qemu-ifup: #!/bin/sh sudo /sbin/ifconfig $1 up case "`ifconfig bridge0`" in *" $1 "*) ;; # already in the bridge *) sudo /sbin/ifconfig bridge0 addm $1 ;; esac Finally, to run multiple qemus with bridged networking you *must* assign them different MAC addresses via -net nic,macaddr=52:54:00:XX:XX:XX (well, one of them can have the default of course). I just hardwire them, but in an earlier discussion here, Bakul Shah posted a nice trick to auto-generate the MAC address: Right. I use a shell function to create a macaddress based on directory of the image file. Something like: macaddr() { echo 52:54:0:$(echo $1|md5 |cut -c1-6|sed 's/\(..\)\(..\)/\1:\2:/') } qemu -net nic,macaddr=$(macaddr $(dirname $(realpath $1))) -hda $* And invoke it as, for example, my-qemu /usr/oszoo/plan9 ... Incidentally that post can *not* be found by searching the freebsd-emulation archives at freebsd.org, but there's always google... --Per