]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/cgroup.h
Revert "update gitignore"
[thirdparty/systemd.git] / src / core / cgroup.h
CommitLineData
03467c88 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
8e274523 2
c2f1db8f 3#pragma once
8e274523
LP
4
5/***
6 This file is part of systemd.
7
4ad49000 8 Copyright 2013 Lennart Poettering
8e274523
LP
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
8e274523
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
8e274523 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
8e274523
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
4ad49000 24#include "list.h"
8e274523 25
4ad49000
LP
26typedef struct CGroupContext CGroupContext;
27typedef struct CGroupDeviceAllow CGroupDeviceAllow;
28typedef struct CGroupBlockIODeviceWeight CGroupBlockIODeviceWeight;
29typedef struct CGroupBlockIODeviceBandwidth CGroupBlockIODeviceBandwidth;
8e274523 30
4ad49000 31typedef enum CGroupDevicePolicy {
8e274523 32
4ad49000
LP
33 /* When devices listed, will allow those, plus built-in ones,
34 if none are listed will allow everything. */
35 CGROUP_AUTO,
8e274523 36
4ad49000
LP
37 /* Everything forbidden, except built-in ones and listed ones. */
38 CGROUP_CLOSED,
9d58f1db 39
4ad49000
LP
40 /* Everythings forbidden, except for the listed devices */
41 CGROUP_STRICT,
9d58f1db 42
4ad49000
LP
43 _CGROUP_DEVICE_POLICY_MAX,
44 _CGROUP_DEVICE_POLICY_INVALID = -1
45} CGroupDevicePolicy;
8e274523 46
4ad49000
LP
47struct CGroupDeviceAllow {
48 LIST_FIELDS(CGroupDeviceAllow, device_allow);
49 char *path;
50 bool r:1;
51 bool w:1;
52 bool m:1;
53};
8c6db833 54
4ad49000
LP
55struct CGroupBlockIODeviceWeight {
56 LIST_FIELDS(CGroupBlockIODeviceWeight, device_weights);
57 char *path;
58 unsigned long weight;
8e274523
LP
59};
60
4ad49000
LP
61struct CGroupBlockIODeviceBandwidth {
62 LIST_FIELDS(CGroupBlockIODeviceBandwidth, device_bandwidths);
63 char *path;
64 uint64_t bandwidth;
65 bool read;
66};
8e274523 67
4ad49000
LP
68struct CGroupContext {
69 bool cpu_accounting;
70 bool blockio_accounting;
71 bool memory_accounting;
8e274523 72
4ad49000 73 unsigned long cpu_shares;
b2f8b02e
LP
74 usec_t cpu_quota_per_sec_usec;
75 usec_t cpu_quota_usec;
76 usec_t cpu_quota_period_usec;
8e274523 77
4ad49000
LP
78 unsigned long blockio_weight;
79 LIST_HEAD(CGroupBlockIODeviceWeight, blockio_device_weights);
80 LIST_HEAD(CGroupBlockIODeviceBandwidth, blockio_device_bandwidths);
246aa6dd 81
4ad49000 82 uint64_t memory_limit;
64747e2d 83
4ad49000
LP
84 CGroupDevicePolicy device_policy;
85 LIST_HEAD(CGroupDeviceAllow, device_allow);
86};
64747e2d 87
4ad49000
LP
88#include "unit.h"
89#include "manager.h"
90#include "cgroup-util.h"
8e274523 91
4ad49000
LP
92void cgroup_context_init(CGroupContext *c);
93void cgroup_context_done(CGroupContext *c);
94void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix);
95void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const char *path);
bc432dc7 96
4ad49000 97CGroupControllerMask cgroup_context_get_mask(CGroupContext *c);
fb385181 98
4ad49000
LP
99void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a);
100void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w);
101void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b);
8e274523 102
b2f8b02e
LP
103usec_t cgroup_context_get_cpu_quota_usec(CGroupContext *c);
104usec_t cgroup_context_get_cpu_quota_per_sec_usec(CGroupContext *c);
105
bc432dc7
LP
106CGroupControllerMask unit_get_cgroup_mask(Unit *u);
107CGroupControllerMask unit_get_siblings_mask(Unit *u);
108CGroupControllerMask unit_get_members_mask(Unit *u);
109CGroupControllerMask unit_get_target_mask(Unit *u);
110
111void unit_update_cgroup_members_masks(Unit *u);
0a1eb06d 112int unit_realize_cgroup(Unit *u);
4ad49000 113void unit_destroy_cgroup(Unit *u);
8e274523 114
4ad49000
LP
115int manager_setup_cgroup(Manager *m);
116void manager_shutdown_cgroup(Manager *m, bool delete);
6dde1f33 117
4ad49000 118unsigned manager_dispatch_cgroup_queue(Manager *m);
4fbf50b3 119
4ad49000
LP
120Unit *manager_get_unit_by_cgroup(Manager *m, const char *cgroup);
121Unit* manager_get_unit_by_pid(Manager *m, pid_t pid);
8e274523 122
4ad49000 123pid_t unit_search_main_pid(Unit *u);
8e274523 124
4ad49000 125int manager_notify_cgroup_empty(Manager *m, const char *group);
8e274523 126
4ad49000
LP
127const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
128CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;