mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
LXC: add cpuset cgroup support for lxc
This patch adds cpuset cgroup support for LXC. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
This commit is contained in:
parent
45e9d27ad8
commit
4dceffadc9
@ -68,6 +68,57 @@ cleanup:
|
||||
}
|
||||
|
||||
|
||||
static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def,
|
||||
virCgroupPtr cgroup,
|
||||
virBitmapPtr nodemask)
|
||||
{
|
||||
int rc = 0;
|
||||
char *mask = NULL;
|
||||
|
||||
if (def->placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
|
||||
def->cpumask) {
|
||||
mask = virBitmapFormat(def->cpumask);
|
||||
if (!mask) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to convert cpumask"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = virCgroupSetCpusetCpus(cgroup, mask);
|
||||
if (rc < 0) {
|
||||
virReportSystemError(-rc, "%s",
|
||||
_("Unable to set cpuset.cpus"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if ((def->numatune.memory.nodemask ||
|
||||
(def->numatune.memory.placement_mode ==
|
||||
VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) &&
|
||||
def->numatune.memory.mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
|
||||
if (def->numatune.memory.placement_mode ==
|
||||
VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)
|
||||
mask = virBitmapFormat(nodemask);
|
||||
else
|
||||
mask = virBitmapFormat(def->numatune.memory.nodemask);
|
||||
|
||||
if (!mask) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to convert memory nodemask"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = virCgroupSetCpusetMems(cgroup, mask);
|
||||
if (rc < 0)
|
||||
virReportSystemError(-rc, "%s", _("Unable to set cpuset.mems"));
|
||||
}
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(mask);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int virLXCCgroupSetupBlkioTune(virDomainDefPtr def,
|
||||
virCgroupPtr cgroup)
|
||||
{
|
||||
@ -516,13 +567,17 @@ cleanup:
|
||||
|
||||
|
||||
int virLXCCgroupSetup(virDomainDefPtr def,
|
||||
virCgroupPtr cgroup)
|
||||
virCgroupPtr cgroup,
|
||||
virBitmapPtr nodemask)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (virLXCCgroupSetupCpuTune(def, cgroup) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCCgroupSetupCpusetTune(def, cgroup, nodemask) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCCgroupSetupBlkioTune(def, cgroup) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
@ -28,7 +28,9 @@
|
||||
|
||||
virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def);
|
||||
int virLXCCgroupSetup(virDomainDefPtr def,
|
||||
virCgroupPtr cgroup);
|
||||
virCgroupPtr cgroup,
|
||||
virBitmapPtr nodemask);
|
||||
|
||||
int virLXCCgroupGetMeminfo(virLXCMeminfoPtr meminfo);
|
||||
|
||||
int
|
||||
|
@ -569,7 +569,7 @@ static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl,
|
||||
if (virLXCControllerSetupCpuAffinity(ctrl) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCCgroupSetup(ctrl->def, cgroup) < 0)
|
||||
if (virLXCCgroupSetup(ctrl->def, cgroup, nodemask) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user