From owner-p4-projects@FreeBSD.ORG Fri Aug 7 16:54:33 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C816E1065670; Fri, 7 Aug 2009 16:54:32 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A990106564A for ; Fri, 7 Aug 2009 16:54:32 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 6A1B48FC1F for ; Fri, 7 Aug 2009 16:54:32 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n77GsWoW060568 for ; Fri, 7 Aug 2009 16:54:32 GMT (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n77GsWsG060566 for perforce@freebsd.org; Fri, 7 Aug 2009 16:54:32 GMT (envelope-from julian@freebsd.org) Date: Fri, 7 Aug 2009 16:54:32 GMT Message-Id: <200908071654.n77GsWsG060566@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to julian@freebsd.org using -f From: Julian Elischer To: Perforce Change Reviews Cc: Subject: PERFORCE change 167090 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Aug 2009 16:54:34 -0000 http://perforce.freebsd.org/chv.cgi?CH=167090 Change 167090 by julian@julian-mac on 2009/08/07 16:54:11 Better examples for shutdown Affected files ... .. //depot/projects/vimage/porting_to_vimage.txt#12 edit Differences ... ==== //depot/projects/vimage/porting_to_vimage.txt#12 (text+ko) ==== @@ -1,4 +1,4 @@ -July 13 2008 +July 7 2009 Julian Elischer =================== @@ -299,6 +299,22 @@ break; case MOD_SHUTDOWN: + /* + * this is called once but you may want to shut down + * things in each jail. + */ + { + VNET_ITERATOR_DECL(vnet_iter); + VNET_LIST_RLOCK(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + mymod_vnet_uninit(NULL); + CURVNET_RESTORE(); + } + VNET_LIST_RUNLOCK(); + } + /* you may need to shutdown something global. */ + mymod_destroy(); break; default: @@ -358,8 +374,6 @@ On system shutdown: [check/fix this ] MODEVENT(shutdown) - ? VNET_SYSUNINIT called for every jail/vnet - ? SYSUNINIT NOTICE that while the order of the SYSINIT and VNET_SYSINIT is reversed from that of SYSUNINIT and VNET_SYSUNINIT, MODEVENTS do not follow @@ -382,25 +396,7 @@ (but not the modevent). Sometimes there is a need to iterate through the vnets. -The following code should be used as a guide. - - VNET_ITERATOR_DECL(vnet_iter); - [...] - - [...] - VNET_LIST_RLOCK(); - VNET_FOREACH(vnet_iter) { - CURVNET_SET(vnet_iter); - [...] - do work, - including calling code that assumes we have curvnet set. - [...] - CURVNET_RESTORE(); - } - VNET_LIST_RUNLOCK(); - [...] -} - +See the modevent shutdown handler (above) for an example of how to do this. finally: The command to make a new jail with a new vnet: