]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-vmspawn.xml
man: fix incorrect XML in man page
[thirdparty/systemd.git] / man / systemd-vmspawn.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="systemd-vmspawn" conditional="ENABLE_VMSPAWN"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>systemd-vmspawn</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>systemd-vmspawn</refentrytitle>
16 <manvolnum>1</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>systemd-vmspawn</refname>
21 <refpurpose>Spawn an OS in a virtual machine</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <cmdsynopsis>
26 <command>systemd-vmspawn</command>
27 <arg choice="opt" rep="repeat">OPTIONS</arg>
28 <arg choice="opt" rep="repeat">ARGS</arg>
29 </cmdsynopsis>
30 </refsynopsisdiv>
31
32 <refsect1>
33 <title>Description</title>
34 <para><command>systemd-vmspawn</command> may be used to start a virtual machine from an OS image. In many ways it is similar to <citerefentry>
35 <refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>, but
36 launches a full virtual machine instead of using namespaces.</para>
37
38 <para>File descriptors for <filename>/dev/kvm</filename> and <filename>/dev/vhost-vsock</filename> can be
39 passed to <command>systemd-vmspawn</command> via systemd's native socket passing interface (see
40 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
41 details about the precise protocol used and the order in which the file descriptors are passed), these
42 file descriptors must be passed with the names <literal>kvm</literal> and <literal>vhost-vsock</literal>
43 respectively.</para>
44
45 <para>Note: on Ubuntu/Debian derivatives systemd-vmspawn requires the user to be in the
46 <literal>kvm</literal> group to use the VSOCK options.</para>
47 </refsect1>
48
49 <refsect1>
50 <title>Options</title>
51
52 <para>The excess arguments are passed as extra kernel command line arguments using SMBIOS.</para>
53
54 <para>The following options are understood:</para>
55
56 <variablelist>
57
58 <varlistentry>
59 <term><option>-q</option></term>
60 <term><option>--quiet</option></term>
61
62 <listitem><para>Turns off any status output by the tool
63 itself. When this switch is used, the only output from vmspawn
64 will be the console output of the Virtual Machine OS itself.</para>
65
66 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
67 </varlistentry>
68
69 </variablelist>
70
71 <refsect2>
72 <title>Image Options</title>
73
74 <varlistentry>
75 <term><option>-D</option></term>
76 <term><option>--directory=</option></term>
77
78 <listitem><para>Directory to use as file system root for the virtual machine.</para>
79
80 <para>One of either <option>--directory=</option> or <option>--image=</option> must be specified.</para>
81
82 <para>Note: If mounting a non-root owned directory you may require <option>--private-users=</option>
83 to map into the user's subuid namespace.</para>
84
85 <xi:include href="version-info.xml" xpointer="v256"/>
86 </listitem>
87 </varlistentry>
88
89 <variablelist>
90 <varlistentry>
91 <term><option>-i</option></term>
92 <term><option>--image=</option></term>
93
94 <listitem><para>Root file system disk image (or device node) for the virtual machine.</para>
95
96 <xi:include href="version-info.xml" xpointer="v255"/>
97 </listitem>
98 </varlistentry>
99 </variablelist>
100 </refsect2>
101
102 <refsect2>
103 <title>Host Configuration</title>
104
105 <variablelist>
106 <varlistentry>
107 <term><option>--cpus=<replaceable>CPUS</replaceable></option></term>
108
109 <listitem><para>Configures the number of CPUs to start the virtual machine with.
110 Defaults to 1.</para>
111
112 <xi:include href="version-info.xml" xpointer="v255"/>
113 </listitem>
114 </varlistentry>
115
116 <varlistentry>
117 <term><option>--ram=<replaceable>BYTES</replaceable></option></term>
118
119 <listitem><para>Configures the amount of memory to start the virtual machine with.
120 Defaults to 2G.</para>
121
122 <xi:include href="version-info.xml" xpointer="v255"/>
123 </listitem>
124 </varlistentry>
125
126 <varlistentry>
127 <term><option>--kvm=<replaceable>BOOL</replaceable></option></term>
128
129 <listitem><para>Configures whether to use KVM. If the option is not specified KVM support will be
130 detected automatically. If true, KVM is always used, and if false, KVM is never used.</para>
131
132 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
133 </varlistentry>
134
135 <varlistentry>
136 <term><option>--vsock=<replaceable>BOOL</replaceable></option></term>
137
138 <listitem>
139 <para>Configure whether to use VSOCK networking.</para>
140
141 <para>If the option is not specified VSOCK support will be detected automatically. If yes is
142 specified VSOCK is always used, and vice versa if no is set VSOCK are never used.</para>
143 <xi:include href="version-info.xml" xpointer="v255"/>
144 </listitem>
145 </varlistentry>
146
147 <varlistentry>
148 <term><option>--vsock-cid=<replaceable>CID</replaceable></option></term>
149
150 <listitem>
151 <para>Configure vmspawn to use a specific CID for the guest.</para>
152
153 <para>If the option is not specified or an empty argument is supplied the guest will be assigned a random CID.</para>
154
155 <para>Valid CIDs are in the range <constant>3</constant> to <constant>4294967294</constant> (<constant>0xFFFF_FFFE</constant>).
156 CIDs outside of this range are reserved.</para>
157
158 <xi:include href="version-info.xml" xpointer="v255"/>
159 </listitem>
160 </varlistentry>
161
162 <varlistentry>
163 <term><option>--tpm=<replaceable>BOOL</replaceable></option></term>
164
165 <listitem>
166 <para>Configure whether to use VM with a virtual TPM or not.</para>
167
168 <para>If the option is not specified vmspawn will detect the presence of <citerefentry project='debian'>
169 <refentrytitle>swtpm</refentrytitle><manvolnum>8</manvolnum></citerefentry> and use it if available.
170 If yes is specified <citerefentry project='debian'><refentrytitle>swtpm</refentrytitle><manvolnum>8</manvolnum></citerefentry>
171 is always used, and vice versa if no is set <citerefentry project='debian'><refentrytitle>swtpm</refentrytitle>
172 <manvolnum>8</manvolnum></citerefentry> is never used.</para>
173
174 <para>Note: the virtual TPM used may change in future.</para>
175
176 <xi:include href="version-info.xml" xpointer="v256"/>
177 </listitem>
178 </varlistentry>
179
180 <varlistentry>
181 <term><option>--linux=<replaceable>PATH</replaceable></option></term>
182
183 <listitem>
184 <para>Set the linux kernel image to use for direct kernel boot.</para>
185
186 <para>If no kernel was installed into the image then the image will fail to boot.</para>
187
188 <xi:include href="version-info.xml" xpointer="v256"/>
189 </listitem>
190 </varlistentry>
191
192 <varlistentry>
193 <term><option>--initrd=<replaceable>PATH</replaceable></option></term>
194
195 <listitem>
196 <para>Set the initrd to use for direct kernel boot.</para>
197
198 <para>If the linux kernel supplied is a UKI then this argument is not required.</para>
199
200 <para>If the option is specified multiple times vmspawn will merge the initrds together.</para>
201
202 <para>If no initrd was installed into the image then the image will fail to boot.</para>
203
204 <xi:include href="version-info.xml" xpointer="v256"/>
205 </listitem>
206 </varlistentry>
207
208 <varlistentry>
209 <term><option>-n</option></term>
210 <term><option>--network-tap</option></term>
211
212 <listitem>
213 <para>Create a TAP device to network with the virtual machine.</para>
214
215 <para>Note: root privileges are required to use TAP networking.
216 Additionally,
217 <citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
218 must be running and correctly set up on the host to provision the host interface. The relevant
219 <literal>.network</literal> file can be found at
220 <filename>/usr/lib/systemd/network/80-vm-vt.network</filename>.
221 </para>
222
223 <xi:include href="version-info.xml" xpointer="v255"/>
224 </listitem>
225 </varlistentry>
226
227 <varlistentry>
228 <term><option>--network-user-mode</option></term>
229
230 <listitem><para>Use user mode networking.</para>
231
232 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
233 </varlistentry>
234
235 <varlistentry>
236 <term><option>--firmware=<replaceable>PATH</replaceable></option></term>
237
238 <listitem><para>Takes an absolute path, or a relative path beginning with
239 <filename>./</filename>. Specifies a JSON firmware definition file, which allows selecting the
240 firmware to boot in the VM. If not specified a suitable firmware is automatically discovered. If the
241 special string <literal>list</literal> is specified lists all discovered firmwares.</para>
242
243 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
244 </varlistentry>
245
246 <varlistentry>
247 <term><option>--discard-disk=<replaceable>BOOL</replaceable></option></term>
248
249 <listitem><para>Controls whether qemu processes discard requests from the VM.
250 This prevents long running VMs from using more disk space than required.
251 This is enabled by default.</para>
252
253 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
254 </varlistentry>
255
256 <varlistentry>
257 <term><option>--secure-boot=<replaceable>BOOL</replaceable></option></term>
258
259 <listitem><para>Configure whether to search for firmware which supports Secure Boot.</para>
260
261 <para>If the option is not specified the first firmware which is detected will be used.
262 If the option is set to yes then the first firmware with Secure Boot support will be selected.
263 If no is specified then the first firmware without Secure Boot will be selected.</para>
264
265 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
266 </varlistentry>
267 </variablelist>
268 </refsect2>
269
270 <refsect2>
271 <title>System Identity Options</title>
272
273 <variablelist>
274 <varlistentry>
275 <term><option>-M</option></term>
276 <term><option>--machine=</option></term>
277
278 <listitem><para>Sets the machine name for this virtual machine. This
279 name may be used to identify this virtual machine during its runtime
280 (for example in tools like
281 <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
282 and similar).</para>
283
284 <xi:include href="version-info.xml" xpointer="v255"/>
285 </listitem>
286 </varlistentry>
287
288 <varlistentry>
289 <term><option>--uuid=</option></term>
290
291 <listitem><para>Set the specified UUID for the virtual machine. The
292 init system will initialize
293 <filename>/etc/machine-id</filename> from this if this file is
294 not set yet. Note that this option takes effect only if
295 <filename>/etc/machine-id</filename> in the virtual machine is
296 unpopulated.</para>
297
298 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
299 </varlistentry>
300 </variablelist>
301 </refsect2>
302
303 <refsect2>
304 <title>Property Options</title>
305
306 <variablelist>
307 <varlistentry>
308 <term><option>--register=</option></term>
309
310 <listitem><para>Controls whether the virtual machine is registered with
311 <citerefentry><refentrytitle>systemd-machined</refentrytitle><manvolnum>8</manvolnum></citerefentry>. Takes a
312 boolean argument, which defaults to <literal>yes</literal> when running as root, and <literal>no</literal> when
313 running as a regular user. This ensures that the virtual machine is accessible via
314 <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
315
316 <para>Note: root privileges are required to use this option as registering with
317 <citerefentry><refentrytitle>systemd-machined</refentrytitle><manvolnum>8</manvolnum></citerefentry>
318 requires privileged D-Bus method calls.</para>
319
320 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
321 </varlistentry>
322 </variablelist>
323 </refsect2>
324
325 <refsect2>
326 <title>User Namespacing Options</title>
327
328 <variablelist>
329 <varlistentry>
330 <term><option>--private-users=<replaceable>UID_SHIFT[:UID_RANGE]</replaceable></option></term>
331
332 <listitem><para>Controls user namespacing under <option>--directory=</option>.
333 If enabled, <command>virtiofsd</command> is instructed to map user and group ids (UIDs and GIDs).
334 This involves mapping the private UIDs/GIDs used in the virtual machine (starting with the virtual machine's
335 root user 0 and up) to a range of UIDs/GIDs on the host that are not used for other purposes (usually in the
336 range beyond the host's UID/GID 65536).</para>
337
338 <para>If one or two colon-separated numbers are specified, user namespacing is turned on. <replaceable>UID_SHIFT</replaceable>
339 specifies the first host UID/GID to map, <replaceable>UID_RANGE</replaceable> is optional and specifies number of host
340 UIDs/GIDs to assign to the virtual machine. If <replaceable>UID_RANGE</replaceable> is omitted, 65536 UIDs/GIDs are assigned.</para>
341
342 <para>When user namespaces are used, the GID range assigned to each virtual machine is always chosen identical to the
343 UID range.</para>
344
345 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
346 </varlistentry>
347 </variablelist>
348 </refsect2>
349
350 <refsect2>
351 <title>Mount Options</title>
352
353 <variablelist>
354
355 <varlistentry>
356 <term><option>--bind=<replaceable>PATH</replaceable></option></term>
357 <term><option>--bind-ro=<replaceable>PATH</replaceable></option></term>
358
359 <listitem><para>Mount a directory from the host into the virtual machine. Takes one of: a path
360 argument — in which case the specified path will be mounted from the host to the same path in the virtual machine, or
361 a colon-separated pair of paths — in which case the first specified path is the source in the host, and the
362 second path is the destination in the virtual machine. If the source path is not absolute, it is resolved
363 relative to the current working directory. The <option>--bind-ro=</option> option creates read-only bind mounts.
364 Backslash escapes are interpreted, so <literal>\:</literal> may be used to embed colons in either path.
365 This option may be specified multiple times for creating multiple independent bind mount points.</para>
366
367 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
368 </varlistentry>
369
370 <varlistentry>
371 <term><option>--extra-drive=<replaceable>PATH</replaceable></option></term>
372
373 <listitem><para>Takes a disk image or block device on the host and supplies it to the virtual machine as another drive.</para>
374
375 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
376 </varlistentry>
377
378 </variablelist>
379 </refsect2>
380
381 <refsect2>
382 <title>Integration Options</title>
383
384 <variablelist>
385 <varlistentry>
386 <term><option>--forward-journal=<replaceable>FILE|DIR</replaceable></option></term>
387
388 <listitem><para>Forward the virtual machine's journal to the host.
389 <citerefentry><refentrytitle>systemd-journal-remote</refentrytitle><manvolnum>8</manvolnum></citerefentry>
390 is currently used to receive the guest VM's forwarded journal entries. This option determines where
391 this journal is saved on the host and has the same semantics as
392 <option>-o</option>/<option>--output</option> described in
393 <citerefentry><refentrytitle>systemd-journal-remote</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
394
395 <xi:include href="version-info.xml" xpointer="v256"/>
396 </listitem>
397 </varlistentry>
398
399 <varlistentry>
400 <term><option>--pass-ssh-key=<replaceable>BOOL</replaceable></option></term>
401
402 <listitem><para>By default an SSH key is generated to allow <command>systemd-vmspawn</command> to open
403 a D-Bus connection to the VM's systemd bus. Setting this to "no" will disable SSH key generation.</para>
404
405 <para>The generated keys are ephemeral. That is they are valid only for the current invocation of <command>systemd-vmspawn</command>,
406 and are typically not persisted.</para>
407
408 <xi:include href="version-info.xml" xpointer="v256"/>
409 </listitem>
410 </varlistentry>
411
412 <varlistentry>
413 <term><option>--ssh-key-type=<replaceable>TYPE</replaceable></option></term>
414
415 <listitem><para>Configures the type of SSH key to generate, see
416 <citerefentry project="man-pages"><refentrytitle>ssh-keygen</refentrytitle><manvolnum>1</manvolnum></citerefentry>
417 for more information.</para>
418
419 <para>By default <literal>ed25519</literal> keys are generated, however <literal>rsa</literal> keys
420 may also be useful if the VM has a particularly old version of <command>sshd</command></para>.
421
422 <xi:include href="version-info.xml" xpointer="v256"/>
423 </listitem>
424 </varlistentry>
425 </variablelist>
426 </refsect2>
427
428 <refsect2>
429 <title>Input/Output Options</title>
430
431 <variablelist>
432 <varlistentry>
433 <term><option>--console=<replaceable>MODE</replaceable></option></term>
434
435 <listitem><para>Configures how to set up the console of the VM. Takes one of
436 <literal>interactive</literal>, <literal>read-only</literal>, <literal>native</literal>,
437 <literal>gui</literal>. Defaults to <literal>interactive</literal>. <literal>interactive</literal>
438 provides an interactive terminal interface to the VM. <literal>read-only</literal> is similar, but
439 is strictly read-only, i.e. does not accept any input from the user. <literal>native</literal> also
440 provides a TTY-based interface, but uses qemu native implementation (which means the qemu monitor
441 is available). <literal>gui</literal> shows the qemu graphical UI.</para>
442
443 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
444 </varlistentry>
445
446 <varlistentry>
447 <term><option>--background=<replaceable>COLOR</replaceable></option></term>
448
449 <listitem><para>Change the terminal background color to the specified ANSI color as long as the VM
450 runs. The color specified should be an ANSI X3.64 SGR background color, i.e. strings such as
451 <literal>40</literal>, <literal>41</literal>, …, <literal>47</literal>, <literal>48;2;…</literal>,
452 <literal>48;5;…</literal>. See <ulink
453 url="https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters">ANSI
454 Escape Code (Wikipedia)</ulink> for details. Assign an empty string to disable any coloring. This
455 only has an effect in <option>--console=interactive</option> and
456 <option>--console=read-only</option> modes.</para>
457
458 <xi:include href="version-info.xml" xpointer="v256"/>
459 </listitem>
460 </varlistentry>
461 </variablelist>
462 </refsect2>
463
464 <refsect2>
465 <title>Credentials</title>
466
467 <variablelist>
468 <varlistentry>
469 <term><option>--load-credential=<replaceable>ID</replaceable>:<replaceable>PATH</replaceable></option></term>
470 <term><option>--set-credential=<replaceable>ID</replaceable>:<replaceable>VALUE</replaceable></option></term>
471
472 <listitem><para>Pass a credential to the virtual machine. These two options correspond to the
473 <varname>LoadCredential=</varname> and <varname>SetCredential=</varname> settings in unit files. See
474 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
475 details about these concepts, as well as the syntax of the option's arguments.</para>
476
477 <para>In order to embed binary data into the credential data for <option>--set-credential=</option>,
478 use C-style escaping (i.e. <literal>\n</literal> to embed a newline, or <literal>\x00</literal> to
479 embed a <constant>NUL</constant> byte). Note that the invoking shell might already apply unescaping
480 once, hence this might require double escaping!</para>
481
482 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
483 </varlistentry>
484 </variablelist>
485
486 </refsect2><refsect2>
487 <title>Other</title>
488
489 <variablelist>
490 <xi:include href="standard-options.xml" xpointer="no-pager" />
491 <xi:include href="standard-options.xml" xpointer="help" />
492 <xi:include href="standard-options.xml" xpointer="version" />
493 </variablelist>
494 </refsect2>
495 </refsect1>
496
497 <xi:include href="common-variables.xml" />
498
499 <refsect1>
500 <title>Examples</title>
501
502 <example>
503 <title>Run an Arch Linux VM image generated by mkosi</title>
504
505 <programlisting>
506 $ mkosi -d arch -p systemd -p linux --autologin -o image.raw -f build
507 $ systemd-vmspawn --image=image.raw
508 </programlisting>
509 </example>
510 </refsect1>
511
512 <refsect1>
513 <title>Exit status</title>
514
515 <para>If an error occurred the value errno is propagated to the return code.
516 If EXIT_STATUS is supplied by the running image that is returned.
517 Otherwise EXIT_SUCCESS is returned.</para>
518 </refsect1>
519
520 <refsect1>
521 <title>See Also</title>
522 <para><simplelist type="inline">
523 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
524 <member><citerefentry project='debian'><refentrytitle>mkosi</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
525 <member><citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
526 <member><citerefentry><refentrytitle>importctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
527 </simplelist></para>
528 </refsect1>
529 </refentry>