}
-int virLXCCgroupSetup(virDomainDefPtr def)
+virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def)
{
virCgroupPtr driver = NULL;
virCgroupPtr cgroup = NULL;
goto cleanup;
}
+ rc = virCgroupAddTask(cgroup, getpid());
+ if (rc != 0) {
+ virReportSystemError(-rc,
+ _("Unable to add task %d to cgroup for domain %s"),
+ getpid(), def->name);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ virCgroupFree(&driver);
+ if (ret < 0) {
+ virCgroupFree(&cgroup);
+ return NULL;
+ }
+
+ return cgroup;
+}
+
+
+int virLXCCgroupSetup(virDomainDefPtr def,
+ virCgroupPtr cgroup)
+{
+ int ret = -1;
+
if (virLXCCgroupSetupCpuTune(def, cgroup) < 0)
goto cleanup;
if (virLXCCgroupSetupDeviceACL(def, cgroup) < 0)
goto cleanup;
- rc = virCgroupAddTask(cgroup, getpid());
- if (rc != 0) {
- virReportSystemError(-rc,
- _("Unable to add task %d to cgroup for domain %s"),
- getpid(), def->name);
- goto cleanup;
- }
-
ret = 0;
cleanup:
- virCgroupFree(&cgroup);
- virCgroupFree(&driver);
-
return ret;
}
# include "lxc_fuse.h"
# include "virusb.h"
-int virLXCCgroupSetup(virDomainDefPtr def);
+virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def);
+int virLXCCgroupSetup(virDomainDefPtr def,
+ virCgroupPtr cgroup);
int virLXCCgroupGetMeminfo(virLXCMeminfoPtr meminfo);
int
*
* Returns 0 on success or -1 in case of error
*/
-static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl)
+static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl,
+ virCgroupPtr cgroup)
{
if (virLXCControllerSetupCpuAffinity(ctrl) < 0)
if (virLXCControllerSetupNUMAPolicy(ctrl) < 0)
return -1;
- return virLXCCgroupSetup(ctrl->def);
+ return virLXCCgroupSetup(ctrl->def, cgroup);
}
int containerhandshake[2] = { -1, -1 };
char **containerTTYPaths = NULL;
size_t i;
+ virCgroupPtr cgroup = NULL;
if (VIR_ALLOC_N(containerTTYPaths, ctrl->nconsoles) < 0) {
virReportOOMError();
if (virLXCControllerSetupPrivateNS() < 0)
goto cleanup;
+ if (!(cgroup = virLXCCgroupCreate(ctrl->def)))
+ goto cleanup;
+
if (virLXCControllerSetupLoopDevices(ctrl) < 0)
goto cleanup;
- if (virLXCControllerSetupResourceLimits(ctrl) < 0)
+ if (virLXCControllerSetupResourceLimits(ctrl, cgroup) < 0)
goto cleanup;
if (virLXCControllerSetupDevPTS(ctrl) < 0)
VIR_FREE(containerTTYPaths[i]);
VIR_FREE(containerTTYPaths);
+ virCgroupFree(&cgroup);
virLXCControllerStopInit(ctrl);
return rc;