2008-10-03 17:58:02 +00:00
|
|
|
/*
|
|
|
|
* cgroup.h: Interface to tools for managing cgroups
|
|
|
|
*
|
2012-03-09 00:35:59 +00:00
|
|
|
* Copyright (C) 2011-2012 Red Hat, Inc.
|
2008-10-03 17:58:02 +00:00
|
|
|
* Copyright IBM Corp. 2008
|
|
|
|
*
|
2012-07-27 09:39:53 +00:00
|
|
|
* This library 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.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-27 09:39:53 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2008-10-03 17:58:02 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Dan Smith <danms@us.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CGROUP_H
|
2010-03-09 18:22:22 +00:00
|
|
|
# define CGROUP_H
|
2008-10-03 17:58:02 +00:00
|
|
|
|
|
|
|
struct virCgroup;
|
|
|
|
typedef struct virCgroup *virCgroupPtr;
|
|
|
|
|
2009-07-22 15:08:04 +00:00
|
|
|
enum {
|
|
|
|
VIR_CGROUP_CONTROLLER_CPU,
|
|
|
|
VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
|
|
VIR_CGROUP_CONTROLLER_CPUSET,
|
|
|
|
VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
|
VIR_CGROUP_CONTROLLER_DEVICES,
|
2009-09-21 14:31:22 +00:00
|
|
|
VIR_CGROUP_CONTROLLER_FREEZER,
|
2011-02-08 17:41:17 +00:00
|
|
|
VIR_CGROUP_CONTROLLER_BLKIO,
|
2009-07-22 15:08:04 +00:00
|
|
|
|
|
|
|
VIR_CGROUP_CONTROLLER_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
VIR_ENUM_DECL(virCgroupController);
|
|
|
|
|
2009-07-10 10:40:04 +00:00
|
|
|
int virCgroupForDriver(const char *name,
|
|
|
|
virCgroupPtr *group,
|
|
|
|
int privileged,
|
|
|
|
int create);
|
2008-10-03 17:58:02 +00:00
|
|
|
|
2009-07-10 10:40:04 +00:00
|
|
|
int virCgroupForDomain(virCgroupPtr driver,
|
|
|
|
const char *name,
|
|
|
|
virCgroupPtr *group,
|
|
|
|
int create);
|
2008-10-03 17:58:02 +00:00
|
|
|
|
2011-07-21 07:12:55 +00:00
|
|
|
int virCgroupForVcpu(virCgroupPtr driver,
|
|
|
|
int vcpuid,
|
|
|
|
virCgroupPtr *group,
|
|
|
|
int create);
|
|
|
|
|
2012-08-21 09:18:24 +00:00
|
|
|
int virCgroupForEmulator(virCgroupPtr driver,
|
|
|
|
virCgroupPtr *group,
|
|
|
|
int create);
|
|
|
|
|
2011-03-07 23:41:40 +00:00
|
|
|
int virCgroupPathOfController(virCgroupPtr group,
|
|
|
|
int controller,
|
|
|
|
const char *key,
|
|
|
|
char **path);
|
|
|
|
|
2008-10-03 17:58:02 +00:00
|
|
|
int virCgroupAddTask(virCgroupPtr group, pid_t pid);
|
|
|
|
|
2012-08-21 09:18:25 +00:00
|
|
|
int virCgroupAddTaskController(virCgroupPtr group,
|
|
|
|
pid_t pid,
|
|
|
|
int controller);
|
|
|
|
|
|
|
|
int virCgroupMoveTask(virCgroupPtr src_group,
|
|
|
|
virCgroupPtr dest_group,
|
|
|
|
int controller);
|
|
|
|
|
2011-02-08 06:56:39 +00:00
|
|
|
int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
|
|
|
|
int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);
|
|
|
|
|
2011-11-08 11:00:34 +00:00
|
|
|
int virCgroupSetBlkioDeviceWeight(virCgroupPtr group,
|
|
|
|
const char *path,
|
|
|
|
unsigned int weight);
|
|
|
|
|
2011-01-13 09:18:11 +00:00
|
|
|
int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb);
|
2009-10-07 13:26:23 +00:00
|
|
|
int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);
|
2008-10-03 17:58:02 +00:00
|
|
|
|
2011-01-13 09:18:11 +00:00
|
|
|
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);
|
2011-03-16 05:07:12 +00:00
|
|
|
int virCgroupSetMemSwapHardLimit(virCgroupPtr group, unsigned long long kb);
|
|
|
|
int virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb);
|
2010-10-12 14:50:53 +00:00
|
|
|
|
2011-03-09 03:13:18 +00:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2008-10-03 17:58:02 +00:00
|
|
|
int virCgroupDenyAllDevices(virCgroupPtr group);
|
|
|
|
|
|
|
|
int virCgroupAllowDevice(virCgroupPtr group,
|
|
|
|
char type,
|
|
|
|
int major,
|
2011-03-09 03:13:18 +00:00
|
|
|
int minor,
|
|
|
|
int perms);
|
2008-10-21 16:46:47 +00:00
|
|
|
int virCgroupAllowDeviceMajor(virCgroupPtr group,
|
|
|
|
char type,
|
2011-03-09 03:13:18 +00:00
|
|
|
int major,
|
|
|
|
int perms);
|
2009-07-09 13:11:49 +00:00
|
|
|
int virCgroupAllowDevicePath(virCgroupPtr group,
|
2011-03-09 03:13:18 +00:00
|
|
|
const char *path,
|
|
|
|
int perms);
|
2009-07-09 13:11:49 +00:00
|
|
|
|
|
|
|
int virCgroupDenyDevice(virCgroupPtr group,
|
|
|
|
char type,
|
|
|
|
int major,
|
2011-03-09 03:13:18 +00:00
|
|
|
int minor,
|
|
|
|
int perms);
|
2009-07-09 13:11:49 +00:00
|
|
|
int virCgroupDenyDeviceMajor(virCgroupPtr group,
|
|
|
|
char type,
|
2011-03-09 03:13:18 +00:00
|
|
|
int major,
|
|
|
|
int perms);
|
2009-07-09 13:11:49 +00:00
|
|
|
int virCgroupDenyDevicePath(virCgroupPtr group,
|
2011-03-09 03:13:18 +00:00
|
|
|
const char *path,
|
|
|
|
int perms);
|
2008-10-03 17:58:02 +00:00
|
|
|
|
2009-07-09 13:11:21 +00:00
|
|
|
int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares);
|
|
|
|
int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares);
|
2008-10-08 16:28:48 +00:00
|
|
|
|
2011-07-21 07:21:05 +00:00
|
|
|
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);
|
|
|
|
|
2009-03-06 14:44:04 +00:00
|
|
|
int virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage);
|
2012-03-02 02:54:23 +00:00
|
|
|
int virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage);
|
2012-03-09 00:35:59 +00:00
|
|
|
int virCgroupGetCpuacctStat(virCgroupPtr group, unsigned long long *user,
|
|
|
|
unsigned long long *sys);
|
2009-03-06 14:44:04 +00:00
|
|
|
|
2009-09-21 14:31:22 +00:00
|
|
|
int virCgroupSetFreezerState(virCgroupPtr group, const char *state);
|
|
|
|
int virCgroupGetFreezerState(virCgroupPtr group, char **state);
|
|
|
|
|
2011-12-20 08:34:58 +00:00
|
|
|
int virCgroupSetCpusetMems(virCgroupPtr group, const char *mems);
|
|
|
|
int virCgroupGetCpusetMems(virCgroupPtr group, char **mems);
|
|
|
|
|
2012-08-21 09:18:30 +00:00
|
|
|
int virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus);
|
|
|
|
int virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus);
|
|
|
|
|
2008-10-03 17:58:02 +00:00
|
|
|
int virCgroupRemove(virCgroupPtr group);
|
|
|
|
|
|
|
|
void virCgroupFree(virCgroupPtr *group);
|
2010-10-29 09:32:16 +00:00
|
|
|
bool virCgroupMounted(virCgroupPtr cgroup, int controller);
|
2008-10-03 17:58:02 +00:00
|
|
|
|
2011-02-22 17:33:59 +00:00
|
|
|
int virCgroupKill(virCgroupPtr group, int signum);
|
|
|
|
int virCgroupKillRecursive(virCgroupPtr group, int signum);
|
|
|
|
int virCgroupKillPainfully(virCgroupPtr group);
|
|
|
|
|
2008-10-03 17:58:02 +00:00
|
|
|
#endif /* CGROUP_H */
|