[PATCH 2/7] qemu: Move common code in virQEMUCapsInitCPUModel one layer up

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b1245ad5d..1a15750a3 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3111,17 +3111,11 @@ virQEMUCapsCPUFilterFeatures(const char *name,
  */
 static int
 virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
-                            virDomainVirtType type,
+                            qemuMonitorCPUModelInfoPtr modelInfo,
                             virCPUDefPtr cpu)
 {
-    qemuMonitorCPUModelInfoPtr modelInfo;
     size_t i;
 
-    if (type == VIR_DOMAIN_VIRT_KVM)
-        modelInfo = qemuCaps->kvmCPUModelInfo;
-    else
-        modelInfo = qemuCaps->tcgCPUModelInfo;
-
     if (!modelInfo) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("missing host CPU model info from QEMU capabilities "
@@ -3163,9 +3157,9 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
 static int
 virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
                            virDomainVirtType type,
+                           qemuMonitorCPUModelInfoPtr model,
                            virCPUDefPtr cpu)
 {
-    qemuMonitorCPUModelInfoPtr model;
     virCPUDataPtr data = NULL;
     unsigned long long sigFamily = 0;
     unsigned long long sigModel = 0;
@@ -3174,11 +3168,6 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
     int ret = -1;
     size_t i;
 
-    if (type == VIR_DOMAIN_VIRT_KVM)
-        model = qemuCaps->kvmCPUModelInfo;
-    else
-        model = qemuCaps->tcgCPUModelInfo;
-
     if (!model)
         return 1;
 
@@ -3239,12 +3228,18 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
                         virDomainVirtType type,
                         virCPUDefPtr cpu)
 {
+    qemuMonitorCPUModelInfoPtr model;
     int ret = 1;
 
+    if (type == VIR_DOMAIN_VIRT_KVM)
+        model = qemuCaps->kvmCPUModelInfo;
+    else
+        model = qemuCaps->tcgCPUModelInfo;
+
     if (ARCH_IS_S390(qemuCaps->arch))
-        ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, cpu);
+        ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu);
     else if (ARCH_IS_X86(qemuCaps->arch))
-        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpu);
+        ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu);
 
     if (ret == 0)
         cpu->fallback = VIR_CPU_FALLBACK_FORBID;
-- 
2.12.0

--
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