This makes possible to add more accelerators by touching less code and reduces code duplication. Signed-off-by: Roman Bolshakov <r.bolshakov@xxxxxxxxx> --- src/qemu/qemu_capabilities.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 02f05aef70..1a2a8c5b7a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -651,6 +651,16 @@ virQEMUCapsToVirtType(virQEMUCapsPtr qemuCaps) return VIR_DOMAIN_VIRT_QEMU; } +static const char * +virQEMUCapsAccelStr(virDomainVirtType type) +{ + if (type == VIR_DOMAIN_VIRT_KVM) { + return "kvm"; + } else { + return "tcg"; + } +} + /* Checks whether a domain with @guest arch can run natively on @host. */ bool @@ -3639,7 +3649,7 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps, { virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type); qemuMonitorCPUModelInfoPtr model = cpuData->info; - const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg"; + const char *typeStr = virQEMUCapsAccelStr(type); size_t i; if (!model) @@ -3694,16 +3704,13 @@ virQEMUCapsFormatCPUModels(virQEMUCapsPtr qemuCaps, virDomainVirtType type) { virDomainCapsCPUModelsPtr cpus; - const char *typeStr; + const char *typeStr = virQEMUCapsAccelStr(type); size_t i; if (virQEMUCapsTypeIsAccelerated(type)) - typeStr = "kvm"; cpus = qemuCaps->accelCPUModels; - } else { - typeStr = "tcg"; + else cpus = qemuCaps->tcgCPUModels; - } if (!cpus) return; -- 2.17.1 (Apple Git-112) -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list