From owner-freebsd-virtualization@FreeBSD.ORG Wed Feb 2 18:05:41 2011 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6034106566B; Wed, 2 Feb 2011 18:05:41 +0000 (UTC) (envelope-from monthadar@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 147C98FC0A; Wed, 2 Feb 2011 18:05:40 +0000 (UTC) Received: by wyf19 with SMTP id 19so242021wyf.13 for ; Wed, 02 Feb 2011 10:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=m0Sr9E64CydevIrSiYAcJv/aeTNe312l8Z6ogU1n1d4=; b=E+vJhQVyXSPaByUtGlrGl7dlLWmGMq9ayhh1YlY66OszqkF1mUeOM16BGgJ5TGmGQ+ TcM5jfYTm3NOeLkLCSyOCBZEPTJNmIYZo5Nayv9EN9U4QKzUFQeB4qJLsawD3GAzQ/Rs dKDvaSAULRTuau+6ZToZ+jQS3A5vR6p6ShRhE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=dcMM8f0dIJqvsaaWdHDsEqrJKGqzLwtSZzV55NcsbBhu9gnD5KQ+ssOS5bfhr1ynnE tTFkFQ2DsUgiQbjKIosuVbYY+IPpAO4KylpA0NVOg6Kfz0y7kuUSbSLbioJT/x/e8XUP mY2YlJw8Y7NubHLa0pG1C6IpjSwDXecx76hN8= MIME-Version: 1.0 Received: by 10.227.129.17 with SMTP id m17mr9455506wbs.79.1296669939819; Wed, 02 Feb 2011 10:05:39 -0800 (PST) Received: by 10.227.134.137 with HTTP; Wed, 2 Feb 2011 10:05:39 -0800 (PST) In-Reply-To: <4D4994CE.2090209@freebsd.org> References: <4D484213.6050100@freebsd.org> <4D486108.5060805@freebsd.org> <20110202164827.I80258@maildrop.int.zabbadoz.net> <4D4994CE.2090209@freebsd.org> Date: Wed, 2 Feb 2011 19:05:39 +0100 Message-ID: From: Monthadar Al Jaberi To: Julian Elischer Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "Bjoern A. Zeeb" , FreeBSD virtualization mailing list Subject: Re: simulating wireless device (if_alloc panic, VirtualBox, VIMAGE) X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Feb 2011 18:05:42 -0000 I just tried something that seems to work, but please dont hit me ^^;;; in wtap_ioctl I assigned curthread->td_vnet myself to point to a VNET (saved it when the module first loaded) (I have not created any jails yet)... and it works... I didnt put any CURVNET macros... my assumption is that if ath drivers dont use VNET I shouldnt :P What is wrong with this hack? br, P.S. I have printed "porting to vnet" text to have it always at hand, but its a bit hard for me... doing my best. On Wed, Feb 2, 2011 at 6:30 PM, Julian Elischer wrote: > On 2/2/11 9:12 AM, Bjoern A. Zeeb wrote: >> >> On Wed, 2 Feb 2011, Monthadar Al Jaberi wrote: >> >> Hi, >> >>> Thanx makes more sense, but I have noticed something weired if you can >>> shade some light on. >>> >>> I added printfs one when the module is first loaded (static int >>> event_handler(module_t module, int event, void *arg)): >>> curthread=3D0xc3f95870 >>> curthread->td_vnet=3D0xc3170e00 >>> curthread->td_ucred=3D0xc3185d00 >>> TD_TO_VNET=3D0 >>> CRED_TO_VNET=3D0 >> >> Try to load it from laoder on boot; I think that should work as we are >> setting the curvent for the kernel startup. >> >> The problem you are seeing is a bug in the current implementation that >> you cannot add any physical network interface after the kernel started. >> This applies to cardbus/usb/... as well as any kind of ethernet >> interface, so a kldload igb should yield it as well. >> >> The fix for that is easy and hard at the same time: >> A) either touch all drivers >> B) or touch all cloned interfaces and change 3 common lines. >> =A0 or try to make cloners aware of vimages. >> >> Solution B) is sitting in perforce with the entire stuff that it depends >> on and was started with CH=3D179022,179255 but not limited to that if yo= u >> want to have a peek. >> >> What you certainly can do locally to your driver for now is to make a >> change like this: >> >> +#ifdef VIMAGE >> + =A0 =A0 =A0 CURVNET_SET(vnet0); >> +#endif >> =A0 =A0 =A0 =A0ifp =3D if_alloc(IFT_ETHER); >> +#ifdef VIMAGE >> + =A0 =A0 =A0 CURVNET_RESTORE(); >> +#endif >> > > you don't really need =A0the #ifdef except for readability as CURVNET_XXX= ar > enot defined for !vnet > >> It's the type A) kind of change from above that will break eventually >> in the future. >> >> /bz >> > > --=20 //Monthadar Al Jaberi