From 4d92d58f2c17cff2435394798abfee77139473de Mon Sep 17 00:00:00 2001 From: Alexander Burluka Date: Tue, 16 Feb 2016 16:43:33 +0300 Subject: [PATCH] Add global period definitions This parameter represents top level period cgroup that limits whole domain enforcement period for a quota Signed-off-by: Alexander Burluka --- docs/schemas/domaincommon.rng | 5 +++++ include/libvirt/libvirt-domain.h | 16 ++++++++++++++++ src/conf/domain_conf.c | 18 ++++++++++++++++++ src/conf/domain_conf.h | 1 + 4 files changed, 40 insertions(+) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 4e57394737..e21ce85df0 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -669,6 +669,11 @@ + + + + + diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 65f1618af3..3ec982ceea 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -311,6 +311,14 @@ typedef enum { */ # define VIR_DOMAIN_SCHEDULER_CPU_SHARES "cpu_shares" +/** + * VIR_DOMAIN_SCHEDULER_GLOBAL_PERIOD: + * + * Macro represents the enforcement period for a quota, in microseconds, + * for whole domain, when using the posix scheduler, as a ullong. + */ +# define VIR_DOMAIN_SCHEDULER_GLOBAL_PERIOD "global_period" + /** * VIR_DOMAIN_SCHEDULER_VCPU_PERIOD: * @@ -3338,6 +3346,14 @@ typedef void (*virConnectDomainEventMigrationIterationCallback)(virConnectPtr co */ # define VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES "cputune.cpu_shares" +/** + * VIR_DOMAIN_TUNABLE_CPU_GLOBAL_PERIOD: + * + * Macro represents the enforcement period for a quota, in microseconds, + * for whole domain, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG. + */ +# define VIR_DOMAIN_TUNABLE_CPU_GLOBAL_PERIOD "cputune.global_period" + /** * VIR_DOMAIN_TUNABLE_CPU_VCPU_PERIOD: * diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7d7594e89f..6872b50444 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15140,6 +15140,21 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } + if (virXPathULongLong("string(./cputune/global_period[1])", ctxt, + &def->cputune.global_period) < -1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("can't parse cputune global period value")); + goto error; + } + + if (def->cputune.global_period > 0 && + (def->cputune.global_period < 1000 || def->cputune.global_period > 1000000)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Value of cputune global period must be in range " + "[1000, 1000000]")); + goto error; + } + if (virXPathULongLong("string(./cputune/emulator_period[1])", ctxt, &def->cputune.emulator_period) < -1) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -21655,6 +21670,9 @@ virDomainCputuneDefFormat(virBufferPtr buf, if (def->cputune.quota) virBufferAsprintf(&childrenBuf, "%lld\n", def->cputune.quota); + if (def->cputune.global_period) + virBufferAsprintf(&childrenBuf, "%llu\n", + def->cputune.global_period); if (def->cputune.emulator_period) virBufferAsprintf(&childrenBuf, "%llu" diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7e437fa90f..9af1a7c07f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2112,6 +2112,7 @@ struct _virDomainCputune { bool sharesSpecified; unsigned long long period; long long quota; + unsigned long long global_period; unsigned long long emulator_period; long long emulator_quota; virBitmapPtr emulatorpin; -- 2.39.5