]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/nspawn/nspawn-settings.h
nspawn: add a new --cpu-affinity= switch
[thirdparty/systemd.git] / src / nspawn / nspawn-settings.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
f757855e
LP
2#pragma once
3
4/***
5 This file is part of systemd.
6
7 Copyright 2015 Lennart Poettering
f757855e
LP
8***/
9
d107bb7d 10#include <sched.h>
f757855e
LP
11#include <stdio.h>
12
dccca82b
LP
13#include "sd-id128.h"
14
f757855e 15#include "macro.h"
7a8f6325 16#include "nspawn-expose-ports.h"
71d35b6b 17#include "nspawn-mount.h"
f757855e 18
7732f92b
LP
19typedef enum StartMode {
20 START_PID1, /* Run parameters as command line as process 1 */
21 START_PID2, /* Use stub init process as PID 1, run parameters as command line as process 2 */
22 START_BOOT, /* Search for init system, pass arguments as parameters */
23 _START_MODE_MAX,
24 _START_MODE_INVALID = -1
25} StartMode;
26
0de7acce
LP
27typedef enum UserNamespaceMode {
28 USER_NAMESPACE_NO,
29 USER_NAMESPACE_FIXED,
30 USER_NAMESPACE_PICK,
31 _USER_NAMESPACE_MODE_MAX,
32 _USER_NAMESPACE_MODE_INVALID = -1,
33} UserNamespaceMode;
34
f757855e 35typedef enum SettingsMask {
bf428efb
LP
36 SETTING_START_MODE = UINT64_C(1) << 0,
37 SETTING_ENVIRONMENT = UINT64_C(1) << 1,
38 SETTING_USER = UINT64_C(1) << 2,
39 SETTING_CAPABILITY = UINT64_C(1) << 3,
40 SETTING_KILL_SIGNAL = UINT64_C(1) << 4,
41 SETTING_PERSONALITY = UINT64_C(1) << 5,
42 SETTING_MACHINE_ID = UINT64_C(1) << 6,
43 SETTING_NETWORK = UINT64_C(1) << 7,
44 SETTING_EXPOSE_PORTS = UINT64_C(1) << 8,
45 SETTING_READ_ONLY = UINT64_C(1) << 9,
46 SETTING_VOLATILE_MODE = UINT64_C(1) << 10,
47 SETTING_CUSTOM_MOUNTS = UINT64_C(1) << 11,
48 SETTING_WORKING_DIRECTORY = UINT64_C(1) << 12,
49 SETTING_USERNS = UINT64_C(1) << 13,
50 SETTING_NOTIFY_READY = UINT64_C(1) << 14,
51 SETTING_PIVOT_ROOT = UINT64_C(1) << 15,
52 SETTING_SYSCALL_FILTER = UINT64_C(1) << 16,
3a9530e5 53 SETTING_HOSTNAME = UINT64_C(1) << 17,
66edd963 54 SETTING_NO_NEW_PRIVILEGES = UINT64_C(1) << 18,
81f345df 55 SETTING_OOM_SCORE_ADJUST = UINT64_C(1) << 19,
d107bb7d
LP
56 SETTING_CPU_AFFINITY = UINT64_C(1) << 20,
57 SETTING_RLIMIT_FIRST = UINT64_C(1) << 21, /* we define one bit per resource limit here */
58 SETTING_RLIMIT_LAST = UINT64_C(1) << (21 + _RLIMIT_MAX - 1),
59 _SETTINGS_MASK_ALL = (UINT64_C(1) << (21 + _RLIMIT_MAX)) - 1
f757855e
LP
60} SettingsMask;
61
62typedef struct Settings {
63 /* [Run] */
7732f92b 64 StartMode start_mode;
f757855e
LP
65 char **parameters;
66 char **environment;
67 char *user;
68 uint64_t capability;
69 uint64_t drop_capability;
70 int kill_signal;
71 unsigned long personality;
72 sd_id128_t machine_id;
5f932eb9 73 char *working_directory;
b53ede69
PW
74 char *pivot_root_new;
75 char *pivot_root_old;
0de7acce
LP
76 UserNamespaceMode userns_mode;
77 uid_t uid_shift, uid_range;
9c1e04d0 78 bool notify_ready;
960e4569
LP
79 char **syscall_whitelist;
80 char **syscall_blacklist;
bf428efb 81 struct rlimit *rlimit[_RLIMIT_MAX];
3a9530e5 82 char *hostname;
66edd963 83 int no_new_privileges;
81f345df
LP
84 int oom_score_adjust;
85 bool oom_score_adjust_set;
d107bb7d
LP
86 cpu_set_t *cpuset;
87 unsigned cpuset_ncpus;
f757855e
LP
88
89 /* [Image] */
90 int read_only;
91 VolatileMode volatile_mode;
92 CustomMount *custom_mounts;
88614c8a 93 size_t n_custom_mounts;
0de7acce 94 int userns_chown;
f757855e
LP
95
96 /* [Network] */
97 int private_network;
98 int network_veth;
99 char *network_bridge;
22b28dfd 100 char *network_zone;
f757855e
LP
101 char **network_interfaces;
102 char **network_macvlan;
103 char **network_ipvlan;
f6d6bad1 104 char **network_veth_extra;
f757855e
LP
105 ExposePort *expose_ports;
106} Settings;
107
108int settings_load(FILE *f, const char *path, Settings **ret);
109Settings* settings_free(Settings *s);
110
0e265674
LP
111bool settings_network_veth(Settings *s);
112bool settings_private_network(Settings *s);
113
f757855e
LP
114DEFINE_TRIVIAL_CLEANUP_FUNC(Settings*, settings_free);
115
c9f7b4d3 116const struct ConfigPerfItem* nspawn_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
f757855e
LP
117
118int config_parse_capability(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
119int config_parse_id128(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
120int config_parse_expose_port(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
121int config_parse_volatile_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
b53ede69 122int config_parse_pivot_root(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
f757855e
LP
123int config_parse_bind(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
124int config_parse_tmpfs(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
7b4318b6 125int config_parse_overlay(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
f6d6bad1 126int config_parse_veth_extra(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
22b28dfd 127int config_parse_network_zone(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
7732f92b
LP
128int config_parse_boot(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
129int config_parse_pid2(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
0de7acce 130int config_parse_private_users(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
960e4569 131int config_parse_syscall_filter(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
3a9530e5 132int config_parse_hostname(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
81f345df 133int config_parse_oom_score_adjust(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
d107bb7d 134int config_parse_cpu_affinity(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);