+ # CPUs
+ if instance.hvparams[constants.HV_CPU_MASK]:
+ cpu_list = utils.ParseCpuMask(instance.hvparams[constants.HV_CPU_MASK])
+ cpus_in_mask = len(cpu_list)
+ if cpus_in_mask != instance.beparams["vcpus"]:
+ raise errors.HypervisorError("Number of VCPUs (%d) doesn't match"
+ " the number of CPUs in the"
+ " cpu_mask (%d)" %
+ (instance.beparams["vcpus"],
+ cpus_in_mask))
+ out.append("lxc.cgroup.cpuset.cpus = %s" %
+ instance.hvparams[constants.HV_CPU_MASK])
+
+ # Memory
+ # Conditionally enable, memory resource controller might be disabled
+ cgroup = self._GetCgroupMountPoint()
+ if os.path.exists(utils.PathJoin(cgroup, 'memory.limit_in_bytes')):
+ out.append("lxc.cgroup.memory.limit_in_bytes = %dM" %
+ instance.beparams[constants.BE_MAXMEM])
+
+ if os.path.exists(utils.PathJoin(cgroup, 'memory.memsw.limit_in_bytes')):
+ out.append("lxc.cgroup.memory.memsw.limit_in_bytes = %dM" %
+ instance.beparams[constants.BE_MAXMEM])
+