mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
qemu: domain: Restructure control flow in qemuDomainFixupCPUs
Do the two fixups of CPU as one block and split up the return value checks to separate conditions. This will make the upcoming refactors simpler. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
8b039b3839
commit
9c627dc762
@ -10802,8 +10802,6 @@ int
|
||||
qemuDomainFixupCPUs(virDomainObj *vm,
|
||||
virCPUDef **origCPU)
|
||||
{
|
||||
g_autoptr(virCPUDef) fixedCPU = NULL;
|
||||
g_autoptr(virCPUDef) fixedOrig = NULL;
|
||||
virArch arch = vm->def->os.arch;
|
||||
|
||||
if (!ARCH_IS_X86(arch))
|
||||
@ -10821,24 +10819,30 @@ qemuDomainFixupCPUs(virDomainObj *vm,
|
||||
if (!*origCPU)
|
||||
return 0;
|
||||
|
||||
if (virCPUDefFindFeature(vm->def->cpu, "cmt") &&
|
||||
(!(fixedCPU = virCPUDefCopyWithoutModel(vm->def->cpu)) ||
|
||||
virCPUDefCopyModelFilter(fixedCPU, vm->def->cpu, false,
|
||||
virQEMUCapsCPUFilterFeatures, &arch) < 0))
|
||||
return -1;
|
||||
if (virCPUDefFindFeature(vm->def->cpu, "cmt")) {
|
||||
g_autoptr(virCPUDef) fixedCPU = virCPUDefCopyWithoutModel(vm->def->cpu);
|
||||
|
||||
if (virCPUDefFindFeature(*origCPU, "cmt") &&
|
||||
(!(fixedOrig = virCPUDefCopyWithoutModel(*origCPU)) ||
|
||||
virCPUDefCopyModelFilter(fixedOrig, *origCPU, false,
|
||||
virQEMUCapsCPUFilterFeatures, &arch) < 0))
|
||||
return -1;
|
||||
if (!fixedCPU)
|
||||
return -1;
|
||||
|
||||
if (virCPUDefCopyModelFilter(fixedCPU, vm->def->cpu, false,
|
||||
virQEMUCapsCPUFilterFeatures, &arch) < 0)
|
||||
return -1;
|
||||
|
||||
if (fixedCPU) {
|
||||
virCPUDefFree(vm->def->cpu);
|
||||
vm->def->cpu = g_steal_pointer(&fixedCPU);
|
||||
}
|
||||
|
||||
if (fixedOrig) {
|
||||
if (virCPUDefFindFeature(*origCPU, "cmt")) {
|
||||
g_autoptr(virCPUDef) fixedOrig = virCPUDefCopyWithoutModel(*origCPU);
|
||||
|
||||
if (!fixedOrig)
|
||||
return -1;
|
||||
|
||||
if (virCPUDefCopyModelFilter(fixedOrig, *origCPU, false,
|
||||
virQEMUCapsCPUFilterFeatures, &arch) < 0)
|
||||
return -1;
|
||||
|
||||
virCPUDefFree(*origCPU);
|
||||
*origCPU = g_steal_pointer(&fixedOrig);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user