From owner-freebsd-emulation@FreeBSD.ORG Sat Jul 10 05:26:26 2010 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 5FCC2106564A; Sat, 10 Jul 2010 05:26:26 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id 2339D8FC15; Sat, 10 Jul 2010 05:26:25 +0000 (UTC) Received: from lawrence1.loshell.room52.net (ppp59-167-184-191.static.internode.on.net [59.167.184.191]) by lauren.room52.net (Postfix) with ESMTPSA id 39D5C7E84A; Sat, 10 Jul 2010 15:26:23 +1000 (EST) Message-ID: <4C38047E.9010506@freebsd.org> Date: Sat, 10 Jul 2010 15:26:22 +1000 From: Lawrence Stewart User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-AU; rv:1.9.1.10) Gecko/20100704 Thunderbird/3.0.5 MIME-Version: 1.0 To: freebsd-emulation@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Pawel Jakub Dawidek , John Baldwin Subject: vbox + gpxe + pxeboot = fail 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: Sat, 10 Jul 2010 05:26:26 -0000 Hi All, I had some frustration trying to get FreeBSD to pxeboot inside a vbox VM a while back. The thread is available here: http://lists.freebsd.org/pipermail/freebsd-emulation/2010-April/007681.html I left things for a while and came back to them yesterday with some fresh resolve to nut the problem out. I have some new insights I wanted to share. I'm using gpxe 1.0.1 from http://kernel.org/pub/software/utils/boot/gpxe/ and doing the builds on a Debian VM. To create a rom for the vbox AMD adapter types, I'm following the details at: http://www.etherboot.org/wiki/romburning/vbox I turned the instructions to pad the rom into a python script you can grab from here: http://people.freebsd.org/~lstewart/misc/vbox/rompad.py Here's what I've figured out so far: - The problem stems from the pxe boot rom environment provided by gpxe. It sends and receives packets correctly, but somehow the IP addresses get mangled (I think this happens inside gpxe) so it thinks the replies it is waiting for should be coming in on one IP address when they actually arrive on the real valid IP address. - Using the binary only vbox on Win XP which uses the Intel pxe boot rom has no problems and works perfectly i.e. further evidence this is isolated to gpxe - By changing the line "if (udpread_p->status > 0) {" to "if (udpread_p->status > 1) {" in sys/boot/i386/libi386/pxe.c, our pxeboot is able to work around the problem and I can pxeboot FreeBSD just fine. gpxe therefore is correctly reading the packets off the wire and passing them to our pxeboot code. gpxe just sets the failure status code because it thinks the packet is not the one we were waiting for because of the IP address being mismatched. The file in the gpxe distribution that I've been adding debug printf's to is: src/arch/i386/interface/pxe/pxe_udp.c By doing a "%s/DBG/dbg_printf/g" in that file, you get debugging output that shows you the failures and the IP address it thinks the pkt should be coming in on. In my case, it correctly sends UDP packets to 172.16.7.21, and then waits for the reply on 172.16.7.50 (but sees that the reply actually comes in on 172.16.7.43 which is the IP of the VM). Because .43 != .50, gpxe returns status failure (i.e. 1) but does still correctly read the pkt and pass it to our pxeboot hence why my hack of ignoring the status actually allows things to work. I've put an unmodified copy of pxe_udp.c at: http://people.freebsd.org/~lstewart/misc/vbox/pxe_udp.c If anyone is able to see any obvious problems in that file I'd love to hear about it. I suspect the problem is embedded somewhere a bit deeper in the gpxe code though so I'll ping the gpxe folks and see what they have to say. Cheers, Lawrence