render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3e5111
From aadb80300ceec4ccded4a31992af12abde3860b5 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <aadb80300ceec4ccded4a31992af12abde3860b5@dist-git>
3e5111
From: Jiri Denemark <jdenemar@redhat.com>
3e5111
Date: Tue, 11 Apr 2017 11:14:30 +0200
3e5111
Subject: [PATCH] qemu: Prepare qemuCaps for multiple host CPU defs
3e5111
3e5111
Soon we will need to store multiple host CPU definitions in
3e5111
virQEMUCapsHostCPUData and qemuCaps users will want to request the one
3e5111
they need. This patch introduces virQEMUCapsHostCPUType enum which will
3e5111
be used for specifying the requested CPU definition.
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
(cherry picked from commit 1fe517c68df92eb7f379fa87cb0d29d566aad6f4)
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1444421
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_capabilities.c | 16 ++++++++++++----
3e5111
 src/qemu/qemu_capabilities.h | 10 +++++++++-
3e5111
 src/qemu/qemu_command.c      |  3 ++-
3e5111
 src/qemu/qemu_process.c      |  6 ++++--
3e5111
 4 files changed, 27 insertions(+), 8 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
3e5111
index 0db149018..e84de9f5b 100644
3e5111
--- a/src/qemu/qemu_capabilities.c
3e5111
+++ b/src/qemu/qemu_capabilities.c
3e5111
@@ -2445,11 +2445,17 @@ virQEMUCapsGetHostCPUData(virQEMUCapsPtr qemuCaps,
3e5111
 
3e5111
 virCPUDefPtr
3e5111
 virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
3e5111
-                        virDomainVirtType type)
3e5111
+                        virDomainVirtType type,
3e5111
+                        virQEMUCapsHostCPUType cpuType)
3e5111
 {
3e5111
     virQEMUCapsHostCPUDataPtr cpuData = virQEMUCapsGetHostCPUData(qemuCaps, type);
3e5111
 
3e5111
-    return cpuData->reported;
3e5111
+    switch (cpuType) {
3e5111
+    case VIR_QEMU_CAPS_HOST_CPU_REPORTED:
3e5111
+        return cpuData->reported;
3e5111
+    }
3e5111
+
3e5111
+    return NULL;
3e5111
 }
3e5111
 
3e5111
 
3e5111
@@ -2478,7 +2484,8 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
3e5111
                virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch);
3e5111
 
3e5111
     case VIR_CPU_MODE_HOST_MODEL:
3e5111
-        return !!virQEMUCapsGetHostModel(qemuCaps, type);
3e5111
+        return !!virQEMUCapsGetHostModel(qemuCaps, type,
3e5111
+                                         VIR_QEMU_CAPS_HOST_CPU_REPORTED);
3e5111
 
3e5111
     case VIR_CPU_MODE_CUSTOM:
3e5111
         if (type == VIR_DOMAIN_VIRT_KVM)
3e5111
@@ -5499,7 +5506,8 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
3e5111
 
3e5111
     if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
3e5111
                                       VIR_CPU_MODE_HOST_MODEL)) {
3e5111
-        virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype);
3e5111
+        virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype,
3e5111
+                                                   VIR_QEMU_CAPS_HOST_CPU_REPORTED);
3e5111
         domCaps->cpu.hostModel = virCPUDefCopy(cpu);
3e5111
     }
3e5111
 
3e5111
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
3e5111
index c466a63e7..50333fc26 100644
3e5111
--- a/src/qemu/qemu_capabilities.h
3e5111
+++ b/src/qemu/qemu_capabilities.h
3e5111
@@ -450,8 +450,16 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
3e5111
                                  virDomainVirtType type,
3e5111
                                  char ***names,
3e5111
                                  size_t *count);
3e5111
+
3e5111
+typedef enum {
3e5111
+    /* Host CPU definition reported in domain capabilities. */
3e5111
+    VIR_QEMU_CAPS_HOST_CPU_REPORTED,
3e5111
+} virQEMUCapsHostCPUType;
3e5111
+
3e5111
 virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
3e5111
-                                     virDomainVirtType type);
3e5111
+                                     virDomainVirtType type,
3e5111
+                                     virQEMUCapsHostCPUType cpuType);
3e5111
+
3e5111
 bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
3e5111
                                    virCapsPtr caps,
3e5111
                                    virDomainVirtType type,
3e5111
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
3e5111
index 2105cde58..9ce90c25b 100644
3e5111
--- a/src/qemu/qemu_command.c
3e5111
+++ b/src/qemu/qemu_command.c
3e5111
@@ -6908,7 +6908,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
3e5111
             if (def->cpu->mode == VIR_CPU_MODE_CUSTOM)
3e5111
                 cpuDef = def->cpu;
3e5111
             else if (def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH)
3e5111
-                cpuDef = virQEMUCapsGetHostModel(qemuCaps, def->virtType);
3e5111
+                cpuDef = virQEMUCapsGetHostModel(qemuCaps, def->virtType,
3e5111
+                                                 VIR_QEMU_CAPS_HOST_CPU_REPORTED);
3e5111
 
3e5111
             if (cpuDef) {
3e5111
                 int svm = virCPUCheckFeature(def->os.arch, cpuDef, "svm");
3e5111
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
3e5111
index afd9dfb71..dc073891a 100644
3e5111
--- a/src/qemu/qemu_process.c
3e5111
+++ b/src/qemu/qemu_process.c
3e5111
@@ -5306,12 +5306,14 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
3e5111
 
3e5111
     if (def->cpu->check == VIR_CPU_CHECK_PARTIAL &&
3e5111
         virCPUCompare(caps->host.arch,
3e5111
-                      virQEMUCapsGetHostModel(qemuCaps, def->virtType),
3e5111
+                      virQEMUCapsGetHostModel(qemuCaps, def->virtType,
3e5111
+                                              VIR_QEMU_CAPS_HOST_CPU_REPORTED),
3e5111
                       def->cpu, true) < 0)
3e5111
         return -1;
3e5111
 
3e5111
     if (virCPUUpdate(def->os.arch, def->cpu,
3e5111
-                     virQEMUCapsGetHostModel(qemuCaps, def->virtType)) < 0)
3e5111
+                     virQEMUCapsGetHostModel(qemuCaps, def->virtType,
3e5111
+                                             VIR_QEMU_CAPS_HOST_CPU_REPORTED)) < 0)
3e5111
         goto cleanup;
3e5111
 
3e5111
     if (virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType,
3e5111
-- 
3e5111
2.12.2
3e5111