From bb61230992246fa0c7d51d1f870772436ad6c2b7 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 23 Jan 2020 13:11:08 +0100 Subject: [PATCH] qemu: capabilities: Extract code from virQEMUCapsStripMachineAliases Separate out the internals as they will become more complex soon. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 073001607e..3358a98920 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6020,6 +6020,21 @@ virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps, } +static void +virQEMUCapsStripMachineAliasesForVirtType(virQEMUCapsPtr qemuCaps, + virDomainVirtType virtType) +{ + virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, virtType); + size_t i; + + for (i = 0; i < accel->nmachineTypes; i++) { + virQEMUCapsMachineTypePtr mach = &accel->machineTypes[i]; + + VIR_FREE(mach->alias); + } +} + + /** * virQEMUCapsStripMachineAliases: * @qemuCaps: capabilities object to process @@ -6030,11 +6045,6 @@ virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps, void virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps) { - size_t i; - - for (i = 0; i < qemuCaps->kvm.nmachineTypes; i++) - VIR_FREE(qemuCaps->kvm.machineTypes[i].alias); - - for (i = 0; i < qemuCaps->tcg.nmachineTypes; i++) - VIR_FREE(qemuCaps->tcg.machineTypes[i].alias); + virQEMUCapsStripMachineAliasesForVirtType(qemuCaps, VIR_DOMAIN_VIRT_KVM); + virQEMUCapsStripMachineAliasesForVirtType(qemuCaps, VIR_DOMAIN_VIRT_QEMU); } -- GitLab