mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
numa_conf: Expose virNumaInterconnect formatter
Expose virNumaInterconnect 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
6ad17e290e
commit
0d7e62348e
@ -82,8 +82,6 @@ VIR_ENUM_IMPL(virMemoryLatency,
|
|||||||
"write"
|
"write"
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef struct _virNumaInterconnect virNumaInterconnect;
|
|
||||||
|
|
||||||
typedef struct _virDomainNumaNode virDomainNumaNode;
|
typedef struct _virDomainNumaNode virDomainNumaNode;
|
||||||
|
|
||||||
struct _virDomainNuma {
|
struct _virDomainNuma {
|
||||||
@ -110,16 +108,7 @@ struct _virDomainNuma {
|
|||||||
} *mem_nodes; /* guest node configuration */
|
} *mem_nodes; /* guest node configuration */
|
||||||
size_t nmem_nodes;
|
size_t nmem_nodes;
|
||||||
|
|
||||||
struct _virNumaInterconnect {
|
virNumaInterconnect *interconnects;
|
||||||
virNumaInterconnectType type; /* whether structure describes latency
|
|
||||||
or bandwidth */
|
|
||||||
unsigned int initiator; /* the initiator NUMA node */
|
|
||||||
unsigned int target; /* the target NUMA node */
|
|
||||||
unsigned int cache; /* the target cache on @target; if 0 then the
|
|
||||||
memory on @target */
|
|
||||||
virMemoryLatency accessType; /* what type of access is defined */
|
|
||||||
unsigned long value; /* value itself */
|
|
||||||
} *interconnects;
|
|
||||||
size_t ninterconnects;
|
size_t ninterconnects;
|
||||||
|
|
||||||
/* Future NUMA tuning related stuff should go here. */
|
/* Future NUMA tuning related stuff should go here. */
|
||||||
@ -1129,46 +1118,7 @@ virDomainNumaDefFormatXML(virBuffer *buf,
|
|||||||
virXMLFormatElement(buf, "cell", &attrBuf, &childBuf);
|
virXMLFormatElement(buf, "cell", &attrBuf, &childBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->ninterconnects) {
|
virNumaInterconnectFormat(buf, def->interconnects, def->ninterconnects);
|
||||||
virBufferAddLit(buf, "<interconnects>\n");
|
|
||||||
virBufferAdjustIndent(buf, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < def->ninterconnects; i++) {
|
|
||||||
virNumaInterconnect *l = &def->interconnects[i];
|
|
||||||
|
|
||||||
switch (l->type) {
|
|
||||||
case VIR_NUMA_INTERCONNECT_TYPE_LATENCY:
|
|
||||||
virBufferAddLit(buf, "<latency");
|
|
||||||
break;
|
|
||||||
case VIR_NUMA_INTERCONNECT_TYPE_BANDWIDTH:
|
|
||||||
virBufferAddLit(buf, "<bandwidth");
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAsprintf(buf,
|
|
||||||
" initiator='%u' target='%u'",
|
|
||||||
l->initiator, l->target);
|
|
||||||
|
|
||||||
if (l->cache > 0) {
|
|
||||||
virBufferAsprintf(buf,
|
|
||||||
" cache='%u'",
|
|
||||||
l->cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAsprintf(buf,
|
|
||||||
" type='%s' value='%lu'",
|
|
||||||
virMemoryLatencyTypeToString(l->accessType),
|
|
||||||
l->value);
|
|
||||||
|
|
||||||
if (l->type == VIR_NUMA_INTERCONNECT_TYPE_BANDWIDTH)
|
|
||||||
virBufferAddLit(buf, " unit='KiB'");
|
|
||||||
virBufferAddLit(buf, "/>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (def->ninterconnects) {
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
|
||||||
virBufferAddLit(buf, "</interconnects>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</numa>\n");
|
virBufferAddLit(buf, "</numa>\n");
|
||||||
@ -1842,3 +1792,50 @@ virNumaCacheFormat(virBuffer *buf,
|
|||||||
virXMLFormatElement(buf, "cache", &attrBuf, &childBuf);
|
virXMLFormatElement(buf, "cache", &attrBuf, &childBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virNumaInterconnectFormat(virBuffer *buf,
|
||||||
|
const virNumaInterconnect *interconnects,
|
||||||
|
size_t ninterconnects)
|
||||||
|
{
|
||||||
|
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < ninterconnects; i++) {
|
||||||
|
const virNumaInterconnect *l = &interconnects[i];
|
||||||
|
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
||||||
|
const char *elem = NULL;
|
||||||
|
|
||||||
|
switch (l->type) {
|
||||||
|
case VIR_NUMA_INTERCONNECT_TYPE_LATENCY:
|
||||||
|
elem = "latency";
|
||||||
|
break;
|
||||||
|
case VIR_NUMA_INTERCONNECT_TYPE_BANDWIDTH:
|
||||||
|
elem = "bandwidth";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(&attrBuf,
|
||||||
|
" initiator='%u' target='%u'",
|
||||||
|
l->initiator, l->target);
|
||||||
|
|
||||||
|
if (l->cache > 0) {
|
||||||
|
virBufferAsprintf(&attrBuf,
|
||||||
|
" cache='%u'",
|
||||||
|
l->cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAsprintf(&attrBuf,
|
||||||
|
" type='%s' value='%lu'",
|
||||||
|
virMemoryLatencyTypeToString(l->accessType),
|
||||||
|
l->value);
|
||||||
|
|
||||||
|
if (l->type == VIR_NUMA_INTERCONNECT_TYPE_BANDWIDTH)
|
||||||
|
virBufferAddLit(&attrBuf, " unit='KiB'");
|
||||||
|
|
||||||
|
virXMLFormatElement(&childBuf, elem, &attrBuf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
virXMLFormatElement(buf, "interconnects", NULL, &childBuf);
|
||||||
|
}
|
||||||
|
@ -272,3 +272,19 @@ struct _virNumaCache {
|
|||||||
void virNumaCacheFormat(virBuffer *buf,
|
void virNumaCacheFormat(virBuffer *buf,
|
||||||
const virNumaCache *caches,
|
const virNumaCache *caches,
|
||||||
size_t ncaches);
|
size_t ncaches);
|
||||||
|
|
||||||
|
typedef struct _virNumaInterconnect virNumaInterconnect;
|
||||||
|
struct _virNumaInterconnect {
|
||||||
|
virNumaInterconnectType type; /* whether structure describes latency
|
||||||
|
or bandwidth */
|
||||||
|
unsigned int initiator; /* the initiator NUMA node */
|
||||||
|
unsigned int target; /* the target NUMA node */
|
||||||
|
unsigned int cache; /* the target cache on @target; if 0 then the
|
||||||
|
memory on @target */
|
||||||
|
virMemoryLatency accessType; /* what type of access is defined */
|
||||||
|
unsigned long value; /* value itself */
|
||||||
|
};
|
||||||
|
|
||||||
|
void virNumaInterconnectFormat(virBuffer *buf,
|
||||||
|
const virNumaInterconnect *interconnects,
|
||||||
|
size_t ninterconnects);
|
||||||
|
@ -915,6 +915,7 @@ virNumaCacheFormat;
|
|||||||
virNumaCachePolicyTypeFromString;
|
virNumaCachePolicyTypeFromString;
|
||||||
virNumaCachePolicyTypeToString;
|
virNumaCachePolicyTypeToString;
|
||||||
virNumaDistanceFormat;
|
virNumaDistanceFormat;
|
||||||
|
virNumaInterconnectFormat;
|
||||||
|
|
||||||
|
|
||||||
# conf/nwfilter_conf.h
|
# conf/nwfilter_conf.h
|
||||||
|
Loading…
Reference in New Issue
Block a user