mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
qemu: fix some api cannot work when disable cpuset in conf
If cpuset is disabled or not available, it libvirt must not use it.
Mainly for actions that do not need it and can use sched_setaffinity()
or numa_membind() instead, because they will fail without good reason.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1244664
Signed-off-by: Luyao Huang <lhuang@redhat.com>
(cherry picked from commit 1439eb32af
)
This commit is contained in:
parent
93fd967f38
commit
e1d8f411f7
@ -1025,10 +1025,6 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
|
||||
if (virCgroupAddTask(cgroup_vcpu, priv->vcpupids[i]) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (mem_mask &&
|
||||
virCgroupSetCpusetMems(cgroup_vcpu, mem_mask) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (period || quota) {
|
||||
if (qemuSetupCgroupVcpuBW(cgroup_vcpu, period, quota) < 0)
|
||||
goto cleanup;
|
||||
@ -1038,6 +1034,10 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
|
||||
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||
virBitmapPtr cpumap = NULL;
|
||||
|
||||
if (mem_mask &&
|
||||
virCgroupSetCpusetMems(cgroup_vcpu, mem_mask) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* try to use the default cpu maps */
|
||||
if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
|
||||
cpumap = priv->autoCpuset;
|
||||
@ -1202,15 +1202,15 @@ qemuSetupCgroupForIOThreads(virDomainObjPtr vm)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (mem_mask &&
|
||||
virCgroupSetCpusetMems(cgroup_iothread, mem_mask) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Set iothreadpin in cgroup if iothreadpin xml is provided */
|
||||
if (virCgroupHasController(priv->cgroup,
|
||||
VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||
virBitmapPtr cpumask = NULL;
|
||||
|
||||
if (mem_mask &&
|
||||
virCgroupSetCpusetMems(cgroup_iothread, mem_mask) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (def->iothreadids[i]->cpumask)
|
||||
cpumask = def->iothreadids[i]->cpumask;
|
||||
else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
|
||||
|
@ -4597,7 +4597,9 @@ qemuDomainAddCgroupForThread(virCgroupPtr cgroup,
|
||||
if (virCgroupNewThread(cgroup, nameval, idx, true, &new_cgroup) < 0)
|
||||
return NULL;
|
||||
|
||||
if (mem_mask && virCgroupSetCpusetMems(new_cgroup, mem_mask) < 0)
|
||||
if (mem_mask &&
|
||||
virCgroupHasController(cgroup, VIR_CGROUP_CONTROLLER_CPUSET) &&
|
||||
virCgroupSetCpusetMems(new_cgroup, mem_mask) < 0)
|
||||
goto error;
|
||||
|
||||
/* Add pid/thread to the cgroup */
|
||||
@ -4653,7 +4655,8 @@ qemuDomainHotplugPinThread(virBitmapPtr cpumask,
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (cgroup) {
|
||||
if (cgroup &&
|
||||
virCgroupHasController(cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||
if (qemuSetupCgroupCpusetCpus(cgroup, cpumask) < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("failed to set cpuset.cpus in cgroup for id %d"),
|
||||
@ -4896,7 +4899,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||
goto endjob;
|
||||
|
||||
if (def && !(flags & VIR_DOMAIN_VCPU_GUEST) && virNumaIsAvailable()) {
|
||||
if (def && !(flags & VIR_DOMAIN_VCPU_GUEST) && virNumaIsAvailable() &&
|
||||
virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||
if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_EMULATOR, 0,
|
||||
false, &cgroup_temp) < 0)
|
||||
goto endjob;
|
||||
|
Loading…
Reference in New Issue
Block a user