mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
numa_conf: Expose virNumaCache formatter
Expose virNumaCache XML formatter so that it can be re-used by other parts of the code. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
b0b7554229
commit
03ba98b259
@ -82,8 +82,6 @@ VIR_ENUM_IMPL(virDomainMemoryLatency,
|
|||||||
"write"
|
"write"
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef struct _virNumaCache virNumaCache;
|
|
||||||
|
|
||||||
typedef struct _virDomainNumaInterconnect virDomainNumaInterconnect;
|
typedef struct _virDomainNumaInterconnect virDomainNumaInterconnect;
|
||||||
|
|
||||||
typedef struct _virDomainNumaNode virDomainNumaNode;
|
typedef struct _virDomainNumaNode virDomainNumaNode;
|
||||||
@ -107,13 +105,7 @@ struct _virDomainNuma {
|
|||||||
virNumaDistance *distances; /* remote node distances */
|
virNumaDistance *distances; /* remote node distances */
|
||||||
size_t ndistances;
|
size_t ndistances;
|
||||||
|
|
||||||
struct _virNumaCache {
|
virNumaCache *caches;
|
||||||
unsigned int level; /* cache level */
|
|
||||||
unsigned int size; /* cache size */
|
|
||||||
unsigned int line; /* line size, !!! in bytes !!! */
|
|
||||||
virNumaCacheAssociativity associativity; /* cache associativity */
|
|
||||||
virNumaCachePolicy policy; /* cache policy */
|
|
||||||
} *caches;
|
|
||||||
size_t ncaches;
|
size_t ncaches;
|
||||||
} *mem_nodes; /* guest node configuration */
|
} *mem_nodes; /* guest node configuration */
|
||||||
size_t nmem_nodes;
|
size_t nmem_nodes;
|
||||||
@ -1102,7 +1094,6 @@ virDomainNumaDefFormatXML(virBuffer *buf,
|
|||||||
virBitmap *cpumask = virDomainNumaGetNodeCpumask(def, i);
|
virBitmap *cpumask = virDomainNumaGetNodeCpumask(def, i);
|
||||||
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
||||||
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
||||||
size_t j;
|
|
||||||
|
|
||||||
memAccess = virDomainNumaGetNodeMemoryAccessMode(def, i);
|
memAccess = virDomainNumaGetNodeMemoryAccessMode(def, i);
|
||||||
discard = virDomainNumaGetNodeDiscard(def, i);
|
discard = virDomainNumaGetNodeDiscard(def, i);
|
||||||
@ -1131,35 +1122,9 @@ virDomainNumaDefFormatXML(virBuffer *buf,
|
|||||||
def->mem_nodes[i].distances,
|
def->mem_nodes[i].distances,
|
||||||
def->mem_nodes[i].ndistances);
|
def->mem_nodes[i].ndistances);
|
||||||
|
|
||||||
for (j = 0; j < def->mem_nodes[i].ncaches; j++) {
|
virNumaCacheFormat(&childBuf,
|
||||||
virNumaCache *cache = &def->mem_nodes[i].caches[j];
|
def->mem_nodes[i].caches,
|
||||||
|
def->mem_nodes[i].ncaches);
|
||||||
virBufferAsprintf(&childBuf, "<cache level='%u'", cache->level);
|
|
||||||
if (cache->associativity) {
|
|
||||||
virBufferAsprintf(&childBuf, " associativity='%s'",
|
|
||||||
virNumaCacheAssociativityTypeToString(cache->associativity));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cache->policy) {
|
|
||||||
virBufferAsprintf(&childBuf, " policy='%s'",
|
|
||||||
virNumaCachePolicyTypeToString(cache->policy));
|
|
||||||
}
|
|
||||||
virBufferAddLit(&childBuf, ">\n");
|
|
||||||
|
|
||||||
virBufferAdjustIndent(&childBuf, 2);
|
|
||||||
virBufferAsprintf(&childBuf,
|
|
||||||
"<size value='%u' unit='KiB'/>\n",
|
|
||||||
cache->size);
|
|
||||||
|
|
||||||
if (cache->line) {
|
|
||||||
virBufferAsprintf(&childBuf,
|
|
||||||
"<line value='%u' unit='B'/>\n",
|
|
||||||
cache->line);
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdjustIndent(&childBuf, -2);
|
|
||||||
virBufferAddLit(&childBuf, "</cache>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
virXMLFormatElement(buf, "cell", &attrBuf, &childBuf);
|
virXMLFormatElement(buf, "cell", &attrBuf, &childBuf);
|
||||||
}
|
}
|
||||||
@ -1839,3 +1804,41 @@ virNumaDistanceFormat(virBuffer *buf,
|
|||||||
|
|
||||||
virXMLFormatElement(buf, "distances", NULL, &childBuf);
|
virXMLFormatElement(buf, "distances", NULL, &childBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virNumaCacheFormat(virBuffer *buf,
|
||||||
|
const virNumaCache *caches,
|
||||||
|
size_t ncaches)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < ncaches; i++) {
|
||||||
|
const virNumaCache *cache = &caches[i];
|
||||||
|
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
||||||
|
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
||||||
|
|
||||||
|
virBufferAsprintf(&attrBuf, " level='%u'", cache->level);
|
||||||
|
if (cache->associativity) {
|
||||||
|
virBufferAsprintf(&attrBuf, " associativity='%s'",
|
||||||
|
virNumaCacheAssociativityTypeToString(cache->associativity));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cache->policy) {
|
||||||
|
virBufferAsprintf(&attrBuf, " policy='%s'",
|
||||||
|
virNumaCachePolicyTypeToString(cache->policy));
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(&childBuf,
|
||||||
|
"<size value='%u' unit='KiB'/>\n",
|
||||||
|
cache->size);
|
||||||
|
|
||||||
|
if (cache->line) {
|
||||||
|
virBufferAsprintf(&childBuf,
|
||||||
|
"<line value='%u' unit='B'/>\n",
|
||||||
|
cache->line);
|
||||||
|
}
|
||||||
|
|
||||||
|
virXMLFormatElement(buf, "cache", &attrBuf, &childBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -259,3 +259,16 @@ struct _virNumaDistance {
|
|||||||
void virNumaDistanceFormat(virBuffer *buf,
|
void virNumaDistanceFormat(virBuffer *buf,
|
||||||
const virNumaDistance *distances,
|
const virNumaDistance *distances,
|
||||||
size_t ndistances);
|
size_t ndistances);
|
||||||
|
|
||||||
|
typedef struct _virNumaCache virNumaCache;
|
||||||
|
struct _virNumaCache {
|
||||||
|
unsigned int level; /* cache level */
|
||||||
|
unsigned int size; /* cache size */
|
||||||
|
unsigned int line; /* line size, !!! in bytes !!! */
|
||||||
|
virNumaCacheAssociativity associativity; /* cache associativity */
|
||||||
|
virNumaCachePolicy policy; /* cache policy */
|
||||||
|
};
|
||||||
|
|
||||||
|
void virNumaCacheFormat(virBuffer *buf,
|
||||||
|
const virNumaCache *caches,
|
||||||
|
size_t ncaches);
|
||||||
|
@ -911,6 +911,7 @@ virDomainNumatuneSet;
|
|||||||
virDomainNumatuneSpecifiedMaxNode;
|
virDomainNumatuneSpecifiedMaxNode;
|
||||||
virNumaCacheAssociativityTypeFromString;
|
virNumaCacheAssociativityTypeFromString;
|
||||||
virNumaCacheAssociativityTypeToString;
|
virNumaCacheAssociativityTypeToString;
|
||||||
|
virNumaCacheFormat;
|
||||||
virNumaCachePolicyTypeFromString;
|
virNumaCachePolicyTypeFromString;
|
||||||
virNumaCachePolicyTypeToString;
|
virNumaCachePolicyTypeToString;
|
||||||
virNumaDistanceFormat;
|
virNumaDistanceFormat;
|
||||||
|
Loading…
Reference in New Issue
Block a user