cgroup.h 4.3 KB
Newer Older
1 2 3
/*
 * cgroup.h: Interface to tools for managing cgroups
 *
4
 * Copyright (C) 2011 Red Hat, Inc.
5 6 7 8 9 10 11 12 13
 * Copyright IBM Corp. 2008
 *
 * See COPYING.LIB for the License of this software
 *
 * Authors:
 *  Dan Smith <danms@us.ibm.com>
 */

#ifndef CGROUP_H
14
# define CGROUP_H
15 16 17 18

struct virCgroup;
typedef struct virCgroup *virCgroupPtr;

19 20 21 22 23 24
enum {
    VIR_CGROUP_CONTROLLER_CPU,
    VIR_CGROUP_CONTROLLER_CPUACCT,
    VIR_CGROUP_CONTROLLER_CPUSET,
    VIR_CGROUP_CONTROLLER_MEMORY,
    VIR_CGROUP_CONTROLLER_DEVICES,
R
Ryota Ozaki 已提交
25
    VIR_CGROUP_CONTROLLER_FREEZER,
26
    VIR_CGROUP_CONTROLLER_BLKIO,
27 28 29 30 31 32

    VIR_CGROUP_CONTROLLER_LAST
};

VIR_ENUM_DECL(virCgroupController);

33 34 35 36
int virCgroupForDriver(const char *name,
                       virCgroupPtr *group,
                       int privileged,
                       int create);
37

38 39 40 41
int virCgroupForDomain(virCgroupPtr driver,
                       const char *name,
                       virCgroupPtr *group,
                       int create);
42

43 44 45 46 47
int virCgroupForVcpu(virCgroupPtr driver,
                     int vcpuid,
                     virCgroupPtr *group,
                     int create);

48 49 50 51 52
int virCgroupPathOfController(virCgroupPtr group,
                              int controller,
                              const char *key,
                              char **path);

53 54
int virCgroupAddTask(virCgroupPtr group, pid_t pid);

55 56 57
int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);

58
int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb);
R
Ryota Ozaki 已提交
59
int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);
60

61 62 63 64
int virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long long kb);
int virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long long *kb);
int virCgroupSetMemorySoftLimit(virCgroupPtr group, unsigned long long kb);
int virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned long long *kb);
65 66
int virCgroupSetMemSwapHardLimit(virCgroupPtr group, unsigned long long kb);
int virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb);
67

68 69 70 71 72 73 74 75
enum {
    VIR_CGROUP_DEVICE_READ  = 1,
    VIR_CGROUP_DEVICE_WRITE = 2,
    VIR_CGROUP_DEVICE_MKNOD = 4,
    VIR_CGROUP_DEVICE_RW    = VIR_CGROUP_DEVICE_READ | VIR_CGROUP_DEVICE_WRITE,
    VIR_CGROUP_DEVICE_RWM   = VIR_CGROUP_DEVICE_RW | VIR_CGROUP_DEVICE_MKNOD,
};

76 77 78 79 80
int virCgroupDenyAllDevices(virCgroupPtr group);

int virCgroupAllowDevice(virCgroupPtr group,
                         char type,
                         int major,
81 82
                         int minor,
                         int perms);
83 84
int virCgroupAllowDeviceMajor(virCgroupPtr group,
                              char type,
85 86
                              int major,
                              int perms);
87
int virCgroupAllowDevicePath(virCgroupPtr group,
88 89
                             const char *path,
                             int perms);
90 91 92 93

int virCgroupDenyDevice(virCgroupPtr group,
                        char type,
                        int major,
94 95
                        int minor,
                        int perms);
96 97
int virCgroupDenyDeviceMajor(virCgroupPtr group,
                             char type,
98 99
                             int major,
                             int perms);
100
int virCgroupDenyDevicePath(virCgroupPtr group,
101 102
                            const char *path,
                            int perms);
103

104 105
int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares);
int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares);
106

107 108 109 110 111 112
int virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period);
int virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period);

int virCgroupSetCpuCfsQuota(virCgroupPtr group, long long cfs_quota);
int virCgroupGetCpuCfsQuota(virCgroupPtr group, long long *cfs_quota);

113 114
int virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage);

R
Ryota Ozaki 已提交
115 116 117
int virCgroupSetFreezerState(virCgroupPtr group, const char *state);
int virCgroupGetFreezerState(virCgroupPtr group, char **state);

118 119 120
int virCgroupRemove(virCgroupPtr group);

void virCgroupFree(virCgroupPtr *group);
L
Lai Jiangshan 已提交
121
bool virCgroupMounted(virCgroupPtr cgroup, int controller);
122

123 124 125 126
int virCgroupKill(virCgroupPtr group, int signum);
int virCgroupKillRecursive(virCgroupPtr group, int signum);
int virCgroupKillPainfully(virCgroupPtr group);

127
#endif /* CGROUP_H */