Merge from vendor branch SENDMAIL:
[dragonfly.git] / share / man / man7 / vkernel.7
1 .\"
2 .\" Copyright (c) 2003, 2004, 2005, 2006, 2007
3 .\"     The DragonFly Project.  All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\"
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in
13 .\"    the documentation and/or other materials provided with the
14 .\"    distribution.
15 .\" 3. Neither the name of The DragonFly Project nor the names of its
16 .\"    contributors may be used to endorse or promote products derived
17 .\"    from this software without specific, prior written permission.
18 .\"
19 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
23 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" $DragonFly: src/share/man/man7/vkernel.7,v 1.15 2007/04/20 07:04:09 swildner Exp $
33 .\"
34 .Dd April 19, 2007
35 .Dt VKERNEL 7
36 .Os
37 .Sh NAME
38 .Nm vkernel ,
39 .Nm vkd ,
40 .Nm vke
41 .Nd virtual kernel architecture
42 .Sh SYNOPSIS
43 .Cd "platform vkernel"
44 .Cd "device vkd"
45 .Cd "device vke"
46 .Pp
47 .Pa /usr/obj/usr/src/sys/VKERNEL/kernel.debug
48 .Op Fl sUv
49 .Op Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ...
50 .Op Fl i Ar file
51 .Op Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc
52 .Op Fl m Ar size
53 .Op Fl r Ar file
54 .Sh DESCRIPTION
55 The
56 .Nm
57 architecture allows for running
58 .Dx
59 kernels in userland.
60 .Pp
61 The following options are available:
62 .Bl -tag -width ".Fl m Ar size"
63 .It Fl e Ar name Ns = Ns Li value : Ns Ar name Ns = Ns Li value : Ns ...
64 Specify an environment to be used by the kernel.
65 .It Fl i Ar file
66 Specify a memory image
67 .Ar file
68 to be used by the virtual kernel.
69 If no
70 .Fl i
71 option is given, the kernel will generate a name of the form
72 .Pa /var/vkernel/memimg.XXXXXX ,
73 with the trailing
74 .Ql X Ns s
75 being replaced by a sequential number, e.g.\&
76 .Pa memimg.000001 .
77 .It Fl I Ar interface Ns Op Ar :address1 Ns Oo Ar :address2 Oc Ns Oo Ar /netmask Oc
78 Create a virtual network device, with the first
79 .Fl I
80 option defining
81 .Li vke0 ,
82 the second one
83 .Li vke1 ,
84 and so on.
85 .Pp
86 The
87 .Ar interface
88 argument is the name of a
89 .Xr tap 4
90 device node.
91 The
92 .Pa /dev/
93 path prefix does not have to be specified and will be automatically prepended.
94 Specifying
95 .Cm auto
96 will pick the first unused
97 .Xr tap 4
98 device.
99 .Pp
100 The
101 .Ar address1
102 and
103 .Ar address2
104 arguments are the IP addresses of the
105 .Xr tap 4
106 and
107 .Nm vke
108 interfaces.
109 Optionally,
110 .Ar address1
111 may be of the form
112 .Li bridge Ns Em X
113 in which case the
114 .Xr tap 4
115 interface is added to the specified
116 .Xr bridge 4
117 interface.
118 .Pp
119 The
120 .Ar netmask
121 argument applies to all interfaces for which an address is specified.
122 .It Fl m Ar size
123 Specify the amount of memory to be used by the kernel in bytes,
124 .Cm K
125 .Pq kilobytes ,
126 .Cm M
127 .Pq megabytes
128 or
129 .Cm G
130 .Pq gigabytes .
131 Lowercase versions of
132 .Cm K , M ,
133 and
134 .Cm G
135 are allowed.
136 .It Fl r Ar file
137 Specify a disk image
138 .Ar file
139 to be used by the kernel, with the first
140 .Fl r
141 option defining
142 .Li vkd0 ,
143 the second one
144 .Li vkd1 ,
145 and so on.
146 .It Fl s
147 Boot into single-user mode.
148 .It Fl U
149 Enable writing to kernel memory and module loading.
150 By default, those are disabled for security reasons.
151 .It Fl v
152 Turn on verbose booting.
153 .El
154 .Sh DEVICES
155 A number of virtual device drivers exist to supplement the virtual kernel.
156 Their names start with
157 .Li vk .
158 .Ss Disk device
159 The
160 .Nm vkd
161 driver allows for up to 16
162 .Xr vn 4
163 based disk devices.
164 The root device will be
165 .Li vkd0
166 (see
167 .Sx EXAMPLES
168 for further information on how to prepare a root image).
169 .Ss Network interface
170 The
171 .Nm vke
172 driver supports up to 16 virtual network interfaces which are associated with
173 .Xr tap 4
174 devices on the host.
175 For each
176 .Nm vke
177 device, the per-interface read only
178 .Xr sysctl 3
179 variable
180 .Va hw.vke Ns Em X Ns Va .tap_unit
181 holds the unit number of the associated
182 .Xr tap 4
183 device.
184 .Sh SIGNALS
185 The virtual kernel enables all terminal signals while in
186 .Xr ddb 4
187 mode but only enables
188 .Ql \&^\e
189 .Pq Dv SIGQUIT
190 while operating as a console which causes the virtual kernel to enter its
191 internal
192 .Xr ddb 4
193 debugger.
194 .Sh DEBUGGING
195 It is possible to directly gdb the virtual kernel's process.
196 It is recommended that you do a
197 .Ql handle SIGSEGV noprint
198 to ignore page faults processed by the virtual kernel itself.
199 .Sh EXAMPLES
200 A couple of steps are necessary in order to prepare the system to build and
201 run a virtual kernel.
202 .Ss Setting up the filesystem
203 The
204 .Nm
205 architecture needs a number of files which reside in
206 .Pa /var/vkernel .
207 Since these files tend to get rather big and the
208 .Pa /var
209 partition is usually of limited size, we recommend the directory to be
210 created in the
211 .Pa /home
212 partition with a link to it in
213 .Pa /var :
214 .Bd -literal
215 mkdir /home/var.vkernel
216 ln -s /home/var.vkernel /var/vkernel
217 .Ed
218 .Pp
219 Next, a filesystem image to be used by the virtual kernel has to be
220 created and populated (assuming world has been built previously):
221 .Bd -literal
222 dd if=/dev/zero of=/var/vkernel/rootimg.01 bs=1m count=2048
223 vnconfig -c -s labels vn0 /var/vkernel/rootimg.01
224 disklabel -r -w vn0 auto
225 disklabel -e vn0        # edit the label to create a vn0a partition
226 newfs /dev/vn0a
227 mount /dev/vn0a /mnt
228 cd /usr/src
229 make installworld DESTDIR=/mnt
230 cd etc
231 make distribution DESTDIR=/mnt
232 echo '/dev/vkd0a / ufs rw 1 1' >/mnt/etc/fstab
233 echo 'console "/usr/libexec/getty Pc" cons25 on secure' >/mnt/etc/ttys
234 umount /mnt
235 vnconfig -u vn0
236 .Ed
237 .Ss Compiling the virtual kernel
238 In order to compile a virtual kernel use the
239 .Li VKERNEL
240 kernel configuration file residing in
241 .Pa /usr/src/sys/config
242 (or a configuration file derived thereof):
243 .Bd -literal
244 cd /usr/src
245 make -DNO_MODULES buildkernel KERNCONF=VKERNEL
246 .Ed
247 .Ss Enabling virtual kernel operation
248 A special
249 .Xr sysctl 8 ,
250 .Va vm.vkernel_enable ,
251 must be set to enable
252 .Nm
253 operation:
254 .Bd -literal
255 sysctl vm.vkernel_enable=1
256 .Ed
257 .Ss Configuring the network on the host system
258 In order to access a network interface of the host system from the
259 .Nm ,
260 you must add the interface to a
261 .Xr bridge 4
262 device which will then be passed to the
263 .Fl I
264 option:
265 .Bd -literal
266 kldload if_bridge.ko
267 kldload if_tap.ko
268 ifconfig bridge0 create
269 ifconfig bridge0 addm re0       # assuming re0 is the host's interface
270 ifconfig bridge0 up
271 .Ed
272 .Ss Running the kernel
273 Finally, the virtual kernel can be run:
274 .Bd -literal
275 cd /usr/obj/usr/src/sys/VKERNEL
276 \&./kernel.debug -m 64m -r /var/vkernel/rootimg.01 -I auto:bridge0
277 .Ed
278 .Pp
279 The
280 .Xr reboot 8
281 command can be used to stop a virtual kernel.
282 .Sh SEE ALSO
283 .Xr bridge 4 ,
284 .Xr tap 4 ,
285 .Xr vn 4 ,
286 .Xr build 7 ,
287 .Xr disklabel 8 ,
288 .Xr ifconfig 8 ,
289 .Xr vnconfig 8
290 .Sh HISTORY
291 Virtual kernels were introduced in
292 .Dx 1.7 .
293 .Sh AUTHORS
294 .An -nosplit
295 .An Matt Dillon
296 thought up and implemented the
297 .Nm
298 architecture and wrote the
299 .Nm vkd
300 device driver.
301 .An Sepherosa Ziehau
302 wrote the
303 .Nm vke
304 device driver.
305 This manual page was written by
306 .An Sascha Wildner .