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.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/capabilities.c | 26 ++++++++------------------
src/conf/capabilities.h | 11 +++--------
src/conf/virconftypes.h | 2 --
src/libxl/libxl_capabilities.c | 8 ++++----
4 files changed, 15 insertions(+), 32 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 926ecb5a24..1290c9c15d 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -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;
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index f11471ef6c..4d4ac476ea 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -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);
diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h
index d21d5a1be3..b21068486e 100644
--- a/src/conf/virconftypes.h
+++ b/src/conf/virconftypes.h
@@ -60,8 +60,6 @@ typedef struct _virCapsHostNUMACellCPU virCapsHostNUMACellCPU;
typedef struct _virCapsHostNUMACellPageInfo virCapsHostNUMACellPageInfo;
-typedef struct _virCapsHostNUMACellDistance virCapsHostNUMACellDistance;
-
typedef struct _virCapsHostSecModel virCapsHostSecModel;
typedef struct _virCapsHostSecModelLabel virCapsHostSecModelLabel;
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index d1a1241279..a73f13f829 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -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];
}
}
--
2.26.3