mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
conf: Deduplicate NUMA distance code
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. This change means that distances with value of 0 are no longer printed out into capabilities XML, because domain XML code allows partial distance specification and thus threats value of 0 as unspecified by user (see virDomainNumaGetNodeDistance() which returns the default LOCAL/REMOTE distance for value of 0). Also, from ACPI 6.1 specification, section 5.2.17 System Locality Distance Information Table (SLIT): Distance values of 0-9 are reserved and have no meaning. Thus we shouldn't be ever reporting 0 in neither domain nor capabilities XML. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
773118632e
commit
4b3dc045b9
@ -157,16 +157,9 @@
|
|||||||
|
|
||||||
<optional>
|
<optional>
|
||||||
<element name="distances">
|
<element name="distances">
|
||||||
<zeroOrMore>
|
<oneOrMore>
|
||||||
<element name="sibling">
|
<ref name="numaDistance"/>
|
||||||
<attribute name="id">
|
</oneOrMore>
|
||||||
<ref name="unsignedInt"/>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="value">
|
|
||||||
<ref name="unsignedInt"/>
|
|
||||||
</attribute>
|
|
||||||
</element>
|
|
||||||
</zeroOrMore>
|
|
||||||
</element>
|
</element>
|
||||||
</optional>
|
</optional>
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
|
|||||||
int ncpus,
|
int ncpus,
|
||||||
virCapsHostNUMACellCPU **cpus,
|
virCapsHostNUMACellCPU **cpus,
|
||||||
int ndistances,
|
int ndistances,
|
||||||
virCapsHostNUMACellDistance **distances,
|
virNumaDistance **distances,
|
||||||
int npageinfo,
|
int npageinfo,
|
||||||
virCapsHostNUMACellPageInfo **pageinfo)
|
virCapsHostNUMACellPageInfo **pageinfo)
|
||||||
{
|
{
|
||||||
@ -833,17 +833,7 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf,
|
|||||||
cell->pageinfo[j].avail);
|
cell->pageinfo[j].avail);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell->ndistances) {
|
virNumaDistanceFormat(buf, cell->distances, cell->ndistances);
|
||||||
virBufferAddLit(buf, "<distances>\n");
|
|
||||||
virBufferAdjustIndent(buf, 2);
|
|
||||||
for (j = 0; j < cell->ndistances; j++) {
|
|
||||||
virBufferAsprintf(buf, "<sibling id='%d' value='%d'/>\n",
|
|
||||||
cell->distances[j].node,
|
|
||||||
cell->distances[j].distance);
|
|
||||||
}
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
|
||||||
virBufferAddLit(buf, "</distances>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<cpus num='%d'>\n", cell->ncpus);
|
virBufferAsprintf(buf, "<cpus num='%d'>\n", cell->ncpus);
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
@ -1457,10 +1447,10 @@ virCapabilitiesFillCPUInfo(int cpu_id G_GNUC_UNUSED,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virCapabilitiesGetNUMADistances(int node,
|
virCapabilitiesGetNUMADistances(int node,
|
||||||
virCapsHostNUMACellDistance **distancesRet,
|
virNumaDistance **distancesRet,
|
||||||
int *ndistancesRet)
|
int *ndistancesRet)
|
||||||
{
|
{
|
||||||
virCapsHostNUMACellDistance *tmp = NULL;
|
virNumaDistance *tmp = NULL;
|
||||||
int tmp_size = 0;
|
int tmp_size = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int *distances = NULL;
|
int *distances = NULL;
|
||||||
@ -1476,14 +1466,14 @@ virCapabilitiesGetNUMADistances(int node,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = g_new0(virCapsHostNUMACellDistance, ndistances);
|
tmp = g_new0(virNumaDistance, ndistances);
|
||||||
|
|
||||||
for (i = 0; i < ndistances; i++) {
|
for (i = 0; i < ndistances; i++) {
|
||||||
if (!distances[i])
|
if (!distances[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tmp[tmp_size].node = i;
|
tmp[tmp_size].cellid = i;
|
||||||
tmp[tmp_size].distance = distances[i];
|
tmp[tmp_size].value = distances[i];
|
||||||
tmp_size++;
|
tmp_size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1607,7 +1597,7 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps)
|
|||||||
|
|
||||||
for (n = 0; n <= max_node; n++) {
|
for (n = 0; n <= max_node; n++) {
|
||||||
g_autoptr(virBitmap) cpumap = NULL;
|
g_autoptr(virBitmap) cpumap = NULL;
|
||||||
g_autofree virCapsHostNUMACellDistance *distances = NULL;
|
g_autofree virNumaDistance *distances = NULL;
|
||||||
int ndistances = 0;
|
int ndistances = 0;
|
||||||
g_autofree virCapsHostNUMACellPageInfo *pageinfo = NULL;
|
g_autofree virCapsHostNUMACellPageInfo *pageinfo = NULL;
|
||||||
int npageinfo;
|
int npageinfo;
|
||||||
|
@ -94,11 +94,6 @@ struct _virCapsHostNUMACellCPU {
|
|||||||
virBitmap *siblings;
|
virBitmap *siblings;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _virCapsHostNUMACellDistance {
|
|
||||||
int node; /* foreign NUMA node */
|
|
||||||
unsigned int distance; /* distance to the node */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _virCapsHostNUMACellPageInfo {
|
struct _virCapsHostNUMACellPageInfo {
|
||||||
unsigned int size; /* page size in kibibytes */
|
unsigned int size; /* page size in kibibytes */
|
||||||
unsigned long long avail; /* the size of pool */
|
unsigned long long avail; /* the size of pool */
|
||||||
@ -109,8 +104,8 @@ struct _virCapsHostNUMACell {
|
|||||||
int ncpus;
|
int ncpus;
|
||||||
unsigned long long mem; /* in kibibytes */
|
unsigned long long mem; /* in kibibytes */
|
||||||
virCapsHostNUMACellCPU *cpus;
|
virCapsHostNUMACellCPU *cpus;
|
||||||
int ndistances;
|
size_t ndistances;
|
||||||
virCapsHostNUMACellDistance *distances;
|
virNumaDistance *distances;
|
||||||
int npageinfo;
|
int npageinfo;
|
||||||
virCapsHostNUMACellPageInfo *pageinfo;
|
virCapsHostNUMACellPageInfo *pageinfo;
|
||||||
};
|
};
|
||||||
@ -256,7 +251,7 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
|
|||||||
int ncpus,
|
int ncpus,
|
||||||
virCapsHostNUMACellCPU **cpus,
|
virCapsHostNUMACellCPU **cpus,
|
||||||
int ndistances,
|
int ndistances,
|
||||||
virCapsHostNUMACellDistance **distances,
|
virNumaDistance **distances,
|
||||||
int npageinfo,
|
int npageinfo,
|
||||||
virCapsHostNUMACellPageInfo **pageinfo);
|
virCapsHostNUMACellPageInfo **pageinfo);
|
||||||
|
|
||||||
|
@ -60,8 +60,6 @@ typedef struct _virCapsHostNUMACellCPU virCapsHostNUMACellCPU;
|
|||||||
|
|
||||||
typedef struct _virCapsHostNUMACellPageInfo virCapsHostNUMACellPageInfo;
|
typedef struct _virCapsHostNUMACellPageInfo virCapsHostNUMACellPageInfo;
|
||||||
|
|
||||||
typedef struct _virCapsHostNUMACellDistance virCapsHostNUMACellDistance;
|
|
||||||
|
|
||||||
typedef struct _virCapsHostSecModel virCapsHostSecModel;
|
typedef struct _virCapsHostSecModel virCapsHostSecModel;
|
||||||
|
|
||||||
typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel;
|
typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel;
|
||||||
|
@ -249,7 +249,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps)
|
|||||||
libxl_cputopology *cpu_topo = NULL;
|
libxl_cputopology *cpu_topo = NULL;
|
||||||
int nr_nodes = 0, nr_cpus = 0, nr_distances = 0;
|
int nr_nodes = 0, nr_cpus = 0, nr_distances = 0;
|
||||||
virCapsHostNUMACellCPU **cpus = NULL;
|
virCapsHostNUMACellCPU **cpus = NULL;
|
||||||
virCapsHostNUMACellDistance *distances = NULL;
|
virNumaDistance *distances = NULL;
|
||||||
int *nr_cpus_node = NULL;
|
int *nr_cpus_node = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -320,11 +320,11 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps)
|
|||||||
if (nr_distances) {
|
if (nr_distances) {
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
distances = g_new0(virCapsHostNUMACellDistance, nr_distances);
|
distances = g_new0(virNumaDistance, nr_distances);
|
||||||
|
|
||||||
for (j = 0; j < nr_distances; j++) {
|
for (j = 0; j < nr_distances; j++) {
|
||||||
distances[j].node = j;
|
distances[j].cellid = j;
|
||||||
distances[j].distance = numa_info[i].dists[j];
|
distances[j].value = numa_info[i].dists[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user