mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00: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:
parent
b6cfd348e9
commit
213b6822a8
@ -45,7 +45,7 @@ int virNumaGetNodeMemory(int node,
|
|||||||
|
|
||||||
unsigned int virNumaGetMaxCPUs(void) G_NO_INLINE;
|
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 virNumaGetNodeCPUs(int node, virBitmap **cpus) G_NO_INLINE;
|
||||||
int virNumaCPUSetToNodeset(virBitmap *cpuset,
|
int virNumaCPUSetToNodeset(virBitmap *cpuset,
|
||||||
virBitmap **nodeset);
|
virBitmap **nodeset);
|
||||||
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu0/node0
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu0/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu1/node0
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu1/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu10/node2
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu10/node2
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node2
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu11/node2
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu11/node2
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node2
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu12/node3
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu12/node3
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node3
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu13/node3
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu13/node3
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node3
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu14/node3
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu14/node3
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node3
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu15/node3
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu15/node3
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node3
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu2/node0
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu2/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu3/node0
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu3/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu4/node1
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu4/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu5/node1
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu5/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu6/node1
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu6/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu7/node1
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu7/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu8/node2
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu8/node2
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node2
|
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu9/node2
Symbolic link
1
tests/vircaps2xmldata/linux-basic/system/cpu/cpu9/node2
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node2
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu0/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu0/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu1/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu1/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu2/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu2/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu3/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu3/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu4/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu4/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu5/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu5/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu6/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu6/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu7/node0
Symbolic link
1
tests/vircaps2xmldata/linux-caches/system/cpu/cpu7/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu0/node0
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu0/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu1/node0
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu1/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu10/node1
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu10/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu11/node1
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu11/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu2/node0
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu2/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu3/node0
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu3/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu4/node0
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu4/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu5/node0
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu5/node0
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node0
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu6/node1
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu6/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu7/node1
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu7/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu8/node1
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu8/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu9/node1
Symbolic link
1
tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu9/node1
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../node/node1
|
@ -21,6 +21,7 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "virnuma.h"
|
#include "virnuma.h"
|
||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
|
#include "virstring.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
@ -171,3 +172,44 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus)
|
|||||||
|
|
||||||
return virBitmapCountBits(*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;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user