2020-11-09 12:23:58 +08:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
2017-11-19 00:35:03 +08:00
|
|
|
#
|
2013-04-30 08:11:37 +08:00
|
|
|
# This file is part of systemd.
|
|
|
|
#
|
|
|
|
# systemd is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU Lesser General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
[Unit]
|
2016-02-27 03:35:09 +08:00
|
|
|
Description=Container %i
|
2013-04-30 08:11:37 +08:00
|
|
|
Documentation=man:systemd-nspawn(1)
|
2022-12-24 00:23:00 +08:00
|
|
|
Wants=modprobe@tun.service modprobe@loop.service modprobe@dm_mod.service
|
2014-12-29 19:38:26 +08:00
|
|
|
PartOf=machines.target
|
|
|
|
Before=machines.target
|
2022-12-16 03:02:25 +08:00
|
|
|
After=network.target modprobe@tun.service modprobe@loop.service modprobe@dm_mod.service
|
2020-02-24 22:54:35 +08:00
|
|
|
RequiresMountsFor=/var/lib/machines/%i
|
2013-04-30 08:11:37 +08:00
|
|
|
|
|
|
|
[Service]
|
2019-07-23 19:11:09 +08:00
|
|
|
# Make sure the DeviceAllow= lines below can properly resolve the 'block-loop' expression (and others)
|
2019-12-18 16:14:57 +08:00
|
|
|
ExecStart=systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth -U --settings=override --machine=%i
|
2014-05-28 23:17:25 +08:00
|
|
|
KillMode=mixed
|
2013-04-30 08:11:37 +08:00
|
|
|
Type=notify
|
2014-07-03 18:50:11 +08:00
|
|
|
RestartForceExitStatus=133
|
|
|
|
SuccessExitStatus=133
|
2015-05-20 01:47:52 +08:00
|
|
|
Slice=machine.slice
|
2014-11-06 00:57:23 +08:00
|
|
|
Delegate=yes
|
2023-04-24 16:19:28 +08:00
|
|
|
DelegateSubgroup=supervisor
|
2016-07-14 18:20:29 +08:00
|
|
|
TasksMax=16384
|
2021-05-16 17:55:36 +08:00
|
|
|
{{SERVICE_WATCHDOG}}
|
2013-04-30 08:11:37 +08:00
|
|
|
|
2021-05-17 01:08:50 +08:00
|
|
|
{# Enforce a strict device policy, similar to the one nspawn configures when it
|
|
|
|
# allocates its own scope unit. Make sure to keep these policies in sync if you
|
|
|
|
# change them! #}
|
2016-07-22 17:58:03 +08:00
|
|
|
DevicePolicy=closed
|
2015-04-29 02:46:03 +08:00
|
|
|
DeviceAllow=/dev/net/tun rwm
|
|
|
|
DeviceAllow=char-pts rw
|
|
|
|
|
2017-08-10 00:19:00 +08:00
|
|
|
# nspawn itself needs access to /dev/loop-control and /dev/loop, to implement
|
|
|
|
# the --image= option. Add these here, too.
|
2015-10-03 17:23:52 +08:00
|
|
|
DeviceAllow=/dev/loop-control rw
|
|
|
|
DeviceAllow=block-loop rw
|
2015-10-22 06:39:57 +08:00
|
|
|
DeviceAllow=block-blkext rw
|
2015-10-03 17:23:52 +08:00
|
|
|
|
2017-08-10 00:19:00 +08:00
|
|
|
# nspawn can set up LUKS encrypted loopback files, in which case it needs
|
|
|
|
# access to /dev/mapper/control and the block devices /dev/mapper/*.
|
|
|
|
DeviceAllow=/dev/mapper/control rw
|
|
|
|
DeviceAllow=block-device-mapper rw
|
|
|
|
|
2013-04-30 08:11:37 +08:00
|
|
|
[Install]
|
2014-12-29 19:38:26 +08:00
|
|
|
WantedBy=machines.target
|