[PATCH 12/13] qemu: Build HMAT command line

Daniel Henrique Barboza danielhb413 at gmail.com
Wed Jun 24 22:23:24 UTC 2020



On 6/24/20 10:49 AM, Michal Privoznik wrote:
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1786303
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>   src/conf/numa_conf.c                          |   7 +
>   src/qemu/qemu_command.c                       | 183 ++++++++++++++++++
>   .../numatune-hmat.x86_64-latest.args          |  53 +++++
>   tests/qemuxml2argvtest.c                      |   1 +
>   4 files changed, 244 insertions(+)
>   create mode 100644 tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args
> 
> diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
> index b35e5040fc..7fbbe0f52e 100644
> --- a/src/conf/numa_conf.c
> +++ b/src/conf/numa_conf.c
> @@ -1904,6 +1904,13 @@ virDomainNumaGetNodeInitiator(const virDomainNuma *numa,
>       if (!numa || node >= numa->nmem_nodes)
>           return -1;
>   
> +    /* A NUMA node which has at least one vCPU is initiator to itself by
> +     * definition. */
> +    if (numa->mem_nodes[node].cpumask)
> +        return node;
> +
> +    /* For the rest, "NUMA node that has best performance (the lowest
> +     * latency or largest bandwidth) to this NUMA node." */
>       for (i = 0; i < numa->nlatencies; i++) {
>           const virDomainNumaLatency *l = &numa->latencies[i];
>   
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 628ff970bd..b28c43f110 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -6932,6 +6932,16 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
>               virBufferAsprintf(&buf, ",pflash1=%s", priv->pflash1->nodeformat);
>       }
>   
> +    if (virDomainNumaHasHMAT(def->numa)) {
> +        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA_HMAT)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("HMAT is not supported with this QEMU"));
> +            return -1;
> +        }


This qemuCaps validation must be moved to qemu_validation.c,
qemuValidateDomainDefNuma(), to allow post-parse checking instead of runtime.
This is the original intent of qemu_validate.c. Yeah, I know that there are still
some validations being done here in qemu_command.c. I'll come back to this
work of moving this stuff to qemu_validate.c soon (TM).


As a bonus:



> +
> +        virBufferAddLit(&buf, ",hmat=on");
> +    }
> +
>       virCommandAddArgBuffer(cmd, &buf);
>   
>       return 0;
> @@ -7114,6 +7124,134 @@ qemuBuildIOThreadCommandLine(virCommandPtr cmd,
>   }
>   

[...]


> +}
> +
> +
>   static int
>   qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg,
>                            virDomainDefPtr def,
> @@ -7126,9 +7264,11 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg,
>       char *next = NULL;
>       virBufferPtr nodeBackends = NULL;
>       bool needBackend = false;
> +    bool hmat = false;
>       int rc;
>       int ret = -1;
>       size_t ncells = virDomainNumaGetNodeCount(def->numa);
> +    ssize_t masterInitiator = -1;
>   
>       if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset))
>           goto cleanup;
> @@ -7138,6 +7278,16 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg,
>                                                  def->os.machine))
>           needBackend = true;
>   
> +    if (virDomainNumaHasHMAT(def->numa)) {
> +        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA_HMAT)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("HMAT is not supported with this QEMU"));
> +            goto cleanup;
> +        }
> +        needBackend = true;
> +        hmat = true;
> +    }
> +


You can get rid of this second duplicated validation block since this would be
already be checked once in qemuValidateDomainDefNuma().


With the validation code moved:


Reviewed-by: Daniel Henrique Barboza <danielhb413 at gmail.com>




More information about the libvir-list mailing list