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(a)redhat.com>
---
src/qemu/qemu_domain.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a44ac83295..74e20c4edb 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -10758,8 +10758,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))
@@ -10777,24 +10775,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);
}
--
2.39.2