|
|
c480ed |
From 50c5a71ce4a4400d08deff481c8781f3fca755c8 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <50c5a71ce4a4400d08deff481c8781f3fca755c8@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:53 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: add support for hybrid configuration
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
This enables to use both cgroup v1 and v2 at the same time together
|
|
|
c480ed |
with libvirt. It is supported by kernel and there is valid use-case,
|
|
|
c480ed |
not all controllers are implemented in cgroup v2 so there might be
|
|
|
c480ed |
configurations where administrator would enable these missing
|
|
|
c480ed |
controllers in cgroup v1.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit b79d858518ed15b1a4271457fc9f39463dd99230)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <c84d8624633d438daa6b4de651eb6bb9e0afa25c.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 351 ++++++++++++++++++++++++++----------
|
|
|
c480ed |
src/util/vircgroupbackend.c | 20 ++
|
|
|
c480ed |
src/util/vircgroupbackend.h | 16 +-
|
|
|
c480ed |
src/util/vircgrouppriv.h | 2 +-
|
|
|
c480ed |
4 files changed, 291 insertions(+), 98 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index a859628241..069f1ae396 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -232,6 +232,7 @@ virCgroupDetectMounts(virCgroupPtr group)
|
|
|
c480ed |
struct mntent entry;
|
|
|
c480ed |
char buf[CGROUP_MAX_VAL];
|
|
|
c480ed |
int ret = -1;
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
|
|
|
c480ed |
mounts = fopen("/proc/mounts", "r");
|
|
|
c480ed |
if (mounts == NULL) {
|
|
|
c480ed |
@@ -240,11 +241,14 @@ virCgroupDetectMounts(virCgroupPtr group)
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
while (getmntent_r(mounts, &entry, buf, sizeof(buf)) != NULL) {
|
|
|
c480ed |
- if (group->backend->detectMounts(group,
|
|
|
c480ed |
- entry.mnt_type,
|
|
|
c480ed |
- entry.mnt_opts,
|
|
|
c480ed |
- entry.mnt_dir) < 0) {
|
|
|
c480ed |
- goto cleanup;
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->detectMounts(group,
|
|
|
c480ed |
+ entry.mnt_type,
|
|
|
c480ed |
+ entry.mnt_opts,
|
|
|
c480ed |
+ entry.mnt_dir) < 0) {
|
|
|
c480ed |
+ goto cleanup;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
}
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
@@ -307,6 +311,7 @@ virCgroupDetectPlacement(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
while (fgets(line, sizeof(line), mapping) != NULL) {
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
char *controllers = strchr(line, ':');
|
|
|
c480ed |
char *selfpath = controllers ? strchr(controllers + 1, ':') : NULL;
|
|
|
c480ed |
char *nl = selfpath ? strchr(selfpath, '\n') : NULL;
|
|
|
c480ed |
@@ -321,9 +326,12 @@ virCgroupDetectPlacement(virCgroupPtr group,
|
|
|
c480ed |
controllers++;
|
|
|
c480ed |
selfpath++;
|
|
|
c480ed |
|
|
|
c480ed |
- if (group->backend->detectPlacement(group, path, controllers,
|
|
|
c480ed |
- selfpath) < 0) {
|
|
|
c480ed |
- goto cleanup;
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->detectPlacement(group, path, controllers,
|
|
|
c480ed |
+ selfpath) < 0) {
|
|
|
c480ed |
+ goto cleanup;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
}
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
@@ -342,8 +350,9 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
virCgroupPtr parent)
|
|
|
c480ed |
{
|
|
|
c480ed |
- int rc;
|
|
|
c480ed |
size_t i;
|
|
|
c480ed |
+ bool backendAvailable = false;
|
|
|
c480ed |
+ int controllersAvailable = 0;
|
|
|
c480ed |
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
|
|
|
c480ed |
|
|
|
c480ed |
VIR_DEBUG("group=%p controllers=%d path=%s parent=%p",
|
|
|
c480ed |
@@ -354,31 +363,40 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
|
|
|
c480ed |
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
if (backends[i] && backends[i]->available()) {
|
|
|
c480ed |
- group->backend = backends[i];
|
|
|
c480ed |
- break;
|
|
|
c480ed |
+ group->backends[i] = backends[i];
|
|
|
c480ed |
+ backendAvailable = true;
|
|
|
c480ed |
}
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- if (!group->backend) {
|
|
|
c480ed |
+ if (!backendAvailable) {
|
|
|
c480ed |
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c480ed |
_("no cgroup backend available"));
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
if (parent) {
|
|
|
c480ed |
- if (group->backend->copyMounts(group, parent) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->copyMounts(group, parent) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
} else {
|
|
|
c480ed |
if (virCgroupDetectMounts(group) < 0)
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- rc = group->backend->detectControllers(group, controllers);
|
|
|
c480ed |
- if (rc < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i]) {
|
|
|
c480ed |
+ int rc = group->backends[i]->detectControllers(group, controllers);
|
|
|
c480ed |
+ if (rc < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ controllersAvailable |= rc;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
|
|
|
c480ed |
/* Check that at least 1 controller is available */
|
|
|
c480ed |
- if (rc == 0) {
|
|
|
c480ed |
+ if (controllersAvailable == 0) {
|
|
|
c480ed |
virReportSystemError(ENXIO, "%s",
|
|
|
c480ed |
_("At least one cgroup controller is required"));
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
@@ -387,17 +405,26 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
/* In some cases we can copy part of the placement info
|
|
|
c480ed |
* based on the parent cgroup...
|
|
|
c480ed |
*/
|
|
|
c480ed |
- if ((parent || path[0] == '/') &&
|
|
|
c480ed |
- group->backend->copyPlacement(group, path, parent) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
+ if (parent || path[0] == '/') {
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->copyPlacement(group, path, parent) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
|
|
|
c480ed |
/* ... but use /proc/cgroups to fill in the rest */
|
|
|
c480ed |
if (virCgroupDetectPlacement(group, pid, path) < 0)
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
|
|
|
c480ed |
/* Check that for every mounted controller, we found our placement */
|
|
|
c480ed |
- if (group->backend->validatePlacement(group, pid) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->validatePlacement(group, pid) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
|
|
|
c480ed |
return 0;
|
|
|
c480ed |
}
|
|
|
c480ed |
@@ -603,9 +630,14 @@ virCgroupMakeGroup(virCgroupPtr parent,
|
|
|
c480ed |
bool create,
|
|
|
c480ed |
unsigned int flags)
|
|
|
c480ed |
{
|
|
|
c480ed |
- if (group->backend->makeGroup(parent, group, create, flags) < 0) {
|
|
|
c480ed |
- virCgroupRemove(group);
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->makeGroup(parent, group, create, flags) < 0) {
|
|
|
c480ed |
+ virCgroupRemove(group);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
return 0;
|
|
|
c480ed |
@@ -666,6 +698,24 @@ virCgroupNew(pid_t pid,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupAddTaskInternal(virCgroupPtr group,
|
|
|
c480ed |
+ pid_t pid,
|
|
|
c480ed |
+ unsigned int flags)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->addTask(group, pid, flags) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
/**
|
|
|
c480ed |
* virCgroupAddProcess:
|
|
|
c480ed |
*
|
|
|
c480ed |
@@ -680,7 +730,7 @@ virCgroupNew(pid_t pid,
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupAddProcess(virCgroupPtr group, pid_t pid)
|
|
|
c480ed |
{
|
|
|
c480ed |
- return group->backend->addTask(group, pid, VIR_CGROUP_TASK_PROCESS);
|
|
|
c480ed |
+ return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_PROCESS);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -697,9 +747,9 @@ virCgroupAddProcess(virCgroupPtr group, pid_t pid)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
|
|
|
c480ed |
{
|
|
|
c480ed |
- return group->backend->addTask(group, pid,
|
|
|
c480ed |
- VIR_CGROUP_TASK_PROCESS |
|
|
|
c480ed |
- VIR_CGROUP_TASK_SYSTEMD);
|
|
|
c480ed |
+ return virCgroupAddTaskInternal(group, pid,
|
|
|
c480ed |
+ VIR_CGROUP_TASK_PROCESS |
|
|
|
c480ed |
+ VIR_CGROUP_TASK_SYSTEMD);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -717,7 +767,7 @@ int
|
|
|
c480ed |
virCgroupAddThread(virCgroupPtr group,
|
|
|
c480ed |
pid_t pid)
|
|
|
c480ed |
{
|
|
|
c480ed |
- return group->backend->addTask(group, pid, VIR_CGROUP_TASK_THREAD);
|
|
|
c480ed |
+ return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_THREAD);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -971,17 +1021,24 @@ virCgroupNewDetectMachine(const char *name,
|
|
|
c480ed |
char *machinename,
|
|
|
c480ed |
virCgroupPtr *group)
|
|
|
c480ed |
{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
if (virCgroupNewDetect(pid, controllers, group) < 0) {
|
|
|
c480ed |
if (virCgroupNewIgnoreError())
|
|
|
c480ed |
return 0;
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- if (!(*group)->backend->validateMachineGroup(*group, name, drivername, machinename)) {
|
|
|
c480ed |
- VIR_DEBUG("Failed to validate machine name for '%s' driver '%s'",
|
|
|
c480ed |
- name, drivername);
|
|
|
c480ed |
- virCgroupFree(group);
|
|
|
c480ed |
- return 0;
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if ((*group)->backends[i] &&
|
|
|
c480ed |
+ !(*group)->backends[i]->validateMachineGroup(*group, name,
|
|
|
c480ed |
+ drivername,
|
|
|
c480ed |
+ machinename)) {
|
|
|
c480ed |
+ VIR_DEBUG("Failed to validate machine name for '%s' driver '%s'",
|
|
|
c480ed |
+ name, drivername);
|
|
|
c480ed |
+ virCgroupFree(group);
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
return 0;
|
|
|
c480ed |
@@ -1059,6 +1116,7 @@ virCgroupNewMachineSystemd(const char *name,
|
|
|
c480ed |
int rv;
|
|
|
c480ed |
virCgroupPtr init;
|
|
|
c480ed |
VIR_AUTOFREE(char *) path = NULL;
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
|
|
|
c480ed |
VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
|
|
|
c480ed |
if ((rv = virSystemdCreateMachine(name,
|
|
|
c480ed |
@@ -1081,7 +1139,12 @@ virCgroupNewMachineSystemd(const char *name,
|
|
|
c480ed |
&init) < 0)
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
|
|
|
c480ed |
- path = init->backend->stealPlacement(init);
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (init->backends[i] &&
|
|
|
c480ed |
+ (path = init->backends[i]->stealPlacement(init))) {
|
|
|
c480ed |
+ break;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
virCgroupFree(&init);
|
|
|
c480ed |
|
|
|
c480ed |
if (!path || STREQ(path, "/") || path[0] != '/') {
|
|
|
c480ed |
@@ -1260,12 +1323,21 @@ virCgroupFree(virCgroupPtr *group)
|
|
|
c480ed |
bool
|
|
|
c480ed |
virCgroupHasController(virCgroupPtr cgroup, int controller)
|
|
|
c480ed |
{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
if (!cgroup)
|
|
|
c480ed |
return false;
|
|
|
c480ed |
if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
|
|
|
c480ed |
return false;
|
|
|
c480ed |
|
|
|
c480ed |
- return cgroup->backend->hasController(cgroup, controller);
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (cgroup->backends[i] &&
|
|
|
c480ed |
+ cgroup->backends[i]->hasController(cgroup, controller)) {
|
|
|
c480ed |
+ return true;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return false;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1281,7 +1353,8 @@ virCgroupPathOfController(virCgroupPtr group,
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- return group->backend->pathOfController(group, controller, key, path);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, controller, pathOfController, -1,
|
|
|
c480ed |
+ controller, key, path);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1303,7 +1376,8 @@ virCgroupGetBlkioIoServiced(virCgroupPtr group,
|
|
|
c480ed |
long long *requests_read,
|
|
|
c480ed |
long long *requests_write)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioIoServiced, -1,
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioIoServiced, -1,
|
|
|
c480ed |
bytes_read, bytes_write,
|
|
|
c480ed |
requests_read, requests_write);
|
|
|
c480ed |
}
|
|
|
c480ed |
@@ -1329,7 +1403,8 @@ virCgroupGetBlkioIoDeviceServiced(virCgroupPtr group,
|
|
|
c480ed |
long long *requests_read,
|
|
|
c480ed |
long long *requests_write)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioIoDeviceServiced, -1,
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioIoDeviceServiced, -1,
|
|
|
c480ed |
path, bytes_read, bytes_write,
|
|
|
c480ed |
requests_read, requests_write);
|
|
|
c480ed |
}
|
|
|
c480ed |
@@ -1346,7 +1421,8 @@ virCgroupGetBlkioIoDeviceServiced(virCgroupPtr group,
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setBlkioWeight, -1, weight);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ setBlkioWeight, -1, weight);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1361,7 +1437,8 @@ virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioWeight, -1, weight);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioWeight, -1, weight);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1377,7 +1454,8 @@ virCgroupSetBlkioDeviceReadIops(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int riops)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceReadIops, -1, path, riops);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ setBlkioDeviceReadIops, -1, path, riops);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1394,7 +1472,8 @@ virCgroupSetBlkioDeviceWriteIops(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int wiops)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceWriteIops, -1, path, wiops);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ setBlkioDeviceWriteIops, -1, path, wiops);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1411,7 +1490,8 @@ virCgroupSetBlkioDeviceReadBps(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned long long rbps)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceReadBps, -1, path, rbps);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ setBlkioDeviceReadBps, -1, path, rbps);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1427,7 +1507,8 @@ virCgroupSetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned long long wbps)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceWriteBps, -1, path, wbps);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ setBlkioDeviceWriteBps, -1, path, wbps);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1445,7 +1526,8 @@ virCgroupSetBlkioDeviceWeight(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int weight)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceWeight, -1, path, weight);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ setBlkioDeviceWeight, -1, path, weight);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1461,7 +1543,8 @@ virCgroupGetBlkioDeviceReadIops(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int *riops)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceReadIops, -1, path, riops);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioDeviceReadIops, -1, path, riops);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1477,7 +1560,8 @@ virCgroupGetBlkioDeviceWriteIops(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int *wiops)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceWriteIops, -1, path, wiops);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioDeviceWriteIops, -1, path, wiops);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1493,7 +1577,8 @@ virCgroupGetBlkioDeviceReadBps(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned long long *rbps)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceReadBps, -1, path, rbps);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioDeviceReadBps, -1, path, rbps);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1509,7 +1594,8 @@ virCgroupGetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned long long *wbps)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceWriteBps, -1, path, wbps);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioDeviceWriteBps, -1, path, wbps);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1525,7 +1611,8 @@ virCgroupGetBlkioDeviceWeight(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int *weight)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceWeight, -1, path, weight);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ getBlkioDeviceWeight, -1, path, weight);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1540,7 +1627,8 @@ virCgroupGetBlkioDeviceWeight(virCgroupPtr group,
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetMemory(virCgroupPtr group, unsigned long long kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setMemory, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ setMemory, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1566,7 +1654,8 @@ virCgroupGetMemoryStat(virCgroupPtr group,
|
|
|
c480ed |
unsigned long long *inactiveFile,
|
|
|
c480ed |
unsigned long long *unevictable)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getMemoryStat, -1, cache,
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ getMemoryStat, -1, cache,
|
|
|
c480ed |
activeAnon, inactiveAnon,
|
|
|
c480ed |
activeFile, inactiveFile,
|
|
|
c480ed |
unevictable);
|
|
|
c480ed |
@@ -1584,7 +1673,8 @@ virCgroupGetMemoryStat(virCgroupPtr group,
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getMemoryUsage, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ getMemoryUsage, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1599,7 +1689,8 @@ virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long long kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setMemoryHardLimit, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ setMemoryHardLimit, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1614,7 +1705,8 @@ virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long long kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getMemoryHardLimit, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ getMemoryHardLimit, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1629,7 +1721,8 @@ virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetMemorySoftLimit(virCgroupPtr group, unsigned long long kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setMemorySoftLimit, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ setMemorySoftLimit, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1644,7 +1737,8 @@ virCgroupSetMemorySoftLimit(virCgroupPtr group, unsigned long long kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getMemorySoftLimit, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ getMemorySoftLimit, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1659,7 +1753,8 @@ virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetMemSwapHardLimit(virCgroupPtr group, unsigned long long kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setMemSwapHardLimit, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ setMemSwapHardLimit, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1674,7 +1769,8 @@ virCgroupSetMemSwapHardLimit(virCgroupPtr group, unsigned long long kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getMemSwapHardLimit, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ getMemSwapHardLimit, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1689,7 +1785,8 @@ virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getMemSwapUsage, -1, kb);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_MEMORY,
|
|
|
c480ed |
+ getMemSwapUsage, -1, kb);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1704,7 +1801,8 @@ virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetCpusetMems(virCgroupPtr group, const char *mems)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setCpusetMems, -1, mems);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUSET,
|
|
|
c480ed |
+ setCpusetMems, -1, mems);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1719,7 +1817,8 @@ virCgroupSetCpusetMems(virCgroupPtr group, const char *mems)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpusetMems(virCgroupPtr group, char **mems)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpusetMems, -1, mems);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUSET,
|
|
|
c480ed |
+ getCpusetMems, -1, mems);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1734,7 +1833,8 @@ virCgroupGetCpusetMems(virCgroupPtr group, char **mems)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setCpusetMemoryMigrate, -1, migrate);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUSET,
|
|
|
c480ed |
+ setCpusetMemoryMigrate, -1, migrate);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1749,7 +1849,8 @@ virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpusetMemoryMigrate, -1, migrate);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUSET,
|
|
|
c480ed |
+ getCpusetMemoryMigrate, -1, migrate);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1764,7 +1865,8 @@ virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setCpusetCpus, -1, cpus);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUSET,
|
|
|
c480ed |
+ setCpusetCpus, -1, cpus);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1779,7 +1881,8 @@ virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpusetCpus, -1, cpus);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUSET,
|
|
|
c480ed |
+ getCpusetCpus, -1, cpus);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1793,7 +1896,8 @@ virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupDenyAllDevices(virCgroupPtr group)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, denyAllDevices, -1);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_DEVICES,
|
|
|
c480ed |
+ denyAllDevices, -1);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1813,7 +1917,8 @@ virCgroupDenyAllDevices(virCgroupPtr group)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupAllowAllDevices(virCgroupPtr group, int perms)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, allowAllDevices, -1, perms);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_DEVICES,
|
|
|
c480ed |
+ allowAllDevices, -1, perms);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1832,7 +1937,8 @@ int
|
|
|
c480ed |
virCgroupAllowDevice(virCgroupPtr group, char type, int major, int minor,
|
|
|
c480ed |
int perms)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, allowDevice, -1, type, major, minor, perms);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_DEVICES,
|
|
|
c480ed |
+ allowDevice, -1, type, major, minor, perms);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1871,7 +1977,8 @@ virCgroupAllowDevicePath(virCgroupPtr group,
|
|
|
c480ed |
if (!S_ISCHR(sb.st_mode) && !S_ISBLK(sb.st_mode))
|
|
|
c480ed |
return 1;
|
|
|
c480ed |
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, allowDevice, -1,
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_DEVICES,
|
|
|
c480ed |
+ allowDevice, -1,
|
|
|
c480ed |
S_ISCHR(sb.st_mode) ? 'c' : 'b',
|
|
|
c480ed |
major(sb.st_rdev),
|
|
|
c480ed |
minor(sb.st_rdev),
|
|
|
c480ed |
@@ -1894,7 +2001,8 @@ int
|
|
|
c480ed |
virCgroupDenyDevice(virCgroupPtr group, char type, int major, int minor,
|
|
|
c480ed |
int perms)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, denyDevice, -1, type, major, minor, perms);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_DEVICES,
|
|
|
c480ed |
+ denyDevice, -1, type, major, minor, perms);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1933,7 +2041,8 @@ virCgroupDenyDevicePath(virCgroupPtr group,
|
|
|
c480ed |
if (!S_ISCHR(sb.st_mode) && !S_ISBLK(sb.st_mode))
|
|
|
c480ed |
return 1;
|
|
|
c480ed |
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, denyDevice, -1,
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_DEVICES,
|
|
|
c480ed |
+ denyDevice, -1,
|
|
|
c480ed |
S_ISCHR(sb.st_mode) ? 'c' : 'b',
|
|
|
c480ed |
major(sb.st_rdev),
|
|
|
c480ed |
minor(sb.st_rdev),
|
|
|
c480ed |
@@ -2176,14 +2285,16 @@ virCgroupGetDomainTotalCpuStats(virCgroupPtr group,
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setCpuShares, -1, shares);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ setCpuShares, -1, shares);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpuShares, -1, shares);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ getCpuShares, -1, shares);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2198,7 +2309,8 @@ virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setCpuCfsPeriod, -1, cfs_period);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ setCpuCfsPeriod, -1, cfs_period);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2213,7 +2325,8 @@ virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpuCfsPeriod, -1, cfs_period);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ getCpuCfsPeriod, -1, cfs_period);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2229,14 +2342,16 @@ virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetCpuCfsQuota(virCgroupPtr group, long long cfs_quota)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setCpuCfsQuota, -1, cfs_quota);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ setCpuCfsQuota, -1, cfs_quota);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpuacctPercpuUsage, -1, usage);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
|
c480ed |
+ getCpuacctPercpuUsage, -1, usage);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2303,7 +2418,16 @@ virCgroupRemoveRecursively(char *grppath)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupRemove(virCgroupPtr group)
|
|
|
c480ed |
{
|
|
|
c480ed |
- return group->backend->remove(group);
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->remove(group) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2312,11 +2436,16 @@ virCgroupPathOfAnyController(virCgroupPtr group,
|
|
|
c480ed |
const char *name,
|
|
|
c480ed |
char **keypath)
|
|
|
c480ed |
{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
int controller;
|
|
|
c480ed |
|
|
|
c480ed |
- controller = group->backend->getAnyController(group);
|
|
|
c480ed |
- if (controller >= 0)
|
|
|
c480ed |
- return virCgroupPathOfController(group, controller, name, keypath);
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i]) {
|
|
|
c480ed |
+ controller = group->backends[i]->getAnyController(group);
|
|
|
c480ed |
+ if (controller >= 0)
|
|
|
c480ed |
+ return virCgroupPathOfController(group, controller, name, keypath);
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
|
|
|
c480ed |
virReportSystemError(ENOSYS, "%s",
|
|
|
c480ed |
_("No controllers are mounted"));
|
|
|
c480ed |
@@ -2552,14 +2681,16 @@ virCgroupKillPainfully(virCgroupPtr group)
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpuCfsQuota(virCgroupPtr group, long long *cfs_quota)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpuCfsQuota, -1, cfs_quota);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ getCpuCfsQuota, -1, cfs_quota);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpuacctUsage, -1, usage);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
|
c480ed |
+ getCpuacctUsage, -1, usage);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2567,21 +2698,24 @@ int
|
|
|
c480ed |
virCgroupGetCpuacctStat(virCgroupPtr group, unsigned long long *user,
|
|
|
c480ed |
unsigned long long *sys)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getCpuacctStat, -1, user, sys);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_CPUACCT,
|
|
|
c480ed |
+ getCpuacctStat, -1, user, sys);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupSetFreezerState(virCgroupPtr group, const char *state)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, setFreezerState, -1, state);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_FREEZER,
|
|
|
c480ed |
+ setFreezerState, -1, state);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupGetFreezerState(virCgroupPtr group, char **state)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(group, getFreezerState, -1, state);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, VIR_CGROUP_CONTROLLER_FREEZER,
|
|
|
c480ed |
+ getFreezerState, -1, state);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2589,7 +2723,16 @@ int
|
|
|
c480ed |
virCgroupBindMount(virCgroupPtr group, const char *oldroot,
|
|
|
c480ed |
const char *mountopts)
|
|
|
c480ed |
{
|
|
|
c480ed |
- return group->backend->bindMount(group, oldroot, mountopts);
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->bindMount(group, oldroot, mountopts) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2598,7 +2741,16 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
|
|
|
c480ed |
gid_t gid,
|
|
|
c480ed |
int controllers)
|
|
|
c480ed |
{
|
|
|
c480ed |
- return cgroup->backend->setOwner(cgroup, uid, gid, controllers);
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (cgroup->backends[i] &&
|
|
|
c480ed |
+ cgroup->backends[i]->setOwner(cgroup, uid, gid, controllers) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -2612,13 +2764,24 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
|
|
|
c480ed |
bool
|
|
|
c480ed |
virCgroupSupportsCpuBW(virCgroupPtr cgroup)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_CGROUP_BACKEND_CALL(cgroup, supportsCpuBW, false);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(cgroup, VIR_CGROUP_CONTROLLER_CPU,
|
|
|
c480ed |
+ supportsCpuBW, false);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller)
|
|
|
c480ed |
{
|
|
|
c480ed |
- return cgroup->backend->hasEmptyTasks(cgroup, controller);
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (cgroup->backends[i]) {
|
|
|
c480ed |
+ int rc = cgroup->backends[i]->hasEmptyTasks(cgroup, controller);
|
|
|
c480ed |
+ if (rc <= 0)
|
|
|
c480ed |
+ return rc;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
bool
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.c b/src/util/vircgroupbackend.c
|
|
|
c480ed |
index 7ee39ac8ca..2e90781dc3 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.c
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.c
|
|
|
c480ed |
@@ -20,6 +20,9 @@
|
|
|
c480ed |
#include <config.h>
|
|
|
c480ed |
|
|
|
c480ed |
#include "vircgroupbackend.h"
|
|
|
c480ed |
+#define __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__
|
|
|
c480ed |
+#include "vircgrouppriv.h"
|
|
|
c480ed |
+#undef __VIR_CGROUP_ALLOW_INCLUDE_PRIV_H__
|
|
|
c480ed |
#include "vircgroupv1.h"
|
|
|
c480ed |
#include "vircgroupv2.h"
|
|
|
c480ed |
#include "virerror.h"
|
|
|
c480ed |
@@ -67,3 +70,20 @@ virCgroupBackendGetAll(void)
|
|
|
c480ed |
}
|
|
|
c480ed |
return virCgroupBackends;
|
|
|
c480ed |
}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+virCgroupBackendPtr
|
|
|
c480ed |
+virCgroupBackendForController(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned int controller)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
|
c480ed |
+ if (group->backends[i] &&
|
|
|
c480ed |
+ group->backends[i]->hasController(group, controller)) {
|
|
|
c480ed |
+ return group->backends[i];
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return NULL;
|
|
|
c480ed |
+}
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index 86d1539e07..bc60b44643 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -436,12 +436,22 @@ virCgroupBackendRegister(virCgroupBackendPtr backend);
|
|
|
c480ed |
virCgroupBackendPtr *
|
|
|
c480ed |
virCgroupBackendGetAll(void);
|
|
|
c480ed |
|
|
|
c480ed |
-# define VIR_CGROUP_BACKEND_CALL(group, func, ret, ...) \
|
|
|
c480ed |
- if (!group->backend->func) { \
|
|
|
c480ed |
+virCgroupBackendPtr
|
|
|
c480ed |
+virCgroupBackendForController(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned int controller);
|
|
|
c480ed |
+
|
|
|
c480ed |
+# define VIR_CGROUP_BACKEND_CALL(group, controller, func, ret, ...) \
|
|
|
c480ed |
+ virCgroupBackendPtr backend = virCgroupBackendForController(group, controller); \
|
|
|
c480ed |
+ if (!backend) { \
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
c480ed |
+ _("failed to get cgroup backend for '%s'"), #func); \
|
|
|
c480ed |
+ return ret; \
|
|
|
c480ed |
+ } \
|
|
|
c480ed |
+ if (!backend->func) { \
|
|
|
c480ed |
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
|
|
|
c480ed |
_("operation '%s' not supported"), #func); \
|
|
|
c480ed |
return ret; \
|
|
|
c480ed |
} \
|
|
|
c480ed |
- return group->backend->func(group, ##__VA_ARGS__);
|
|
|
c480ed |
+ return backend->func(group, ##__VA_ARGS__);
|
|
|
c480ed |
|
|
|
c480ed |
#endif /* __VIR_CGROUP_BACKEND_H__ */
|
|
|
c480ed |
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
|
|
|
c480ed |
index 4a0d75ddbc..8f24b0891e 100644
|
|
|
c480ed |
--- a/src/util/vircgrouppriv.h
|
|
|
c480ed |
+++ b/src/util/vircgrouppriv.h
|
|
|
c480ed |
@@ -56,7 +56,7 @@ typedef virCgroupV2Controller *virCgroupV2ControllerPtr;
|
|
|
c480ed |
struct _virCgroup {
|
|
|
c480ed |
char *path;
|
|
|
c480ed |
|
|
|
c480ed |
- virCgroupBackendPtr backend;
|
|
|
c480ed |
+ virCgroupBackendPtr backends[VIR_CGROUP_BACKEND_TYPE_LAST];
|
|
|
c480ed |
|
|
|
c480ed |
virCgroupV1Controller legacy[VIR_CGROUP_CONTROLLER_LAST];
|
|
|
c480ed |
virCgroupV2Controller unified;
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|