File 74fc32a9-s390-host-cpu-model.patch of Package libvirt.8586

commit 74fc32a955e12c40aba3be902f857d832a1deb9a
Author: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Date:   Fri Nov 24 09:02:02 2017 +0100

    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 <jjherne@linux.vnet.ibm.com>
    Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
    Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
    Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

    SUSE backport note:
    [BSC#1065766]
    On SLE12 SP3, when querying host cpu model info fails, just skip printing the
    error message and return 2 as libvirtd can still start successfully.

Index: libvirt-3.3.0/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt-3.3.0.orig/src/qemu/qemu_capabilities.c
+++ libvirt-3.3.0/src/qemu/qemu_capabilities.c
@@ -3237,23 +3237,21 @@ virQEMUCapsCPUFilterFeatures(const char
 /**
  * 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)
 {
     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 (!modelInfo)
+        return 2;
 
     if (VIR_STRDUP(cpu->model, modelInfo->name) < 0 ||
         VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0)
@@ -3361,6 +3359,8 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPt
 /**
  * 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
@@ -3376,7 +3376,7 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr q
         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,
@@ -3436,6 +3436,11 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsP
                                      virQEMUCapsCPUFilterFeatures,
                                      qemuCaps) < 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,
openSUSE Build Service is sponsored by