From owner-freebsd-emulation@FreeBSD.ORG Mon Jan 24 08:12:01 2011 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 0A344106564A; Mon, 24 Jan 2011 08:12:01 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id BA6768FC27; Mon, 24 Jan 2011 08:12:00 +0000 (UTC) Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) (authenticated bits=0) by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id p0O7a9hm059479 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 24 Jan 2011 07:36:22 GMT (envelope-from julian@freebsd.org) Message-ID: <4D3D2DE9.2060004@freebsd.org> Date: Sun, 23 Jan 2011 23:44:41 -0800 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: Mikolaj Golub References: <86oc77heqk.fsf@kopusha.home.net> In-Reply-To: <86oc77heqk.fsf@kopusha.home.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-emulation@freebsd.org, freebsd-virtualization@freebsd.org Subject: Re: VirtualBox + VIMAGE 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: Mon, 24 Jan 2011 08:12:01 -0000 On 1/23/11 6:33 AM, Mikolaj Golub wrote: > Hi, > > Sorry for cross posting, but this question concerns both VirtualBox and VIMAGE :-). > > I would like to be able to run VirtualBox on my desktop, with kernel compilled > with VIMAGE, so I would use light vnet jails for FreeBSD VMs and VirtualBox > for other OSes. > > Currently the system will crash if you try to use VirtualBox bridged > networking under VIMAGE kernel. > > The crash may look like below: > > db> bt > > Tracing pid 2349 tid 100239 td 0xc984b2d0 > ifunit(c7e3b9ac,6f,c129e970,f8089984,c08d6dc0,...) at ifunit+0x33 > vboxNetFltOsInitInstance(c7e3b810,0,8,7,c9aa6ae0,...) at vboxNetFltOsInitInstance+0x31 > vboxNetFltFactoryCreateAndConnect(c9aa8cc8,c96636d4,c9664010,0,c966403c,...) at vboxNetFltFactory > CreateAndConnect+0x1f7 > _end(c7b11810,c962c238,3,c962c2b8,0,...) at 0xc9c0114f > _end(c7b11810,c962c22c,f20,c0d31268,f8089a90,...) at 0xc9c01265 > _end(c962c22c,0,0,c7b11810,c0cfe2fe,...) at 0xc9bbc775 > _end(f808a000,fffffffd,28,c962c22c,0,...) at 0xc9bbd086 > supdrvIOCtl(c10c5607,c12a0a40,c7b11810,c962c200,c0e81df8,...) at supdrvIOCtl+0x1af1 > VBoxDrvFreeBSDIOCtl(c94efb00,c10c5607,c962c200,3,c984b2d0,...) at VBoxDrvFreeBSDIOCtl+0x1ea > devfs_ioctl_f(c8e70118,c10c5607,c962c200,c9a82900,c984b2d0,...) at devfs_ioctl_f+0x10b > kern_ioctl(c984b2d0,e,c10c5607,c962c200,1089cec,...) at kern_ioctl+0x1fd > ioctl(c984b2d0,f8089cec,2b077000,1,c94ed2a8,...) at ioctl+0x134 > syscallenter(c984b2d0,f8089ce4,c0c20e2d,c0e83290,0,...) at syscallenter+0x2a6 > syscall(f8089d28) at syscall+0x4f > Xint0x80_syscall() at Xint0x80_syscall+0x21 > --- syscall (54, FreeBSD ELF32, ioctl), eip = 0x282ae093, esp = 0xbf8b980c, ebp = 0xbf8b9828 --- > > So it crashes when a function (ifunit in this case) tries to access > virtualized variable (V_ifnet in this case). The macro uses td->td_vnet for > this, which should be set to current vnet, but for VBox driver threads it is > NULL. > > As a quick fix I added in VBoxNetFlt-freebsd.c in all "problem" functions > CURVNET_SET_QUIET(vnet0) macro, which sets td->td_vnet to default vnet (see the > attached patch). This has fixed the issue for me and now I am happily running > both VNET jails and VirtualBox machines on my desktop. > > But the way I fixed the issue looks hackish for me. Could someone suggest a > better solution? this is probably at east partially the correct solution. Usually you should also set the value back to its previous value when you leave that code as well. > In case someone is interested in trying this patch, below are the instructions > how to build "VIMAGE safe" vbox driver from ports: > > cd /usr/ports/emulators/virtualbox-ose-kmod > make patch > cd work > patch -p0< /path/to/VirtualBox-3.2.12.VIMAGE.patch > cd .. > VIMAGE=1 make > > > > _______________________________________________ > freebsd-virtualization@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization > To unsubscribe, send any mail to "freebsd-virtualization-unsubscribe@freebsd.org"