The function is needed to support multiple accelerators without cluttering codebase by conditionals. At the first glance that might cause an issue related to the ordering capabilities being checked on a system with many accelerators but in the current code base it should be just fine because virQEMUCapsGetHostCPUData is not interested in the exact type of accelarator. Signed-off-by: Roman Bolshakov <r.bolshakov@xxxxxxxxx> --- src/qemu/qemu_capabilities.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 648e5bd585..02f05aef70 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -642,6 +642,15 @@ virQEMUCapsHaveAccel(virQEMUCapsPtr qemuCaps) return virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM); } +static virDomainVirtType +virQEMUCapsToVirtType(virQEMUCapsPtr qemuCaps) +{ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + return VIR_DOMAIN_VIRT_KVM; + else + return VIR_DOMAIN_VIRT_QEMU; +} + /* Checks whether a domain with @guest arch can run natively on @host. */ bool @@ -2401,7 +2410,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, virtType = VIR_DOMAIN_VIRT_QEMU; model = "max"; } else { - virtType = VIR_DOMAIN_VIRT_KVM; + virtType = virQEMUCapsToVirtType(qemuCaps); model = "host"; } @@ -4935,10 +4944,7 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache, machine = virQEMUCapsGetPreferredMachine(qemuCaps); } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) - capsType = VIR_DOMAIN_VIRT_KVM; - else - capsType = VIR_DOMAIN_VIRT_QEMU; + capsType = virQEMUCapsToVirtType(qemuCaps); if (virttype == VIR_DOMAIN_VIRT_NONE) virttype = capsType; -- 2.17.1 (Apple Git-112) -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list