2018-08-15 11:10:24 +00:00
|
|
|
/*
|
|
|
|
* vircgroupbackend.h: methods for cgroups backend
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:54 +00:00
|
|
|
#pragma once
|
2018-08-15 11:10:24 +00:00
|
|
|
|
2019-06-18 16:12:54 +00:00
|
|
|
#include "internal.h"
|
2018-08-15 11:10:24 +00:00
|
|
|
|
2019-06-18 16:12:54 +00:00
|
|
|
#include "vircgroup.h"
|
2018-08-15 11:10:24 +00:00
|
|
|
|
2019-06-18 16:12:54 +00:00
|
|
|
#define CGROUP_MAX_VAL 512
|
2018-08-15 11:10:24 +00:00
|
|
|
|
2018-09-18 14:11:47 +00:00
|
|
|
typedef enum {
|
|
|
|
VIR_CGROUP_NONE = 0, /* create subdir under each cgroup if possible. */
|
|
|
|
VIR_CGROUP_MEM_HIERACHY = 1 << 0, /* call virCgroupSetMemoryUseHierarchy
|
|
|
|
* before creating subcgroups and
|
|
|
|
* attaching tasks
|
|
|
|
*/
|
2018-09-18 15:49:19 +00:00
|
|
|
VIR_CGROUP_THREAD = 1 << 1, /* cgroup v2 handles threads differently */
|
2019-06-27 12:54:54 +00:00
|
|
|
VIR_CGROUP_SYSTEMD = 1 << 2, /* with systemd and cgroups v2 we cannot
|
|
|
|
* manually enable controllers that systemd
|
|
|
|
* doesn't know how to delegate */
|
2018-09-18 14:11:47 +00:00
|
|
|
} virCgroupBackendFlags;
|
|
|
|
|
2018-09-24 23:14:36 +00:00
|
|
|
typedef enum {
|
|
|
|
/* Adds a whole process with all threads to specific cgroup except
|
|
|
|
* to systemd named controller. */
|
|
|
|
VIR_CGROUP_TASK_PROCESS = 1 << 0,
|
|
|
|
|
|
|
|
/* Same as VIR_CGROUP_TASK_PROCESS but it also adds the task to systemd
|
|
|
|
* named controller. */
|
|
|
|
VIR_CGROUP_TASK_SYSTEMD = 1 << 1,
|
|
|
|
|
|
|
|
/* Moves only specific thread into cgroup except to systemd
|
|
|
|
* named controller. */
|
|
|
|
VIR_CGROUP_TASK_THREAD = 1 << 2,
|
|
|
|
} virCgroupBackendTaskFlags;
|
|
|
|
|
2018-08-15 11:10:24 +00:00
|
|
|
typedef enum {
|
2018-09-18 15:48:33 +00:00
|
|
|
VIR_CGROUP_BACKEND_TYPE_V2 = 0,
|
|
|
|
VIR_CGROUP_BACKEND_TYPE_V1,
|
2018-08-15 11:10:24 +00:00
|
|
|
VIR_CGROUP_BACKEND_TYPE_LAST,
|
|
|
|
} virCgroupBackendType;
|
|
|
|
|
2021-04-16 14:14:33 +00:00
|
|
|
VIR_ENUM_DECL(virCgroupBackend);
|
|
|
|
|
2018-09-13 14:27:56 +00:00
|
|
|
typedef bool
|
|
|
|
(*virCgroupAvailableCB)(void);
|
|
|
|
|
2018-09-14 11:21:19 +00:00
|
|
|
typedef bool
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupValidateMachineGroupCB)(virCgroup *group,
|
2018-09-14 11:21:19 +00:00
|
|
|
const char *name,
|
|
|
|
const char *drivername,
|
|
|
|
const char *machinename);
|
|
|
|
|
2018-08-17 07:46:10 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupCopyMountsCB)(virCgroup *group,
|
|
|
|
virCgroup *parent);
|
2018-08-17 07:46:10 +00:00
|
|
|
|
2018-09-14 10:53:47 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupCopyPlacementCB)(virCgroup *group,
|
2018-09-14 10:53:47 +00:00
|
|
|
const char *path,
|
2021-03-11 07:16:13 +00:00
|
|
|
virCgroup *parent);
|
2018-09-14 10:53:47 +00:00
|
|
|
|
2018-09-14 10:51:27 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupDetectMountsCB)(virCgroup *group,
|
2018-09-14 10:51:27 +00:00
|
|
|
const char *mntType,
|
|
|
|
const char *mntOpts,
|
|
|
|
const char *mntDir);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupDetectPlacementCB)(virCgroup *group,
|
2018-09-14 10:51:27 +00:00
|
|
|
const char *path,
|
|
|
|
const char *controllers,
|
|
|
|
const char *selfpath);
|
|
|
|
|
2020-10-21 12:35:48 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetPlacementCB)(virCgroup *group,
|
2020-10-21 12:35:48 +00:00
|
|
|
const char *path);
|
|
|
|
|
2018-08-24 13:15:23 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupValidatePlacementCB)(virCgroup *group,
|
2018-08-24 13:15:23 +00:00
|
|
|
pid_t pid);
|
|
|
|
|
2018-08-17 10:00:29 +00:00
|
|
|
typedef char *
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupStealPlacementCB)(virCgroup *group);
|
2018-08-17 10:00:29 +00:00
|
|
|
|
2018-09-24 23:12:22 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupDetectControllersCB)(virCgroup *group,
|
2019-07-22 12:37:36 +00:00
|
|
|
int controllers,
|
2021-03-11 07:16:13 +00:00
|
|
|
virCgroup *parent,
|
2019-11-14 10:44:42 +00:00
|
|
|
int detected);
|
2018-09-24 23:12:22 +00:00
|
|
|
|
2018-08-19 17:17:27 +00:00
|
|
|
typedef bool
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupHasControllerCB)(virCgroup *cgroup,
|
2018-08-19 17:17:27 +00:00
|
|
|
int controller);
|
|
|
|
|
2018-08-19 17:20:25 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetAnyControllerCB)(virCgroup *group);
|
2018-08-19 17:20:25 +00:00
|
|
|
|
2018-08-19 17:24:58 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupPathOfControllerCB)(virCgroup *group,
|
2018-08-19 17:24:58 +00:00
|
|
|
int controller,
|
|
|
|
const char *key,
|
|
|
|
char **path);
|
|
|
|
|
2021-02-09 11:31:13 +00:00
|
|
|
typedef bool
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupExistsCB)(virCgroup *group);
|
2021-02-09 11:31:13 +00:00
|
|
|
|
2018-09-18 14:11:47 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupMakeGroupCB)(virCgroup *parent,
|
|
|
|
virCgroup *group,
|
2018-09-18 14:11:47 +00:00
|
|
|
bool create,
|
2020-11-04 18:55:44 +00:00
|
|
|
pid_t pid,
|
2018-09-18 14:11:47 +00:00
|
|
|
unsigned int flags);
|
|
|
|
|
2018-08-17 08:02:05 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupRemoveCB)(virCgroup *group);
|
2018-08-17 08:02:05 +00:00
|
|
|
|
2018-09-24 23:14:36 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupAddTaskCB)(virCgroup *group,
|
2018-09-24 23:14:36 +00:00
|
|
|
pid_t pid,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2018-08-17 13:25:48 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupHasEmptyTasksCB)(virCgroup *cgroup,
|
2018-08-17 13:25:48 +00:00
|
|
|
int controller);
|
|
|
|
|
2018-12-10 08:51:14 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupKillRecursiveCB)(virCgroup *group,
|
2018-12-10 08:51:14 +00:00
|
|
|
int signum,
|
2020-10-20 15:01:51 +00:00
|
|
|
GHashTable *pids);
|
2018-12-10 08:51:14 +00:00
|
|
|
|
2018-08-17 08:04:20 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupBindMountCB)(virCgroup *group,
|
2018-08-17 08:04:20 +00:00
|
|
|
const char *oldroot,
|
|
|
|
const char *mountopts);
|
|
|
|
|
2018-08-17 08:09:49 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetOwnerCB)(virCgroup *cgroup,
|
2018-08-17 08:09:49 +00:00
|
|
|
uid_t uid,
|
|
|
|
gid_t gid,
|
|
|
|
int controllers);
|
|
|
|
|
2018-08-17 13:28:50 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetBlkioWeightCB)(virCgroup *group,
|
2018-08-17 13:28:50 +00:00
|
|
|
unsigned int weight);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioWeightCB)(virCgroup *group,
|
2018-08-17 13:28:50 +00:00
|
|
|
unsigned int *weight);
|
|
|
|
|
2018-08-17 13:29:39 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioIoServicedCB)(virCgroup *group,
|
2018-08-17 13:29:39 +00:00
|
|
|
long long *bytes_read,
|
|
|
|
long long *bytes_write,
|
|
|
|
long long *requests_read,
|
|
|
|
long long *requests_write);
|
|
|
|
|
2018-08-17 13:30:21 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioIoDeviceServicedCB)(virCgroup *group,
|
2018-08-17 13:30:21 +00:00
|
|
|
const char *path,
|
|
|
|
long long *bytes_read,
|
|
|
|
long long *bytes_write,
|
|
|
|
long long *requests_read,
|
|
|
|
long long *requests_write);
|
|
|
|
|
2018-09-24 10:20:19 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetBlkioDeviceWeightCB)(virCgroup *group,
|
2018-09-24 10:20:19 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned int weight);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioDeviceWeightCB)(virCgroup *group,
|
2018-09-24 10:20:19 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned int *weight);
|
|
|
|
|
2018-09-24 10:20:31 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetBlkioDeviceReadIopsCB)(virCgroup *group,
|
2018-09-24 10:20:31 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned int riops);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioDeviceReadIopsCB)(virCgroup *group,
|
2018-09-24 10:20:31 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned int *riops);
|
|
|
|
|
2018-09-24 10:20:50 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetBlkioDeviceWriteIopsCB)(virCgroup *group,
|
2018-09-24 10:20:50 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned int wiops);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioDeviceWriteIopsCB)(virCgroup *group,
|
2018-09-24 10:20:50 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned int *wiops);
|
|
|
|
|
2018-09-24 10:21:07 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetBlkioDeviceReadBpsCB)(virCgroup *group,
|
2018-09-24 10:21:07 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned long long rbps);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioDeviceReadBpsCB)(virCgroup *group,
|
2018-09-24 10:21:07 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned long long *rbps);
|
|
|
|
|
2018-09-24 10:21:21 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetBlkioDeviceWriteBpsCB)(virCgroup *group,
|
2018-09-24 10:21:21 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned long long wbps);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetBlkioDeviceWriteBpsCB)(virCgroup *group,
|
2018-09-24 10:21:21 +00:00
|
|
|
const char *path,
|
|
|
|
unsigned long long *wbps);
|
|
|
|
|
2018-08-17 13:53:41 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetMemoryCB)(virCgroup *group,
|
2018-08-17 13:53:41 +00:00
|
|
|
unsigned long long kb);
|
|
|
|
|
2018-08-17 13:55:47 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetMemoryStatCB)(virCgroup *group,
|
2018-08-17 13:55:47 +00:00
|
|
|
unsigned long long *cache,
|
|
|
|
unsigned long long *activeAnon,
|
|
|
|
unsigned long long *inactiveAnon,
|
|
|
|
unsigned long long *activeFile,
|
|
|
|
unsigned long long *inactiveFile,
|
|
|
|
unsigned long long *unevictable);
|
|
|
|
|
2018-08-17 13:56:33 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetMemoryUsageCB)(virCgroup *group,
|
2018-08-17 13:56:33 +00:00
|
|
|
unsigned long *kb);
|
|
|
|
|
2018-08-17 14:18:38 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetMemoryHardLimitCB)(virCgroup *group,
|
2018-08-17 14:18:38 +00:00
|
|
|
unsigned long long kb);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetMemoryHardLimitCB)(virCgroup *group,
|
2018-08-17 14:18:38 +00:00
|
|
|
unsigned long long *kb);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetMemorySoftLimitCB)(virCgroup *group,
|
2018-08-17 14:18:38 +00:00
|
|
|
unsigned long long kb);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetMemorySoftLimitCB)(virCgroup *group,
|
2018-08-17 14:18:38 +00:00
|
|
|
unsigned long long *kb);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetMemSwapHardLimitCB)(virCgroup *group,
|
2018-08-17 14:18:38 +00:00
|
|
|
unsigned long long kb);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetMemSwapHardLimitCB)(virCgroup *group,
|
2018-08-17 14:18:38 +00:00
|
|
|
unsigned long long *kb);
|
|
|
|
|
2018-08-17 14:19:08 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetMemSwapUsageCB)(virCgroup *group,
|
2018-08-17 14:19:08 +00:00
|
|
|
unsigned long long *kb);
|
|
|
|
|
2018-09-05 18:08:48 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupAllowDeviceCB)(virCgroup *group,
|
2018-09-05 18:08:48 +00:00
|
|
|
char type,
|
|
|
|
int major,
|
|
|
|
int minor,
|
|
|
|
int perms);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupDenyDeviceCB)(virCgroup *group,
|
2018-09-05 18:08:48 +00:00
|
|
|
char type,
|
|
|
|
int major,
|
|
|
|
int minor,
|
|
|
|
int perms);
|
|
|
|
|
2018-09-05 18:10:02 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupAllowAllDevicesCB)(virCgroup *group,
|
2018-09-05 18:10:02 +00:00
|
|
|
int perms);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupDenyAllDevicesCB)(virCgroup *group);
|
2018-09-05 18:10:02 +00:00
|
|
|
|
2018-09-05 18:11:38 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetCpuSharesCB)(virCgroup *group,
|
2018-09-05 18:11:38 +00:00
|
|
|
unsigned long long shares);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpuSharesCB)(virCgroup *group,
|
2018-09-05 18:11:38 +00:00
|
|
|
unsigned long long *shares);
|
|
|
|
|
2018-08-17 14:22:30 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetCpuCfsPeriodCB)(virCgroup *group,
|
2018-08-17 14:22:30 +00:00
|
|
|
unsigned long long cfs_period);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpuCfsPeriodCB)(virCgroup *group,
|
2018-08-17 14:22:30 +00:00
|
|
|
unsigned long long *cfs_period);
|
|
|
|
|
2018-08-17 14:22:56 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetCpuCfsQuotaCB)(virCgroup *group,
|
2018-08-17 14:22:56 +00:00
|
|
|
long long cfs_quota);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpuCfsQuotaCB)(virCgroup *group,
|
2018-08-17 14:22:56 +00:00
|
|
|
long long *cfs_quota);
|
|
|
|
|
2018-08-17 14:23:14 +00:00
|
|
|
typedef bool
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSupportsCpuBWCB)(virCgroup *cgroup);
|
2018-08-17 14:23:14 +00:00
|
|
|
|
2018-08-20 07:57:51 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpuacctUsageCB)(virCgroup *group,
|
2018-08-20 07:57:51 +00:00
|
|
|
unsigned long long *usage);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpuacctPercpuUsageCB)(virCgroup *group,
|
2018-08-20 07:57:51 +00:00
|
|
|
char **usage);
|
|
|
|
|
2018-08-20 07:58:33 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpuacctStatCB)(virCgroup *group,
|
2018-08-20 07:58:33 +00:00
|
|
|
unsigned long long *user,
|
|
|
|
unsigned long long *sys);
|
|
|
|
|
2018-08-16 16:22:08 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetFreezerStateCB)(virCgroup *group,
|
2018-08-16 16:22:08 +00:00
|
|
|
const char *state);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetFreezerStateCB)(virCgroup *group,
|
2018-08-16 16:22:08 +00:00
|
|
|
char **state);
|
|
|
|
|
2018-08-20 08:00:04 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetCpusetMemsCB)(virCgroup *group,
|
2018-08-20 08:00:04 +00:00
|
|
|
const char *mems);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpusetMemsCB)(virCgroup *group,
|
2018-08-20 08:00:04 +00:00
|
|
|
char **mems);
|
|
|
|
|
2018-08-20 08:00:57 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetCpusetMemoryMigrateCB)(virCgroup *group,
|
2018-08-20 08:00:57 +00:00
|
|
|
bool migrate);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpusetMemoryMigrateCB)(virCgroup *group,
|
2018-08-20 08:00:57 +00:00
|
|
|
bool *migrate);
|
|
|
|
|
2018-08-20 08:01:10 +00:00
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupSetCpusetCpusCB)(virCgroup *group,
|
2018-08-20 08:01:10 +00:00
|
|
|
const char *cpus);
|
|
|
|
|
|
|
|
typedef int
|
2021-03-11 07:16:13 +00:00
|
|
|
(*virCgroupGetCpusetCpusCB)(virCgroup *group,
|
2018-08-20 08:01:10 +00:00
|
|
|
char **cpus);
|
|
|
|
|
2018-08-15 11:10:24 +00:00
|
|
|
struct _virCgroupBackend {
|
|
|
|
virCgroupBackendType type;
|
2018-09-13 14:27:56 +00:00
|
|
|
|
|
|
|
/* Mandatory callbacks that need to be implemented for every backend. */
|
|
|
|
virCgroupAvailableCB available;
|
2018-09-14 11:21:19 +00:00
|
|
|
virCgroupValidateMachineGroupCB validateMachineGroup;
|
2018-08-17 07:46:10 +00:00
|
|
|
virCgroupCopyMountsCB copyMounts;
|
2018-09-14 10:53:47 +00:00
|
|
|
virCgroupCopyPlacementCB copyPlacement;
|
2018-09-14 10:51:27 +00:00
|
|
|
virCgroupDetectMountsCB detectMounts;
|
|
|
|
virCgroupDetectPlacementCB detectPlacement;
|
2020-10-21 12:35:48 +00:00
|
|
|
virCgroupSetPlacementCB setPlacement;
|
2018-08-24 13:15:23 +00:00
|
|
|
virCgroupValidatePlacementCB validatePlacement;
|
2018-08-17 10:00:29 +00:00
|
|
|
virCgroupStealPlacementCB stealPlacement;
|
2018-09-24 23:12:22 +00:00
|
|
|
virCgroupDetectControllersCB detectControllers;
|
2018-08-19 17:17:27 +00:00
|
|
|
virCgroupHasControllerCB hasController;
|
2018-08-19 17:20:25 +00:00
|
|
|
virCgroupGetAnyControllerCB getAnyController;
|
2018-08-19 17:24:58 +00:00
|
|
|
virCgroupPathOfControllerCB pathOfController;
|
2018-09-18 14:11:47 +00:00
|
|
|
virCgroupMakeGroupCB makeGroup;
|
2021-02-09 11:31:13 +00:00
|
|
|
virCgroupExistsCB exists;
|
2018-08-17 08:02:05 +00:00
|
|
|
virCgroupRemoveCB remove;
|
2018-09-24 23:14:36 +00:00
|
|
|
virCgroupAddTaskCB addTask;
|
2018-08-17 13:25:48 +00:00
|
|
|
virCgroupHasEmptyTasksCB hasEmptyTasks;
|
2018-12-10 08:51:14 +00:00
|
|
|
virCgroupKillRecursiveCB killRecursive;
|
2018-08-17 08:04:20 +00:00
|
|
|
virCgroupBindMountCB bindMount;
|
2018-08-17 08:09:49 +00:00
|
|
|
virCgroupSetOwnerCB setOwner;
|
2018-08-17 13:28:50 +00:00
|
|
|
|
|
|
|
/* Optional cgroup controller specific callbacks. */
|
|
|
|
virCgroupSetBlkioWeightCB setBlkioWeight;
|
|
|
|
virCgroupGetBlkioWeightCB getBlkioWeight;
|
2018-08-17 13:29:39 +00:00
|
|
|
virCgroupGetBlkioIoServicedCB getBlkioIoServiced;
|
2018-08-17 13:30:21 +00:00
|
|
|
virCgroupGetBlkioIoDeviceServicedCB getBlkioIoDeviceServiced;
|
2018-09-24 10:20:19 +00:00
|
|
|
virCgroupSetBlkioDeviceWeightCB setBlkioDeviceWeight;
|
|
|
|
virCgroupGetBlkioDeviceWeightCB getBlkioDeviceWeight;
|
2018-09-24 10:20:31 +00:00
|
|
|
virCgroupSetBlkioDeviceReadIopsCB setBlkioDeviceReadIops;
|
|
|
|
virCgroupGetBlkioDeviceReadIopsCB getBlkioDeviceReadIops;
|
2018-09-24 10:20:50 +00:00
|
|
|
virCgroupSetBlkioDeviceWriteIopsCB setBlkioDeviceWriteIops;
|
|
|
|
virCgroupGetBlkioDeviceWriteIopsCB getBlkioDeviceWriteIops;
|
2018-09-24 10:21:07 +00:00
|
|
|
virCgroupSetBlkioDeviceReadBpsCB setBlkioDeviceReadBps;
|
|
|
|
virCgroupGetBlkioDeviceReadBpsCB getBlkioDeviceReadBps;
|
2018-09-24 10:21:21 +00:00
|
|
|
virCgroupSetBlkioDeviceWriteBpsCB setBlkioDeviceWriteBps;
|
|
|
|
virCgroupGetBlkioDeviceWriteBpsCB getBlkioDeviceWriteBps;
|
2018-08-17 13:53:41 +00:00
|
|
|
|
|
|
|
virCgroupSetMemoryCB setMemory;
|
2018-08-17 13:55:47 +00:00
|
|
|
virCgroupGetMemoryStatCB getMemoryStat;
|
2018-08-17 13:56:33 +00:00
|
|
|
virCgroupGetMemoryUsageCB getMemoryUsage;
|
2018-08-17 14:18:38 +00:00
|
|
|
virCgroupSetMemoryHardLimitCB setMemoryHardLimit;
|
|
|
|
virCgroupGetMemoryHardLimitCB getMemoryHardLimit;
|
|
|
|
virCgroupSetMemorySoftLimitCB setMemorySoftLimit;
|
|
|
|
virCgroupGetMemorySoftLimitCB getMemorySoftLimit;
|
|
|
|
virCgroupSetMemSwapHardLimitCB setMemSwapHardLimit;
|
|
|
|
virCgroupGetMemSwapHardLimitCB getMemSwapHardLimit;
|
2018-08-17 14:19:08 +00:00
|
|
|
virCgroupGetMemSwapUsageCB getMemSwapUsage;
|
2018-09-05 18:08:48 +00:00
|
|
|
|
|
|
|
virCgroupAllowDeviceCB allowDevice;
|
|
|
|
virCgroupDenyDeviceCB denyDevice;
|
2018-09-05 18:10:02 +00:00
|
|
|
virCgroupAllowAllDevicesCB allowAllDevices;
|
|
|
|
virCgroupDenyAllDevicesCB denyAllDevices;
|
2018-09-05 18:11:38 +00:00
|
|
|
|
|
|
|
virCgroupSetCpuSharesCB setCpuShares;
|
|
|
|
virCgroupGetCpuSharesCB getCpuShares;
|
2018-08-17 14:22:30 +00:00
|
|
|
virCgroupSetCpuCfsPeriodCB setCpuCfsPeriod;
|
|
|
|
virCgroupGetCpuCfsPeriodCB getCpuCfsPeriod;
|
2018-08-17 14:22:56 +00:00
|
|
|
virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
|
|
|
|
virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
|
2018-08-17 14:23:14 +00:00
|
|
|
virCgroupSupportsCpuBWCB supportsCpuBW;
|
2018-08-20 07:57:51 +00:00
|
|
|
|
|
|
|
virCgroupGetCpuacctUsageCB getCpuacctUsage;
|
|
|
|
virCgroupGetCpuacctPercpuUsageCB getCpuacctPercpuUsage;
|
2018-08-20 07:58:33 +00:00
|
|
|
virCgroupGetCpuacctStatCB getCpuacctStat;
|
2018-08-16 16:22:08 +00:00
|
|
|
|
|
|
|
virCgroupSetFreezerStateCB setFreezerState;
|
|
|
|
virCgroupGetFreezerStateCB getFreezerState;
|
2018-08-20 08:00:04 +00:00
|
|
|
|
|
|
|
virCgroupSetCpusetMemsCB setCpusetMems;
|
|
|
|
virCgroupGetCpusetMemsCB getCpusetMems;
|
2018-08-20 08:00:57 +00:00
|
|
|
virCgroupSetCpusetMemoryMigrateCB setCpusetMemoryMigrate;
|
|
|
|
virCgroupGetCpusetMemoryMigrateCB getCpusetMemoryMigrate;
|
2018-08-20 08:01:10 +00:00
|
|
|
virCgroupSetCpusetCpusCB setCpusetCpus;
|
|
|
|
virCgroupGetCpusetCpusCB getCpusetCpus;
|
2018-08-15 11:10:24 +00:00
|
|
|
};
|
|
|
|
typedef struct _virCgroupBackend virCgroupBackend;
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virCgroupBackendRegister(virCgroupBackend *backend);
|
2018-08-15 11:10:24 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virCgroupBackend **
|
2018-08-15 11:10:24 +00:00
|
|
|
virCgroupBackendGetAll(void);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virCgroupBackend *
|
|
|
|
virCgroupBackendForController(virCgroup *group,
|
2018-09-28 17:53:05 +00:00
|
|
|
unsigned int controller);
|
|
|
|
|
2019-06-18 16:12:54 +00:00
|
|
|
#define VIR_CGROUP_BACKEND_CALL(group, controller, func, ret, ...) \
|
2020-07-28 18:08:07 +00:00
|
|
|
do { \
|
2021-03-11 07:16:13 +00:00
|
|
|
virCgroupBackend *backend = virCgroupBackendForController(group, controller); \
|
2020-07-28 18:08:07 +00:00
|
|
|
if (!backend) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
2021-04-16 14:14:33 +00:00
|
|
|
_("failed to get cgroup backend for '%s' controller '%u'"), \
|
|
|
|
#func, controller); \
|
2020-07-28 18:08:07 +00:00
|
|
|
return ret; \
|
|
|
|
} \
|
|
|
|
if (!backend->func) { \
|
|
|
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
|
2021-04-16 14:14:33 +00:00
|
|
|
_("operation '%s' not supported for backend '%s'"), \
|
|
|
|
#func, virCgroupBackendTypeToString(backend->type)); \
|
2020-07-28 18:08:07 +00:00
|
|
|
return ret; \
|
|
|
|
} \
|
|
|
|
return backend->func(group, ##__VA_ARGS__); \
|
|
|
|
} while (0)
|