1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

virnumamock: Introduce virNumaGetNodeOfCPU() mock

Introduce a mock of virNumaGetNodeOfCPU() because soon we will
need virNumaCPUSetToNodeset() to return predictable results.
Also, fill in missing symlinks in vircaps2xmldata/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Michal Privoznik 2023-03-07 15:44:41 +01:00
parent b6cfd348e9
commit 213b6822a8
39 changed files with 80 additions and 1 deletions

View File

@ -45,7 +45,7 @@ int virNumaGetNodeMemory(int node,
unsigned int virNumaGetMaxCPUs(void) G_NO_INLINE;
int virNumaGetNodeOfCPU(int cpu);
int virNumaGetNodeOfCPU(int cpu) G_NO_INLINE;
int virNumaGetNodeCPUs(int node, virBitmap **cpus) G_NO_INLINE;
int virNumaCPUSetToNodeset(virBitmap *cpuset,
virBitmap **nodeset);

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node2

View File

@ -0,0 +1 @@
../../node/node2

View File

@ -0,0 +1 @@
../../node/node3

View File

@ -0,0 +1 @@
../../node/node3

View File

@ -0,0 +1 @@
../../node/node3

View File

@ -0,0 +1 @@
../../node/node3

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node2

View File

@ -0,0 +1 @@
../../node/node2

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node0

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -0,0 +1 @@
../../node/node1

View File

@ -21,6 +21,7 @@
#include "internal.h"
#include "virnuma.h"
#include "virfile.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@ -171,3 +172,44 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus)
return virBitmapCountBits(*cpus);
}
int
virNumaGetNodeOfCPU(int cpu)
{
g_autoptr(DIR) cpuDir = NULL;
g_autofree char *sysfs_cpu_path = NULL;
struct dirent *ent = NULL;
int dirErr = 0;
sysfs_cpu_path = g_strdup_printf("%s/cpu/cpu%d", SYSFS_SYSTEM_PATH, cpu);
if (virDirOpen(&cpuDir, sysfs_cpu_path) < 0)
return -1;
while ((dirErr = virDirRead(cpuDir, &ent, sysfs_cpu_path)) > 0) {
g_autofree char *entPath = NULL;
const char *number = NULL;
int node;
if (!(number = STRSKIP(ent->d_name, "node")))
continue;
entPath = g_strdup_printf("%s/%s", sysfs_cpu_path, ent->d_name);
if (!virFileIsLink(entPath))
continue;
if (virStrToLong_i(number, NULL, 10, &node) < 0) {
errno = EINVAL;
return -1;
}
return node;
}
if (dirErr < 0)
return -1;
errno = EINVAL;
return -1;
}