[libvirt] [PATCH 0/2] qemu: Fix for emulatorsched

Partially-related-to: https://bugzilla.redhat.com/show_bug.cgi?id=1712781 Martin Kletzander (2): qemu: Set emulator thread scheduler only after QEMU starts docs: Add emulatorsched fix info to news.xml docs/news.xml | 12 ++++++++++++ src/qemu/qemu_process.c | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) -- 2.21.0

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@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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- docs/news.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 2ecb835e45f0..9922cd4de0e2 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -45,6 +45,18 @@ <section title="Improvements"> </section> <section title="Bug fixes"> + <change> + <summary> + qemu: Fix emulator scheduler support + </summary> + <description> + Setting the scheduler for QEMU's main thread before QEMU had a chance + to start up other threads was misleading as it would affect other + threads (vCPU and I/O) as well. In some particular situations this + could also lead to an error when the thread for vCPU #0 was being + moved to its cpu,cpuacct cgroup. This was fixed so that the scheduler for the main thread is set after QEMU starts. + </description> + </change> </section> </release> <release version="v5.3.0" date="2019-05-04"> -- 2.21.0

On 5/22/19 12:27 PM, Martin Kletzander wrote:
Partially-related-to: https://bugzilla.redhat.com/show_bug.cgi?id=1712781
Martin Kletzander (2): qemu: Set emulator thread scheduler only after QEMU starts docs: Add emulatorsched fix info to news.xml
docs/news.xml | 12 ++++++++++++ src/qemu/qemu_process.c | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
ACK Michal
participants (2)
-
Martin Kletzander
-
Michal Privoznik