[PATCH v2 17/20] cpu: Implement backwards compatibility in the ppc64 driver

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

 



All previously recognized CPU models (POWER7_v2.1, POWER7_v2.3,
POWER7+_v2.1 and POWER8_v1.0) are internally converted to the
corrisponding generation name so that existing guests don't stop
working.
---
 src/cpu/cpu_ppc64.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index bfc14fc..9cafa4b 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -57,6 +57,33 @@ struct ppc64_map {
     struct ppc64_model *models;
 };
 
+/* Convert a legacy CPU definition by transforming
+ * model names to generation names:
+ *   POWER7_v2.1  => POWER7
+ *   POWER7_v2.3  => POWER7
+ *   POWER7+_v2.1 => POWER7
+ *   POWER8_v1.0  => POWER8 */
+static virCPUDefPtr
+ppc64LegacyConvertCPUDef(const virCPUDef *legacy)
+{
+    virCPUDefPtr cpu;
+
+    if (!(cpu = virCPUDefCopy(legacy)))
+        goto out;
+
+    if (!(STREQ(cpu->model, "POWER7_v2.1") ||
+          STREQ(cpu->model, "POWER7_v2.3") ||
+          STREQ(cpu->model, "POWER7+_v2.1") ||
+          STREQ(cpu->model, "POWER8_v1.0"))) {
+        goto out;
+    }
+
+    cpu->model[strlen("POWERx")] = 0;
+
+ out:
+    return cpu;
+}
+
 static void
 ppc64DataFree(virCPUppc64Data *data)
 {
@@ -426,18 +453,22 @@ ppc64MakeCPUData(virArch arch,
 
 static virCPUCompareResult
 ppc64Compute(virCPUDefPtr host,
-             const virCPUDef *cpu,
+             const virCPUDef *other,
              virCPUDataPtr *guestData,
              char **message)
 {
     struct ppc64_map *map = NULL;
     struct ppc64_model *host_model = NULL;
     struct ppc64_model *guest_model = NULL;
-
+    virCPUDefPtr cpu = NULL;
     virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
     virArch arch;
     size_t i;
 
+    /* Ensure existing configurations are handled correctly */
+    if (!(cpu = ppc64LegacyConvertCPUDef(other)))
+        goto cleanup;
+
     if (cpu->arch != VIR_ARCH_NONE) {
         bool found = false;
 
@@ -506,6 +537,7 @@ ppc64Compute(virCPUDefPtr host,
     ret = VIR_CPU_COMPARE_IDENTICAL;
 
  cleanup:
+    virCPUDefFree(cpu);
     ppc64MapFree(map);
     ppc64ModelFree(host_model);
     ppc64ModelFree(guest_model);
-- 
2.4.3

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