From 74fc32a955e12c40aba3be902f857d832a1deb9a Mon Sep 17 00:00:00 2001 From: "Jason J. Herne" Date: Fri, 24 Nov 2017 09:02:02 +0100 Subject: [PATCH] s390: qemu-capabilities: Avoid error message when missing non-kvm host cpu info Libvirt prints an error on startup when it is missing host cpu model information for any queried qemu binary. On s390 we only have host cpu model information for kvm enabled qemu instances. So when virt type is not kvm, this is actually not an error on s390. This patch adds virt type as a parameter to virQEMUCapsInitCPUModelS390, and a new return code 2 for virQEMUCapsInitCPUModel and virQEMUCapsInitCPUModelS390. If the virt type is not kvm then we skip printing the scary error message and return 2 because this case is actually expected behavior. The new return code is meant to differentiate between the failure case and the case where we simply expect the cpu model information to be unattainable. Signed-off-by: Jason J. Herne Reviewed-by: Boris Fiuczynski Reviewed-by: Marc Hartmayer Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3adea664f7..201e83c45c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3306,10 +3306,13 @@ virQEMUCapsCPUFilterFeatures(const char *name, /** * Returns 0 when host CPU model provided by QEMU was filled in qemuCaps, * 1 when the caller should fall back to using virCapsPtr->host.cpu, + * 2 when cpu model info is not supported for this configuration and + * fall back should not be used. * -1 on error. */ static int virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, + virDomainVirtType type, qemuMonitorCPUModelInfoPtr modelInfo, virCPUDefPtr cpu, bool migratable) @@ -3317,11 +3320,14 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, size_t i; if (!modelInfo) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing host CPU model info from QEMU capabilities " - "for binary %s"), - qemuCaps->binary); - return -1; + if (type == VIR_DOMAIN_VIRT_KVM) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing host CPU model info from QEMU " + "capabilities for binary %s"), + qemuCaps->binary); + return -1; + } + return 2; } if (VIR_STRDUP(cpu->model, modelInfo->name) < 0 || @@ -3429,6 +3435,8 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, /** * Returns 0 when host CPU model provided by QEMU was filled in qemuCaps, * 1 when the caller should fall back to other methods + * 2 when cpu model info is not supported for this configuration and + * fall back should not be used. * -1 on error. */ int @@ -3444,7 +3452,7 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps, return 1; if (ARCH_IS_S390(qemuCaps->arch)) { - ret = virQEMUCapsInitCPUModelS390(qemuCaps, cpuData->info, + ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, cpuData->info, cpu, migratable); } else if (ARCH_IS_X86(qemuCaps->arch)) { ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpuData->info, @@ -3504,6 +3512,11 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, virQEMUCapsCPUFilterFeatures, &qemuCaps->arch) < 0) goto error; + } else if (rc == 2) { + VIR_DEBUG("QEMU does not provide CPU model for arch=%s virttype=%s", + virArchToString(qemuCaps->arch), + virDomainVirtTypeToString(type)); + goto error; } else if (type == VIR_DOMAIN_VIRT_KVM && virCPUGetHostIsSupported(qemuCaps->arch)) { if (!(fullCPU = virCPUGetHost(qemuCaps->arch, VIR_CPU_TYPE_GUEST, -- 2.39.5