[libvirt PATCH v7 07/18] qemu: Introduce virQEMUCapsAccelStr

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

 



From: Roman Bolshakov <r.bolshakov@xxxxxxxxx>

This makes possible to add more accelerators by touching less code and
reduces code duplication.

Signed-off-by: Roman Bolshakov <r.bolshakov@xxxxxxxxx>
Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
Tested-by: Brad Laue <brad@xxxxxxxxxx>
Tested-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index dac9fa11fc..f27d2fd241 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -839,6 +839,16 @@ virQEMUCapsFindTarget(virArch hostarch,
 }
 
 
+static const char *
+virQEMUCapsAccelStr(virDomainVirtType type)
+{
+    if (type == VIR_DOMAIN_VIRT_KVM)
+        return "kvm";
+
+    return "tcg";
+}
+
+
 static virQEMUCapsAccel *
 virQEMUCapsGetAccel(virQEMUCaps *qemuCaps,
                     virDomainVirtType type)
@@ -4067,7 +4077,7 @@ virQEMUCapsLoadAccel(virQEMUCaps *qemuCaps,
                      virDomainVirtType type)
 {
     virQEMUCapsAccel *caps = virQEMUCapsGetAccel(qemuCaps, type);
-    const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
+    const char *typeStr = virQEMUCapsAccelStr(type);
 
     if (virQEMUCapsLoadHostCPUModelInfo(caps, ctxt, typeStr) < 0)
         return -1;
@@ -4620,7 +4630,7 @@ virQEMUCapsFormatAccel(virQEMUCaps *qemuCaps,
                        virDomainVirtType type)
 {
     virQEMUCapsAccel *caps = virQEMUCapsGetAccel(qemuCaps, type);
-    const char *typeStr = type == VIR_DOMAIN_VIRT_KVM ? "kvm" : "tcg";
+    const char *typeStr = virQEMUCapsAccelStr(type);
 
     virQEMUCapsFormatHostCPUModelInfo(caps, buf, typeStr);
     virQEMUCapsFormatCPUModels(caps, buf, typeStr);
-- 
2.34.1




[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