>From 01ee68b76ffa2efd124cbcbe5fb2a5ba060c5095 Mon Sep 17 00:00:00 2001
From: John Ferlan <jferlan@redhat.com>
Date: Wed, 23 Nov 2016 10:11:39 -0500
Subject: [PATCH] merge
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
src/lxc/lxc_process.c | 48 +++++++++++++++++++++++-------------------------
1 file changed, 23 insertions(+), 25 deletions(-)
@@ -1170,6 +1170,28 @@ virLXCProcessEnsureRootFS(virDomainObjPtr vm)
return -1;
}
+
+static int
+virLXCProcessCheckCgroup(void)
+{
+ int ret = -1;
+ virCgroupPtr selfcgroup;
+
+ if (virCgroupNewSelf(&selfcgroup) < 0)
+ return -1;
+
+ virCheckControllerGoto(selfcgroup, VIR_CGROUP_CONTROLLER_CPUACCT, cleanup);
+ virCheckControllerGoto(selfcgroup, VIR_CGROUP_CONTROLLER_DEVICES, cleanup);
+ virCheckControllerGoto(selfcgroup, VIR_CGROUP_CONTROLLER_MEMORY, cleanup);
+
+ ret = 0;
+
+ cleanup:
+ virCgroupFree(&selfcgroup);
+ return ret;
+}
+
+
/**
* virLXCProcessStart:
* @conn: pointer to connection
@@ -1207,37 +1229,13 @@ int virLXCProcessStart(virConnectPtr conn,
virCapsPtr caps = NULL;
virErrorPtr err = NULL;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
- virCgroupPtr selfcgroup;
int status;
char *pidfile = NULL;
bool clearSeclabel = false;
bool need_stop = false;
- if (virCgroupNewSelf(&selfcgroup) < 0)
- return -1;
-
- if (!virCgroupHasController(selfcgroup,
- VIR_CGROUP_CONTROLLER_CPUACCT)) {
- virCgroupFree(&selfcgroup);
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to find 'cpuacct' cgroups controller mount"));
- return -1;
- }
- if (!virCgroupHasController(selfcgroup,
- VIR_CGROUP_CONTROLLER_DEVICES)) {
- virCgroupFree(&selfcgroup);
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to find 'devices' cgroups controller mount"));
+ if (virLXCProcessCheckCgroup() < 0)
return -1;
- }
- if (!virCgroupHasController(selfcgroup,
- VIR_CGROUP_CONTROLLER_MEMORY)) {
- virCgroupFree(&selfcgroup);
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to find 'memory' cgroups controller mount"));
- return -1;
- }
- virCgroupFree(&selfcgroup);
if (vm->def->nconsoles == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
--
2.7.4