s390: Cpu driver support for update and compare

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@linux.vnet.ibm.com>
Acked-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jason J. Herne 2016-12-18 14:22:21 -05:00 committed by Jiri Denemark
parent c1140eb9ed
commit 79d72011ee
2 changed files with 72 additions and 2 deletions

View File

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

View File

@ -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,
};