[libvirt] [PATCH 1/2] qemu: Set emulator thread scheduler only after QEMU starts

Martin Kletzander mkletzan at redhat.com
Wed May 22 10:27:03 UTC 2019


If the scheduler is set before vCPU0 cannot be moved into its cpu,cpuacct
cgroup.  While it is not yet known whether this is a bug or not, it makes sense
for us to do that later as otherwise the scheduler would be inherited by vCPU
and I/O Threads even when they do not have any such setting specified.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/qemu/qemu_process.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 90466771cd87..fa5909e9bed3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2658,8 +2658,9 @@ qemuProcessSetupPid(virDomainObjPtr vm,
     if (use_cpumask && virProcessSetAffinity(pid, use_cpumask) < 0)
         goto cleanup;
 
-    /* Set scheduler type and priority. */
+    /* Set scheduler type and priority, but not for the main thread. */
     if (sched &&
+        nameval != VIR_CGROUP_THREAD_EMULATOR &&
         virProcessSetScheduler(pid, sched->policy, sched->priority) < 0)
         goto cleanup;
 
@@ -6773,6 +6774,13 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuProcessSetupIOThreads(vm) < 0)
         goto cleanup;
 
+    VIR_DEBUG("Setting emulator scheduler");
+    if (vm->def->cputune.emulatorsched &&
+        virProcessSetScheduler(vm->pid,
+                               vm->def->cputune.emulatorsched->policy,
+                               vm->def->cputune.emulatorsched->priority) < 0)
+        goto cleanup;
+
     VIR_DEBUG("Setting any required VM passwords");
     if (qemuProcessInitPasswords(driver, vm, asyncJob) < 0)
         goto cleanup;
-- 
2.21.0




More information about the libvir-list mailing list