Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1178986
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_driver.c | 5 +++++
src/qemu/qemu_process.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_process.h | 5 ++++-
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cf351e6..087a69d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4617,6 +4617,11 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
}
virCgroupFree(&cgroup_vcpu);
+
+ if (qemuProcessSetSchedParams(i, cpupids[i],
+ vm->def->cputune.nvcpusched,
+ vm->def->cputune.vcpusched) < 0)
+ goto cleanup;
}
} else {
for (i = oldvcpus - 1; i >= nvcpus; i--) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d5df60d..4773120 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1,7 +1,7 @@
/*
* qemu_process.c: QEMU process management
*
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -2574,6 +2574,57 @@ qemuProcessSetIOThreadsAffinity(virDomainObjPtr vm)
return ret;
}
+/* Set Scheduler parameters for vCPU or I/O threads. */
+int
+qemuProcessSetSchedParams(int id,
+ pid_t pid,
+ size_t nsp,
+ virDomainThreadSchedParamPtr sp)
+{
+ bool val = false;
+ size_t i = 0;
+ virDomainThreadSchedParamPtr s = NULL;
+
+ for (i = 0; i < nsp; i++) {
+ if (virBitmapGetBit(sp[i].ids, id, &val) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot get bit from bitmap"));
+ }
+ if (val) {
+ s = &sp[i];
+ break;
+ }
+ }
+
+ if (!s)
+ return 0;
+
+ return virProcessSetScheduler(pid, s->scheduler, s->priority);
+}
+
+static int
+qemuProcessSetSchedulers(virDomainObjPtr vm)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ size_t i = 0;
+
+ for (i = 0; i < priv->nvcpupids; i++) {
+ if (qemuProcessSetSchedParams(i, priv->vcpupids[i],
+ vm->def->cputune.nvcpusched,
+ vm->def->cputune.vcpusched) < 0)
+ return -1;
+ }
+
+ for (i = 0; i < priv->niothreadpids; i++) {
+ if (qemuProcessSetSchedParams(i + 1, priv->iothreadpids[i],
+ vm->def->cputune.niothreadsched,
+ vm->def->cputune.iothreadsched) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
static int
qemuProcessInitPasswords(virConnectPtr conn,
virQEMUDriverPtr driver,
@@ -4869,6 +4920,10 @@ int qemuProcessStart(virConnectPtr conn,
if (qemuProcessSetIOThreadsAffinity(vm) < 0)
goto cleanup;
+ VIR_DEBUG("Setting scheduler parameters");
+ if (qemuProcessSetSchedulers(vm) < 0)
+ goto cleanup;
+
VIR_DEBUG("Setting any required VM passwords");
if (qemuProcessInitPasswords(conn, driver, vm, asyncJob) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 5948ea4..2e1d393 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -1,7 +1,7 @@
/*
* qemu_process.h: QEMU process management
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2012, 2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -104,4 +104,7 @@ virBitmapPtr qemuPrepareCpumap(virQEMUDriverPtr driver,
int qemuProcessReadLog(int fd, char *buf, int buflen, int off, bool skipchar);
+int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp,
+ virDomainThreadSchedParamPtr sp);
+
#endif /* __QEMU_PROCESS_H__ */
--
2.3.0