Add 'controllers' arg to virCgroupNewDetect

When detecting cgroups we must honour any controllers
whitelist the driver may have.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-07-24 17:31:25 +01:00
parent c101b851c1
commit 5ec5a22493
4 changed files with 11 additions and 5 deletions

View File

@ -1190,7 +1190,7 @@ int virLXCProcessStart(virConnectPtr conn,
}
if (virCgroupNewDetectMachine(vm->def->name, "lxc",
vm->pid, &priv->cgroup) < 0)
vm->pid, -1, &priv->cgroup) < 0)
goto error;
if (!priv->cgroup) {
@ -1398,7 +1398,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm,
goto error;
if (virCgroupNewDetectMachine(vm->def->name, "lxc",
vm->pid, &priv->cgroup) < 0)
vm->pid, -1, &priv->cgroup) < 0)
goto error;
if (!priv->cgroup) {

View File

@ -707,6 +707,7 @@ qemuConnectCgroup(virQEMUDriverPtr driver,
if (virCgroupNewDetectMachine(vm->def->name,
"qemu",
vm->pid,
cfg->cgroupControllers,
&priv->cgroup) < 0)
goto cleanup;

View File

@ -1406,7 +1406,7 @@ int virCgroupNewPartition(const char *path ATTRIBUTE_UNUSED,
*/
int virCgroupNewSelf(virCgroupPtr *group)
{
return virCgroupNewDetect(-1, group);
return virCgroupNewDetect(-1, -1, group);
}
@ -1577,12 +1577,14 @@ int virCgroupNewEmulator(virCgroupPtr domain ATTRIBUTE_UNUSED,
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupNewDetect(pid_t pid,
int controllers,
virCgroupPtr *group)
{
return virCgroupNew(pid, "", NULL, -1, group);
return virCgroupNew(pid, "", NULL, controllers, group);
}
#else
int virCgroupNewDetect(pid_t pid ATTRIBUTE_UNUSED,
int controllers ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED)
{
virReportSystemError(ENXIO, "%s",
@ -1597,9 +1599,10 @@ int virCgroupNewDetect(pid_t pid ATTRIBUTE_UNUSED,
int virCgroupNewDetectMachine(const char *name,
const char *drivername,
pid_t pid,
int controllers,
virCgroupPtr *group)
{
if (virCgroupNewDetect(pid, group) < 0) {
if (virCgroupNewDetect(pid, controllers, group) < 0) {
if (virCgroupNewIgnoreError())
return 0;
return -1;

View File

@ -76,11 +76,13 @@ int virCgroupNewEmulator(virCgroupPtr domain,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
int virCgroupNewDetect(pid_t pid,
int controllers,
virCgroupPtr *group);
int virCgroupNewDetectMachine(const char *name,
const char *drivername,
pid_t pid,
int controllers,
virCgroupPtr *group);
int virCgroupNewMachine(const char *name,