[libvirt] [PATCH v4 1/7] Add global period definitions

Alexander Burluka aburluka at virtuozzo.com
Thu Jan 14 15:40:12 UTC 2016


This parameter represents top level period cgroup
that limits whole domain enforcement period for a quota

Signed-off-by: Alexander Burluka <aburluka at virtuozzo.com>
---
 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 5deb17b..aa7eae9 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -670,6 +670,11 @@
           </element>
         </optional>
         <optional>
+          <element name="global_period">
+            <ref name="cpuperiod"/>
+          </element>
+        </optional>
+        <optional>
           <element name="period">
             <ref name="cpuperiod"/>
           </element>
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index d26faa5..cb30313 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -312,6 +312,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:
  *
  * Macro represents the enforcement period for a quota, in microseconds,
@@ -3318,6 +3326,14 @@ typedef void (*virConnectDomainEventDeviceAddedCallback)(virConnectPtr conn,
 # 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:
  *
  * Macro represents the enforcement period for a quota, in microseconds,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a9706b0..5ee53c2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15059,6 +15059,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",
@@ -21818,6 +21833,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     if (def->cputune.quota)
         virBufferAsprintf(&childrenBuf, "<quota>%lld</quota>\n",
                           def->cputune.quota);
+    if (def->cputune.global_period)
+        virBufferAsprintf(&childrenBuf, "<global_period>%llu</global_period>\n",
+                          def->cputune.global_period);
 
     if (def->cputune.emulator_period)
         virBufferAsprintf(&childrenBuf, "<emulator_period>%llu"
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0141009..7c43e7d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2135,6 +2135,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;
     size_t nvcpupin;
-- 
1.8.3.1




More information about the libvir-list mailing list