mirror of https://gitee.com/openkylin/libvirt.git
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>
|
||||
<element name="distances">
|
||||
<zeroOrMore>
|
||||
<element name="sibling">
|
||||
<attribute name="id">
|
||||
<ref name="unsignedInt"/>
|
||||
</attribute>
|
||||
<attribute name="value">
|
||||
<ref name="unsignedInt"/>
|
||||
</attribute>
|
||||
</element>
|
||||
</zeroOrMore>
|
||||
<oneOrMore>
|
||||
<ref name="numaDistance"/>
|
||||
</oneOrMore>
|
||||
</element>
|
||||
</optional>
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
|
|||
int ncpus,
|
||||
virCapsHostNUMACellCPU **cpus,
|
||||
int ndistances,
|
||||
virCapsHostNUMACellDistance **distances,
|
||||
virNumaDistance **distances,
|
||||
int npageinfo,
|
||||
virCapsHostNUMACellPageInfo **pageinfo)
|
||||
{
|
||||
|
@ -833,17 +833,7 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf,
|
|||
cell->pageinfo[j].avail);
|
||||
}
|
||||
|
||||
if (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");
|
||||
}
|
||||
virNumaDistanceFormat(buf, cell->distances, cell->ndistances);
|
||||
|
||||
virBufferAsprintf(buf, "<cpus num='%d'>\n", cell->ncpus);
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
|
@ -1457,10 +1447,10 @@ virCapabilitiesFillCPUInfo(int cpu_id G_GNUC_UNUSED,
|
|||
|
||||
static int
|
||||
virCapabilitiesGetNUMADistances(int node,
|
||||
virCapsHostNUMACellDistance **distancesRet,
|
||||
virNumaDistance **distancesRet,
|
||||
int *ndistancesRet)
|
||||
{
|
||||
virCapsHostNUMACellDistance *tmp = NULL;
|
||||
virNumaDistance *tmp = NULL;
|
||||
int tmp_size = 0;
|
||||
int ret = -1;
|
||||
int *distances = NULL;
|
||||
|
@ -1476,14 +1466,14 @@ virCapabilitiesGetNUMADistances(int node,
|
|||
return 0;
|
||||
}
|
||||
|
||||
tmp = g_new0(virCapsHostNUMACellDistance, ndistances);
|
||||
tmp = g_new0(virNumaDistance, ndistances);
|
||||
|
||||
for (i = 0; i < ndistances; i++) {
|
||||
if (!distances[i])
|
||||
continue;
|
||||
|
||||
tmp[tmp_size].node = i;
|
||||
tmp[tmp_size].distance = distances[i];
|
||||
tmp[tmp_size].cellid = i;
|
||||
tmp[tmp_size].value = distances[i];
|
||||
tmp_size++;
|
||||
}
|
||||
|
||||
|
@ -1607,7 +1597,7 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps)
|
|||
|
||||
for (n = 0; n <= max_node; n++) {
|
||||
g_autoptr(virBitmap) cpumap = NULL;
|
||||
g_autofree virCapsHostNUMACellDistance *distances = NULL;
|
||||
g_autofree virNumaDistance *distances = NULL;
|
||||
int ndistances = 0;
|
||||
g_autofree virCapsHostNUMACellPageInfo *pageinfo = NULL;
|
||||
int npageinfo;
|
||||
|
|
|
@ -94,11 +94,6 @@ struct _virCapsHostNUMACellCPU {
|
|||
virBitmap *siblings;
|
||||
};
|
||||
|
||||
struct _virCapsHostNUMACellDistance {
|
||||
int node; /* foreign NUMA node */
|
||||
unsigned int distance; /* distance to the node */
|
||||
};
|
||||
|
||||
struct _virCapsHostNUMACellPageInfo {
|
||||
unsigned int size; /* page size in kibibytes */
|
||||
unsigned long long avail; /* the size of pool */
|
||||
|
@ -109,8 +104,8 @@ struct _virCapsHostNUMACell {
|
|||
int ncpus;
|
||||
unsigned long long mem; /* in kibibytes */
|
||||
virCapsHostNUMACellCPU *cpus;
|
||||
int ndistances;
|
||||
virCapsHostNUMACellDistance *distances;
|
||||
size_t ndistances;
|
||||
virNumaDistance *distances;
|
||||
int npageinfo;
|
||||
virCapsHostNUMACellPageInfo *pageinfo;
|
||||
};
|
||||
|
@ -256,7 +251,7 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
|
|||
int ncpus,
|
||||
virCapsHostNUMACellCPU **cpus,
|
||||
int ndistances,
|
||||
virCapsHostNUMACellDistance **distances,
|
||||
virNumaDistance **distances,
|
||||
int npageinfo,
|
||||
virCapsHostNUMACellPageInfo **pageinfo);
|
||||
|
||||
|
|
|
@ -60,8 +60,6 @@ typedef struct _virCapsHostNUMACellCPU virCapsHostNUMACellCPU;
|
|||
|
||||
typedef struct _virCapsHostNUMACellPageInfo virCapsHostNUMACellPageInfo;
|
||||
|
||||
typedef struct _virCapsHostNUMACellDistance virCapsHostNUMACellDistance;
|
||||
|
||||
typedef struct _virCapsHostSecModel virCapsHostSecModel;
|
||||
|
||||
typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel;
|
||||
|
|
|
@ -249,7 +249,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps)
|
|||
libxl_cputopology *cpu_topo = NULL;
|
||||
int nr_nodes = 0, nr_cpus = 0, nr_distances = 0;
|
||||
virCapsHostNUMACellCPU **cpus = NULL;
|
||||
virCapsHostNUMACellDistance *distances = NULL;
|
||||
virNumaDistance *distances = NULL;
|
||||
int *nr_cpus_node = NULL;
|
||||
size_t i;
|
||||
int ret = -1;
|
||||
|
@ -320,11 +320,11 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps)
|
|||
if (nr_distances) {
|
||||
size_t j;
|
||||
|
||||
distances = g_new0(virCapsHostNUMACellDistance, nr_distances);
|
||||
distances = g_new0(virNumaDistance, nr_distances);
|
||||
|
||||
for (j = 0; j < nr_distances; j++) {
|
||||
distances[j].node = j;
|
||||
distances[j].distance = numa_info[i].dists[j];
|
||||
distances[j].cellid = j;
|
||||
distances[j].value = numa_info[i].dists[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue