render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
e8e641
From 3dedbaa936d82e51442e4363fdafe6ec5d651dbf Mon Sep 17 00:00:00 2001
e8e641
Message-Id: <3dedbaa936d82e51442e4363fdafe6ec5d651dbf@dist-git>
e8e641
From: Michal Privoznik <mprivozn@redhat.com>
e8e641
Date: Tue, 7 Mar 2023 15:44:41 +0100
e8e641
Subject: [PATCH] virnumamock: Introduce virNumaGetNodeOfCPU() mock
e8e641
e8e641
Introduce a mock of virNumaGetNodeOfCPU() because soon we will
e8e641
need virNumaCPUSetToNodeset() to return predictable results.
e8e641
Also, fill in missing symlinks in vircaps2xmldata/.
e8e641
e8e641
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
e8e641
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
e8e641
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
e8e641
(cherry picked from commit 213b6822a8ae508e0dd5e262b28c2c7000140293)
e8e641
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2185039
e8e641
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
e8e641
---
e8e641
 src/util/virnuma.h                            |  2 +-
e8e641
 .../linux-basic/system/cpu/cpu0/node0         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu1/node0         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu10/node2        |  1 +
e8e641
 .../linux-basic/system/cpu/cpu11/node2        |  1 +
e8e641
 .../linux-basic/system/cpu/cpu12/node3        |  1 +
e8e641
 .../linux-basic/system/cpu/cpu13/node3        |  1 +
e8e641
 .../linux-basic/system/cpu/cpu14/node3        |  1 +
e8e641
 .../linux-basic/system/cpu/cpu15/node3        |  1 +
e8e641
 .../linux-basic/system/cpu/cpu2/node0         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu3/node0         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu4/node1         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu5/node1         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu6/node1         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu7/node1         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu8/node2         |  1 +
e8e641
 .../linux-basic/system/cpu/cpu9/node2         |  1 +
e8e641
 .../linux-caches/system/cpu/cpu0/node0        |  1 +
e8e641
 .../linux-caches/system/cpu/cpu1/node0        |  1 +
e8e641
 .../linux-caches/system/cpu/cpu2/node0        |  1 +
e8e641
 .../linux-caches/system/cpu/cpu3/node0        |  1 +
e8e641
 .../linux-caches/system/cpu/cpu4/node0        |  1 +
e8e641
 .../linux-caches/system/cpu/cpu5/node0        |  1 +
e8e641
 .../linux-caches/system/cpu/cpu6/node0        |  1 +
e8e641
 .../linux-caches/system/cpu/cpu7/node0        |  1 +
e8e641
 .../system/cpu/cpu0/node0                     |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu0/node0       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu1/node0       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu10/node1      |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu11/node1      |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu2/node0       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu3/node0       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu4/node0       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu5/node0       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu6/node1       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu7/node1       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu8/node1       |  1 +
e8e641
 .../linux-resctrl/system/cpu/cpu9/node1       |  1 +
e8e641
 tests/virnumamock.c                           | 42 +++++++++++++++++++
e8e641
 39 files changed, 80 insertions(+), 1 deletion(-)
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu0/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu1/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu10/node2
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu11/node2
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu12/node3
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu13/node3
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu14/node3
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu15/node3
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu2/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu3/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu4/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu5/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu6/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu7/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu8/node2
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-basic/system/cpu/cpu9/node2
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu0/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu1/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu2/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu3/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu4/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu5/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu6/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-caches/system/cpu/cpu7/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu0/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu1/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu10/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu11/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu2/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu3/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu4/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu5/node0
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu6/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu7/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu8/node1
e8e641
 create mode 120000 tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu9/node1
e8e641
e8e641
diff --git a/src/util/virnuma.h b/src/util/virnuma.h
e8e641
index 2c30ef4e31..edd701d5c8 100644
e8e641
--- a/src/util/virnuma.h
e8e641
+++ b/src/util/virnuma.h
e8e641
@@ -45,7 +45,7 @@ int virNumaGetNodeMemory(int node,
e8e641
 
e8e641
 unsigned int virNumaGetMaxCPUs(void) G_NO_INLINE;
e8e641
 
e8e641
-int virNumaGetNodeOfCPU(int cpu);
e8e641
+int virNumaGetNodeOfCPU(int cpu) G_NO_INLINE;
e8e641
 int virNumaGetNodeCPUs(int node, virBitmap **cpus) G_NO_INLINE;
e8e641
 int virNumaCPUSetToNodeset(virBitmap *cpuset,
e8e641
                            virBitmap **nodeset);
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu0/node0 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu0/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu0/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu1/node0 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu1/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu1/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu10/node2 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu10/node2
e8e641
new file mode 120000
e8e641
index 0000000000..e04af16eeb
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu10/node2
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node2
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu11/node2 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu11/node2
e8e641
new file mode 120000
e8e641
index 0000000000..e04af16eeb
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu11/node2
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node2
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu12/node3 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu12/node3
e8e641
new file mode 120000
e8e641
index 0000000000..f213d662fe
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu12/node3
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node3
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu13/node3 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu13/node3
e8e641
new file mode 120000
e8e641
index 0000000000..f213d662fe
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu13/node3
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node3
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu14/node3 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu14/node3
e8e641
new file mode 120000
e8e641
index 0000000000..f213d662fe
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu14/node3
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node3
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu15/node3 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu15/node3
e8e641
new file mode 120000
e8e641
index 0000000000..f213d662fe
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu15/node3
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node3
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu2/node0 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu2/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu2/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu3/node0 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu3/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu3/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu4/node1 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu4/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu4/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu5/node1 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu5/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu5/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu6/node1 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu6/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu6/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu7/node1 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu7/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu7/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu8/node2 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu8/node2
e8e641
new file mode 120000
e8e641
index 0000000000..e04af16eeb
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu8/node2
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node2
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-basic/system/cpu/cpu9/node2 b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu9/node2
e8e641
new file mode 120000
e8e641
index 0000000000..e04af16eeb
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-basic/system/cpu/cpu9/node2
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node2
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu0/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu0/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu0/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu1/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu1/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu1/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu2/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu2/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu2/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu3/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu3/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu3/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu4/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu4/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu4/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu5/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu5/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu5/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu6/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu6/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu6/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-caches/system/cpu/cpu7/node0 b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu7/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-caches/system/cpu/cpu7/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/node0 b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl-skx-twocaches/system/cpu/cpu0/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu0/node0 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu0/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu0/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu1/node0 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu1/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu1/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu10/node1 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu10/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu10/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu11/node1 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu11/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu11/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu2/node0 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu2/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu2/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu3/node0 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu3/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu3/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu4/node0 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu4/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu4/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu5/node0 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu5/node0
e8e641
new file mode 120000
e8e641
index 0000000000..222b6af326
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu5/node0
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node0
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu6/node1 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu6/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu6/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu7/node1 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu7/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu7/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu8/node1 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu8/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu8/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu9/node1 b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu9/node1
e8e641
new file mode 120000
e8e641
index 0000000000..1f9c101cd1
e8e641
--- /dev/null
e8e641
+++ b/tests/vircaps2xmldata/linux-resctrl/system/cpu/cpu9/node1
e8e641
@@ -0,0 +1 @@
e8e641
+../../node/node1
e8e641
\ No newline at end of file
e8e641
diff --git a/tests/virnumamock.c b/tests/virnumamock.c
e8e641
index 87c9a58c6f..8d5c862fa2 100644
e8e641
--- a/tests/virnumamock.c
e8e641
+++ b/tests/virnumamock.c
e8e641
@@ -21,6 +21,7 @@
e8e641
 #include "internal.h"
e8e641
 #include "virnuma.h"
e8e641
 #include "virfile.h"
e8e641
+#include "virstring.h"
e8e641
 
e8e641
 #define VIR_FROM_THIS VIR_FROM_NONE
e8e641
 
e8e641
@@ -171,3 +172,44 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus)
e8e641
 
e8e641
     return virBitmapCountBits(*cpus);
e8e641
 }
e8e641
+
e8e641
+int
e8e641
+virNumaGetNodeOfCPU(int cpu)
e8e641
+{
e8e641
+    g_autoptr(DIR) cpuDir = NULL;
e8e641
+    g_autofree char *sysfs_cpu_path = NULL;
e8e641
+    struct dirent *ent = NULL;
e8e641
+    int dirErr = 0;
e8e641
+
e8e641
+    sysfs_cpu_path =  g_strdup_printf("%s/cpu/cpu%d", SYSFS_SYSTEM_PATH, cpu);
e8e641
+
e8e641
+    if (virDirOpen(&cpuDir, sysfs_cpu_path) < 0)
e8e641
+        return -1;
e8e641
+
e8e641
+    while ((dirErr = virDirRead(cpuDir, &ent, sysfs_cpu_path)) > 0) {
e8e641
+        g_autofree char *entPath = NULL;
e8e641
+        const char *number = NULL;
e8e641
+        int node;
e8e641
+
e8e641
+        if (!(number = STRSKIP(ent->d_name, "node")))
e8e641
+            continue;
e8e641
+
e8e641
+        entPath = g_strdup_printf("%s/%s", sysfs_cpu_path, ent->d_name);
e8e641
+
e8e641
+        if (!virFileIsLink(entPath))
e8e641
+            continue;
e8e641
+
e8e641
+        if (virStrToLong_i(number, NULL, 10, &node) < 0) {
e8e641
+            errno = EINVAL;
e8e641
+            return -1;
e8e641
+        }
e8e641
+
e8e641
+        return node;
e8e641
+    }
e8e641
+
e8e641
+    if (dirErr < 0)
e8e641
+        return -1;
e8e641
+
e8e641
+    errno = EINVAL;
e8e641
+    return -1;
e8e641
+}
e8e641
-- 
e8e641
2.40.0