qemuProcessSetupPid: Use @numatune variable more

Inside of qemuProcessSetupPid() there's @numatune variable which
is set to vm->def->numa, but it lives only in one block. In the
rest of places the expanded form (vm->def->numa) is used instead.
Move the variable declaration at the beginning of the function
and use it instead of the expanded form.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2023-05-19 14:02:01 +02:00
parent 1bb439e4b0
commit c4a7f8007c

View File

@ -2553,6 +2553,7 @@ qemuProcessSetupPid(virDomainObj *vm,
virDomainThreadSchedParam *sched) virDomainThreadSchedParam *sched)
{ {
qemuDomainObjPrivate *priv = vm->privateData; qemuDomainObjPrivate *priv = vm->privateData;
virDomainNuma *numatune = vm->def->numa;
virDomainNumatuneMemMode mem_mode; virDomainNumatuneMemMode mem_mode;
virCgroup *cgroup = NULL; virCgroup *cgroup = NULL;
virBitmap *use_cpumask = NULL; virBitmap *use_cpumask = NULL;
@ -2589,10 +2590,10 @@ qemuProcessSetupPid(virDomainObj *vm,
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) || if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) ||
virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 && if (virDomainNumatuneGetMode(numatune, -1, &mem_mode) == 0 &&
(mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT || (mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT ||
mem_mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) && mem_mode == VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) &&
virDomainNumatuneMaybeFormatNodeset(vm->def->numa, virDomainNumatuneMaybeFormatNodeset(numatune,
priv->autoNodeset, priv->autoNodeset,
&mem_mask, -1) < 0) &mem_mask, -1) < 0)
goto cleanup; goto cleanup;
@ -2601,8 +2602,6 @@ qemuProcessSetupPid(virDomainObj *vm,
* threads based on the node they are in as there is nothing else uses * threads based on the node they are in as there is nothing else uses
* for such restriction (e.g. numa_set_membind). */ * for such restriction (e.g. numa_set_membind). */
if (nameval == VIR_CGROUP_THREAD_VCPU) { if (nameval == VIR_CGROUP_THREAD_VCPU) {
virDomainNuma *numatune = vm->def->numa;
/* Look for the guest NUMA node of this vCPU */ /* Look for the guest NUMA node of this vCPU */
for (i = 0; i < virDomainNumaGetNodeCount(numatune); i++) { for (i = 0; i < virDomainNumaGetNodeCount(numatune); i++) {
virBitmap *node_cpus = virDomainNumaGetNodeCpumask(numatune, i); virBitmap *node_cpus = virDomainNumaGetNodeCpumask(numatune, i);