[PATCHv2 09/16] qemu: Introduce virQEMUCapsToVirtType

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 f80ee62019..1c6b79594d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -649,6 +649,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
@@ -2423,7 +2432,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
         virtType = VIR_DOMAIN_VIRT_QEMU;
         model = "max";
     } else {
-        virtType = VIR_DOMAIN_VIRT_KVM;
+        virtType = virQEMUCapsToVirtType(qemuCaps);
         model = "host";
     }
 
@@ -4969,10 +4978,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.19.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux