render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From ba8699bf038f3fe588cc0e40bf484260c08e6f48 Mon Sep 17 00:00:00 2001
Message-Id: <ba8699bf038f3fe588cc0e40bf484260c08e6f48@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 25 Nov 2019 11:02:21 +0100
Subject: [PATCH] qemu_process: fix starting VMs if machine group has limited
 cpuset.cpus

Commit <f136b83139c63f20de0df3285d9e82df2fb97bfc> reworked process
affinity setting but did not take cgroups into account which introduced
an issue when starting VM with custom cpuset.cpus for the whole machine
group.

If the machine group is limited to some pCPUs libvirt should not try to
set a VM to run on all pCPUs as it will result in permission denied when
writing to cpuset.cpus.

To fix this the affinity has to be set separately from cgroups cpuset.

Resolves: <https://bugzilla.redhat.com/show_bug.cgi?id=1746517>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 4c0398b5284d14c55eca51095673b6fadbbd85fb)

Conflicts:
    src/qemu/qemu_process.c - upstream commit that introduced this
            issue was modified to not use VIR_AUTOFREE

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <86eec31e53a4d061e098919d145e6a89cc8740c4.1574676123.git.phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_process.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 307098cd63..4a2864af27 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2476,6 +2476,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
     virDomainNumatuneMemMode mem_mode;
     virCgroupPtr cgroup = NULL;
     virBitmapPtr use_cpumask = NULL;
+    virBitmapPtr afinity_cpumask = NULL;
     virBitmapPtr hostcpumap = NULL;
     char *mem_mask = NULL;
     int ret = -1;
@@ -2501,7 +2502,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
          * its config file */
         if (qemuProcessGetAllCpuAffinity(&hostcpumap) < 0)
             goto cleanup;
-        use_cpumask = hostcpumap;
+        afinity_cpumask = hostcpumap;
     }
 
     /*
@@ -2542,8 +2543,11 @@ qemuProcessSetupPid(virDomainObjPtr vm,
 
     }
 
+    if (!afinity_cpumask)
+        afinity_cpumask = use_cpumask;
+
     /* Setup legacy affinity. */
-    if (use_cpumask && virProcessSetAffinity(pid, use_cpumask) < 0)
+    if (afinity_cpumask && virProcessSetAffinity(pid, afinity_cpumask) < 0)
         goto cleanup;
 
     /* Set scheduler type and priority. */
-- 
2.24.0