mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
numa_conf: Expose virNumaDistance formatter
Expose virNumaDistance 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: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
ccb8acc966
commit
773118632e
@ -82,8 +82,6 @@ VIR_ENUM_IMPL(virDomainMemoryLatency,
|
|||||||
"write"
|
"write"
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef struct _virNumaDistance virNumaDistance;
|
|
||||||
|
|
||||||
typedef struct _virDomainNumaCache virDomainNumaCache;
|
typedef struct _virDomainNumaCache virDomainNumaCache;
|
||||||
|
|
||||||
typedef struct _virDomainNumaInterconnect virDomainNumaInterconnect;
|
typedef struct _virDomainNumaInterconnect virDomainNumaInterconnect;
|
||||||
@ -106,10 +104,7 @@ struct _virDomainNuma {
|
|||||||
virDomainMemoryAccess memAccess; /* shared memory access configuration */
|
virDomainMemoryAccess memAccess; /* shared memory access configuration */
|
||||||
virTristateBool discard; /* discard-data for memory-backend-file */
|
virTristateBool discard; /* discard-data for memory-backend-file */
|
||||||
|
|
||||||
struct _virNumaDistance {
|
virNumaDistance *distances; /* remote node distances */
|
||||||
unsigned int value; /* locality value for node i->j or j->i */
|
|
||||||
unsigned int cellid;
|
|
||||||
} *distances; /* remote node distances */
|
|
||||||
size_t ndistances;
|
size_t ndistances;
|
||||||
|
|
||||||
struct _virDomainNumaCache {
|
struct _virDomainNumaCache {
|
||||||
@ -1132,22 +1127,9 @@ virDomainNumaDefFormatXML(virBuffer *buf,
|
|||||||
virBufferAsprintf(&attrBuf, " discard='%s'",
|
virBufferAsprintf(&attrBuf, " discard='%s'",
|
||||||
virTristateBoolTypeToString(discard));
|
virTristateBoolTypeToString(discard));
|
||||||
|
|
||||||
if (def->mem_nodes[i].ndistances) {
|
virNumaDistanceFormat(&childBuf,
|
||||||
virNumaDistance *distances = def->mem_nodes[i].distances;
|
def->mem_nodes[i].distances,
|
||||||
|
def->mem_nodes[i].ndistances);
|
||||||
virBufferAddLit(&childBuf, "<distances>\n");
|
|
||||||
virBufferAdjustIndent(&childBuf, 2);
|
|
||||||
for (j = 0; j < def->mem_nodes[i].ndistances; j++) {
|
|
||||||
if (distances[j].value) {
|
|
||||||
virBufferAddLit(&childBuf, "<sibling");
|
|
||||||
virBufferAsprintf(&childBuf, " id='%d'", distances[j].cellid);
|
|
||||||
virBufferAsprintf(&childBuf, " value='%d'", distances[j].value);
|
|
||||||
virBufferAddLit(&childBuf, "/>\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virBufferAdjustIndent(&childBuf, -2);
|
|
||||||
virBufferAddLit(&childBuf, "</distances>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < def->mem_nodes[i].ncaches; j++) {
|
for (j = 0; j < def->mem_nodes[i].ncaches; j++) {
|
||||||
virDomainNumaCache *cache = &def->mem_nodes[i].caches[j];
|
virDomainNumaCache *cache = &def->mem_nodes[i].caches[j];
|
||||||
@ -1836,3 +1818,24 @@ virDomainNumaGetInterconnect(const virDomainNuma *numa,
|
|||||||
*value = l->value;
|
*value = l->value;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virNumaDistanceFormat(virBuffer *buf,
|
||||||
|
const virNumaDistance *distances,
|
||||||
|
size_t ndistances)
|
||||||
|
{
|
||||||
|
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < ndistances; i++) {
|
||||||
|
if (distances[i].value == 0)
|
||||||
|
continue;
|
||||||
|
virBufferAddLit(&childBuf, "<sibling");
|
||||||
|
virBufferAsprintf(&childBuf, " id='%d'", distances[i].cellid);
|
||||||
|
virBufferAsprintf(&childBuf, " value='%d'", distances[i].value);
|
||||||
|
virBufferAddLit(&childBuf, "/>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
virXMLFormatElement(buf, "distances", NULL, &childBuf);
|
||||||
|
}
|
||||||
|
@ -249,3 +249,13 @@ int virDomainNumaGetInterconnect(const virDomainNuma *numa,
|
|||||||
unsigned int *cache,
|
unsigned int *cache,
|
||||||
virDomainMemoryLatency *accessType,
|
virDomainMemoryLatency *accessType,
|
||||||
unsigned long *value);
|
unsigned long *value);
|
||||||
|
|
||||||
|
typedef struct _virNumaDistance virNumaDistance;
|
||||||
|
struct _virNumaDistance {
|
||||||
|
unsigned int value; /* locality value for node i->j or j->i */
|
||||||
|
unsigned int cellid;
|
||||||
|
};
|
||||||
|
|
||||||
|
void virNumaDistanceFormat(virBuffer *buf,
|
||||||
|
const virNumaDistance *distances,
|
||||||
|
size_t ndistances);
|
||||||
|
@ -915,6 +915,7 @@ virDomainNumatunePlacementTypeFromString;
|
|||||||
virDomainNumatunePlacementTypeToString;
|
virDomainNumatunePlacementTypeToString;
|
||||||
virDomainNumatuneSet;
|
virDomainNumatuneSet;
|
||||||
virDomainNumatuneSpecifiedMaxNode;
|
virDomainNumatuneSpecifiedMaxNode;
|
||||||
|
virNumaDistanceFormat;
|
||||||
|
|
||||||
|
|
||||||
# conf/nwfilter_conf.h
|
# conf/nwfilter_conf.h
|
||||||
|
Loading…
Reference in New Issue
Block a user