[PATCH v2 01/11] s390: Cpu driver support for update and compare

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

 



Implement compare for s390. Required to test the guest against the host for
guest cpu model runnability checking. We always return IDENTICAL to bypass
Libvirt's checking. s390 will rely on Qemu to perform the runnability checking.

Implement update for s390. required to support use of cpu "host-model" mode.

Signed-off-by: Jason J. Herne <jjherne@xxxxxxxxxxxxxxxxxx>
---
 po/POTFILES.in     |  1 +
 src/cpu/cpu_s390.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index b0a1ed4..570ebf1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -46,6 +46,7 @@ src/cpu/cpu.c
 src/cpu/cpu_arm.c
 src/cpu/cpu_map.c
 src/cpu/cpu_ppc64.c
+src/cpu/cpu_s390.c
 src/cpu/cpu_x86.c
 src/datatypes.c
 src/driver.c
diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c
index 04a6bea..3efc948 100644
--- a/src/cpu/cpu_s390.c
+++ b/src/cpu/cpu_s390.c
@@ -71,15 +71,84 @@ s390DataFree(virCPUDataPtr data)
     VIR_FREE(data);
 }
 
+static virCPUCompareResult
+virCPUs390Compare(virCPUDefPtr host ATTRIBUTE_UNUSED,
+                  virCPUDefPtr cpu ATTRIBUTE_UNUSED,
+                  bool failMessages ATTRIBUTE_UNUSED)
+{
+    /* s390 relies on Qemu to perform all runability checking. Return
+     * VIR_CPU_COMPARE_IDENTICAL to bypass Libvirt checking.
+     */
+    return VIR_CPU_COMPARE_IDENTICAL;
+}
+
+static int
+virCPUs390Update(virCPUDefPtr guest,
+                 const virCPUDef *host)
+{
+     virCPUDefPtr updated = NULL;
+     int ret = -1;
+     size_t i;
+
+     if (guest->match == VIR_CPU_MATCH_MINIMUM) {
+         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                        _("match mode %s not supported"),
+                        virCPUMatchTypeToString(guest->match));
+         goto cleanup;
+     }
+
+     if (guest->mode != VIR_CPU_MODE_HOST_MODEL) {
+         ret = 0;
+         goto cleanup;
+     }
+
+     if (!host) {
+         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                        _("unknown host CPU model"));
+         goto cleanup;
+     }
+
+     if (!(updated = virCPUDefCopyWithoutModel(guest)))
+         goto cleanup;
+
+     updated->mode = VIR_CPU_MODE_CUSTOM;
+     if (virCPUDefCopyModel(updated, host, true) < 0)
+         goto cleanup;
+
+     for (i = 0; i < guest->nfeatures; i++) {
+         if (guest->features[i].policy == VIR_CPU_FEATURE_OPTIONAL) {
+             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                 _("Only cpu feature policies 'require' and 'disable' are "
+                 "supported for %s"),
+                 guest->features[i].name);
+             goto cleanup;
+        }
+
+        if (virCPUDefUpdateFeature(updated,
+                                   guest->features[i].name,
+                                   guest->features[i].policy) < 0)
+            goto cleanup;
+     }
+
+     virCPUDefStealModel(guest, updated, false);
+     guest->mode = VIR_CPU_MODE_CUSTOM;
+     guest->match = VIR_CPU_MATCH_EXACT;
+     ret = 0;
+
+ cleanup:
+     virCPUDefFree(updated);
+     return ret;
+}
+
 struct cpuArchDriver cpuDriverS390 = {
     .name = "s390",
     .arch = archs,
     .narch = ARRAY_CARDINALITY(archs),
-    .compare    = NULL,
+    .compare    = virCPUs390Compare,
     .decode     = s390Decode,
     .encode     = NULL,
     .free       = s390DataFree,
     .nodeData   = s390NodeData,
     .baseline   = NULL,
-    .update     = NULL,
+    .update     = virCPUs390Update,
 };
-- 
2.7.4

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