From owner-p4-projects@FreeBSD.ORG Fri Aug 15 18:17:33 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6C14610656C3; Fri, 15 Aug 2008 18:17:33 +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 2FA6E10656C8 for ; Fri, 15 Aug 2008 18:17:33 +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 147D18FC14 for ; Fri, 15 Aug 2008 18:17:33 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7FIHXcF031072 for ; Fri, 15 Aug 2008 18:17:33 GMT (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7FIHXfm031070 for perforce@freebsd.org; Fri, 15 Aug 2008 18:17:33 GMT (envelope-from julian@freebsd.org) Date: Fri, 15 Aug 2008 18:17:33 GMT Message-Id: <200808151817.m7FIHXfm031070@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 147478 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, 15 Aug 2008 18:17:33 -0000 http://perforce.freebsd.org/chv.cgi?CH=147478 Change 147478 by julian@julian_trafmon1 on 2008/08/15 18:17:22 Fix nits Affected files ... .. //depot/projects/vimage/porting_to_vimage.txt#7 edit Differences ... ==== //depot/projects/vimage/porting_to_vimage.txt#7 (text+ko) ==== @@ -13,13 +13,13 @@ of selected global state variables with constructs that allow for the virtualized state to be stored and resolved in appropriate instances of module-specific container structures. The code operating on virtualized state -has to conform to a set of rules described further bellow, among other things +has to conform to a set of rules described further below, among other things in order to allow for all the changes to be conditionally compilable, i.e. permitting the virtualized code to fall back to operation on global state. The most visible change throughout the existing code is typically replacement -of direct references to global variables with macros; foo_var thus becomes -V_foo_var. V_foo_bar macros will resolve back to foo_bar global in default +of direct references to global variables with macros; foo_bar thus becomes +V_foo_bar. V_foo_bar macros will resolve back to foo_bar global in default kernel builds, and alternatively to some_base_pointer->_foo_bar for "options VIMAGE" kernel configs. Prepending of "V_" prefixes to variable references helps in visual discrimination between global and virtualized state. The @@ -102,7 +102,7 @@ virtualizable in a particular virtual machine instance. As an example, in a virtualization, one might to allocate a couple of - processors to it, but keep the saem filesystem and network setup, or + processors to it, but keep the same filesystem and network setup, or alternatively to share processors but to have virtualised networking. 3/ If the module is to be virtualised, decide which attributes of the @@ -116,7 +116,7 @@ on a virtual system by virtual system basis. 4/ Work out what global variables and structures are to be virtualised to - achieve the behaviour required for part #2. + achieve the behaviour required for part #3. 5/ Work out for all the code paths through the module, how the path entering the module can divine which virtual environment it is on. @@ -124,10 +124,11 @@ Some examples: * Since interfaces are all assigned to one vnet or another, an incoming packet has a pointer to the receive interface, which in turn has a - pointer back to the vnet. + pointer back to the vnet. Often "curvnet" will already have been set + by the time your code is called anyhow. * Similarly, on any request from outside the kernel, (direct or indirect) the current thread has a way to get to the current virtual environment - instance via td->ucred->vimage. For existig sockets the vnet context + instance via td->ucred->vimage. For existing sockets the vnet context must be used via so->so_vnet since td->ucred->vimage might change after socket creation. * Timer initiated actions usually have a (void *) argument which points to @@ -148,7 +149,7 @@ Details: temp. note: for module FOO add a definition for VNET_MOD_FOO in sys/vimage.h. -Thos will eventually be dynamically assigned. +This will eventually be dynamically assigned. For now these instructions refer mainly to VNET and not VCPU, VPROCG etc. @@ -157,8 +158,10 @@ .h file for just this purpose. If a module will never export virtualise symbols beyond it's borders, then this structure may well just be in a common include file for that module. As an example, common networking -(but not protocol) variables have been moved to a file called net/vnet.h , -the gre module has simply added the virtualisation structure to if_gre.h. +(but not protocol) variables have been moved to a file called net/vnet.h, but +the gre module has simply added the virtualisation structure to if_gre.h as +no code outside the gre interface will access those values. + Accesses to virtualised symbols are achieved via macros, which generally are of the same name as the original symbol but with a "V_" prepended, thus the head of the interface list, called 'ifnet' is replaced whereever @@ -173,15 +176,17 @@ When VIMAGE is compiled in, the macro will evaluate to an access to an element in a structure pointed to by a local varible. For this reason, it is necessary to also add, at the beginning of -these functions another MACRO that will instantiate this local variable +these functions another macro that will instantiate this local variable and point it at the correct place. As an example, prior to using the "V_ifnet" structure in a program block, -we must add the following MACRO at the head of a code block enclosing the +we must add the following macro at the head of a code block enclosing the references to set up module-specific base pointer variable: - INIT_VNET_NET(initial_valu); + + INIT_VNET_NET(initial_value); /* initial value is usually curvnet */ When VIMAGE is not defined, this will evaluate to nothing but when it IS defined, it will evaluate to: + struct vnet_net *vnet_net = (initial_value); The initial value is usually something like "curvnet" which in turn @@ -226,9 +231,9 @@ the first entry here; eventually this should be automatically done by module name. The DEPENDSON field tells us the order that modules should be initialised in a new virtual environment. This may later need -to be changes to a list of text module names for dynamic calculation. -The rest of the fields are self explanatory. -With the exception of the symmap entry. +to be changed to a list of text module names for dynamic calculation. +The rest of the fields are self explanatory, with the exception of the +symmap entry. The symmap allows us to intercept calls by libkvm to the linker when it is looking up symbols and to redirect it dynamically. this allows for example "netstat -r" to find the