[PATCH 4/4] conf: Deduplicate NUMA distance code

Peter Krempa pkrempa at redhat.com
Fri May 21 07:58:08 UTC 2021


On Thu, May 20, 2021 at 17:24:56 +0200, Michal Privoznik wrote:
> After previous patches we have two structures:
> virCapsHostNUMACellDistance and virNumaDistance which express the
> same thing. And have the exact same members (modulo their names).
> Drop the former in favor of the latter.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/conf/capabilities.c        | 26 ++++++++------------------
>  src/conf/capabilities.h        | 11 +++--------
>  src/conf/virconftypes.h        |  2 --
>  src/libxl/libxl_capabilities.c |  8 ++++----
>  4 files changed, 15 insertions(+), 32 deletions(-)
> 
> diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
> index 926ecb5a24..1290c9c15d 100644
> --- a/src/conf/capabilities.c
> +++ b/src/conf/capabilities.c

[...]

> @@ -833,17 +833,7 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf,
>                                cell->pageinfo[j].avail);
>          }
>  
> -        if (cell->ndistances) {
> -            virBufferAddLit(buf, "<distances>\n");
> -            virBufferAdjustIndent(buf, 2);
> -            for (j = 0; j < cell->ndistances; j++) {

This code didn't skip printing the sibling if 'value' is 0 ...

> -                virBufferAsprintf(buf, "<sibling id='%d' value='%d'/>\n",
> -                                  cell->distances[j].node,
> -                                  cell->distances[j].distance);
> -            }
> -            virBufferAdjustIndent(buf, -2);
> -            virBufferAddLit(buf, "</distances>\n");
> -        }
> +        virNumaDistanceFormat(buf, cell->distances, cell->ndistances);

... but this new implementation does that. I didn't check whether that's
justified or not, but the commit message doesn't try to justify it
either.

Was that an expected change?

>  
>          virBufferAsprintf(buf, "<cpus num='%d'>\n", cell->ncpus);
>          virBufferAdjustIndent(buf, 2);




More information about the libvir-list mailing list