xref: /dflybsd-src/share/man/man7/vkernel.7 (revision 82065d92c64009c8ac0cacd446573b1e52faf767)
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.\"
32dd7331feSSascha Wildner.Dd June 20, 2015
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
48*82065d92SSascha Wildner.Op Fl hdsUv
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
584af18995SSascha Wildner.Sh DESCRIPTION
594af18995SSascha WildnerThe
604af18995SSascha Wildner.Nm
614af18995SSascha Wildnerarchitecture allows for running
624af18995SSascha Wildner.Dx
634af18995SSascha Wildnerkernels in userland.
644af18995SSascha Wildner.Pp
654af18995SSascha WildnerThe following options are available:
664af18995SSascha Wildner.Bl -tag -width ".Fl m Ar size"
67a72d8a9fSMatthew Dillon.It Fl c Ar file
687834fbccSSascha WildnerSpecify a readonly CD-ROM image
69a72d8a9fSMatthew Dillon.Ar file
70a72d8a9fSMatthew Dillonto be used by the kernel, with the first
71a72d8a9fSMatthew Dillon.Fl c
72a72d8a9fSMatthew Dillonoption defining
73a72d8a9fSMatthew Dillon.Li vcd0 ,
74a72d8a9fSMatthew Dillonthe second one
75a72d8a9fSMatthew Dillon.Li vcd1 ,
7662aea38eSSascha Wildnerand so on.
7762aea38eSSascha WildnerThe first
78a72d8a9fSMatthew Dillon.Fl r
79a72d8a9fSMatthew Dillonor
80a72d8a9fSMatthew Dillon.Fl c
81a72d8a9fSMatthew Dillonoption specified on the command line will be the boot disk.
827834fbccSSascha WildnerThe CD9660 filesystem is assumed when booting from this media.
83822dfb20SSascha Wildner.It Fl d
84822dfb20SSascha WildnerDisables hardware pagetable for
85822dfb20SSascha Wildner.Nm .
8609b03fffSSascha Wildner.It Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ...
8709b03fffSSascha WildnerSpecify an environment to be used by the kernel.
88974f8ffeSAntonio Huete JimenezThis option can be specified more than once.
89278c4e67SSamuel J. Greear.It Fl h
90278c4e67SSamuel J. GreearShows a list of available options, each with a short description.
91dd54cb3aSSascha Wildner.It Fl i Ar file
92dd54cb3aSSascha WildnerSpecify a memory image
93dd54cb3aSSascha Wildner.Ar file
94dd54cb3aSSascha Wildnerto be used by the virtual kernel.
95dd54cb3aSSascha WildnerIf no
96dd54cb3aSSascha Wildner.Fl i
97dd54cb3aSSascha Wildneroption is given, the kernel will generate a name of the form
98dd54cb3aSSascha Wildner.Pa /var/vkernel/memimg.XXXXXX ,
99dd54cb3aSSascha Wildnerwith the trailing
100dd54cb3aSSascha Wildner.Ql X Ns s
101dd54cb3aSSascha Wildnerbeing replaced by a sequential number, e.g.\&
102dd54cb3aSSascha Wildner.Pa memimg.000001 .
10386d2b040SAntonio 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
10409b03fffSSascha WildnerCreate a virtual network device, with the first
10509b03fffSSascha Wildner.Fl I
10609b03fffSSascha Wildneroption defining
1070592e24dSSascha Wildner.Li vke0 ,
10809b03fffSSascha Wildnerthe second one
1090592e24dSSascha Wildner.Li vke1 ,
11009b03fffSSascha Wildnerand so on.
11109b03fffSSascha Wildner.Pp
11209b03fffSSascha WildnerThe
11309b03fffSSascha Wildner.Ar interface
11409b03fffSSascha Wildnerargument is the name of a
11509b03fffSSascha Wildner.Xr tap 4
116bc3cc25eSMatthew Dillondevice node or the path to a
117bc3cc25eSMatthew Dillon.Xr vknetd 8
118bc3cc25eSMatthew Dillonsocket.
11909b03fffSSascha WildnerThe
12009b03fffSSascha Wildner.Pa /dev/
121bc3cc25eSMatthew Dillonpath prefix does not have to be specified and will be automatically prepended
122bc3cc25eSMatthew Dillonfor a device node.
12309b03fffSSascha WildnerSpecifying
12409b03fffSSascha Wildner.Cm auto
12509b03fffSSascha Wildnerwill pick the first unused
12609b03fffSSascha Wildner.Xr tap 4
12709b03fffSSascha Wildnerdevice.
12809b03fffSSascha Wildner.Pp
12909b03fffSSascha WildnerThe
13009b03fffSSascha Wildner.Ar address1
13109b03fffSSascha Wildnerand
13209b03fffSSascha Wildner.Ar address2
13309b03fffSSascha Wildnerarguments are the IP addresses of the
13409b03fffSSascha Wildner.Xr tap 4
13509b03fffSSascha Wildnerand
1360592e24dSSascha Wildner.Nm vke
13709b03fffSSascha Wildnerinterfaces.
13809b03fffSSascha WildnerOptionally,
13909b03fffSSascha Wildner.Ar address1
14009b03fffSSascha Wildnermay be of the form
14109b03fffSSascha Wildner.Li bridge Ns Em X
14209b03fffSSascha Wildnerin which case the
14309b03fffSSascha Wildner.Xr tap 4
14409b03fffSSascha Wildnerinterface is added to the specified
14509b03fffSSascha Wildner.Xr bridge 4
14609b03fffSSascha Wildnerinterface.
147a8cc122dSSascha WildnerThe
148a8cc122dSSascha Wildner.Nm vke
149a8cc122dSSascha Wildneraddress is not assigned until the interface is brought up in the guest.
15009b03fffSSascha Wildner.Pp
15109b03fffSSascha WildnerThe
15209b03fffSSascha Wildner.Ar netmask
15309b03fffSSascha Wildnerargument applies to all interfaces for which an address is specified.
154bc3cc25eSMatthew Dillon.Pp
15586d2b040SAntonio Huete JimenezThe
15686d2b040SAntonio Huete Jimenez.Ar MAC
15786d2b040SAntonio Huete Jimenezargument is the MAC address of the
15886d2b040SAntonio Huete Jimenez.Xr vke 4
15986d2b040SAntonio Huete Jimenezinterface.
16086d2b040SAntonio Huete JimenezIf not specified, a pseudo-random one will be generated.
16186d2b040SAntonio Huete Jimenez.Pp
162bc3cc25eSMatthew DillonWhen running multiple vkernels it is often more convenient to simply
163bc3cc25eSMatthew Dillonconnect to a
164bc3cc25eSMatthew Dillon.Xr vknetd 8
165c6e9e022SSascha Wildnersocket and let vknetd deal with the tap and/or bridge.
166c6e9e022SSascha WildnerAn example of this would be
167c6e9e022SSascha Wildner.Pa /var/run/vknet:0.0.0.0:10.2.0.2/16 .
168702acf06SJoe Talbott.It Fl l Ar cpulock
169702acf06SJoe TalbottSpecify which, if any, real CPUs to lock virtual CPUs to.
170702acf06SJoe Talbott.Ar cpulock
171702acf06SJoe Talbottis one of
172702acf06SJoe Talbott.Cm any ,
17326ea2793SSascha Wildner.Cm map Ns Op Ns , Ns Ar startCPU ,
17426ea2793SSascha Wildneror
17526ea2793SSascha Wildner.Ar CPU .
176702acf06SJoe Talbott.Pp
177702acf06SJoe Talbott.Cm any
17826ea2793SSascha Wildnerdoes not map virtual CPUs to real CPUs.
17926ea2793SSascha WildnerThis is the default.
180702acf06SJoe Talbott.Pp
181702acf06SJoe Talbott.Cm map Ns Op Ns , Ns Ar startCPU
182702acf06SJoe Talbottmaps each virtual CPU to a real CPU starting with real CPU 0 or
183702acf06SJoe Talbott.Ar startCPU
184702acf06SJoe Talbottif specified.
185702acf06SJoe Talbott.Pp
186702acf06SJoe Talbott.Ar CPU
18726ea2793SSascha Wildnerlocks all virtual CPUs to the real CPU specified by
18826ea2793SSascha Wildner.Ar CPU .
1894af18995SSascha Wildner.It Fl m Ar size
1904af18995SSascha WildnerSpecify the amount of memory to be used by the kernel in bytes,
1914af18995SSascha Wildner.Cm K
1923cea05a4SSascha Wildner.Pq kilobytes ,
1934af18995SSascha Wildner.Cm M
1943cea05a4SSascha Wildner.Pq megabytes
1953cea05a4SSascha Wildneror
1964af18995SSascha Wildner.Cm G
1973cea05a4SSascha Wildner.Pq gigabytes .
19809b03fffSSascha WildnerLowercase versions of
1994af18995SSascha Wildner.Cm K , M ,
2004af18995SSascha Wildnerand
2014af18995SSascha Wildner.Cm G
2024af18995SSascha Wildnerare allowed.
2039bea6114SMihai Carabas.It Fl n Ar numcpus Ns Op Ar :lbits Ns Oo Ar :cbits Oc
2049bea6114SMihai Carabas.Ar numcpus
2059bea6114SMihai Carabasspecifies the number of CPUs you wish to emulate.
2066e837288SSascha WildnerUp to 16 CPUs are supported with 2 being the default unless otherwise
2076e837288SSascha Wildnerspecified.
208*82065d92SSascha Wildner.Pp
2099bea6114SMihai Carabas.Ar lbits
2109bea6114SMihai Carabasspecifies the number of bits within APICID(=CPUID) needed for representing
2119bea6114SMihai Carabasthe logical ID.
2129bea6114SMihai CarabasControls the number of threads/core (0 bits - 1 thread, 1 bit - 2 threads).
2139bea6114SMihai CarabasThis parameter is optional (mandatory only if
2149bea6114SMihai Carabas.Ar cbits
2159bea6114SMihai Carabasis specified).
216*82065d92SSascha Wildner.Pp
2179bea6114SMihai Carabas.Ar cbits
2189bea6114SMihai Carabasspecifies the number of bits within APICID(=CPUID) needed for representing
2199bea6114SMihai Carabasthe core ID.
2209bea6114SMihai CarabasControls the number of core/package (0 bits - 1 core, 1 bit - 2 cores).
2219bea6114SMihai CarabasThis parameter is optional.
222bc3cc25eSMatthew Dillon.It Fl p Ar pidfile
223bc3cc25eSMatthew DillonSpecify a pidfile in which to store the process ID.
224bc3cc25eSMatthew DillonScripts can use this file to locate the vkernel pid for the purpose of
225bc3cc25eSMatthew Dillonshutting down or killing it.
226bc3cc25eSMatthew Dillon.Pp
227bc3cc25eSMatthew DillonThe vkernel will hold a lock on the pidfile while running.
228bc3cc25eSMatthew DillonScripts may test for the lock to determine if the pidfile is valid or
22967cdc5a5SSascha Wildnerstale so as to avoid accidentally killing a random process.
230bc3cc25eSMatthew DillonSomething like '/usr/bin/lockf -ks -t 0 pidfile echo -n' may be used
231bc3cc25eSMatthew Dillonto test the lock.
232bc3cc25eSMatthew DillonA non-zero exit code indicates that the pidfile represents a running
233bc3cc25eSMatthew Dillonvkernel.
234bc3cc25eSMatthew Dillon.Pp
235bc3cc25eSMatthew DillonAn error is issued and the vkernel exits if this file cannot be opened for
236bc3cc25eSMatthew Dillonwriting or if it is already locked by an active vkernel process.
2372a4f37b8SAntonio Huete Jimenez.It Fl r Ar file Ns Op Ar :serno
238a72d8a9fSMatthew DillonSpecify a R/W disk image
2394af18995SSascha Wildner.Ar file
240ec1a8a4dSSascha Wildnerto be used by the kernel, with the first
241ec1a8a4dSSascha Wildner.Fl r
242ec1a8a4dSSascha Wildneroption defining
2430592e24dSSascha Wildner.Li vkd0 ,
244ec1a8a4dSSascha Wildnerthe second one
2450592e24dSSascha Wildner.Li vkd1 ,
24662aea38eSSascha Wildnerand so on.
2472a4f37b8SAntonio Huete JimenezA serial number for the virtual disk can be specified in
2482a4f37b8SAntonio Huete Jimenez.Ar serno .
2492a4f37b8SAntonio Huete Jimenez.Pp
25062aea38eSSascha WildnerThe first
251a72d8a9fSMatthew Dillon.Fl r
252a72d8a9fSMatthew Dillonor
253a72d8a9fSMatthew Dillon.Fl c
254a72d8a9fSMatthew Dillonoption specified on the command line will be the boot disk.
255c8e7d028SSascha Wildner.It Fl s
256c8e7d028SSascha WildnerBoot into single-user mode.
25703071031SSascha Wildner.It Fl U
25803071031SSascha WildnerEnable writing to kernel memory and module loading.
25903071031SSascha WildnerBy default, those are disabled for security reasons.
2604af18995SSascha Wildner.It Fl v
2614af18995SSascha WildnerTurn on verbose booting.
2624af18995SSascha Wildner.El
2630592e24dSSascha Wildner.Sh DEVICES
2640592e24dSSascha WildnerA number of virtual device drivers exist to supplement the virtual kernel.
2650592e24dSSascha Wildner.Ss Disk device
2660592e24dSSascha WildnerThe
2670592e24dSSascha Wildner.Nm vkd
2680592e24dSSascha Wildnerdriver allows for up to 16
2690592e24dSSascha Wildner.Xr vn 4
2700592e24dSSascha Wildnerbased disk devices.
2710592e24dSSascha WildnerThe root device will be
2720592e24dSSascha Wildner.Li vkd0
2730592e24dSSascha Wildner(see
2740592e24dSSascha Wildner.Sx EXAMPLES
2750592e24dSSascha Wildnerfor further information on how to prepare a root image).
27698b2ba80SSascha Wildner.Ss CD-ROM device
27798b2ba80SSascha WildnerThe
27898b2ba80SSascha Wildner.Nm vcd
27998b2ba80SSascha Wildnerdriver allows for up to 16 virtual CD-ROM devices.
28098b2ba80SSascha WildnerBasically this is a read only
28198b2ba80SSascha Wildner.Nm vkd
28298b2ba80SSascha Wildnerdevice with a block size of 2048.
2830592e24dSSascha Wildner.Ss Network interface
2840592e24dSSascha WildnerThe
2850592e24dSSascha Wildner.Nm vke
2860592e24dSSascha Wildnerdriver supports up to 16 virtual network interfaces which are associated with
2870592e24dSSascha Wildner.Xr tap 4
2880592e24dSSascha Wildnerdevices on the host.
2890592e24dSSascha WildnerFor each
2900592e24dSSascha Wildner.Nm vke
2910592e24dSSascha Wildnerdevice, the per-interface read only
2920592e24dSSascha Wildner.Xr sysctl 3
2930592e24dSSascha Wildnervariable
2940592e24dSSascha Wildner.Va hw.vke Ns Em X Ns Va .tap_unit
2950592e24dSSascha Wildnerholds the unit number of the associated
2960592e24dSSascha Wildner.Xr tap 4
2970592e24dSSascha Wildnerdevice.
29833c27d6cSAntonio Huete Jimenez.Pp
29933c27d6cSAntonio Huete JimenezBy default, half of the total mbuf clusters available is distributed equally
300c6e9e022SSascha Wildneramong all the vke devices up to 256.
30149af6f0fSSascha WildnerThis can be overridden with the tunable
30233c27d6cSAntonio Huete Jimenez.Va hw.vke.max_ringsize .
30333c27d6cSAntonio Huete JimenezTake into account the number passed will be aligned to the lower power of two.
3041e4d9fd9SSascha Wildner.Sh SIGNALS
305bb195a01SMatthew DillonThe virtual kernel only enables
306bb195a01SMatthew Dillon.Dv SIGQUIT
307bb195a01SMatthew Dillonand
308bb195a01SMatthew Dillon.Dv SIGTERM
309bb195a01SMatthew Dillonwhile operating in regular console mode.
310bb195a01SMatthew DillonSending
3111e4d9fd9SSascha Wildner.Ql \&^\e
3121e4d9fd9SSascha Wildner.Pq Dv SIGQUIT
313bb195a01SMatthew Dillonto the virtual kernel causes the virtual kernel to enter its internal
3141e4d9fd9SSascha Wildner.Xr ddb 4
315bb195a01SMatthew Dillondebugger and re-enable all other terminal signals.
316bb195a01SMatthew DillonSending
317bb195a01SMatthew Dillon.Dv SIGTERM
318bb195a01SMatthew Dillonto the virtual kernel triggers a clean shutdown by passing a
319bb195a01SMatthew Dillon.Dv SIGUSR2
320bb195a01SMatthew Dillonto the virtual kernel's
321bb195a01SMatthew Dillon.Xr init 8
322bb195a01SMatthew Dillonprocess.
323974b26bfSSascha Wildner.Sh DEBUGGING
324974b26bfSSascha WildnerIt is possible to directly gdb the virtual kernel's process.
325974b26bfSSascha WildnerIt is recommended that you do a
326974b26bfSSascha Wildner.Ql handle SIGSEGV noprint
3274010bf94SNicolas Theryto ignore page faults processed by the virtual kernel itself and
328e7c2f376SNicolas Thery.Ql handle SIGUSR1 noprint
32920ce32a9SSascha Wildnerto ignore signals used for simulating inter-processor interrupts.
330b96eeefdSSascha Wildner.Sh PROFILING
331b96eeefdSSascha WildnerTo compile a vkernel with profiling support, the
332b96eeefdSSascha Wildner.Va CONFIGARGS
333b96eeefdSSascha Wildnervariable needs to be used to pass
334b96eeefdSSascha Wildner.Fl p
335b96eeefdSSascha Wildnerto
336b96eeefdSSascha Wildner.Xr config 8 .
337b96eeefdSSascha Wildner.Bd -literal
338b96eeefdSSascha Wildnercd /usr/src
339dd7331feSSascha Wildnermake -DNO_MODULES CONFIGARGS=-p buildkernel KERNCONF=VKERNEL64
340b96eeefdSSascha Wildner.Ed
341a154d422SThomas Nikolajsen.Sh FILES
342ec363e75SSascha Wildner.Bl -tag -width ".It Pa /sys/config/VKERNEL64" -compact
343ec363e75SSascha Wildner.It Pa /dev/vcdX
344ec363e75SSascha Wildner.Nm vcd
345ec363e75SSascha Wildnerdevice nodes
346ec363e75SSascha Wildner.It Pa /dev/vkdX
347ec363e75SSascha Wildner.Nm vkd
348ec363e75SSascha Wildnerdevice nodes
349163fd4e7SAntonio Huete Jimenez.It Pa /sys/config/VKERNEL64
350a154d422SThomas Nikolajsen.El
351163fd4e7SAntonio Huete Jimenez.Pp
352163fd4e7SAntonio Huete Jimenez.Nm
353dd7331feSSascha Wildnerconfiguration file, for
354163fd4e7SAntonio Huete Jimenez.Xr config 8 .
355a68e0df0SSascha Wildner.Sh CONFIGURATION FILES
356a68e0df0SSascha WildnerYour virtual kernel is a complete
357a68e0df0SSascha Wildner.Dx
358a68e0df0SSascha Wildnersystem, but you might not want to run all the services a normal kernel runs.
359a68e0df0SSascha WildnerHere is what a typical virtual kernel's
360a68e0df0SSascha Wildner.Pa /etc/rc.conf
361a68e0df0SSascha Wildnerfile looks like, with some additional possibilities commented out.
362a68e0df0SSascha Wildner.Bd -literal
363a68e0df0SSascha Wildnerhostname="vkernel"
364a68e0df0SSascha Wildnernetwork_interfaces="lo0 vke0"
365a68e0df0SSascha Wildnerifconfig_vke0="DHCP"
366a68e0df0SSascha Wildnersendmail_enable="NO"
367a68e0df0SSascha Wildner#syslog_enable="NO"
368a68e0df0SSascha Wildnerblanktime="NO"
369a68e0df0SSascha Wildner.Ed
370163fd4e7SAntonio Huete Jimenez.Sh DISKLESS OPERATION
371163fd4e7SAntonio Huete JimenezTo boot a
372163fd4e7SAntonio Huete Jimenez.Nm
373163fd4e7SAntonio Huete Jimenezfrom a NFS root, a number of tunables need to be set:
374163fd4e7SAntonio Huete Jimenez.Bl -tag -width indent
375163fd4e7SAntonio Huete Jimenez.It Va boot.netif.ip
376163fd4e7SAntonio Huete JimenezIP address to be set in the vkernel interface.
377163fd4e7SAntonio Huete Jimenez.It Va boot.netif.netmask
378163fd4e7SAntonio Huete JimenezNetmask for the IP to be set.
379163fd4e7SAntonio Huete Jimenez.It Va boot.netif.name
380163fd4e7SAntonio Huete JimenezNetwork interface name inside the vkernel.
381163fd4e7SAntonio Huete Jimenez.It Va boot.nfsroot.server
382163fd4e7SAntonio Huete JimenezHost running
383163fd4e7SAntonio Huete Jimenez.Xr nfsd 8 .
384163fd4e7SAntonio Huete Jimenez.It Va boot.nfsroot.path
385163fd4e7SAntonio Huete JimenezHost path where a world and distribution
386163fd4e7SAntonio Huete Jimeneztargets are properly installed.
387163fd4e7SAntonio Huete Jimenez.El
388163fd4e7SAntonio Huete Jimenez.Pp
389163fd4e7SAntonio Huete JimenezSee an example on how to boot a diskless
390163fd4e7SAntonio Huete Jimenez.Nm
391163fd4e7SAntonio Huete Jimenezin the
392163fd4e7SAntonio Huete Jimenez.Sx EXAMPLES
393163fd4e7SAntonio Huete Jimenezsection.
394c8e7d028SSascha Wildner.Sh EXAMPLES
3954af18995SSascha WildnerA couple of steps are necessary in order to prepare the system to build and
3964af18995SSascha Wildnerrun a virtual kernel.
3974af18995SSascha Wildner.Ss Setting up the filesystem
3984af18995SSascha WildnerThe
3994af18995SSascha Wildner.Nm
4004af18995SSascha Wildnerarchitecture needs a number of files which reside in
4014af18995SSascha Wildner.Pa /var/vkernel .
4024af18995SSascha WildnerSince these files tend to get rather big and the
4034af18995SSascha Wildner.Pa /var
4044af18995SSascha Wildnerpartition is usually of limited size, we recommend the directory to be
4054af18995SSascha Wildnercreated in the
4064af18995SSascha Wildner.Pa /home
4074af18995SSascha Wildnerpartition with a link to it in
4084af18995SSascha Wildner.Pa /var :
409c8e7d028SSascha Wildner.Bd -literal
410c009fcfaSThomas Nikolajsenmkdir -p /home/var.vkernel/boot
4114af18995SSascha Wildnerln -s /home/var.vkernel /var/vkernel
4124af18995SSascha Wildner.Ed
4134af18995SSascha Wildner.Pp
4144af18995SSascha WildnerNext, a filesystem image to be used by the virtual kernel has to be
41562aea38eSSascha Wildnercreated and populated (assuming world has been built previously).
41662aea38eSSascha WildnerIf the image is created on a UFS filesystem you might want to pre-zero it.
41749802d4eSMatthew DillonOn a HAMMER filesystem you should just truncate-extend to the image size
41849802d4eSMatthew Dillonas HAMMER does not re-use data blocks already present in the file.
419c8e7d028SSascha Wildner.Bd -literal
420f73862c5SSascha Wildnervnconfig -c -S 2g -T vn0 /var/vkernel/rootimg.01
42158c55700SSascha Wildnerdisklabel -r -w vn0s0 auto
422c009fcfaSThomas Nikolajsendisklabel -e vn0s0	# add `a' partition with fstype `4.2BSD'
42358c55700SSascha Wildnernewfs /dev/vn0s0a
42458c55700SSascha Wildnermount /dev/vn0s0a /mnt
425c8e7d028SSascha Wildnercd /usr/src
426c8e7d028SSascha Wildnermake installworld DESTDIR=/mnt
427c8e7d028SSascha Wildnercd etc
428c8e7d028SSascha Wildnermake distribution DESTDIR=/mnt
4297a3238b8SMatthew Dillonecho '/dev/vkd0s0a	/	ufs	rw	1  1' >/mnt/etc/fstab
4307a3238b8SMatthew Dillonecho 'proc		/proc	procfs	rw	0  0' >>/mnt/etc/fstab
4317834fbccSSascha Wildner.Ed
4327834fbccSSascha Wildner.Pp
4337834fbccSSascha WildnerEdit
4347834fbccSSascha Wildner.Pa /mnt/etc/ttys
4357834fbccSSascha Wildnerand replace the
4367834fbccSSascha Wildner.Li console
4377834fbccSSascha Wildnerentry with the following line and turn off all other gettys.
4387834fbccSSascha Wildner.Bd -literal
4397834fbccSSascha Wildnerconsole	"/usr/libexec/getty Pc"		cons25	on  secure
4407834fbccSSascha Wildner.Ed
4417834fbccSSascha Wildner.Pp
442eed435ddSStathis KamperisReplace
443eed435ddSStathis Kamperis.Li \&Pc
444eed435ddSStathis Kamperiswith
445eed435ddSStathis Kamperis.Li al.Pc
446eed435ddSStathis Kamperisif you would like to automatically log in as root.
447eed435ddSStathis Kamperis.Pp
4487834fbccSSascha WildnerThen, unmount the disk.
4497834fbccSSascha Wildner.Bd -literal
4504af18995SSascha Wildnerumount /mnt
4514af18995SSascha Wildnervnconfig -u vn0
4524af18995SSascha Wildner.Ed
4534af18995SSascha Wildner.Ss Compiling the virtual kernel
4544af18995SSascha WildnerIn order to compile a virtual kernel use the
455dd7331feSSascha Wildner.Li VKERNEL64
4564af18995SSascha Wildnerkernel configuration file residing in
457a154d422SThomas Nikolajsen.Pa /sys/config
4584af18995SSascha Wildner(or a configuration file derived thereof):
459c8e7d028SSascha Wildner.Bd -literal
4604af18995SSascha Wildnercd /usr/src
461dd7331feSSascha Wildnermake -DNO_MODULES buildkernel KERNCONF=VKERNEL64
462dd7331feSSascha Wildnermake -DNO_MODULES installkernel KERNCONF=VKERNEL64 DESTDIR=/var/vkernel
4634af18995SSascha Wildner.Ed
4644af18995SSascha Wildner.Ss Enabling virtual kernel operation
4654af18995SSascha WildnerA special
4664af18995SSascha Wildner.Xr sysctl 8 ,
4674af18995SSascha Wildner.Va vm.vkernel_enable ,
4684af18995SSascha Wildnermust be set to enable
4694af18995SSascha Wildner.Nm
4704af18995SSascha Wildneroperation:
471c8e7d028SSascha Wildner.Bd -literal
4724af18995SSascha Wildnersysctl vm.vkernel_enable=1
4734af18995SSascha Wildner.Ed
47409b03fffSSascha Wildner.Ss Configuring the network on the host system
47509b03fffSSascha WildnerIn order to access a network interface of the host system from the
47609b03fffSSascha Wildner.Nm ,
47709b03fffSSascha Wildneryou must add the interface to a
47809b03fffSSascha Wildner.Xr bridge 4
47909b03fffSSascha Wildnerdevice which will then be passed to the
48009b03fffSSascha Wildner.Fl I
48109b03fffSSascha Wildneroption:
48209b03fffSSascha Wildner.Bd -literal
48309b03fffSSascha Wildnerkldload if_bridge.ko
48409b03fffSSascha Wildnerkldload if_tap.ko
48509b03fffSSascha Wildnerifconfig bridge0 create
48609b03fffSSascha Wildnerifconfig bridge0 addm re0	# assuming re0 is the host's interface
48709b03fffSSascha Wildnerifconfig bridge0 up
48809b03fffSSascha Wildner.Ed
4894af18995SSascha Wildner.Ss Running the kernel
4904af18995SSascha WildnerFinally, the virtual kernel can be run:
491c8e7d028SSascha Wildner.Bd -literal
49279b58aaeSMatthew Dilloncd /var/vkernel
4931a92ebbbSSamuel J. Greear\&./boot/kernel/kernel -m 64m -r rootimg.01 -I auto:bridge0
4944af18995SSascha Wildner.Ed
495c8e7d028SSascha Wildner.Pp
49679b58aaeSMatthew DillonYou can issue the
49779b58aaeSMatthew Dillon.Xr reboot 8 ,
49879b58aaeSMatthew Dillon.Xr halt 8 ,
49979b58aaeSMatthew Dillonor
50079b58aaeSMatthew Dillon.Xr shutdown 8
50179b58aaeSMatthew Dilloncommands from inside a virtual kernel.
50279b58aaeSMatthew DillonAfter doing a clean shutdown the
503c8e7d028SSascha Wildner.Xr reboot 8
50479b58aaeSMatthew Dilloncommand will re-exec the virtual kernel binary while the other two will
50579b58aaeSMatthew Dilloncause the virtual kernel to exit.
506163fd4e7SAntonio Huete Jimenez.Ss Diskless operation
507163fd4e7SAntonio Huete JimenezBooting a
508163fd4e7SAntonio Huete Jimenez.Nm
509163fd4e7SAntonio Huete Jimenezwith a
510163fd4e7SAntonio Huete Jimenez.Xr vknetd 8
511163fd4e7SAntonio Huete Jimeneznetwork configuration:
512163fd4e7SAntonio Huete Jimenez.Bd -literal
513163fd4e7SAntonio Huete Jimenez\&./boot/kernel/kernel -m 64m -m -i memimg.0000 -I /var/run/vknet
514163fd4e7SAntonio Huete Jimenez	-e boot.netif.ip=172.1.0.4
515163fd4e7SAntonio Huete Jimenez	-e boot.netif.netmask=255.255.0.0
516163fd4e7SAntonio Huete Jimenez	-e boot.netif.name=vke0
517163fd4e7SAntonio Huete Jimenez	-e boot.nfsroot.server=172.1.0.1
518163fd4e7SAntonio Huete Jimenez	-e boot.nfsroot.path=/home/vkernel/vkdiskless
519163fd4e7SAntonio Huete Jimenez.Ed
52034caba04SMatthew Dillon.Sh BUILDING THE WORLD UNDER A VKERNEL
52134caba04SMatthew DillonThe virtual kernel platform does not have all the header files expected
52234caba04SMatthew Dillonby a world build, so the easiest thing to do right now is to specify a
523579b67d2SSascha Wildnerpc64 (in a 64 bit vkernel) target when building the world under a virtual
524579b67d2SSascha Wildnerkernel, like this:
52534caba04SMatthew Dillon.Bd -literal
526579b67d2SSascha Wildnervkernel# make MACHINE_PLATFORM=pc64 buildworld
527579b67d2SSascha Wildnervkernel# make MACHINE_PLATFORM=pc64 installworld
52834caba04SMatthew Dillon.Ed
5294af18995SSascha Wildner.Sh SEE ALSO
530666855caSSascha Wildner.Xr vknet 1 ,
53109b03fffSSascha Wildner.Xr bridge 4 ,
5328988c073SSascha Wildner.Xr ifmedia 4 ,
53309b03fffSSascha Wildner.Xr tap 4 ,
534c8e7d028SSascha Wildner.Xr vn 4 ,
535a154d422SThomas Nikolajsen.Xr sysctl.conf 5 ,
536c8e7d028SSascha Wildner.Xr build 7 ,
537b96eeefdSSascha Wildner.Xr config 8 ,
538c8e7d028SSascha Wildner.Xr disklabel 8 ,
53909b03fffSSascha Wildner.Xr ifconfig 8 ,
540dbfd168bSMatthew Dillon.Xr vknetd 8 ,
541c8e7d028SSascha Wildner.Xr vnconfig 8
542c203b6f9SSascha Wildner.Rs
543c203b6f9SSascha Wildner.%A Aggelos Economopoulos
544c203b6f9SSascha Wildner.%D March 2007
545c203b6f9SSascha Wildner.%T "A Peek at the DragonFly Virtual Kernel"
546c203b6f9SSascha Wildner.Re
5474af18995SSascha Wildner.Sh HISTORY
5484af18995SSascha WildnerVirtual kernels were introduced in
5494af18995SSascha Wildner.Dx 1.7 .
5504af18995SSascha Wildner.Sh AUTHORS
5514af18995SSascha Wildner.An -nosplit
5524af18995SSascha Wildner.An Matt Dillon
5534af18995SSascha Wildnerthought up and implemented the
5544af18995SSascha Wildner.Nm
5550592e24dSSascha Wildnerarchitecture and wrote the
5560592e24dSSascha Wildner.Nm vkd
5570592e24dSSascha Wildnerdevice driver.
5580592e24dSSascha Wildner.An Sepherosa Ziehau
5590592e24dSSascha Wildnerwrote the
5600592e24dSSascha Wildner.Nm vke
5610592e24dSSascha Wildnerdevice driver.
5624af18995SSascha WildnerThis manual page was written by
5634af18995SSascha Wildner.An Sascha Wildner .
564