qemu: Move cpuset preference evaluation into a separate function

The set of if()-s that determines the preference in cpumask used
for setting things like emulatorpin, vcpupin, etc. is going to be
re-used. Separate it out into a function.

You may think that this changes behaviour, but
qemuProcessPrepareDomainNUMAPlacement() ensures that
priv->autoCpuset is set for VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Michal Privoznik 2023-03-07 12:27:05 +01:00
parent 95ae91fdd4
commit b4ccb0dc41
3 changed files with 25 additions and 7 deletions

View File

@ -12454,3 +12454,21 @@ qemuDomainStartupCleanup(virDomainObj *vm)
for (i = 0; i < vm->def->ndisks; i++)
qemuDomainCleanupStorageSourceFD(vm->def->disks[i]->src);
}
virBitmap *
qemuDomainEvaluateCPUMask(const virDomainDef *def,
virBitmap *cpumask,
virBitmap *autoCpuset)
{
if (cpumask) {
return cpumask;
} else if (autoCpuset &&
def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
return autoCpuset;
} else if (def->cpumask) {
return def->cpumask;
}
return NULL;
}

View File

@ -1133,3 +1133,8 @@ qemuDomainSchedCoreStart(virQEMUDriverConfig *cfg,
void
qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv);
virBitmap *
qemuDomainEvaluateCPUMask(const virDomainDef *def,
virBitmap *cpumask,
virBitmap *autoCpuset);

View File

@ -2571,13 +2571,8 @@ qemuProcessSetupPid(virDomainObj *vm,
}
/* Infer which cpumask shall be used. */
if (cpumask) {
use_cpumask = cpumask;
} else if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
use_cpumask = priv->autoCpuset;
} else if (vm->def->cpumask) {
use_cpumask = vm->def->cpumask;
} else {
if (!(use_cpumask = qemuDomainEvaluateCPUMask(vm->def,
cpumask, priv->autoCpuset))) {
/* You may think this is redundant, but we can't assume libvirtd
* itself is running on all pCPUs, so we need to explicitly set
* the spawned QEMU instance to all pCPUs if no map is given in