cgroup.h 3.0 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

int virCgroupAddTask(virCgroupPtr group, pid_t pid);

45 46 47
int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);

48
int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb);
R
Ryota Ozaki 已提交
49
int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);
50

51 52 53 54 55 56
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);
int virCgroupSetSwapHardLimit(virCgroupPtr group, unsigned long long kb);
int virCgroupGetSwapHardLimit(virCgroupPtr group, unsigned long long *kb);
57

58 59 60 61 62 63
int virCgroupDenyAllDevices(virCgroupPtr group);

int virCgroupAllowDevice(virCgroupPtr group,
                         char type,
                         int major,
                         int minor);
64 65 66
int virCgroupAllowDeviceMajor(virCgroupPtr group,
                              char type,
                              int major);
67 68 69 70 71 72 73 74 75 76 77 78
int virCgroupAllowDevicePath(virCgroupPtr group,
                             const char *path);

int virCgroupDenyDevice(virCgroupPtr group,
                        char type,
                        int major,
                        int minor);
int virCgroupDenyDeviceMajor(virCgroupPtr group,
                             char type,
                             int major);
int virCgroupDenyDevicePath(virCgroupPtr group,
                            const char *path);
79

80 81
int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares);
int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares);
82

83 84
int virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage);

R
Ryota Ozaki 已提交
85 86 87
int virCgroupSetFreezerState(virCgroupPtr group, const char *state);
int virCgroupGetFreezerState(virCgroupPtr group, char **state);

88 89 90
int virCgroupRemove(virCgroupPtr group);

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

#endif /* CGROUP_H */