summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2023-03-07 12:27:05 +0100
committerMichal Privoznik <mprivozn@redhat.com>2023-03-15 12:46:40 +0100
commitb4ccb0dc412bcdb09863b2fa1ee65d09808a2c08 (patch)
tree751b2b6e0cc3ad3596e7451ebd75c89946d73114 /src
parent95ae91fdd4da33323ead8f916824b48f8506383c (diff)
downloadlibvirt-b4ccb0dc412bcdb09863b2fa1ee65d09808a2c08.tar.gz
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>
Diffstat (limited to 'src')
-rw-r--r--src/qemu/qemu_domain.c18
-rw-r--r--src/qemu/qemu_domain.h5
-rw-r--r--src/qemu/qemu_process.c9
3 files changed, 25 insertions, 7 deletions
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 72940efefb..9019b22af1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 9bcc5e1380..e230e9777b 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1133,3 +1133,8 @@ qemuDomainSchedCoreStart(virQEMUDriverConfig *cfg,
void
qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv);
+
+virBitmap *
+qemuDomainEvaluateCPUMask(const virDomainDef *def,
+ virBitmap *cpumask,
+ virBitmap *autoCpuset);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index be418ad8e6..18b7781cbb 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -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