render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d759b5
From ba8699bf038f3fe588cc0e40bf484260c08e6f48 Mon Sep 17 00:00:00 2001
d759b5
Message-Id: <ba8699bf038f3fe588cc0e40bf484260c08e6f48@dist-git>
d759b5
From: Pavel Hrdina <phrdina@redhat.com>
d759b5
Date: Mon, 25 Nov 2019 11:02:21 +0100
d759b5
Subject: [PATCH] qemu_process: fix starting VMs if machine group has limited
d759b5
 cpuset.cpus
d759b5
d759b5
Commit <f136b83139c63f20de0df3285d9e82df2fb97bfc> reworked process
d759b5
affinity setting but did not take cgroups into account which introduced
d759b5
an issue when starting VM with custom cpuset.cpus for the whole machine
d759b5
group.
d759b5
d759b5
If the machine group is limited to some pCPUs libvirt should not try to
d759b5
set a VM to run on all pCPUs as it will result in permission denied when
d759b5
writing to cpuset.cpus.
d759b5
d759b5
To fix this the affinity has to be set separately from cgroups cpuset.
d759b5
d759b5
Resolves: <https://bugzilla.redhat.com/show_bug.cgi?id=1746517>
d759b5
d759b5
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
d759b5
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
d759b5
(cherry picked from commit 4c0398b5284d14c55eca51095673b6fadbbd85fb)
d759b5
d759b5
Conflicts:
d759b5
    src/qemu/qemu_process.c - upstream commit that introduced this
d759b5
            issue was modified to not use VIR_AUTOFREE
d759b5
d759b5
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
d759b5
Message-Id: <86eec31e53a4d061e098919d145e6a89cc8740c4.1574676123.git.phrdina@redhat.com>
d759b5
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
d759b5
---
d759b5
 src/qemu/qemu_process.c | 8 ++++++--
d759b5
 1 file changed, 6 insertions(+), 2 deletions(-)
d759b5
d759b5
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
d759b5
index 307098cd63..4a2864af27 100644
d759b5
--- a/src/qemu/qemu_process.c
d759b5
+++ b/src/qemu/qemu_process.c
d759b5
@@ -2476,6 +2476,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
d759b5
     virDomainNumatuneMemMode mem_mode;
d759b5
     virCgroupPtr cgroup = NULL;
d759b5
     virBitmapPtr use_cpumask = NULL;
d759b5
+    virBitmapPtr afinity_cpumask = NULL;
d759b5
     virBitmapPtr hostcpumap = NULL;
d759b5
     char *mem_mask = NULL;
d759b5
     int ret = -1;
d759b5
@@ -2501,7 +2502,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
d759b5
          * its config file */
d759b5
         if (qemuProcessGetAllCpuAffinity(&hostcpumap) < 0)
d759b5
             goto cleanup;
d759b5
-        use_cpumask = hostcpumap;
d759b5
+        afinity_cpumask = hostcpumap;
d759b5
     }
d759b5
 
d759b5
     /*
d759b5
@@ -2542,8 +2543,11 @@ qemuProcessSetupPid(virDomainObjPtr vm,
d759b5
 
d759b5
     }
d759b5
 
d759b5
+    if (!afinity_cpumask)
d759b5
+        afinity_cpumask = use_cpumask;
d759b5
+
d759b5
     /* Setup legacy affinity. */
d759b5
-    if (use_cpumask && virProcessSetAffinity(pid, use_cpumask) < 0)
d759b5
+    if (afinity_cpumask && virProcessSetAffinity(pid, afinity_cpumask) < 0)
d759b5
         goto cleanup;
d759b5
 
d759b5
     /* Set scheduler type and priority. */
d759b5
-- 
d759b5
2.24.0
d759b5