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(a)linux.vnet.ibm.com>
---
po/POTFILES.in | 1 +
src/cpu/cpu_s390.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 25867ae..ea70e33 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..0073565 100644
--- a/src/cpu/cpu_s390.c
+++ b/src/cpu/cpu_s390.c
@@ -71,15 +71,65 @@ s390DataFree(virCPUDataPtr data)
VIR_FREE(data);
}
+static virCPUCompareResult
+virCPUs390Compare(virCPUDefPtr host ATTRIBUTE_UNUSED,
+ virCPUDefPtr cpu ATTRIBUTE_UNUSED,
+ bool failMessages ATTRIBUTE_UNUSED)
+{
+ return VIR_CPU_COMPARE_IDENTICAL;
+}
+
+static int
+virCPUs390Update(virCPUDefPtr guest,
+ const virCPUDef *host)
+{
+ virCPUDefPtr updated = NULL;
+ int ret = -1;
+
+ 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;
+
+ 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,
};
--
1.9.1