From 987fd7db4fc4ed8ff47339d440cdfb02ef1f0b58 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 18 Jan 2013 20:39:00 +0100 Subject: [PATCH] conf: Split out NUMA topology formatting to simplify access to data --- src/conf/capabilities.c | 43 ++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 365c511e11..0d2512e6af 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -678,6 +678,28 @@ virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, return NULL; } +static void +virCapabilitiesFormatNUMATopology(virBufferPtr xml, + size_t ncells, + virCapsHostNUMACellPtr *cells) +{ + int i; + int j; + + virBufferAddLit(xml, " \n"); + virBufferAsprintf(xml, " \n", ncells); + for (i = 0; i < ncells; i++) { + virBufferAsprintf(xml, " \n", cells[i]->num); + virBufferAsprintf(xml, " \n", cells[i]->ncpus); + for (j = 0; j < cells[i]->ncpus; j++) + virBufferAsprintf(xml, " \n", + cells[i]->cpus[j]); + virBufferAddLit(xml, " \n"); + virBufferAddLit(xml, " \n"); + } + virBufferAddLit(xml, " \n"); + virBufferAddLit(xml, " \n"); +} /** * virCapabilitiesFormatXML: @@ -752,24 +774,9 @@ virCapabilitiesFormatXML(virCapsPtr caps) virBufferAddLit(&xml, " \n"); } - if (caps->host.nnumaCell) { - virBufferAddLit(&xml, " \n"); - virBufferAsprintf(&xml, " \n", - caps->host.nnumaCell); - for (i = 0 ; i < caps->host.nnumaCell ; i++) { - virBufferAsprintf(&xml, " \n", - caps->host.numaCell[i]->num); - virBufferAsprintf(&xml, " \n", - caps->host.numaCell[i]->ncpus); - for (j = 0 ; j < caps->host.numaCell[i]->ncpus ; j++) - virBufferAsprintf(&xml, " \n", - caps->host.numaCell[i]->cpus[j]); - virBufferAddLit(&xml, " \n"); - virBufferAddLit(&xml, " \n"); - } - virBufferAddLit(&xml, " \n"); - virBufferAddLit(&xml, " \n"); - } + if (caps->host.nnumaCell) + virCapabilitiesFormatNUMATopology(&xml, caps->host.nnumaCell, + caps->host.numaCell); for (i = 0; i < caps->host.nsecModels; i++) { virBufferAddLit(&xml, " \n");