xref: /dflybsd-src/share/man/man7/vkernel.7 (revision 9bea61140575a5730974980a453d1b7b4057b3e4)
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.\"
32b96eeefdSSascha Wildner.Dd May 17, 2012
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 vkernel   # for 32 bit vkernels"
43b6a66df5SSascha Wildner.Cd "platform vkernel64 # for 64 bit vkernels"
4498b2ba80SSascha Wildner.Cd "device vcd"
45c8e7d028SSascha Wildner.Cd "device vkd"
46c8e7d028SSascha Wildner.Cd "device vke"
47c8e7d028SSascha Wildner.Pp
481a92ebbbSSamuel J. Greear.Pa /var/vkernel/boot/kernel/kernel
49278c4e67SSamuel J. Greear.Op Fl hsUv
50a72d8a9fSMatthew Dillon.Op Fl c Ar file
5109b03fffSSascha Wildner.Op Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ...
52dd54cb3aSSascha Wildner.Op Fl i Ar file
5309b03fffSSascha Wildner.Op Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc
54702acf06SJoe Talbott.Op Fl l Ar cpulock
554af18995SSascha Wildner.Op Fl m Ar size
56*9bea6114SMihai Carabas.Op Fl n Ar numcpus Ns Op Ar :lbits Ns Oo Ar :cbits Oc
57bc3cc25eSMatthew Dillon.Op Fl p Ar pidfile
584af18995SSascha Wildner.Op Fl r Ar file
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
79a72d8a9fSMatthew Dillon.Fl r
80a72d8a9fSMatthew Dillonor
81a72d8a9fSMatthew Dillon.Fl c
82a72d8a9fSMatthew Dillonoption specified on the command line will be the boot disk.
837834fbccSSascha WildnerThe CD9660 filesystem is assumed when booting from this media.
8409b03fffSSascha Wildner.It Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ...
8509b03fffSSascha WildnerSpecify an environment to be used by the kernel.
86974f8ffeSAntonio Huete JimenezThis option can be specified more than once.
87278c4e67SSamuel J. Greear.It Fl h
88278c4e67SSamuel J. GreearShows a list of available options, each with a short description.
89dd54cb3aSSascha Wildner.It Fl i Ar file
90dd54cb3aSSascha WildnerSpecify a memory image
91dd54cb3aSSascha Wildner.Ar file
92dd54cb3aSSascha Wildnerto be used by the virtual kernel.
93dd54cb3aSSascha WildnerIf no
94dd54cb3aSSascha Wildner.Fl i
95dd54cb3aSSascha Wildneroption is given, the kernel will generate a name of the form
96dd54cb3aSSascha Wildner.Pa /var/vkernel/memimg.XXXXXX ,
97dd54cb3aSSascha Wildnerwith the trailing
98dd54cb3aSSascha Wildner.Ql X Ns s
99dd54cb3aSSascha Wildnerbeing replaced by a sequential number, e.g.\&
100dd54cb3aSSascha Wildner.Pa memimg.000001 .
10109b03fffSSascha Wildner.It Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc
10209b03fffSSascha WildnerCreate a virtual network device, with the first
10309b03fffSSascha Wildner.Fl I
10409b03fffSSascha Wildneroption defining
1050592e24dSSascha Wildner.Li vke0 ,
10609b03fffSSascha Wildnerthe second one
1070592e24dSSascha Wildner.Li vke1 ,
10809b03fffSSascha Wildnerand so on.
10909b03fffSSascha Wildner.Pp
11009b03fffSSascha WildnerThe
11109b03fffSSascha Wildner.Ar interface
11209b03fffSSascha Wildnerargument is the name of a
11309b03fffSSascha Wildner.Xr tap 4
114bc3cc25eSMatthew Dillondevice node or the path to a
115bc3cc25eSMatthew Dillon.Xr vknetd 8
116bc3cc25eSMatthew Dillonsocket.
11709b03fffSSascha WildnerThe
11809b03fffSSascha Wildner.Pa /dev/
119bc3cc25eSMatthew Dillonpath prefix does not have to be specified and will be automatically prepended
120bc3cc25eSMatthew Dillonfor a device node.
12109b03fffSSascha WildnerSpecifying
12209b03fffSSascha Wildner.Cm auto
12309b03fffSSascha Wildnerwill pick the first unused
12409b03fffSSascha Wildner.Xr tap 4
12509b03fffSSascha Wildnerdevice.
12609b03fffSSascha Wildner.Pp
12709b03fffSSascha WildnerThe
12809b03fffSSascha Wildner.Ar address1
12909b03fffSSascha Wildnerand
13009b03fffSSascha Wildner.Ar address2
13109b03fffSSascha Wildnerarguments are the IP addresses of the
13209b03fffSSascha Wildner.Xr tap 4
13309b03fffSSascha Wildnerand
1340592e24dSSascha Wildner.Nm vke
13509b03fffSSascha Wildnerinterfaces.
13609b03fffSSascha WildnerOptionally,
13709b03fffSSascha Wildner.Ar address1
13809b03fffSSascha Wildnermay be of the form
13909b03fffSSascha Wildner.Li bridge Ns Em X
14009b03fffSSascha Wildnerin which case the
14109b03fffSSascha Wildner.Xr tap 4
14209b03fffSSascha Wildnerinterface is added to the specified
14309b03fffSSascha Wildner.Xr bridge 4
14409b03fffSSascha Wildnerinterface.
145a8cc122dSSascha WildnerThe
146a8cc122dSSascha Wildner.Nm vke
147a8cc122dSSascha Wildneraddress is not assigned until the interface is brought up in the guest.
14809b03fffSSascha Wildner.Pp
14909b03fffSSascha WildnerThe
15009b03fffSSascha Wildner.Ar netmask
15109b03fffSSascha Wildnerargument applies to all interfaces for which an address is specified.
152bc3cc25eSMatthew Dillon.Pp
153bc3cc25eSMatthew DillonWhen running multiple vkernels it is often more convenient to simply
154bc3cc25eSMatthew Dillonconnect to a
155bc3cc25eSMatthew Dillon.Xr vknetd 8
156bc3cc25eSMatthew Dillonsocket and let vknetd deal with the tap and/or bridge.  An example of
157bc3cc25eSMatthew Dillonthis would be '/var/run/vknet:0.0.0.0:10.2.0.2/16'.
158702acf06SJoe Talbott.It Fl l Ar cpulock
159702acf06SJoe TalbottSpecify which, if any, real CPUs to lock virtual CPUs to.
160702acf06SJoe Talbott.Ar cpulock
161702acf06SJoe Talbottis one of
162702acf06SJoe Talbott.Cm any ,
16326ea2793SSascha Wildner.Cm map Ns Op Ns , Ns Ar startCPU ,
16426ea2793SSascha Wildneror
16526ea2793SSascha Wildner.Ar CPU .
166702acf06SJoe Talbott.Pp
167702acf06SJoe Talbott.Cm any
16826ea2793SSascha Wildnerdoes not map virtual CPUs to real CPUs.
16926ea2793SSascha WildnerThis is the default.
170702acf06SJoe Talbott.Pp
171702acf06SJoe Talbott.Cm map Ns Op Ns , Ns Ar startCPU
172702acf06SJoe Talbottmaps each virtual CPU to a real CPU starting with real CPU 0 or
173702acf06SJoe Talbott.Ar startCPU
174702acf06SJoe Talbottif specified.
175702acf06SJoe Talbott.Pp
176702acf06SJoe Talbott.Ar CPU
17726ea2793SSascha Wildnerlocks all virtual CPUs to the real CPU specified by
17826ea2793SSascha Wildner.Ar CPU .
1794af18995SSascha Wildner.It Fl m Ar size
1804af18995SSascha WildnerSpecify the amount of memory to be used by the kernel in bytes,
1814af18995SSascha Wildner.Cm K
1823cea05a4SSascha Wildner.Pq kilobytes ,
1834af18995SSascha Wildner.Cm M
1843cea05a4SSascha Wildner.Pq megabytes
1853cea05a4SSascha Wildneror
1864af18995SSascha Wildner.Cm G
1873cea05a4SSascha Wildner.Pq gigabytes .
18809b03fffSSascha WildnerLowercase versions of
1894af18995SSascha Wildner.Cm K , M ,
1904af18995SSascha Wildnerand
1914af18995SSascha Wildner.Cm G
1924af18995SSascha Wildnerare allowed.
193*9bea6114SMihai Carabas.It Fl n Ar numcpus Ns Op Ar :lbits Ns Oo Ar :cbits Oc
194*9bea6114SMihai Carabas.Ar numcpus
195*9bea6114SMihai Carabasspecifies the number of CPUs you wish to emulate.
19643cfb771SSascha WildnerUp to 16 CPUs are supported.
1978cf87c92SSascha WildnerThe virtual kernel must be built with
1988cf87c92SSascha Wildner.Cd options SMP
1998cf87c92SSascha Wildnerto use this option and will default to 2 CPUs unless otherwise specified.
200*9bea6114SMihai Carabas.Ar lbits
201*9bea6114SMihai Carabasspecifies the number of bits within APICID(=CPUID) needed for representing
202*9bea6114SMihai Carabasthe logical ID.
203*9bea6114SMihai CarabasControls the number of threads/core (0bits - 1 thread, 1bit - 2 threads).
204*9bea6114SMihai CarabasThis parameter is optional (mandatory only if
205*9bea6114SMihai Carabas.Ar cbits
206*9bea6114SMihai Carabasis specified).
207*9bea6114SMihai Carabas.Ar cbits
208*9bea6114SMihai Carabasspecifies the number of bits within APICID(=CPUID) needed for representing
209*9bea6114SMihai Carabasthe core ID.
210*9bea6114SMihai CarabasControls the number of core/package (0bits - 1 core, 1bit - 2 cores).
211*9bea6114SMihai CarabasThis parameter is optional.
212bc3cc25eSMatthew Dillon.It Fl p Ar pidfile
213bc3cc25eSMatthew DillonSpecify a pidfile in which to store the process ID.
214bc3cc25eSMatthew DillonScripts can use this file to locate the vkernel pid for the purpose of
215bc3cc25eSMatthew Dillonshutting down or killing it.
216bc3cc25eSMatthew Dillon.Pp
217bc3cc25eSMatthew DillonThe vkernel will hold a lock on the pidfile while running.
218bc3cc25eSMatthew DillonScripts may test for the lock to determine if the pidfile is valid or
21967cdc5a5SSascha Wildnerstale so as to avoid accidentally killing a random process.
220bc3cc25eSMatthew DillonSomething like '/usr/bin/lockf -ks -t 0 pidfile echo -n' may be used
221bc3cc25eSMatthew Dillonto test the lock.
222bc3cc25eSMatthew DillonA non-zero exit code indicates that the pidfile represents a running
223bc3cc25eSMatthew Dillonvkernel.
224bc3cc25eSMatthew Dillon.Pp
225bc3cc25eSMatthew DillonAn error is issued and the vkernel exits if this file cannot be opened for
226bc3cc25eSMatthew Dillonwriting or if it is already locked by an active vkernel process.
2274af18995SSascha Wildner.It Fl r Ar file
228a72d8a9fSMatthew DillonSpecify a R/W disk image
2294af18995SSascha Wildner.Ar file
230ec1a8a4dSSascha Wildnerto be used by the kernel, with the first
231ec1a8a4dSSascha Wildner.Fl r
232ec1a8a4dSSascha Wildneroption defining
2330592e24dSSascha Wildner.Li vkd0 ,
234ec1a8a4dSSascha Wildnerthe second one
2350592e24dSSascha Wildner.Li vkd1 ,
23662aea38eSSascha Wildnerand so on.
23762aea38eSSascha WildnerThe first
238a72d8a9fSMatthew Dillon.Fl r
239a72d8a9fSMatthew Dillonor
240a72d8a9fSMatthew Dillon.Fl c
241a72d8a9fSMatthew Dillonoption specified on the command line will be the boot disk.
242c8e7d028SSascha Wildner.It Fl s
243c8e7d028SSascha WildnerBoot into single-user mode.
24403071031SSascha Wildner.It Fl U
24503071031SSascha WildnerEnable writing to kernel memory and module loading.
24603071031SSascha WildnerBy default, those are disabled for security reasons.
2474af18995SSascha Wildner.It Fl v
2484af18995SSascha WildnerTurn on verbose booting.
2494af18995SSascha Wildner.El
2500592e24dSSascha Wildner.Sh DEVICES
2510592e24dSSascha WildnerA number of virtual device drivers exist to supplement the virtual kernel.
2520592e24dSSascha Wildner.Ss Disk device
2530592e24dSSascha WildnerThe
2540592e24dSSascha Wildner.Nm vkd
2550592e24dSSascha Wildnerdriver allows for up to 16
2560592e24dSSascha Wildner.Xr vn 4
2570592e24dSSascha Wildnerbased disk devices.
2580592e24dSSascha WildnerThe root device will be
2590592e24dSSascha Wildner.Li vkd0
2600592e24dSSascha Wildner(see
2610592e24dSSascha Wildner.Sx EXAMPLES
2620592e24dSSascha Wildnerfor further information on how to prepare a root image).
26398b2ba80SSascha Wildner.Ss CD-ROM device
26498b2ba80SSascha WildnerThe
26598b2ba80SSascha Wildner.Nm vcd
26698b2ba80SSascha Wildnerdriver allows for up to 16 virtual CD-ROM devices.
26798b2ba80SSascha WildnerBasically this is a read only
26898b2ba80SSascha Wildner.Nm vkd
26998b2ba80SSascha Wildnerdevice with a block size of 2048.
2700592e24dSSascha Wildner.Ss Network interface
2710592e24dSSascha WildnerThe
2720592e24dSSascha Wildner.Nm vke
2730592e24dSSascha Wildnerdriver supports up to 16 virtual network interfaces which are associated with
2740592e24dSSascha Wildner.Xr tap 4
2750592e24dSSascha Wildnerdevices on the host.
2760592e24dSSascha WildnerFor each
2770592e24dSSascha Wildner.Nm vke
2780592e24dSSascha Wildnerdevice, the per-interface read only
2790592e24dSSascha Wildner.Xr sysctl 3
2800592e24dSSascha Wildnervariable
2810592e24dSSascha Wildner.Va hw.vke Ns Em X Ns Va .tap_unit
2820592e24dSSascha Wildnerholds the unit number of the associated
2830592e24dSSascha Wildner.Xr tap 4
2840592e24dSSascha Wildnerdevice.
2851e4d9fd9SSascha Wildner.Sh SIGNALS
286bb195a01SMatthew DillonThe virtual kernel only enables
287bb195a01SMatthew Dillon.Dv SIGQUIT
288bb195a01SMatthew Dillonand
289bb195a01SMatthew Dillon.Dv SIGTERM
290bb195a01SMatthew Dillonwhile operating in regular console mode.
291bb195a01SMatthew DillonSending
2921e4d9fd9SSascha Wildner.Ql \&^\e
2931e4d9fd9SSascha Wildner.Pq Dv SIGQUIT
294bb195a01SMatthew Dillonto the virtual kernel causes the virtual kernel to enter its internal
2951e4d9fd9SSascha Wildner.Xr ddb 4
296bb195a01SMatthew Dillondebugger and re-enable all other terminal signals.
297bb195a01SMatthew DillonSending
298bb195a01SMatthew Dillon.Dv SIGTERM
299bb195a01SMatthew Dillonto the virtual kernel triggers a clean shutdown by passing a
300bb195a01SMatthew Dillon.Dv SIGUSR2
301bb195a01SMatthew Dillonto the virtual kernel's
302bb195a01SMatthew Dillon.Xr init 8
303bb195a01SMatthew Dillonprocess.
304974b26bfSSascha Wildner.Sh DEBUGGING
305974b26bfSSascha WildnerIt is possible to directly gdb the virtual kernel's process.
306974b26bfSSascha WildnerIt is recommended that you do a
307974b26bfSSascha Wildner.Ql handle SIGSEGV noprint
3084010bf94SNicolas Theryto ignore page faults processed by the virtual kernel itself and
309e7c2f376SNicolas Thery.Ql handle SIGUSR1 noprint
3104010bf94SNicolas Theryto ignore signals used for simulating inter-processor interrupts (SMP build
3114010bf94SNicolas Theryonly).
312b96eeefdSSascha Wildner.Sh PROFILING
313b96eeefdSSascha WildnerTo compile a vkernel with profiling support, the
314b96eeefdSSascha Wildner.Va CONFIGARGS
315b96eeefdSSascha Wildnervariable needs to be used to pass
316b96eeefdSSascha Wildner.Fl p
317b96eeefdSSascha Wildnerto
318b96eeefdSSascha Wildner.Xr config 8 .
319b96eeefdSSascha Wildner.Bd -literal
320b96eeefdSSascha Wildnercd /usr/src
321b96eeefdSSascha Wildnermake -DNO_MODULES CONFIGARGS=-p buildkernel KERNCONF=VKERNEL
322b96eeefdSSascha Wildner.Ed
323a154d422SThomas Nikolajsen.Sh FILES
324a154d422SThomas Nikolajsen.Bl -tag -width ".It Pa /sys/config/VKERNEL" -compact
325a154d422SThomas Nikolajsen.It Pa /sys/config/VKERNEL
326163fd4e7SAntonio Huete Jimenez.It Pa /sys/config/VKERNEL64
327a154d422SThomas Nikolajsen.El
328163fd4e7SAntonio Huete Jimenez.Pp
329163fd4e7SAntonio Huete JimenezPer architecture
330163fd4e7SAntonio Huete Jimenez.Nm
331163fd4e7SAntonio Huete Jimenezconfiguration files, for
332163fd4e7SAntonio Huete Jimenez.Xr config 8 .
333a68e0df0SSascha Wildner.Sh CONFIGURATION FILES
334a68e0df0SSascha WildnerYour virtual kernel is a complete
335a68e0df0SSascha Wildner.Dx
336a68e0df0SSascha Wildnersystem, but you might not want to run all the services a normal kernel runs.
337a68e0df0SSascha WildnerHere is what a typical virtual kernel's
338a68e0df0SSascha Wildner.Pa /etc/rc.conf
339a68e0df0SSascha Wildnerfile looks like, with some additional possibilities commented out.
340a68e0df0SSascha Wildner.Bd -literal
341a68e0df0SSascha Wildnerhostname="vkernel"
342a68e0df0SSascha Wildnernetwork_interfaces="lo0 vke0"
343a68e0df0SSascha Wildnerifconfig_vke0="DHCP"
344a68e0df0SSascha Wildnersendmail_enable="NO"
345a68e0df0SSascha Wildner#syslog_enable="NO"
346a68e0df0SSascha Wildnerblanktime="NO"
347a68e0df0SSascha Wildner.Ed
348163fd4e7SAntonio Huete Jimenez.Sh DISKLESS OPERATION
349163fd4e7SAntonio Huete JimenezTo boot a
350163fd4e7SAntonio Huete Jimenez.Nm
351163fd4e7SAntonio Huete Jimenezfrom a NFS root, a number of tunables need to be set:
352163fd4e7SAntonio Huete Jimenez.Bl -tag -width indent
353163fd4e7SAntonio Huete Jimenez.It Va boot.netif.ip
354163fd4e7SAntonio Huete JimenezIP address to be set in the vkernel interface.
355163fd4e7SAntonio Huete Jimenez.It Va boot.netif.netmask
356163fd4e7SAntonio Huete JimenezNetmask for the IP to be set.
357163fd4e7SAntonio Huete Jimenez.It Va boot.netif.name
358163fd4e7SAntonio Huete JimenezNetwork interface name inside the vkernel.
359163fd4e7SAntonio Huete Jimenez.It Va boot.nfsroot.server
360163fd4e7SAntonio Huete JimenezHost running
361163fd4e7SAntonio Huete Jimenez.Xr nfsd 8 .
362163fd4e7SAntonio Huete Jimenez.It Va boot.nfsroot.path
363163fd4e7SAntonio Huete JimenezHost path where a world and distribution
364163fd4e7SAntonio Huete Jimeneztargets are properly installed.
365163fd4e7SAntonio Huete Jimenez.El
366163fd4e7SAntonio Huete Jimenez.Pp
367163fd4e7SAntonio Huete JimenezSee an example on how to boot a diskless
368163fd4e7SAntonio Huete Jimenez.Nm
369163fd4e7SAntonio Huete Jimenezin the
370163fd4e7SAntonio Huete Jimenez.Sx EXAMPLES
371163fd4e7SAntonio Huete Jimenezsection.
372c8e7d028SSascha Wildner.Sh EXAMPLES
3734af18995SSascha WildnerA couple of steps are necessary in order to prepare the system to build and
3744af18995SSascha Wildnerrun a virtual kernel.
3754af18995SSascha Wildner.Ss Setting up the filesystem
3764af18995SSascha WildnerThe
3774af18995SSascha Wildner.Nm
3784af18995SSascha Wildnerarchitecture needs a number of files which reside in
3794af18995SSascha Wildner.Pa /var/vkernel .
3804af18995SSascha WildnerSince these files tend to get rather big and the
3814af18995SSascha Wildner.Pa /var
3824af18995SSascha Wildnerpartition is usually of limited size, we recommend the directory to be
3834af18995SSascha Wildnercreated in the
3844af18995SSascha Wildner.Pa /home
3854af18995SSascha Wildnerpartition with a link to it in
3864af18995SSascha Wildner.Pa /var :
387c8e7d028SSascha Wildner.Bd -literal
388c009fcfaSThomas Nikolajsenmkdir -p /home/var.vkernel/boot
3894af18995SSascha Wildnerln -s /home/var.vkernel /var/vkernel
3904af18995SSascha Wildner.Ed
3914af18995SSascha Wildner.Pp
3924af18995SSascha WildnerNext, a filesystem image to be used by the virtual kernel has to be
39362aea38eSSascha Wildnercreated and populated (assuming world has been built previously).
39462aea38eSSascha WildnerIf the image is created on a UFS filesystem you might want to pre-zero it.
39549802d4eSMatthew DillonOn a HAMMER filesystem you should just truncate-extend to the image size
39649802d4eSMatthew Dillonas HAMMER does not re-use data blocks already present in the file.
397c8e7d028SSascha Wildner.Bd -literal
398f73862c5SSascha Wildnervnconfig -c -S 2g -T vn0 /var/vkernel/rootimg.01
39958c55700SSascha Wildnerdisklabel -r -w vn0s0 auto
400c009fcfaSThomas Nikolajsendisklabel -e vn0s0	# add `a' partition with fstype `4.2BSD'
40158c55700SSascha Wildnernewfs /dev/vn0s0a
40258c55700SSascha Wildnermount /dev/vn0s0a /mnt
403c8e7d028SSascha Wildnercd /usr/src
404c8e7d028SSascha Wildnermake installworld DESTDIR=/mnt
405c8e7d028SSascha Wildnercd etc
406c8e7d028SSascha Wildnermake distribution DESTDIR=/mnt
4077a3238b8SMatthew Dillonecho '/dev/vkd0s0a	/	ufs	rw	1  1' >/mnt/etc/fstab
4087a3238b8SMatthew Dillonecho 'proc		/proc	procfs	rw	0  0' >>/mnt/etc/fstab
4097834fbccSSascha Wildner.Ed
4107834fbccSSascha Wildner.Pp
4117834fbccSSascha WildnerEdit
4127834fbccSSascha Wildner.Pa /mnt/etc/ttys
4137834fbccSSascha Wildnerand replace the
4147834fbccSSascha Wildner.Li console
4157834fbccSSascha Wildnerentry with the following line and turn off all other gettys.
4167834fbccSSascha Wildner.Bd -literal
4177834fbccSSascha Wildnerconsole	"/usr/libexec/getty Pc"		cons25	on  secure
4187834fbccSSascha Wildner.Ed
4197834fbccSSascha Wildner.Pp
420eed435ddSStathis KamperisReplace
421eed435ddSStathis Kamperis.Li \&Pc
422eed435ddSStathis Kamperiswith
423eed435ddSStathis Kamperis.Li al.Pc
424eed435ddSStathis Kamperisif you would like to automatically log in as root.
425eed435ddSStathis Kamperis.Pp
4267834fbccSSascha WildnerThen, unmount the disk.
4277834fbccSSascha Wildner.Bd -literal
4284af18995SSascha Wildnerumount /mnt
4294af18995SSascha Wildnervnconfig -u vn0
4304af18995SSascha Wildner.Ed
4314af18995SSascha Wildner.Ss Compiling the virtual kernel
4324af18995SSascha WildnerIn order to compile a virtual kernel use the
4334af18995SSascha Wildner.Li VKERNEL
4344af18995SSascha Wildnerkernel configuration file residing in
435a154d422SThomas Nikolajsen.Pa /sys/config
4364af18995SSascha Wildner(or a configuration file derived thereof):
437c8e7d028SSascha Wildner.Bd -literal
4384af18995SSascha Wildnercd /usr/src
43909b03fffSSascha Wildnermake -DNO_MODULES buildkernel KERNCONF=VKERNEL
44079b58aaeSMatthew Dillonmake -DNO_MODULES installkernel KERNCONF=VKERNEL DESTDIR=/var/vkernel
4414af18995SSascha Wildner.Ed
4424af18995SSascha Wildner.Ss Enabling virtual kernel operation
4434af18995SSascha WildnerA special
4444af18995SSascha Wildner.Xr sysctl 8 ,
4454af18995SSascha Wildner.Va vm.vkernel_enable ,
4464af18995SSascha Wildnermust be set to enable
4474af18995SSascha Wildner.Nm
4484af18995SSascha Wildneroperation:
449c8e7d028SSascha Wildner.Bd -literal
4504af18995SSascha Wildnersysctl vm.vkernel_enable=1
4514af18995SSascha Wildner.Ed
45209b03fffSSascha Wildner.Ss Configuring the network on the host system
45309b03fffSSascha WildnerIn order to access a network interface of the host system from the
45409b03fffSSascha Wildner.Nm ,
45509b03fffSSascha Wildneryou must add the interface to a
45609b03fffSSascha Wildner.Xr bridge 4
45709b03fffSSascha Wildnerdevice which will then be passed to the
45809b03fffSSascha Wildner.Fl I
45909b03fffSSascha Wildneroption:
46009b03fffSSascha Wildner.Bd -literal
46109b03fffSSascha Wildnerkldload if_bridge.ko
46209b03fffSSascha Wildnerkldload if_tap.ko
46309b03fffSSascha Wildnerifconfig bridge0 create
46409b03fffSSascha Wildnerifconfig bridge0 addm re0	# assuming re0 is the host's interface
46509b03fffSSascha Wildnerifconfig bridge0 up
46609b03fffSSascha Wildner.Ed
4674af18995SSascha Wildner.Ss Running the kernel
4684af18995SSascha WildnerFinally, the virtual kernel can be run:
469c8e7d028SSascha Wildner.Bd -literal
47079b58aaeSMatthew Dilloncd /var/vkernel
4711a92ebbbSSamuel J. Greear\&./boot/kernel/kernel -m 64m -r rootimg.01 -I auto:bridge0
4724af18995SSascha Wildner.Ed
473c8e7d028SSascha Wildner.Pp
47479b58aaeSMatthew DillonYou can issue the
47579b58aaeSMatthew Dillon.Xr reboot 8 ,
47679b58aaeSMatthew Dillon.Xr halt 8 ,
47779b58aaeSMatthew Dillonor
47879b58aaeSMatthew Dillon.Xr shutdown 8
47979b58aaeSMatthew Dilloncommands from inside a virtual kernel.
48079b58aaeSMatthew DillonAfter doing a clean shutdown the
481c8e7d028SSascha Wildner.Xr reboot 8
48279b58aaeSMatthew Dilloncommand will re-exec the virtual kernel binary while the other two will
48379b58aaeSMatthew Dilloncause the virtual kernel to exit.
484163fd4e7SAntonio Huete Jimenez.Ss Diskless operation
485163fd4e7SAntonio Huete JimenezBooting a
486163fd4e7SAntonio Huete Jimenez.Nm
487163fd4e7SAntonio Huete Jimenezwith a
488163fd4e7SAntonio Huete Jimenez.Xr vknetd 8
489163fd4e7SAntonio Huete Jimeneznetwork configuration:
490163fd4e7SAntonio Huete Jimenez.Bd -literal
491163fd4e7SAntonio Huete Jimenez\&./boot/kernel/kernel -m 64m -m -i memimg.0000 -I /var/run/vknet
492163fd4e7SAntonio Huete Jimenez	-e boot.netif.ip=172.1.0.4
493163fd4e7SAntonio Huete Jimenez	-e boot.netif.netmask=255.255.0.0
494163fd4e7SAntonio Huete Jimenez	-e boot.netif.name=vke0
495163fd4e7SAntonio Huete Jimenez	-e boot.nfsroot.server=172.1.0.1
496163fd4e7SAntonio Huete Jimenez	-e boot.nfsroot.path=/home/vkernel/vkdiskless
497163fd4e7SAntonio Huete Jimenez.Ed
49834caba04SMatthew Dillon.Sh BUILDING THE WORLD UNDER A VKERNEL
49934caba04SMatthew DillonThe virtual kernel platform does not have all the header files expected
50034caba04SMatthew Dillonby a world build, so the easiest thing to do right now is to specify a
501b6a66df5SSascha Wildnerpc32 (in a 32 bit vkernel) or pc64 (in a 64 bit vkernel) target when
502b6a66df5SSascha Wildnerbuilding the world under a virtual kernel, like this:
50334caba04SMatthew Dillon.Bd -literal
50434caba04SMatthew Dillonvkernel# make MACHINE_PLATFORM=pc32 buildworld
50534caba04SMatthew Dillonvkernel# make MACHINE_PLATFORM=pc32 installworld
50634caba04SMatthew Dillon.Ed
5074af18995SSascha Wildner.Sh SEE ALSO
508666855caSSascha Wildner.Xr vknet 1 ,
50909b03fffSSascha Wildner.Xr bridge 4 ,
51009b03fffSSascha Wildner.Xr tap 4 ,
511c8e7d028SSascha Wildner.Xr vn 4 ,
512a154d422SThomas Nikolajsen.Xr sysctl.conf 5 ,
513c8e7d028SSascha Wildner.Xr build 7 ,
514b96eeefdSSascha Wildner.Xr config 8 ,
515c8e7d028SSascha Wildner.Xr disklabel 8 ,
51609b03fffSSascha Wildner.Xr ifconfig 8 ,
517dbfd168bSMatthew Dillon.Xr vknetd 8 ,
518c8e7d028SSascha Wildner.Xr vnconfig 8
519c203b6f9SSascha Wildner.Rs
520c203b6f9SSascha Wildner.%A Aggelos Economopoulos
521c203b6f9SSascha Wildner.%D March 2007
522c203b6f9SSascha Wildner.%T "A Peek at the DragonFly Virtual Kernel"
523c203b6f9SSascha Wildner.Re
5244af18995SSascha Wildner.Sh HISTORY
5254af18995SSascha WildnerVirtual kernels were introduced in
5264af18995SSascha Wildner.Dx 1.7 .
5274af18995SSascha Wildner.Sh AUTHORS
5284af18995SSascha Wildner.An -nosplit
5294af18995SSascha Wildner.An Matt Dillon
5304af18995SSascha Wildnerthought up and implemented the
5314af18995SSascha Wildner.Nm
5320592e24dSSascha Wildnerarchitecture and wrote the
5330592e24dSSascha Wildner.Nm vkd
5340592e24dSSascha Wildnerdevice driver.
5350592e24dSSascha Wildner.An Sepherosa Ziehau
5360592e24dSSascha Wildnerwrote the
5370592e24dSSascha Wildner.Nm vke
5380592e24dSSascha Wildnerdevice driver.
5394af18995SSascha WildnerThis manual page was written by
5404af18995SSascha Wildner.An Sascha Wildner .
541