|
|
6ae9ed |
From 6a60677f21bd3ef90603e25d9c609c3f569918c3 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <6a60677f21bd3ef90603e25d9c609c3f569918c3@dist-git>
|
|
|
6ae9ed |
From: John Ferlan <jferlan@redhat.com>
|
|
|
6ae9ed |
Date: Tue, 6 Sep 2016 16:43:14 -0400
|
|
|
6ae9ed |
Subject: [PATCH] qemu: Add support to get/set IOThread period and quota cgroup
|
|
|
6ae9ed |
values
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1356937
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Add support for IOThread quota/bandwidth and period parameters for non
|
|
|
6ae9ed |
session mode. If in session mode, then error out. Uses all the same
|
|
|
6ae9ed |
places where {vcpu|emulator|global}_{period|quota} are adjusted and
|
|
|
6ae9ed |
adds the iothread values.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit e4e4d17c9c2828b3a7d2909295e724c57e60a334)
|
|
|
6ae9ed |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/qemu/qemu_command.c | 3 +-
|
|
|
6ae9ed |
src/qemu/qemu_driver.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
6ae9ed |
src/qemu/qemu_process.c | 4 +-
|
|
|
6ae9ed |
3 files changed, 129 insertions(+), 5 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
6ae9ed |
index e292f48..de121c5 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_command.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_command.c
|
|
|
6ae9ed |
@@ -9306,7 +9306,8 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
if (def->cputune.sharesSpecified || def->cputune.period ||
|
|
|
6ae9ed |
def->cputune.quota || def->cputune.global_period ||
|
|
|
6ae9ed |
def->cputune.global_quota || def->cputune.emulator_period ||
|
|
|
6ae9ed |
- def->cputune.emulator_quota) {
|
|
|
6ae9ed |
+ def->cputune.emulator_quota || def->cputune.iothread_period ||
|
|
|
6ae9ed |
+ def->cputune.iothread_quota) {
|
|
|
6ae9ed |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
6ae9ed |
_("CPU tuning is not available in session mode"));
|
|
|
6ae9ed |
return -1;
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
index 8081417..33bfb67 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
@@ -8705,7 +8705,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom,
|
|
|
6ae9ed |
/* Domain not running, thus no cgroups - return defaults */
|
|
|
6ae9ed |
if (!virDomainObjIsActive(vm)) {
|
|
|
6ae9ed |
if (nparams)
|
|
|
6ae9ed |
- *nparams = 7;
|
|
|
6ae9ed |
+ *nparams = 9;
|
|
|
6ae9ed |
ignore_value(VIR_STRDUP(ret, "posix"));
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
@@ -8718,7 +8718,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (nparams) {
|
|
|
6ae9ed |
if (virCgroupSupportsCpuBW(priv->cgroup))
|
|
|
6ae9ed |
- *nparams = 7;
|
|
|
6ae9ed |
+ *nparams = 9;
|
|
|
6ae9ed |
else
|
|
|
6ae9ed |
*nparams = 1;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
@@ -9939,6 +9939,40 @@ qemuSetEmulatorBandwidthLive(virCgroupPtr cgroup,
|
|
|
6ae9ed |
return -1;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+static int
|
|
|
6ae9ed |
+qemuSetIOThreadsBWLive(virDomainObjPtr vm, virCgroupPtr cgroup,
|
|
|
6ae9ed |
+ unsigned long long period, long long quota)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ size_t i;
|
|
|
6ae9ed |
+ virCgroupPtr cgroup_iothread = NULL;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (period == 0 && quota == 0)
|
|
|
6ae9ed |
+ return 0;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!vm->def->niothreadids)
|
|
|
6ae9ed |
+ return 0;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ for (i = 0; i < vm->def->niothreadids; i++) {
|
|
|
6ae9ed |
+ if (virCgroupNewThread(cgroup, VIR_CGROUP_THREAD_IOTHREAD,
|
|
|
6ae9ed |
+ vm->def->iothreadids[i]->iothread_id,
|
|
|
6ae9ed |
+ false, &cgroup_iothread) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (qemuSetupCgroupVcpuBW(cgroup_iothread, period, quota) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ virCgroupFree(&cgroup_iothread);
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ return 0;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ cleanup:
|
|
|
6ae9ed |
+ virCgroupFree(&cgroup_iothread);
|
|
|
6ae9ed |
+ return -1;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
#define SCHED_RANGE_CHECK(VAR, NAME, MIN, MAX) \
|
|
|
6ae9ed |
if (((VAR) > 0 && (VAR) < (MIN)) || (VAR) > (MAX)) { \
|
|
|
6ae9ed |
virReportError(VIR_ERR_INVALID_ARG, \
|
|
|
6ae9ed |
@@ -9989,6 +10023,10 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
6ae9ed |
VIR_TYPED_PARAM_ULLONG,
|
|
|
6ae9ed |
VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA,
|
|
|
6ae9ed |
VIR_TYPED_PARAM_LLONG,
|
|
|
6ae9ed |
+ VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD,
|
|
|
6ae9ed |
+ VIR_TYPED_PARAM_ULLONG,
|
|
|
6ae9ed |
+ VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA,
|
|
|
6ae9ed |
+ VIR_TYPED_PARAM_LLONG,
|
|
|
6ae9ed |
NULL) < 0)
|
|
|
6ae9ed |
return -1;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
@@ -10181,6 +10219,46 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (persistentDef)
|
|
|
6ae9ed |
persistentDefCopy->cputune.emulator_quota = value_l;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD)) {
|
|
|
6ae9ed |
+ SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD,
|
|
|
6ae9ed |
+ QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (def && value_ul) {
|
|
|
6ae9ed |
+ if ((rc = qemuSetIOThreadsBWLive(vm, priv->cgroup, value_ul, 0)))
|
|
|
6ae9ed |
+ goto endjob;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ def->cputune.iothread_period = value_ul;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (virTypedParamsAddULLong(&eventParams, &eventNparams,
|
|
|
6ae9ed |
+ &eventMaxNparams,
|
|
|
6ae9ed |
+ VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD,
|
|
|
6ae9ed |
+ value_ul) < 0)
|
|
|
6ae9ed |
+ goto endjob;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (persistentDef)
|
|
|
6ae9ed |
+ persistentDefCopy->cputune.iothread_period = params[i].value.ul;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA)) {
|
|
|
6ae9ed |
+ SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA,
|
|
|
6ae9ed |
+ QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (def && value_l) {
|
|
|
6ae9ed |
+ if ((rc = qemuSetIOThreadsBWLive(vm, priv->cgroup, 0, value_l)))
|
|
|
6ae9ed |
+ goto endjob;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ def->cputune.iothread_quota = value_l;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (virTypedParamsAddLLong(&eventParams, &eventNparams,
|
|
|
6ae9ed |
+ &eventMaxNparams,
|
|
|
6ae9ed |
+ VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA,
|
|
|
6ae9ed |
+ value_l) < 0)
|
|
|
6ae9ed |
+ goto endjob;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (persistentDef)
|
|
|
6ae9ed |
+ persistentDefCopy->cputune.iothread_quota = value_l;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
@@ -10304,6 +10382,43 @@ qemuGetEmulatorBandwidthLive(virCgroupPtr cgroup,
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
static int
|
|
|
6ae9ed |
+qemuGetIOThreadsBWLive(virDomainObjPtr vm,
|
|
|
6ae9ed |
+ unsigned long long *period, long long *quota)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ virCgroupPtr cgroup_iothread = NULL;
|
|
|
6ae9ed |
+ qemuDomainObjPrivatePtr priv = NULL;
|
|
|
6ae9ed |
+ int rc;
|
|
|
6ae9ed |
+ int ret = -1;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ priv = vm->privateData;
|
|
|
6ae9ed |
+ if (!vm->def->niothreadids) {
|
|
|
6ae9ed |
+ /* We do not create sub dir for each iothread */
|
|
|
6ae9ed |
+ if ((rc = qemuGetVcpuBWLive(priv->cgroup, period, quota)) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ goto out;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ /* get period and quota for the "first" IOThread */
|
|
|
6ae9ed |
+ if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_IOTHREAD,
|
|
|
6ae9ed |
+ vm->def->iothreadids[0]->iothread_id,
|
|
|
6ae9ed |
+ false, &cgroup_iothread) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ rc = qemuGetVcpuBWLive(cgroup_iothread, period, quota);
|
|
|
6ae9ed |
+ if (rc < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ out:
|
|
|
6ae9ed |
+ ret = 0;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ cleanup:
|
|
|
6ae9ed |
+ virCgroupFree(&cgroup_iothread);
|
|
|
6ae9ed |
+ return ret;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+static int
|
|
|
6ae9ed |
qemuGetGlobalBWLive(virCgroupPtr cgroup, unsigned long long *period,
|
|
|
6ae9ed |
long long *quota)
|
|
|
6ae9ed |
{
|
|
|
6ae9ed |
@@ -10378,6 +10493,11 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
6ae9ed |
qemuGetGlobalBWLive(priv->cgroup, &data.global_period,
|
|
|
6ae9ed |
&data.global_quota) < 0)
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (maxparams > 7 &&
|
|
|
6ae9ed |
+ qemuGetIOThreadsBWLive(vm, &data.iothread_period,
|
|
|
6ae9ed |
+ &data.iothread_quota) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
} else {
|
|
|
6ae9ed |
cpu_bw_status = false;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
@@ -10402,6 +10522,9 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
QEMU_SCHED_ASSIGN(global_period, GLOBAL_PERIOD, ULLONG);
|
|
|
6ae9ed |
QEMU_SCHED_ASSIGN(global_quota, GLOBAL_QUOTA, LLONG);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ QEMU_SCHED_ASSIGN(iothread_period, IOTHREAD_PERIOD, ULLONG);
|
|
|
6ae9ed |
+ QEMU_SCHED_ASSIGN(iothread_quota, IOTHREAD_QUOTA, LLONG);
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
#undef QEMU_SCHED_ASSIGN
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
6ae9ed |
index 2eac422..9583506 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_process.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_process.c
|
|
|
6ae9ed |
@@ -4697,8 +4697,8 @@ qemuProcessSetupIOThread(virDomainObjPtr vm,
|
|
|
6ae9ed |
VIR_CGROUP_THREAD_IOTHREAD,
|
|
|
6ae9ed |
iothread->iothread_id,
|
|
|
6ae9ed |
iothread->cpumask,
|
|
|
6ae9ed |
- vm->def->cputune.period,
|
|
|
6ae9ed |
- vm->def->cputune.quota,
|
|
|
6ae9ed |
+ vm->def->cputune.iothread_period,
|
|
|
6ae9ed |
+ vm->def->cputune.iothread_quota,
|
|
|
6ae9ed |
&iothread->sched);
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.10.0
|
|
|
6ae9ed |
|