numa_nodes_ptr is a global variable in libnuma.so. It is been freed
after main thread exits. If we have many running vms, restart the
libvirtd service continuously at intervals of a few seconds, the main
thread may exit before qemuProcessReconnect thread, and a segfault
error occurs. Backstrace as follows:
0 0x00007f40e3d2dd72 in numa_bitmask_isbitset () from /lib64/libnuma.so.1
1 0x00007f40e4d14c55 in virNumaNodeIsAvailable (node=node@entry=0) at util/virnuma.c:396
2 0x00007f40e4d16010 in virNumaGetHostMemoryNodeset () at util/virnuma.c:1011
3 0x00007f40b94ced90 in qemuRestoreCgroupState (vm=0x7f407c39df00, vm=0x7f407c39df00) at
qemu/qemu_cgroup.c:877
4 qemuConnectCgroup (driver=driver@entry=0x7f407c21fe80, vm=0x7f407c39df00) at
qemu/qemu_cgroup.c:969
5 0x00007f40b94eef93 in qemuProcessReconnect (opaque=<optimized out>) at
qemu/qemu_process.c:3531
6 0x00007f40e4d34bd2 in virThreadHelper (data=<optimized out>) at
util/virthread.c:206
7 0x00007f40e214ee25 in start_thread () from /lib64/libpthread.so.0
8 0x00007f40e1e7c36d in clone () from /lib64/libc.so.6
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
---
src/util/virnuma.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 67e6c86..502b1d5 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -381,7 +381,10 @@ virNumaGetMaxCPUs(void)
bool
virNumaNodeIsAvailable(int node)
{
- return numa_bitmask_isbitset(numa_nodes_ptr, node);
+ if (numa_nodes_ptr)
+ return numa_bitmask_isbitset(numa_nodes_ptr, node);
+ else
+ return false;
}
--
1.8.3.1