bool inShutdown;
int timerShutdown;
+ virCgroupPtr cgroup;
+
virLXCFusePtr fuse;
};
virObjectUnref(ctrl->server);
virLXCControllerFreeFuse(ctrl);
+ virCgroupFree(&ctrl->cgroup);
+
/* This must always be the last thing to be closed */
VIR_FORCE_CLOSE(ctrl->handshakeFd);
VIR_FREE(ctrl);
*
* Returns 0 on success or -1 in case of error
*/
-static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl,
- virCgroupPtr cgroup)
+static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl)
{
virBitmapPtr nodemask = NULL;
int ret = -1;
if (virLXCControllerSetupCpuAffinity(ctrl) < 0)
goto cleanup;
- if (virLXCCgroupSetup(ctrl->def, cgroup, nodemask) < 0)
+ if (virLXCCgroupSetup(ctrl->def, ctrl->cgroup, nodemask) < 0)
goto cleanup;
ret = 0;
int containerhandshake[2] = { -1, -1 };
char **containerTTYPaths = NULL;
size_t i;
- virCgroupPtr cgroup = NULL;
if (VIR_ALLOC_N(containerTTYPaths, ctrl->nconsoles) < 0)
goto cleanup;
if (virLXCControllerSetupPrivateNS() < 0)
goto cleanup;
- if (!(cgroup = virLXCCgroupJoin(ctrl->def)))
- goto cleanup;
-
if (virLXCControllerSetupLoopDevices(ctrl) < 0)
goto cleanup;
- if (virLXCControllerSetupResourceLimits(ctrl, cgroup) < 0)
+ if (virLXCControllerSetupResourceLimits(ctrl) < 0)
goto cleanup;
if (virLXCControllerSetupDevPTS(ctrl) < 0)
VIR_FREE(containerTTYPaths[i]);
VIR_FREE(containerTTYPaths);
- virCgroupFree(&cgroup);
virLXCControllerStopInit(ctrl);
return rc;
if (virLXCControllerValidateConsoles(ctrl) < 0)
goto cleanup;
+ if (!(ctrl->cgroup = virLXCCgroupJoin(ctrl->def)))
+ goto cleanup;
+
if (virLXCControllerSetupServer(ctrl) < 0)
goto cleanup;
#include "virhook.h"
#include "virstring.h"
#include "viratomic.h"
+#include "virprocess.h"
#define VIR_FROM_THIS VIR_FROM_LXC
return -1;
}
} else {
- /* If cgroup doesn't exist, the VM pids must have already
- * died and so we're just cleaning up stale state
- */
+ /* If cgroup doesn't exist, just try cleaning up the
+ * libvirt_lxc process */
+ virProcessKillPainfully(vm->pid, true);
}
virLXCProcessCleanup(driver, vm, reason);
virCapsPtr caps = NULL;
virErrorPtr err = NULL;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
+ virCgroupPtr selfcgroup;
- virCgroupFree(&priv->cgroup);
-
- if (!(priv->cgroup = virLXCCgroupCreate(vm->def)))
+ if (virCgroupNewSelf(&selfcgroup) < 0)
return -1;
- if (!virCgroupHasController(priv->cgroup,
+ if (!virCgroupHasController(selfcgroup,
VIR_CGROUP_CONTROLLER_CPUACCT)) {
- virCgroupFree(&priv->cgroup);
+ virCgroupFree(&selfcgroup);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'cpuacct' cgroups controller mount"));
return -1;
}
- if (!virCgroupHasController(priv->cgroup,
+ if (!virCgroupHasController(selfcgroup,
VIR_CGROUP_CONTROLLER_DEVICES)) {
- virCgroupFree(&priv->cgroup);
+ virCgroupFree(&selfcgroup);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'devices' cgroups controller mount"));
return -1;
}
- if (!virCgroupHasController(priv->cgroup,
+ if (!virCgroupHasController(selfcgroup,
VIR_CGROUP_CONTROLLER_MEMORY)) {
- virCgroupFree(&priv->cgroup);
+ virCgroupFree(&selfcgroup);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'memory' cgroups controller mount"));
return -1;
}
+ virCgroupFree(&selfcgroup);
if (virFileMakePath(cfg->logDir) < 0) {
virReportSystemError(errno,
/* Connect to the controller as a client *first* because
* this will block until the child has written their
- * pid file out to disk */
+ * pid file out to disk & created their cgroup */
if (!(priv->monitor = virLXCProcessConnectMonitor(driver, vm)))
goto cleanup;
goto cleanup;
}
+ if (virCgroupNewDetect(vm->pid, &priv->cgroup) < 0)
+ goto error;
+
+ if (!virCgroupIsValidMachineGroup(priv->cgroup,
+ vm->def->name,
+ "lxc")) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cgroup name is not valid for machine %s"),
+ vm->def->name);
+ virCgroupFree(&priv->cgroup);
+ goto error;
+ }
+
priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_FAILED;
priv->wantReboot = false;
vm->def->id = vm->pid;