[libvirt] [PATCH v4 8/8] qemu_driver: hook up query-cpu-model-comparison

Collin Walling posted 8 patches 6 years, 6 months ago
There is a newer version of this series
[libvirt] [PATCH v4 8/8] qemu_driver: hook up query-cpu-model-comparison
Posted by Collin Walling 6 years, 6 months ago
This command is hooked into the virsh hypervisor-cpu-compare command.
As such, the CPU model XML provided to the command will be compared
to the hypervisor CPU contained in the QEMU capabilities file for the
appropriate QEMU binary (for s390x, this CPU definition can be observed
via virsh domcapabilities).

s390x can report that the first model (A) is a subset of the second
(B). If A is the hypervisor CPU and a subset of B (the CPU contained
in the XML), then B would not be able to run on this machine and thus
we will report that CPU model B is incompatible.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
---
 src/qemu/qemu_capabilities.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_capabilities.h |  9 +++++++++
 src/qemu/qemu_driver.c       | 11 ++++++++++
 3 files changed, 68 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a99ebcb..20cb82b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5660,3 +5660,51 @@ virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
     virCPUDefFree(cpu);
     return baseline;
 }
+
+virCPUCompareResult
+virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
+                              const char *libDir,
+                              uid_t runUid,
+                              gid_t runGid,
+                              virCPUDefPtr cpu_a,
+                              virCPUDefPtr cpu_b,
+                              bool failIncompatible)
+{
+    qemuProcessQMPPtr proc = NULL;
+    qemuMonitorCPUModelInfoPtr result = NULL;
+    int ret = -1;
+
+    if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
+                                   runUid, runGid, false)))
+        goto cleanup;
+
+    if (qemuProcessQMPStart(proc) < 0)
+        goto cleanup;
+
+    if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a->model,
+                                         cpu_a->nfeatures, cpu_a->features,
+                                         cpu_b->model, cpu_b->nfeatures,
+                                         cpu_b->features, &result) < 0)
+        goto cleanup;
+
+    if (STREQ(result->name, "incompatible") ||
+        STREQ(result->name, "subset"))
+        ret = VIR_CPU_COMPARE_INCOMPATIBLE;
+    else if (STREQ(result->name, "identical"))
+        ret = VIR_CPU_COMPARE_IDENTICAL;
+    else if (STREQ(result->name, "superset"))
+        ret = VIR_CPU_COMPARE_SUPERSET;
+
+    if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
+        ret = VIR_CPU_COMPARE_ERROR;
+        virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
+    }
+
+ cleanup:
+    if (ret < 0)
+        virQEMUCapsLogProbeFailure(qemuCaps->binary);
+
+    qemuMonitorCPUModelInfoFree(result);
+    qemuProcessQMPFree(proc);
+    return ret;
+}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 8afa05c..a62499f 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -673,3 +673,12 @@ virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
                                         gid_t runGid,
                                         int ncpus,
                                         virCPUDefPtr *cpus);
+
+virCPUCompareResult
+virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
+                              const char *libDir,
+                              uid_t runUid,
+                              gid_t runGid,
+                              virCPUDefPtr cpu_a,
+                              virCPUDefPtr cpu_b,
+                              bool failIncompatible);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 37b9c75..3e49c04 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13446,9 +13446,11 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
 {
     int ret = VIR_CPU_COMPARE_ERROR;
     virQEMUDriverPtr driver = conn->privateData;
+    virQEMUDriverConfigPtr config = driver->config;
     virQEMUCapsPtr qemuCaps = NULL;
     bool failIncompatible;
     virCPUDefPtr hvCPU;
+    virCPUDefPtr cpu;
     virArch arch;
     virDomainVirtType virttype;
 
@@ -13483,6 +13485,14 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
 
     if (ARCH_IS_X86(arch)) {
         ret = virCPUCompareXML(arch, hvCPU, xmlCPU, failIncompatible);
+    } else if (ARCH_IS_S390(arch) &&
+               virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON)) {
+        if (virCPUDefParseXMLHelper(xmlCPU, NULL, VIR_CPU_TYPE_AUTO, &cpu) < 0)
+            goto cleanup;
+
+        ret = virQEMUCapsCPUModelComparison(qemuCaps, config->libDir,
+                                            config->user, config->group,
+                                            hvCPU, cpu, failIncompatible);
     } else {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
                        _("comparing with the hypervisor CPU is not supported "
@@ -13490,6 +13500,7 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
     }
 
  cleanup:
+    virCPUDefFree(cpu);
     virObjectUnref(qemuCaps);
     return ret;
 }
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 8/8] qemu_driver: hook up query-cpu-model-comparison
Posted by Boris Fiuczynski 6 years, 6 months ago
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>

On 7/17/19 4:03 PM, Collin Walling wrote:
> This command is hooked into the virsh hypervisor-cpu-compare command.
> As such, the CPU model XML provided to the command will be compared
> to the hypervisor CPU contained in the QEMU capabilities file for the
> appropriate QEMU binary (for s390x, this CPU definition can be observed
> via virsh domcapabilities).
> 
> s390x can report that the first model (A) is a subset of the second
> (B). If A is the hypervisor CPU and a subset of B (the CPU contained
> in the XML), then B would not be able to run on this machine and thus
> we will report that CPU model B is incompatible.
> 
> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
> ---
>   src/qemu/qemu_capabilities.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
>   src/qemu/qemu_capabilities.h |  9 +++++++++
>   src/qemu/qemu_driver.c       | 11 ++++++++++
>   3 files changed, 68 insertions(+)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index a99ebcb..20cb82b 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -5660,3 +5660,51 @@ virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
>       virCPUDefFree(cpu);
>       return baseline;
>   }
> +
> +virCPUCompareResult
> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
> +                              const char *libDir,
> +                              uid_t runUid,
> +                              gid_t runGid,
> +                              virCPUDefPtr cpu_a,
> +                              virCPUDefPtr cpu_b,
> +                              bool failIncompatible)
> +{
> +    qemuProcessQMPPtr proc = NULL;
> +    qemuMonitorCPUModelInfoPtr result = NULL;
> +    int ret = -1;
> +
> +    if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
> +                                   runUid, runGid, false)))
> +        goto cleanup;
> +
> +    if (qemuProcessQMPStart(proc) < 0)
> +        goto cleanup;
> +
> +    if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a->model,
> +                                         cpu_a->nfeatures, cpu_a->features,
> +                                         cpu_b->model, cpu_b->nfeatures,
> +                                         cpu_b->features, &result) < 0)
> +        goto cleanup;
> +
> +    if (STREQ(result->name, "incompatible") ||
> +        STREQ(result->name, "subset"))
> +        ret = VIR_CPU_COMPARE_INCOMPATIBLE;
> +    else if (STREQ(result->name, "identical"))
> +        ret = VIR_CPU_COMPARE_IDENTICAL;
> +    else if (STREQ(result->name, "superset"))
> +        ret = VIR_CPU_COMPARE_SUPERSET;
> +
> +    if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
> +        ret = VIR_CPU_COMPARE_ERROR;
> +        virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
> +    }
> +
> + cleanup:
> +    if (ret < 0)
> +        virQEMUCapsLogProbeFailure(qemuCaps->binary);
> +
> +    qemuMonitorCPUModelInfoFree(result);
> +    qemuProcessQMPFree(proc);
> +    return ret;
> +}
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 8afa05c..a62499f 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -673,3 +673,12 @@ virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
>                                           gid_t runGid,
>                                           int ncpus,
>                                           virCPUDefPtr *cpus);
> +
> +virCPUCompareResult
> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
> +                              const char *libDir,
> +                              uid_t runUid,
> +                              gid_t runGid,
> +                              virCPUDefPtr cpu_a,
> +                              virCPUDefPtr cpu_b,
> +                              bool failIncompatible);
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 37b9c75..3e49c04 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -13446,9 +13446,11 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>   {
>       int ret = VIR_CPU_COMPARE_ERROR;
>       virQEMUDriverPtr driver = conn->privateData;
> +    virQEMUDriverConfigPtr config = driver->config;
>       virQEMUCapsPtr qemuCaps = NULL;
>       bool failIncompatible;
>       virCPUDefPtr hvCPU;
> +    virCPUDefPtr cpu;
>       virArch arch;
>       virDomainVirtType virttype;
>   
> @@ -13483,6 +13485,14 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>   
>       if (ARCH_IS_X86(arch)) {
>           ret = virCPUCompareXML(arch, hvCPU, xmlCPU, failIncompatible);
> +    } else if (ARCH_IS_S390(arch) &&
> +               virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON)) {
> +        if (virCPUDefParseXMLHelper(xmlCPU, NULL, VIR_CPU_TYPE_AUTO, &cpu) < 0)
> +            goto cleanup;
> +
> +        ret = virQEMUCapsCPUModelComparison(qemuCaps, config->libDir,
> +                                            config->user, config->group,
> +                                            hvCPU, cpu, failIncompatible);
>       } else {
>           virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
>                          _("comparing with the hypervisor CPU is not supported "
> @@ -13490,6 +13500,7 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>       }
>   
>    cleanup:
> +    virCPUDefFree(cpu);
>       virObjectUnref(qemuCaps);
>       return ret;
>   }
> 


-- 
Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Matthias Hartmann
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 8/8] qemu_driver: hook up query-cpu-model-comparison
Posted by Collin Walling 6 years, 6 months ago
[...]

>> +
>> +virCPUCompareResult
>> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
>> +                              const char *libDir,
>> +                              uid_t runUid,
>> +                              gid_t runGid,
>> +                              virCPUDefPtr cpu_a,
>> +                              virCPUDefPtr cpu_b,
>> +                              bool failIncompatible)
>> +{
>> +    qemuProcessQMPPtr proc = NULL;
>> +    qemuMonitorCPUModelInfoPtr result = NULL;

Set ret = VIR_CPU_COMPARE_INCOMPATIBLE

>> +    int ret = -1;
>> +
>> +    if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
>> +                                   runUid, runGid, false)))
>> +        goto cleanup;
>> +
>> +    if (qemuProcessQMPStart(proc) < 0)
>> +        goto cleanup;
>> +
>> +    if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a->model,
>> +                                         cpu_a->nfeatures, 
>> cpu_a->features,
>> +                                         cpu_b->model, cpu_b->nfeatures,
>> +                                         cpu_b->features, &result) < 0)
>> +        goto cleanup;
>> +
>> +    if (STREQ(result->name, "incompatible") ||
>> +        STREQ(result->name, "subset"))
>> +        ret = VIR_CPU_COMPARE_INCOMPATIBLE;
>> +    else if (STREQ(result->name, "identical"))
>> +        ret = VIR_CPU_COMPARE_IDENTICAL;
>> +    else if (STREQ(result->name, "superset"))
>> +        ret = VIR_CPU_COMPARE_SUPERSET;

and change this:

>> +
>> +    if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
>> +        ret = VIR_CPU_COMPARE_ERROR;
>> +        virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
>> +    }
>> +
>> + cleanup:
>> +    if (ret < 0)
>> +        virQEMUCapsLogProbeFailure(qemuCaps->binary);

To this:

  cleanup:
     if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
         ret = VIR_CPU_COMPARE_ERROR;
         virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
         virQEMUCapsLogProbeFailure(qemuCaps->binary);
     }

>> +
>> +    qemuMonitorCPUModelInfoFree(result);
>> +    qemuProcessQMPFree(proc);
>> +    return ret;
>> +}

And now the output will look like this when the xml contains an
erroneous CPU model or feature:

virsh hypervisor-cpu-compare cpufail.xml
CPU described in cpufail.xml is incompatible with the CPU provided by 
hypervisor on the host


virsh hypervisor-cpu-compare cpufail.xml --error
error: Failed to compare hypervisor CPU with cpufail.xml
error: the CPU is incompatible with host CPU

If this output is not acceptable, then perhaps we should further explore
option 2 that I described on patch 5.

[...]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 8/8] qemu_driver: hook up query-cpu-model-comparison
Posted by Boris Fiuczynski 6 years, 6 months ago
On 7/25/19 8:26 PM, Collin Walling wrote:
> [...]
> 
>>> +
>>> +virCPUCompareResult
>>> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
>>> +                              const char *libDir,
>>> +                              uid_t runUid,
>>> +                              gid_t runGid,
>>> +                              virCPUDefPtr cpu_a,
>>> +                              virCPUDefPtr cpu_b,
>>> +                              bool failIncompatible)
>>> +{
>>> +    qemuProcessQMPPtr proc = NULL;
>>> +    qemuMonitorCPUModelInfoPtr result = NULL;
> 
> Set ret = VIR_CPU_COMPARE_INCOMPATIBLE
> 
>>> +    int ret = -1;
>>> +
>>> +    if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
>>> +                                   runUid, runGid, false)))
>>> +        goto cleanup;
>>> +
>>> +    if (qemuProcessQMPStart(proc) < 0)
>>> +        goto cleanup;
>>> +
>>> +    if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a->model,
>>> +                                         cpu_a->nfeatures, 
>>> cpu_a->features,
>>> +                                         cpu_b->model, 
>>> cpu_b->nfeatures,
>>> +                                         cpu_b->features, &result) < 0)
>>> +        goto cleanup;
>>> +
>>> +    if (STREQ(result->name, "incompatible") ||
>>> +        STREQ(result->name, "subset"))
>>> +        ret = VIR_CPU_COMPARE_INCOMPATIBLE;
>>> +    else if (STREQ(result->name, "identical"))
>>> +        ret = VIR_CPU_COMPARE_IDENTICAL;
>>> +    else if (STREQ(result->name, "superset"))
>>> +        ret = VIR_CPU_COMPARE_SUPERSET;
> 
> and change this:
> 
>>> +
>>> +    if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
>>> +        ret = VIR_CPU_COMPARE_ERROR;
>>> +        virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
>>> +    }
>>> +
>>> + cleanup:
>>> +    if (ret < 0)
>>> +        virQEMUCapsLogProbeFailure(qemuCaps->binary);
> 
> To this:
> 
>   cleanup:
>      if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
>          ret = VIR_CPU_COMPARE_ERROR;
>          virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
>          virQEMUCapsLogProbeFailure(qemuCaps->binary);
>      }
> 
>>> +
>>> +    qemuMonitorCPUModelInfoFree(result);
>>> +    qemuProcessQMPFree(proc);
>>> +    return ret;
>>> +}
> 
> And now the output will look like this when the xml contains an
> erroneous CPU model or feature:
> 
> virsh hypervisor-cpu-compare cpufail.xml
> CPU described in cpufail.xml is incompatible with the CPU provided by 
> hypervisor on the host
> 
> 
> virsh hypervisor-cpu-compare cpufail.xml --error
> error: Failed to compare hypervisor CPU with cpufail.xml
> error: the CPU is incompatible with host CPU
> 
> If this output is not acceptable, then perhaps we should further explore
> option 2 that I described on patch 5.
> 
> [...]

Please see my response in patch 5.

> 
> -- 
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list


-- 
Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Matthias Hartmann
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 8/8] qemu_driver: hook up query-cpu-model-comparison
Posted by Jiri Denemark 6 years, 5 months ago
On Wed, Jul 17, 2019 at 10:03:29 -0400, Collin Walling wrote:
> This command is hooked into the virsh hypervisor-cpu-compare command.
> As such, the CPU model XML provided to the command will be compared
> to the hypervisor CPU contained in the QEMU capabilities file for the
> appropriate QEMU binary (for s390x, this CPU definition can be observed
> via virsh domcapabilities).
> 
> s390x can report that the first model (A) is a subset of the second
> (B). If A is the hypervisor CPU and a subset of B (the CPU contained
> in the XML), then B would not be able to run on this machine and thus
> we will report that CPU model B is incompatible.
> 
> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
> ---
>  src/qemu/qemu_capabilities.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_capabilities.h |  9 +++++++++
>  src/qemu/qemu_driver.c       | 11 ++++++++++
>  3 files changed, 68 insertions(+)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index a99ebcb..20cb82b 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -5660,3 +5660,51 @@ virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
>      virCPUDefFree(cpu);
>      return baseline;
>  }
> +
> +virCPUCompareResult
> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
> +                              const char *libDir,
> +                              uid_t runUid,
> +                              gid_t runGid,
> +                              virCPUDefPtr cpu_a,
> +                              virCPUDefPtr cpu_b,
> +                              bool failIncompatible)

This function should go into qemu_driver.c and its name should change
accordingly.

> +{
> +    qemuProcessQMPPtr proc = NULL;
> +    qemuMonitorCPUModelInfoPtr result = NULL;
> +    int ret = -1;
> +
> +    if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
> +                                   runUid, runGid, false)))
> +        goto cleanup;
> +
> +    if (qemuProcessQMPStart(proc) < 0)
> +        goto cleanup;
> +
> +    if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a->model,
> +                                         cpu_a->nfeatures, cpu_a->features,
> +                                         cpu_b->model, cpu_b->nfeatures,
> +                                         cpu_b->features, &result) < 0)
> +        goto cleanup;
> +
> +    if (STREQ(result->name, "incompatible") ||
> +        STREQ(result->name, "subset"))
> +        ret = VIR_CPU_COMPARE_INCOMPATIBLE;
> +    else if (STREQ(result->name, "identical"))
> +        ret = VIR_CPU_COMPARE_IDENTICAL;
> +    else if (STREQ(result->name, "superset"))
> +        ret = VIR_CPU_COMPARE_SUPERSET;
> +
> +    if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
> +        ret = VIR_CPU_COMPARE_ERROR;
> +        virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
> +    }
> +
> + cleanup:
> +    if (ret < 0)
> +        virQEMUCapsLogProbeFailure(qemuCaps->binary);

Again, no logging here, please. The reported error is already going to
be logged anyway. And mainly since this is called from inside an API
invoked by a client, the client will get the error. Probing is different
as there's no API involved, QEMU binaries are probed when libvirtd
starts.

> +
> +    qemuMonitorCPUModelInfoFree(result);
> +    qemuProcessQMPFree(proc);
> +    return ret;
> +}
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 8afa05c..a62499f 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -673,3 +673,12 @@ virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
>                                          gid_t runGid,
>                                          int ncpus,
>                                          virCPUDefPtr *cpus);
> +
> +virCPUCompareResult
> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
> +                              const char *libDir,
> +                              uid_t runUid,
> +                              gid_t runGid,
> +                              virCPUDefPtr cpu_a,
> +                              virCPUDefPtr cpu_b,
> +                              bool failIncompatible);
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 37b9c75..3e49c04 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -13446,9 +13446,11 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>  {
>      int ret = VIR_CPU_COMPARE_ERROR;
>      virQEMUDriverPtr driver = conn->privateData;
> +    virQEMUDriverConfigPtr config = driver->config;

VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);

>      virQEMUCapsPtr qemuCaps = NULL;
>      bool failIncompatible;
>      virCPUDefPtr hvCPU;
> +    virCPUDefPtr cpu;
>      virArch arch;
>      virDomainVirtType virttype;
>  
> @@ -13483,6 +13485,14 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>  
>      if (ARCH_IS_X86(arch)) {
>          ret = virCPUCompareXML(arch, hvCPU, xmlCPU, failIncompatible);
> +    } else if (ARCH_IS_S390(arch) &&
> +               virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON)) {
> +        if (virCPUDefParseXMLHelper(xmlCPU, NULL, VIR_CPU_TYPE_AUTO, &cpu) < 0)
> +            goto cleanup;
> +
> +        ret = virQEMUCapsCPUModelComparison(qemuCaps, config->libDir,
> +                                            config->user, config->group,
> +                                            hvCPU, cpu, failIncompatible);
>      } else {
>          virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
>                         _("comparing with the hypervisor CPU is not supported "
> @@ -13490,6 +13500,7 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>      }
>  
>   cleanup:
> +    virCPUDefFree(cpu);
>      virObjectUnref(qemuCaps);
>      return ret;
>  }

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list