When we use iothreadinfo to get iothread information, we will get error like this:
# virsh iothreadinfo rhel7.0 --live error: Unable to get domain IOThreads information error: Unable to encode message payload This is because virProcessGetAffinity() return a bitmap which map_len is too big to send via rpc: (gdb) p *map $7 = {max_bit = 262144, map_len = 4096, map = 0x7f9b6c2c0a20} To fix this issue add a new parameter &maxcpu to virProcessGetAffinity() to let callers specify the maxcpu (also in most machine, no need loop 262144 times to check if cpu is set), if set &maxcpu to zero, virProcessGetAffinity() will use default value (262144 or 1024) to create bitmap. This issue was introduced in commit 825df8c. Signed-off-by: Luyao Huang <lhu...@redhat.com> --- src/qemu/qemu_driver.c | 4 ++-- src/util/virprocess.c | 7 ++++--- src/util/virprocess.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2b530c8..e1ad696 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1459,7 +1459,7 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm, virVcpuInfoPtr info, int maxinfo, unsigned char *cpumap = VIR_GET_CPUMAP(cpumaps, maplen, v); virBitmapPtr map = NULL; - if (!(map = virProcessGetAffinity(priv->vcpupids[v]))) + if (!(map = virProcessGetAffinity(priv->vcpupids[v], hostcpus))) return -1; virBitmapToDataBuf(map, cpumap, maplen); @@ -5619,7 +5619,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, goto endjob; info_ret[i]->iothread_id = iothreads[i]->iothread_id; - if (!(map = virProcessGetAffinity(iothreads[i]->thread_id))) + if (!(map = virProcessGetAffinity(iothreads[i]->thread_id, hostcpus))) goto endjob; if (virBitmapToData(map, &info_ret[i]->cpumap, diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 8fa7a9b..8800623 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -469,7 +469,8 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map) } virBitmapPtr -virProcessGetAffinity(pid_t pid) +virProcessGetAffinity(pid_t pid, + int maxcpu) { size_t i; cpu_set_t *mask; @@ -504,10 +505,10 @@ virProcessGetAffinity(pid_t pid) goto cleanup; } - if (!(ret = virBitmapNew(ncpus))) + if (!(ret = virBitmapNew(maxcpu ? maxcpu : ncpus))) goto cleanup; - for (i = 0; i < ncpus; i++) { + for (i = 0; i < (maxcpu ? maxcpu : ncpus); i++) { # ifdef CPU_ALLOC /* coverity[overrun-local] */ if (CPU_ISSET_S(i, masklen, mask)) diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 1768009..cc903ac 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -58,7 +58,7 @@ int virProcessKillPainfully(pid_t pid, bool force); int virProcessSetAffinity(pid_t pid, virBitmapPtr map); -virBitmapPtr virProcessGetAffinity(pid_t pid); +virBitmapPtr virProcessGetAffinity(pid_t pid, int maxcpu); int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list