]> xenbits.xensource.com Git - libvirt.git/commitdiff
virprocess: Debug affinity map in virProcessSetAffinity()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 16 May 2024 11:19:32 +0000 (13:19 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 17 Jun 2024 10:30:39 +0000 (12:30 +0200)
The aim of virProcessSetAffinity() is to set affinity of given
process to given CPUs. While we currently print the PID into
logs, the CPU map is not printed. It may help when debugging
weird scenarios.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virprocess.c

index 5cdf3e3eb9393083bad073f0a93b3be18a79be60..f1e5e4decd68640b2286e57992da899da24c3b31 100644 (file)
@@ -452,8 +452,9 @@ int virProcessSetAffinity(pid_t pid,
 {
     size_t i;
     cpuset_t mask;
+    g_autofree char *mapStr = virBitmapFormat(map);
 
-    VIR_DEBUG("Set process affinity on %lld", (long long)pid);
+    VIR_DEBUG("Set process affinity on %1$lld to %2$s", (long long)pid, mapStr);
 
     CPU_ZERO(&mask);
     for (i = 0; i < virBitmapSize(map); i++) {
@@ -509,8 +510,9 @@ int virProcessSetAffinity(pid_t pid, virBitmap *map, bool quiet)
     size_t masklen;
     cpu_set_t *mask;
     int rv = -1;
+    g_autofree char *mapStr = virBitmapFormat(map);
 
-    VIR_DEBUG("Set process affinity on %lld", (long long)pid);
+    VIR_DEBUG("Set process affinity on %1$lld to %2$s", (long long)pid, mapStr);
 
     /* Not only may the statically allocated cpu_set_t be too small,
      * but there is no way to ask the kernel what size is large enough.