14af18995SSascha Wildner.\" 298b2ba80SSascha Wildner.\" Copyright (c) 2006, 2007 34af18995SSascha Wildner.\" The DragonFly Project. All rights reserved. 44af18995SSascha Wildner.\" 54af18995SSascha Wildner.\" Redistribution and use in source and binary forms, with or without 64af18995SSascha Wildner.\" modification, are permitted provided that the following conditions 74af18995SSascha Wildner.\" are met: 84af18995SSascha Wildner.\" 94af18995SSascha Wildner.\" 1. Redistributions of source code must retain the above copyright 104af18995SSascha Wildner.\" notice, this list of conditions and the following disclaimer. 114af18995SSascha Wildner.\" 2. Redistributions in binary form must reproduce the above copyright 124af18995SSascha Wildner.\" notice, this list of conditions and the following disclaimer in 134af18995SSascha Wildner.\" the documentation and/or other materials provided with the 144af18995SSascha Wildner.\" distribution. 154af18995SSascha Wildner.\" 3. Neither the name of The DragonFly Project nor the names of its 164af18995SSascha Wildner.\" contributors may be used to endorse or promote products derived 174af18995SSascha Wildner.\" from this software without specific, prior written permission. 184af18995SSascha Wildner.\" 194af18995SSascha Wildner.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 204af18995SSascha Wildner.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 214af18995SSascha Wildner.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 224af18995SSascha Wildner.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 234af18995SSascha Wildner.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 244af18995SSascha Wildner.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 254af18995SSascha Wildner.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 264af18995SSascha Wildner.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 274af18995SSascha Wildner.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 284af18995SSascha Wildner.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 294af18995SSascha Wildner.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304af18995SSascha Wildner.\" SUCH DAMAGE. 314af18995SSascha Wildner.\" 32f37681eeSAaron LI.Dd December 27, 2018 334af18995SSascha Wildner.Dt VKERNEL 7 344af18995SSascha Wildner.Os 354af18995SSascha Wildner.Sh NAME 360592e24dSSascha Wildner.Nm vkernel , 3798b2ba80SSascha Wildner.Nm vcd , 380592e24dSSascha Wildner.Nm vkd , 390592e24dSSascha Wildner.Nm vke 404af18995SSascha Wildner.Nd virtual kernel architecture 414af18995SSascha Wildner.Sh SYNOPSIS 42b6a66df5SSascha Wildner.Cd "platform vkernel64 # for 64 bit vkernels" 4398b2ba80SSascha Wildner.Cd "device vcd" 44c8e7d028SSascha Wildner.Cd "device vkd" 45c8e7d028SSascha Wildner.Cd "device vke" 46c8e7d028SSascha Wildner.Pp 471a92ebbbSSamuel J. Greear.Pa /var/vkernel/boot/kernel/kernel 48c5f1256bSMatthew Dillon.Op Fl hdstUvz 49a72d8a9fSMatthew Dillon.Op Fl c Ar file 5009b03fffSSascha Wildner.Op Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ... 51dd54cb3aSSascha Wildner.Op Fl i Ar file 52cbbd1e6dSAntonio Huete Jimenez.Op Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc Ns Oo Ar =mac Oc 53702acf06SJoe Talbott.Op Fl l Ar cpulock 544af18995SSascha Wildner.Op Fl m Ar size 559bea6114SMihai Carabas.Op Fl n Ar numcpus Ns Op Ar :lbits Ns Oo Ar :cbits Oc 56bc3cc25eSMatthew Dillon.Op Fl p Ar pidfile 572a4f37b8SAntonio Huete Jimenez.Op Fl r Ar file Ns Op Ar :serno 5854ea00b8SMatthew Dillon.Op Fl R Ar file Ns Op Ar :serno 594af18995SSascha Wildner.Sh DESCRIPTION 604af18995SSascha WildnerThe 614af18995SSascha Wildner.Nm 624af18995SSascha Wildnerarchitecture allows for running 634af18995SSascha Wildner.Dx 644af18995SSascha Wildnerkernels in userland. 654af18995SSascha Wildner.Pp 664af18995SSascha WildnerThe following options are available: 674af18995SSascha Wildner.Bl -tag -width ".Fl m Ar size" 68a72d8a9fSMatthew Dillon.It Fl c Ar file 697834fbccSSascha WildnerSpecify a readonly CD-ROM image 70a72d8a9fSMatthew Dillon.Ar file 71a72d8a9fSMatthew Dillonto be used by the kernel, with the first 72a72d8a9fSMatthew Dillon.Fl c 73a72d8a9fSMatthew Dillonoption defining 74a72d8a9fSMatthew Dillon.Li vcd0 , 75a72d8a9fSMatthew Dillonthe second one 76a72d8a9fSMatthew Dillon.Li vcd1 , 7762aea38eSSascha Wildnerand so on. 7862aea38eSSascha WildnerThe first 7954ea00b8SMatthew Dillon.Fl r , 8054ea00b8SMatthew Dillon.Fl R , 81a72d8a9fSMatthew Dillonor 82a72d8a9fSMatthew Dillon.Fl c 83a72d8a9fSMatthew Dillonoption specified on the command line will be the boot disk. 847834fbccSSascha WildnerThe CD9660 filesystem is assumed when booting from this media. 85822dfb20SSascha Wildner.It Fl d 86822dfb20SSascha WildnerDisables hardware pagetable for 87822dfb20SSascha Wildner.Nm . 8809b03fffSSascha Wildner.It Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ... 8909b03fffSSascha WildnerSpecify an environment to be used by the kernel. 90974f8ffeSAntonio Huete JimenezThis option can be specified more than once. 91278c4e67SSamuel J. Greear.It Fl h 92278c4e67SSamuel J. GreearShows a list of available options, each with a short description. 93dd54cb3aSSascha Wildner.It Fl i Ar file 94dd54cb3aSSascha WildnerSpecify a memory image 95dd54cb3aSSascha Wildner.Ar file 96dd54cb3aSSascha Wildnerto be used by the virtual kernel. 97dd54cb3aSSascha WildnerIf no 98dd54cb3aSSascha Wildner.Fl i 99dd54cb3aSSascha Wildneroption is given, the kernel will generate a name of the form 100dd54cb3aSSascha Wildner.Pa /var/vkernel/memimg.XXXXXX , 101dd54cb3aSSascha Wildnerwith the trailing 102dd54cb3aSSascha Wildner.Ql X Ns s 103dd54cb3aSSascha Wildnerbeing replaced by a sequential number, e.g.\& 104dd54cb3aSSascha Wildner.Pa memimg.000001 . 10586d2b040SAntonio Huete Jimenez.It Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc Ns Oo Ar =MAC Oc 10609b03fffSSascha WildnerCreate a virtual network device, with the first 10709b03fffSSascha Wildner.Fl I 10809b03fffSSascha Wildneroption defining 1090592e24dSSascha Wildner.Li vke0 , 11009b03fffSSascha Wildnerthe second one 1110592e24dSSascha Wildner.Li vke1 , 11209b03fffSSascha Wildnerand so on. 11309b03fffSSascha Wildner.Pp 11409b03fffSSascha WildnerThe 11509b03fffSSascha Wildner.Ar interface 11609b03fffSSascha Wildnerargument is the name of a 11709b03fffSSascha Wildner.Xr tap 4 118bc3cc25eSMatthew Dillondevice node or the path to a 119bc3cc25eSMatthew Dillon.Xr vknetd 8 120bc3cc25eSMatthew Dillonsocket. 12109b03fffSSascha WildnerThe 12209b03fffSSascha Wildner.Pa /dev/ 123bc3cc25eSMatthew Dillonpath prefix does not have to be specified and will be automatically prepended 124bc3cc25eSMatthew Dillonfor a device node. 12509b03fffSSascha WildnerSpecifying 12609b03fffSSascha Wildner.Cm auto 12709b03fffSSascha Wildnerwill pick the first unused 12809b03fffSSascha Wildner.Xr tap 4 12909b03fffSSascha Wildnerdevice. 13009b03fffSSascha Wildner.Pp 13109b03fffSSascha WildnerThe 13209b03fffSSascha Wildner.Ar address1 13309b03fffSSascha Wildnerand 13409b03fffSSascha Wildner.Ar address2 13509b03fffSSascha Wildnerarguments are the IP addresses of the 13609b03fffSSascha Wildner.Xr tap 4 13709b03fffSSascha Wildnerand 1380592e24dSSascha Wildner.Nm vke 13909b03fffSSascha Wildnerinterfaces. 14009b03fffSSascha WildnerOptionally, 14109b03fffSSascha Wildner.Ar address1 14209b03fffSSascha Wildnermay be of the form 14309b03fffSSascha Wildner.Li bridge Ns Em X 14409b03fffSSascha Wildnerin which case the 14509b03fffSSascha Wildner.Xr tap 4 14609b03fffSSascha Wildnerinterface is added to the specified 14709b03fffSSascha Wildner.Xr bridge 4 14809b03fffSSascha Wildnerinterface. 149a8cc122dSSascha WildnerThe 150a8cc122dSSascha Wildner.Nm vke 151a8cc122dSSascha Wildneraddress is not assigned until the interface is brought up in the guest. 15209b03fffSSascha Wildner.Pp 15309b03fffSSascha WildnerThe 15409b03fffSSascha Wildner.Ar netmask 15509b03fffSSascha Wildnerargument applies to all interfaces for which an address is specified. 156bc3cc25eSMatthew Dillon.Pp 15786d2b040SAntonio Huete JimenezThe 15886d2b040SAntonio Huete Jimenez.Ar MAC 15986d2b040SAntonio Huete Jimenezargument is the MAC address of the 16086d2b040SAntonio Huete Jimenez.Xr vke 4 16186d2b040SAntonio Huete Jimenezinterface. 16286d2b040SAntonio Huete JimenezIf not specified, a pseudo-random one will be generated. 16386d2b040SAntonio Huete Jimenez.Pp 164bc3cc25eSMatthew DillonWhen running multiple vkernels it is often more convenient to simply 165bc3cc25eSMatthew Dillonconnect to a 166bc3cc25eSMatthew Dillon.Xr vknetd 8 167c6e9e022SSascha Wildnersocket and let vknetd deal with the tap and/or bridge. 168c6e9e022SSascha WildnerAn example of this would be 169c6e9e022SSascha Wildner.Pa /var/run/vknet:0.0.0.0:10.2.0.2/16 . 170702acf06SJoe Talbott.It Fl l Ar cpulock 171702acf06SJoe TalbottSpecify which, if any, real CPUs to lock virtual CPUs to. 172702acf06SJoe Talbott.Ar cpulock 173702acf06SJoe Talbottis one of 174702acf06SJoe Talbott.Cm any , 17526ea2793SSascha Wildner.Cm map Ns Op Ns , Ns Ar startCPU , 17626ea2793SSascha Wildneror 17726ea2793SSascha Wildner.Ar CPU . 178702acf06SJoe Talbott.Pp 179702acf06SJoe Talbott.Cm any 18026ea2793SSascha Wildnerdoes not map virtual CPUs to real CPUs. 18126ea2793SSascha WildnerThis is the default. 182702acf06SJoe Talbott.Pp 183702acf06SJoe Talbott.Cm map Ns Op Ns , Ns Ar startCPU 184702acf06SJoe Talbottmaps each virtual CPU to a real CPU starting with real CPU 0 or 185702acf06SJoe Talbott.Ar startCPU 186702acf06SJoe Talbottif specified. 187702acf06SJoe Talbott.Pp 188702acf06SJoe Talbott.Ar CPU 18926ea2793SSascha Wildnerlocks all virtual CPUs to the real CPU specified by 19026ea2793SSascha Wildner.Ar CPU . 191c5f1256bSMatthew Dillon.Pp 192c5f1256bSMatthew DillonLocking the vkernel to a set of cpus is recommended on multi-socket systems 193c5f1256bSMatthew Dillonto improve NUMA locality of reference. 1944af18995SSascha Wildner.It Fl m Ar size 1954af18995SSascha WildnerSpecify the amount of memory to be used by the kernel in bytes, 1964af18995SSascha Wildner.Cm K 1973cea05a4SSascha Wildner.Pq kilobytes , 1984af18995SSascha Wildner.Cm M 1993cea05a4SSascha Wildner.Pq megabytes 2003cea05a4SSascha Wildneror 2014af18995SSascha Wildner.Cm G 2023cea05a4SSascha Wildner.Pq gigabytes . 20309b03fffSSascha WildnerLowercase versions of 2044af18995SSascha Wildner.Cm K , M , 2054af18995SSascha Wildnerand 2064af18995SSascha Wildner.Cm G 2074af18995SSascha Wildnerare allowed. 2089bea6114SMihai Carabas.It Fl n Ar numcpus Ns Op Ar :lbits Ns Oo Ar :cbits Oc 2099bea6114SMihai Carabas.Ar numcpus 2109bea6114SMihai Carabasspecifies the number of CPUs you wish to emulate. 2116e837288SSascha WildnerUp to 16 CPUs are supported with 2 being the default unless otherwise 2126e837288SSascha Wildnerspecified. 21382065d92SSascha Wildner.Pp 2149bea6114SMihai Carabas.Ar lbits 2159bea6114SMihai Carabasspecifies the number of bits within APICID(=CPUID) needed for representing 2169bea6114SMihai Carabasthe logical ID. 2179bea6114SMihai CarabasControls the number of threads/core (0 bits - 1 thread, 1 bit - 2 threads). 2189bea6114SMihai CarabasThis parameter is optional (mandatory only if 2199bea6114SMihai Carabas.Ar cbits 2209bea6114SMihai Carabasis specified). 22182065d92SSascha Wildner.Pp 2229bea6114SMihai Carabas.Ar cbits 2239bea6114SMihai Carabasspecifies the number of bits within APICID(=CPUID) needed for representing 2249bea6114SMihai Carabasthe core ID. 2259bea6114SMihai CarabasControls the number of core/package (0 bits - 1 core, 1 bit - 2 cores). 2269bea6114SMihai CarabasThis parameter is optional. 227bc3cc25eSMatthew Dillon.It Fl p Ar pidfile 228bc3cc25eSMatthew DillonSpecify a pidfile in which to store the process ID. 229bc3cc25eSMatthew DillonScripts can use this file to locate the vkernel pid for the purpose of 230bc3cc25eSMatthew Dillonshutting down or killing it. 231bc3cc25eSMatthew Dillon.Pp 232bc3cc25eSMatthew DillonThe vkernel will hold a lock on the pidfile while running. 233bc3cc25eSMatthew DillonScripts may test for the lock to determine if the pidfile is valid or 23467cdc5a5SSascha Wildnerstale so as to avoid accidentally killing a random process. 235bc3cc25eSMatthew DillonSomething like '/usr/bin/lockf -ks -t 0 pidfile echo -n' may be used 236bc3cc25eSMatthew Dillonto test the lock. 237bc3cc25eSMatthew DillonA non-zero exit code indicates that the pidfile represents a running 238bc3cc25eSMatthew Dillonvkernel. 239bc3cc25eSMatthew Dillon.Pp 240bc3cc25eSMatthew DillonAn error is issued and the vkernel exits if this file cannot be opened for 241bc3cc25eSMatthew Dillonwriting or if it is already locked by an active vkernel process. 2422a4f37b8SAntonio Huete Jimenez.It Fl r Ar file Ns Op Ar :serno 243a72d8a9fSMatthew DillonSpecify a R/W disk image 2444af18995SSascha Wildner.Ar file 245ec1a8a4dSSascha Wildnerto be used by the kernel, with the first 246ec1a8a4dSSascha Wildner.Fl r 247ec1a8a4dSSascha Wildneroption defining 2480592e24dSSascha Wildner.Li vkd0 , 249ec1a8a4dSSascha Wildnerthe second one 2500592e24dSSascha Wildner.Li vkd1 , 25162aea38eSSascha Wildnerand so on. 2522a4f37b8SAntonio Huete JimenezA serial number for the virtual disk can be specified in 2532a4f37b8SAntonio Huete Jimenez.Ar serno . 2542a4f37b8SAntonio Huete Jimenez.Pp 25562aea38eSSascha WildnerThe first 256a72d8a9fSMatthew Dillon.Fl r 257a72d8a9fSMatthew Dillonor 258a72d8a9fSMatthew Dillon.Fl c 259a72d8a9fSMatthew Dillonoption specified on the command line will be the boot disk. 26054ea00b8SMatthew Dillon.It Fl R Ar file Ns Op Ar :serno 26154ea00b8SMatthew DillonWorks like 26254ea00b8SMatthew Dillon.Fl r 26354ea00b8SMatthew Dillonbut treats the disk image as copy-on-write. This allows 26454ea00b8SMatthew Dillona private copy of the image to be modified but does not 26554ea00b8SMatthew Dillonmodify the image file. The image file will not be locked 26654ea00b8SMatthew Dillonin this situation and multiple vkernels can run off the 26754ea00b8SMatthew Dillonsame image file if desired. 26854ea00b8SMatthew Dillon.Pp 26954ea00b8SMatthew DillonSince modifications are thrown away, any data you wish 27054ea00b8SMatthew Dillonto retain across invocations needs to be exported over 27154ea00b8SMatthew Dillonthe network prior to shutdown. 27254ea00b8SMatthew DillonThis gives you the flexibility to mount the disk image 27354ea00b8SMatthew Dilloneither read-only or read-write depending on what is 27454ea00b8SMatthew Dillonconvenient. 27554ea00b8SMatthew DillonHowever, keep in mind that when mounting a COW image 27654ea00b8SMatthew Dillonread-write, modifications will eat system memory and 27754ea00b8SMatthew Dillonswap space until the vkernel is shut down. 278c8e7d028SSascha Wildner.It Fl s 279c8e7d028SSascha WildnerBoot into single-user mode. 280dc1b9d13SMatthew Dillon.It Fl t 281dc1b9d13SMatthew DillonTell the vkernel to use a precise host timer when calculating clock values. 2827b21e5e4SImre VadászIf the TSC isn't used, this will impose higher overhead on the vkernel as it 2837b21e5e4SImre Vadászwill have to make a system call to the real host every time it wants to get 2847b21e5e4SImre Vadászthe time. 285dc1b9d13SMatthew DillonHowever, the more precise timer might be necessary for your application. 286dc1b9d13SMatthew Dillon.Pp 2877b21e5e4SImre VadászBy default, the vkernel uses the TSC cpu timer if possible, or an imprecise 288f37681eeSAaron LI(host-tick-resolution) timer which uses a user-mapped kernel page and does 2897b21e5e4SImre Vadásznot have any syscall overhead. 290*fab26d8fSImre VadászTo disable the TSC cpu timer, use the 291*fab26d8fSImre Vadász.Fl e Ar hw.tsc_cputimer_enable=0 292*fab26d8fSImre Vadászflag. 29303071031SSascha Wildner.It Fl U 29403071031SSascha WildnerEnable writing to kernel memory and module loading. 29503071031SSascha WildnerBy default, those are disabled for security reasons. 2964af18995SSascha Wildner.It Fl v 2974af18995SSascha WildnerTurn on verbose booting. 298c5f1256bSMatthew Dillon.It Fl z 299c5f1256bSMatthew DillonForce the vkernel's ram to be pre-zerod. Useful for benchmarking on 300c5f1256bSMatthew Dillonsingle-socket systems where the memory allocation does not have to be 301c5f1256bSMatthew DillonNUMA-friendly. 302c5f1256bSMatthew DillonThis options is not recommended on multi-socket systems or when the 303c5f1256bSMatthew Dillon.Fl l 304c5f1256bSMatthew Dillonoption is used. 3054af18995SSascha Wildner.El 3060592e24dSSascha Wildner.Sh DEVICES 3070592e24dSSascha WildnerA number of virtual device drivers exist to supplement the virtual kernel. 3080592e24dSSascha Wildner.Ss Disk device 3090592e24dSSascha WildnerThe 3100592e24dSSascha Wildner.Nm vkd 3110592e24dSSascha Wildnerdriver allows for up to 16 3120592e24dSSascha Wildner.Xr vn 4 3130592e24dSSascha Wildnerbased disk devices. 3140592e24dSSascha WildnerThe root device will be 3150592e24dSSascha Wildner.Li vkd0 3160592e24dSSascha Wildner(see 3170592e24dSSascha Wildner.Sx EXAMPLES 3180592e24dSSascha Wildnerfor further information on how to prepare a root image). 31998b2ba80SSascha Wildner.Ss CD-ROM device 32098b2ba80SSascha WildnerThe 32198b2ba80SSascha Wildner.Nm vcd 32298b2ba80SSascha Wildnerdriver allows for up to 16 virtual CD-ROM devices. 32398b2ba80SSascha WildnerBasically this is a read only 32498b2ba80SSascha Wildner.Nm vkd 32598b2ba80SSascha Wildnerdevice with a block size of 2048. 3260592e24dSSascha Wildner.Ss Network interface 3270592e24dSSascha WildnerThe 3280592e24dSSascha Wildner.Nm vke 3290592e24dSSascha Wildnerdriver supports up to 16 virtual network interfaces which are associated with 3300592e24dSSascha Wildner.Xr tap 4 3310592e24dSSascha Wildnerdevices on the host. 3320592e24dSSascha WildnerFor each 3330592e24dSSascha Wildner.Nm vke 3340592e24dSSascha Wildnerdevice, the per-interface read only 3350592e24dSSascha Wildner.Xr sysctl 3 3360592e24dSSascha Wildnervariable 3370592e24dSSascha Wildner.Va hw.vke Ns Em X Ns Va .tap_unit 3380592e24dSSascha Wildnerholds the unit number of the associated 3390592e24dSSascha Wildner.Xr tap 4 3400592e24dSSascha Wildnerdevice. 34133c27d6cSAntonio Huete Jimenez.Pp 34233c27d6cSAntonio Huete JimenezBy default, half of the total mbuf clusters available is distributed equally 343c6e9e022SSascha Wildneramong all the vke devices up to 256. 34449af6f0fSSascha WildnerThis can be overridden with the tunable 34533c27d6cSAntonio Huete Jimenez.Va hw.vke.max_ringsize . 34633c27d6cSAntonio Huete JimenezTake into account the number passed will be aligned to the lower power of two. 3471e4d9fd9SSascha Wildner.Sh SIGNALS 348bb195a01SMatthew DillonThe virtual kernel only enables 349bb195a01SMatthew Dillon.Dv SIGQUIT 350bb195a01SMatthew Dillonand 351bb195a01SMatthew Dillon.Dv SIGTERM 352bb195a01SMatthew Dillonwhile operating in regular console mode. 353bb195a01SMatthew DillonSending 3541e4d9fd9SSascha Wildner.Ql \&^\e 3551e4d9fd9SSascha Wildner.Pq Dv SIGQUIT 356bb195a01SMatthew Dillonto the virtual kernel causes the virtual kernel to enter its internal 3571e4d9fd9SSascha Wildner.Xr ddb 4 358bb195a01SMatthew Dillondebugger and re-enable all other terminal signals. 359bb195a01SMatthew DillonSending 360bb195a01SMatthew Dillon.Dv SIGTERM 361bb195a01SMatthew Dillonto the virtual kernel triggers a clean shutdown by passing a 362bb195a01SMatthew Dillon.Dv SIGUSR2 363bb195a01SMatthew Dillonto the virtual kernel's 364bb195a01SMatthew Dillon.Xr init 8 365bb195a01SMatthew Dillonprocess. 366974b26bfSSascha Wildner.Sh DEBUGGING 367974b26bfSSascha WildnerIt is possible to directly gdb the virtual kernel's process. 368974b26bfSSascha WildnerIt is recommended that you do a 369974b26bfSSascha Wildner.Ql handle SIGSEGV noprint 3704010bf94SNicolas Theryto ignore page faults processed by the virtual kernel itself and 371e7c2f376SNicolas Thery.Ql handle SIGUSR1 noprint 37220ce32a9SSascha Wildnerto ignore signals used for simulating inter-processor interrupts. 373b96eeefdSSascha Wildner.Sh PROFILING 374b96eeefdSSascha WildnerTo compile a vkernel with profiling support, the 375b96eeefdSSascha Wildner.Va CONFIGARGS 376b96eeefdSSascha Wildnervariable needs to be used to pass 377b96eeefdSSascha Wildner.Fl p 378b96eeefdSSascha Wildnerto 379b96eeefdSSascha Wildner.Xr config 8 . 380b96eeefdSSascha Wildner.Bd -literal 381b96eeefdSSascha Wildnercd /usr/src 382dd7331feSSascha Wildnermake -DNO_MODULES CONFIGARGS=-p buildkernel KERNCONF=VKERNEL64 383b96eeefdSSascha Wildner.Ed 384a154d422SThomas Nikolajsen.Sh FILES 385ec363e75SSascha Wildner.Bl -tag -width ".It Pa /sys/config/VKERNEL64" -compact 386ec363e75SSascha Wildner.It Pa /dev/vcdX 387ec363e75SSascha Wildner.Nm vcd 388ec363e75SSascha Wildnerdevice nodes 389ec363e75SSascha Wildner.It Pa /dev/vkdX 390ec363e75SSascha Wildner.Nm vkd 391ec363e75SSascha Wildnerdevice nodes 392163fd4e7SAntonio Huete Jimenez.It Pa /sys/config/VKERNEL64 393a154d422SThomas Nikolajsen.El 394163fd4e7SAntonio Huete Jimenez.Pp 395163fd4e7SAntonio Huete Jimenez.Nm 396dd7331feSSascha Wildnerconfiguration file, for 397163fd4e7SAntonio Huete Jimenez.Xr config 8 . 398a68e0df0SSascha Wildner.Sh CONFIGURATION FILES 399a68e0df0SSascha WildnerYour virtual kernel is a complete 400a68e0df0SSascha Wildner.Dx 401a68e0df0SSascha Wildnersystem, but you might not want to run all the services a normal kernel runs. 402a68e0df0SSascha WildnerHere is what a typical virtual kernel's 403a68e0df0SSascha Wildner.Pa /etc/rc.conf 404a68e0df0SSascha Wildnerfile looks like, with some additional possibilities commented out. 405a68e0df0SSascha Wildner.Bd -literal 406a68e0df0SSascha Wildnerhostname="vkernel" 407a68e0df0SSascha Wildnernetwork_interfaces="lo0 vke0" 408a68e0df0SSascha Wildnerifconfig_vke0="DHCP" 409a68e0df0SSascha Wildnersendmail_enable="NO" 410a68e0df0SSascha Wildner#syslog_enable="NO" 411a68e0df0SSascha Wildnerblanktime="NO" 412a68e0df0SSascha Wildner.Ed 41354ea00b8SMatthew Dillon.Sh BOOT DRIVE SELECTION 41454ea00b8SMatthew DillonYou can override the default boot drive selection and filesystem 41554ea00b8SMatthew Dillonusing a kernel environment variable. Note that the filesystem 41654ea00b8SMatthew Dillonselected must be compiled into the vkernel and not loaded as 41754ea00b8SMatthew Dillona module. You need to escape some quotes around the variable data 41854ea00b8SMatthew Dillonto avoid mis-interpretation of the colon in the 41954ea00b8SMatthew Dillon.Fl e 42054ea00b8SMatthew Dillonoption. For example: 42154ea00b8SMatthew Dillon.Pp 42254ea00b8SMatthew Dillon.Fl e 42354ea00b8SMatthew Dillonvfs.root.mountfrom=\\"hammer:vkd0s1d\\" 424163fd4e7SAntonio Huete Jimenez.Sh DISKLESS OPERATION 425163fd4e7SAntonio Huete JimenezTo boot a 426163fd4e7SAntonio Huete Jimenez.Nm 427163fd4e7SAntonio Huete Jimenezfrom a NFS root, a number of tunables need to be set: 428163fd4e7SAntonio Huete Jimenez.Bl -tag -width indent 429163fd4e7SAntonio Huete Jimenez.It Va boot.netif.ip 430163fd4e7SAntonio Huete JimenezIP address to be set in the vkernel interface. 431163fd4e7SAntonio Huete Jimenez.It Va boot.netif.netmask 432163fd4e7SAntonio Huete JimenezNetmask for the IP to be set. 433163fd4e7SAntonio Huete Jimenez.It Va boot.netif.name 434163fd4e7SAntonio Huete JimenezNetwork interface name inside the vkernel. 435163fd4e7SAntonio Huete Jimenez.It Va boot.nfsroot.server 436163fd4e7SAntonio Huete JimenezHost running 437163fd4e7SAntonio Huete Jimenez.Xr nfsd 8 . 438163fd4e7SAntonio Huete Jimenez.It Va boot.nfsroot.path 439163fd4e7SAntonio Huete JimenezHost path where a world and distribution 440163fd4e7SAntonio Huete Jimeneztargets are properly installed. 441163fd4e7SAntonio Huete Jimenez.El 442163fd4e7SAntonio Huete Jimenez.Pp 443163fd4e7SAntonio Huete JimenezSee an example on how to boot a diskless 444163fd4e7SAntonio Huete Jimenez.Nm 445163fd4e7SAntonio Huete Jimenezin the 446163fd4e7SAntonio Huete Jimenez.Sx EXAMPLES 447163fd4e7SAntonio Huete Jimenezsection. 448c8e7d028SSascha Wildner.Sh EXAMPLES 4494af18995SSascha WildnerA couple of steps are necessary in order to prepare the system to build and 4504af18995SSascha Wildnerrun a virtual kernel. 4514af18995SSascha Wildner.Ss Setting up the filesystem 4524af18995SSascha WildnerThe 4534af18995SSascha Wildner.Nm 4544af18995SSascha Wildnerarchitecture needs a number of files which reside in 4554af18995SSascha Wildner.Pa /var/vkernel . 4564af18995SSascha WildnerSince these files tend to get rather big and the 4574af18995SSascha Wildner.Pa /var 4584af18995SSascha Wildnerpartition is usually of limited size, we recommend the directory to be 4594af18995SSascha Wildnercreated in the 4604af18995SSascha Wildner.Pa /home 4614af18995SSascha Wildnerpartition with a link to it in 4624af18995SSascha Wildner.Pa /var : 463c8e7d028SSascha Wildner.Bd -literal 464c009fcfaSThomas Nikolajsenmkdir -p /home/var.vkernel/boot 4654af18995SSascha Wildnerln -s /home/var.vkernel /var/vkernel 4664af18995SSascha Wildner.Ed 4674af18995SSascha Wildner.Pp 4684af18995SSascha WildnerNext, a filesystem image to be used by the virtual kernel has to be 46962aea38eSSascha Wildnercreated and populated (assuming world has been built previously). 47062aea38eSSascha WildnerIf the image is created on a UFS filesystem you might want to pre-zero it. 47149802d4eSMatthew DillonOn a HAMMER filesystem you should just truncate-extend to the image size 47249802d4eSMatthew Dillonas HAMMER does not re-use data blocks already present in the file. 473c8e7d028SSascha Wildner.Bd -literal 474f73862c5SSascha Wildnervnconfig -c -S 2g -T vn0 /var/vkernel/rootimg.01 47558c55700SSascha Wildnerdisklabel -r -w vn0s0 auto 476c009fcfaSThomas Nikolajsendisklabel -e vn0s0 # add `a' partition with fstype `4.2BSD' 47758c55700SSascha Wildnernewfs /dev/vn0s0a 47858c55700SSascha Wildnermount /dev/vn0s0a /mnt 479c8e7d028SSascha Wildnercd /usr/src 480c8e7d028SSascha Wildnermake installworld DESTDIR=/mnt 481c8e7d028SSascha Wildnercd etc 482c8e7d028SSascha Wildnermake distribution DESTDIR=/mnt 4837a3238b8SMatthew Dillonecho '/dev/vkd0s0a / ufs rw 1 1' >/mnt/etc/fstab 4847a3238b8SMatthew Dillonecho 'proc /proc procfs rw 0 0' >>/mnt/etc/fstab 4857834fbccSSascha Wildner.Ed 4867834fbccSSascha Wildner.Pp 4877834fbccSSascha WildnerEdit 4887834fbccSSascha Wildner.Pa /mnt/etc/ttys 4897834fbccSSascha Wildnerand replace the 4907834fbccSSascha Wildner.Li console 4917834fbccSSascha Wildnerentry with the following line and turn off all other gettys. 4927834fbccSSascha Wildner.Bd -literal 4937834fbccSSascha Wildnerconsole "/usr/libexec/getty Pc" cons25 on secure 4947834fbccSSascha Wildner.Ed 4957834fbccSSascha Wildner.Pp 496eed435ddSStathis KamperisReplace 497eed435ddSStathis Kamperis.Li \&Pc 498eed435ddSStathis Kamperiswith 499eed435ddSStathis Kamperis.Li al.Pc 500eed435ddSStathis Kamperisif you would like to automatically log in as root. 501eed435ddSStathis Kamperis.Pp 5027834fbccSSascha WildnerThen, unmount the disk. 5037834fbccSSascha Wildner.Bd -literal 5044af18995SSascha Wildnerumount /mnt 5054af18995SSascha Wildnervnconfig -u vn0 5064af18995SSascha Wildner.Ed 5074af18995SSascha Wildner.Ss Compiling the virtual kernel 5084af18995SSascha WildnerIn order to compile a virtual kernel use the 509dd7331feSSascha Wildner.Li VKERNEL64 5104af18995SSascha Wildnerkernel configuration file residing in 511a154d422SThomas Nikolajsen.Pa /sys/config 5124af18995SSascha Wildner(or a configuration file derived thereof): 513c8e7d028SSascha Wildner.Bd -literal 5144af18995SSascha Wildnercd /usr/src 515dd7331feSSascha Wildnermake -DNO_MODULES buildkernel KERNCONF=VKERNEL64 516dd7331feSSascha Wildnermake -DNO_MODULES installkernel KERNCONF=VKERNEL64 DESTDIR=/var/vkernel 5174af18995SSascha Wildner.Ed 5184af18995SSascha Wildner.Ss Enabling virtual kernel operation 5194af18995SSascha WildnerA special 5204af18995SSascha Wildner.Xr sysctl 8 , 5214af18995SSascha Wildner.Va vm.vkernel_enable , 5224af18995SSascha Wildnermust be set to enable 5234af18995SSascha Wildner.Nm 5244af18995SSascha Wildneroperation: 525c8e7d028SSascha Wildner.Bd -literal 5264af18995SSascha Wildnersysctl vm.vkernel_enable=1 5274af18995SSascha Wildner.Ed 52809b03fffSSascha Wildner.Ss Configuring the network on the host system 52909b03fffSSascha WildnerIn order to access a network interface of the host system from the 53009b03fffSSascha Wildner.Nm , 53109b03fffSSascha Wildneryou must add the interface to a 53209b03fffSSascha Wildner.Xr bridge 4 53309b03fffSSascha Wildnerdevice which will then be passed to the 53409b03fffSSascha Wildner.Fl I 53509b03fffSSascha Wildneroption: 53609b03fffSSascha Wildner.Bd -literal 53709b03fffSSascha Wildnerkldload if_bridge.ko 53809b03fffSSascha Wildnerkldload if_tap.ko 53909b03fffSSascha Wildnerifconfig bridge0 create 54009b03fffSSascha Wildnerifconfig bridge0 addm re0 # assuming re0 is the host's interface 54109b03fffSSascha Wildnerifconfig bridge0 up 54209b03fffSSascha Wildner.Ed 5434af18995SSascha Wildner.Ss Running the kernel 5444af18995SSascha WildnerFinally, the virtual kernel can be run: 545c8e7d028SSascha Wildner.Bd -literal 54679b58aaeSMatthew Dilloncd /var/vkernel 5477374a7a6SMatthew Dillon\&./boot/kernel/kernel -m 1g -r rootimg.01 -I auto:bridge0 5484af18995SSascha Wildner.Ed 549c8e7d028SSascha Wildner.Pp 55079b58aaeSMatthew DillonYou can issue the 55179b58aaeSMatthew Dillon.Xr reboot 8 , 55279b58aaeSMatthew Dillon.Xr halt 8 , 55379b58aaeSMatthew Dillonor 55479b58aaeSMatthew Dillon.Xr shutdown 8 55579b58aaeSMatthew Dilloncommands from inside a virtual kernel. 55679b58aaeSMatthew DillonAfter doing a clean shutdown the 557c8e7d028SSascha Wildner.Xr reboot 8 55879b58aaeSMatthew Dilloncommand will re-exec the virtual kernel binary while the other two will 55979b58aaeSMatthew Dilloncause the virtual kernel to exit. 5607374a7a6SMatthew Dillon.Ss Diskless operation (vkernel as a NFS client) 561163fd4e7SAntonio Huete JimenezBooting a 562163fd4e7SAntonio Huete Jimenez.Nm 563163fd4e7SAntonio Huete Jimenezwith a 564163fd4e7SAntonio Huete Jimenez.Xr vknetd 8 5657374a7a6SMatthew Dillonnetwork configuration. The line continuation backslashes have been 5667374a7a6SMatthew Dillonomitted. For convenience and to reduce confusion I recommend mounting 5677374a7a6SMatthew Dillonthe server's remote vkernel root onto the host running the vkernel binary 5687374a7a6SMatthew Dillonusing the same path as the NFS mount. It is assumed that a full system 5697374a7a6SMatthew Dilloninstall has been made to /var/vkernel/root using a kernel KERNCONF=VKERNEL64 5707374a7a6SMatthew Dillonfor the kernel build. 571163fd4e7SAntonio Huete Jimenez.Bd -literal 5727374a7a6SMatthew Dillon\&/var/vkernel/root/boot/kernel/kernel 5737374a7a6SMatthew Dillon -m 1g -n 4 -I /var/run/vknet 5747374a7a6SMatthew Dillon -e boot.netif.ip=10.100.0.2 575163fd4e7SAntonio Huete Jimenez -e boot.netif.netmask=255.255.0.0 5767374a7a6SMatthew Dillon -e boot.netif.gateway=10.100.0.1 577163fd4e7SAntonio Huete Jimenez -e boot.netif.name=vke0 5787374a7a6SMatthew Dillon -e boot.nfsroot.server=10.0.0.55 5797374a7a6SMatthew Dillon -e boot.nfsroot.path=/var/vkernel/root 580163fd4e7SAntonio Huete Jimenez.Ed 5817374a7a6SMatthew Dillon.Pp 5827374a7a6SMatthew DillonIn this example vknetd is assumed to have been started as shown below, before 5837374a7a6SMatthew Dillonrunning the vkernel, using an unbridged TAP configuration routed through 5847374a7a6SMatthew Dillonthe host. 5857374a7a6SMatthew DillonIP forwarding must be turned on, and in this example the server resides 5867374a7a6SMatthew Dillonon a different network accessible to the host executing the vkernel but not 5877374a7a6SMatthew Dillondirectly on the vkernel's subnet. 5887374a7a6SMatthew Dillon.Bd -literal 5897374a7a6SMatthew Dillonkldload if_tap 5907374a7a6SMatthew Dillonsysctl net.inet.ip.forwarding=1 5917374a7a6SMatthew Dillonvknetd -t tap0 10.100.0.1/16 5927374a7a6SMatthew Dillon.Ed 5937374a7a6SMatthew Dillon.Pp 5947374a7a6SMatthew DillonYou can run multiple vkernels trivially with the same NFS root as long as 5957374a7a6SMatthew Dillonyou assign each one a different IP on the subnet (2, 3, 4, etc). You 5967374a7a6SMatthew Dillonshould also be careful with certain directories, particularly /var/run 5977374a7a6SMatthew Dillonand possibly also /var/db depending on what your vkernels are going to be 5987374a7a6SMatthew Dillondoing. 5997374a7a6SMatthew DillonThis can complicate matters with /var/db/pkg. 60034caba04SMatthew Dillon.Sh BUILDING THE WORLD UNDER A VKERNEL 60134caba04SMatthew DillonThe virtual kernel platform does not have all the header files expected 60234caba04SMatthew Dillonby a world build, so the easiest thing to do right now is to specify a 603579b67d2SSascha Wildnerpc64 (in a 64 bit vkernel) target when building the world under a virtual 604579b67d2SSascha Wildnerkernel, like this: 60534caba04SMatthew Dillon.Bd -literal 606579b67d2SSascha Wildnervkernel# make MACHINE_PLATFORM=pc64 buildworld 607579b67d2SSascha Wildnervkernel# make MACHINE_PLATFORM=pc64 installworld 60834caba04SMatthew Dillon.Ed 6094af18995SSascha Wildner.Sh SEE ALSO 610666855caSSascha Wildner.Xr vknet 1 , 61109b03fffSSascha Wildner.Xr bridge 4 , 6128988c073SSascha Wildner.Xr ifmedia 4 , 61309b03fffSSascha Wildner.Xr tap 4 , 614c8e7d028SSascha Wildner.Xr vn 4 , 615a154d422SThomas Nikolajsen.Xr sysctl.conf 5 , 616c8e7d028SSascha Wildner.Xr build 7 , 617b96eeefdSSascha Wildner.Xr config 8 , 618c8e7d028SSascha Wildner.Xr disklabel 8 , 61909b03fffSSascha Wildner.Xr ifconfig 8 , 620dbfd168bSMatthew Dillon.Xr vknetd 8 , 621c8e7d028SSascha Wildner.Xr vnconfig 8 622c203b6f9SSascha Wildner.Rs 623c203b6f9SSascha Wildner.%A Aggelos Economopoulos 624c203b6f9SSascha Wildner.%D March 2007 625c203b6f9SSascha Wildner.%T "A Peek at the DragonFly Virtual Kernel" 626c203b6f9SSascha Wildner.Re 6274af18995SSascha Wildner.Sh HISTORY 6284af18995SSascha WildnerVirtual kernels were introduced in 6294af18995SSascha Wildner.Dx 1.7 . 6304af18995SSascha Wildner.Sh AUTHORS 6314af18995SSascha Wildner.An -nosplit 6324af18995SSascha Wildner.An Matt Dillon 6334af18995SSascha Wildnerthought up and implemented the 6344af18995SSascha Wildner.Nm 6350592e24dSSascha Wildnerarchitecture and wrote the 6360592e24dSSascha Wildner.Nm vkd 6370592e24dSSascha Wildnerdevice driver. 6380592e24dSSascha Wildner.An Sepherosa Ziehau 6390592e24dSSascha Wildnerwrote the 6400592e24dSSascha Wildner.Nm vke 6410592e24dSSascha Wildnerdevice driver. 6424af18995SSascha WildnerThis manual page was written by 6434af18995SSascha Wildner.An Sascha Wildner . 644