On Sat, May 05, 2018 at 12:48:46 -0500, Chris Venteicher wrote:
> Spinup QEMU instance and complete QMP query-cpu-model-baseline exchanges
> to determine CPUModel Baseline.
> 
> query-cpu-model-baseline only compares two CPUModels so multiple
> exchanges are needed to evaluate more than two CPUModels.
> ---
>  src/qemu/qemu_capabilities.c | 132 
> +++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_capabilities.h |   9 +++
>  2 files changed, 141 insertions(+)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 097985cbe7..9ffbf91a90 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -5122,3 +5122,135 @@ virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr 
> qemuCaps,
>  {
>      qemuCaps->microcodeVersion = microcodeVersion;
>  }
> +
> +
> +/* in:
> + * <host>
> + *   <cpu>
> + *     <arch>s390x</arch>
> + *     <model>z13-base</model>
> + *     <feature name='xxx'/>
> + *     ...
> + *     <feature name='yyy'/>
> + *   </cpu>
> + *   <cpu>
> + *     <arch>s390x</arch>
> + *     <model>z114-base</model>
> + *     <feature name='xxx'/>
> + *     ...
> + *     <feature name='yyy'/>
> + *   </cpu>
> + * </host>
> + *
> + * out:
> + * <cpu match='exact'>
> + *  <model>z13-base</model>
> + *  <feature policy='require' name='xxx'/>
> + *  <feature policy='require' name='yyy'/>
> + * </cpu>
> + *
> + * (ret==0) && (baseline.len == 0) if baseline not supported by QEMU
> + */
> +int
> +virQEMUCapsQMPBaselineCPUModel(char *exec,
> +                               const char *libDir,
> +                               uid_t runUid,
> +                               gid_t runGid,
> +                               const char **xmlCPUs,
> +                               unsigned int ncpus,
> +                               bool migratable,
> +                               virBufferPtr baseline)
> +{
> +    qemuMonitorCPUModelInfoPtr  model_baseline = NULL;
> +    qemuMonitorCPUModelInfoPtr  new_model_baseline = NULL;
> +    qemuMonitorCPUModelInfoPtr  model_b = NULL;
> +    virQEMUCapsInitQMPCommandPtr cmd = NULL;
> +    virBuffer buf = VIR_BUFFER_INITIALIZER;
> +    bool forceTCG = false;
> +    int ret = -1;
> +    size_t i;
> +
> +    VIR_DEBUG("ncpus=%i, migratable=%i", ncpus, migratable);
> +
> +    if (!(cmd = virQEMUCapsSpinUpQemu(exec, libDir, runUid, runGid, 
> forceTCG)))
> +        goto cleanup;
> +
> +    if (!(cmd->mon)) {

This test will never be true.

> +        /* Not connected to QEMU (monitor) */
> +        VIR_DEBUG("QEMU failed to initialize error=%s", 
> virGetLastErrorMessage());
> +        goto cleanup;
> +    }
> +
> +    /* QEMU requires qmp_capabilities exchange first */
> +    if (qemuMonitorSetCapabilities(cmd->mon) < 0) {
> +        VIR_DEBUG("Failed to set monitor capabilities %s",
> +                  virGetLastErrorMessage());
> +        goto cleanup;
> +    }

This should be moved inside virQEMUCapsSpinUpQemu.

And the rest of the function needs to be changed to work on CPUDefs
already parsed by the caller.

Jirka

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

Reply via email to