]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Add IOThread quota and period scheduler/cputune defs
authorJohn Ferlan <jferlan@redhat.com>
Mon, 25 Jul 2016 11:04:38 +0000 (07:04 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 3 Aug 2016 10:36:22 +0000 (06:36 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1356937

Add the definitions to allow for viewing/setting cgroup period and quota
limits for IOThreads.

This is similar to the work done for emulator quota and period by
commit ids 'b65dafa' and 'e051c482'.

Being able to view/set the IOThread specific values is related to more
recent changes adding global period (commmit id '4d92d58f') and global
quota (commit id '55ecdae') definitions and qemu support (commit id
'4e17ff79' and 'fbcbd1b2'). With a global setting though, if somehow
the IOThread value in the cgroup hierarchy was set "outside of libvirt"
to a value that is incompatible with the global value.

Allowing control over IOThread specific values provides the capability
to alter the IOThread values as necessary.

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
include/libvirt/libvirt-domain.h
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/qemuxml2argv-cputune.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml
tools/virsh.pod

index c4198360b4de9322c1667ca1d69df5d10457658d..fa88839ec59a102bb3926fe4f799efd5eb8f47cc 100644 (file)
     &lt;quota&gt;-1&lt;/quota&gt;
     &lt;emulator_period&gt;1000000&lt;/emulator_period&gt;
     &lt;emulator_quota&gt;-1&lt;/emulator_quota&gt;
+    &lt;iothread_period&gt;1000000&lt;/iothread_period&gt;
+    &lt;iothread_quota&gt;-1&lt;/iothread_quota&gt;
     &lt;vcpusched vcpus='0-4,^3' scheduler='fifo' priority='1'/&gt;
     &lt;iothreadsched iothreads='2' scheduler='batch'/&gt;
   &lt;/cputune&gt;
         <span class="since">Only QEMU driver support since 0.10.0</span>
       </dd>
 
+      <dt><code>iothread_period</code></dt>
+      <dd>
+        The optional <code>iothread_period</code> element specifies the
+        enforcement interval(unit: microseconds) for IOThreads. Within
+        <code>iothread_period</code>, each IOThread of the domain will
+        not be allowed to consume more than <code>iothread_quota</code>
+        worth of runtime. The value should be in range [1000, 1000000].
+        An iothread_period with value 0 means no value.
+        <span class="since">Only QEMU driver support since 2.1.0</span>
+      </dd>
+      <dt><code>iothread_quota</code></dt>
+      <dd>
+        The optional <code>iothread_quota</code> element specifies the maximum
+        allowed bandwidth(unit: microseconds) for IOThreads. A domain with
+        <code>iothread_quota</code> as any negative value indicates that the
+        domain IOThreads have infinite bandwidth, which means that it is
+        not bandwidth controlled. The value should be in range
+        [1000, 18446744073709551] or less than 0. An <code>iothread_quota</code>
+        with value 0 means no value. You can use this feature to ensure that
+        all IOThreads run at the same speed.
+        <span class="since">Only QEMU driver support since 2.1.0</span>
+      </dd>
+
       <dt><code>vcpusched</code> and <code>iothreadsched</code></dt>
       <dd>
         The optional <code>vcpusched</code> elements specifies the scheduler
index 727014014ecee023ee5f66391ee6a5ffd75a0eac..cb9f1349f3c9326b9adb21b911c3ddf30547980c 100644 (file)
             <ref name="cpuquota"/>
           </element>
         </optional>
+        <optional>
+          <element name="iothread_period">
+            <ref name="cpuperiod"/>
+          </element>
+        </optional>
+        <optional>
+          <element name="iothread_quota">
+            <ref name="cpuquota"/>
+          </element>
+        </optional>
         <zeroOrMore>
           <element name="vcpupin">
             <attribute name="vcpu">
index 7300f3a74992b3907b07e43212f5ea79d2fe8df4..42a2beaa14e212d052a2a16f68168e08ea167b61 100644 (file)
@@ -364,6 +364,22 @@ typedef enum {
  */
 # define VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA "emulator_quota"
 
+/**
+ * VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD:
+ *
+ * Macro represents the enforcement period for a quota, in microseconds,
+ * for IOThreads only, when using the posix scheduler, as a ullong.
+ */
+# define VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD "iothread_period"
+
+/**
+ * VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA:
+ *
+ * Macro represents the maximum bandwidth to be used within a period for
+ * IOThreads only, when using the posix scheduler, as an llong.
+ */
+# define VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA "iothread_quota"
+
 /**
  * VIR_DOMAIN_SCHEDULER_WEIGHT:
  *
@@ -3612,6 +3628,22 @@ typedef void (*virConnectDomainEventJobCompletedCallback)(virConnectPtr conn,
  */
 # define VIR_DOMAIN_TUNABLE_CPU_EMULATOR_QUOTA "cputune.emulator_quota"
 
+/**
+ * VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD:
+ *
+ * Macro represents the enforcement period for a quota, in microseconds, for
+ * iothreads only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD "cputune.iothread_period"
+
+/**
+ * VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA:
+ *
+ * Macro represents the maximum bandwidth to be used within a period for
+ * iothreads only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG.
+ */
+# define VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA "cputune.iothread_quota"
+
 /**
  * VIR_DOMAIN_TUNABLE_BLKDEV_DISK:
  *
index 0d6a1541770f9f6eb1c392c4072176e8128abdfb..e58046be89c516a89847e870c6bd532b48d14e89 100644 (file)
@@ -16131,6 +16131,38 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto error;
     }
 
+    if (virXPathULongLong("string(./cputune/iothread_period[1])", ctxt,
+                          &def->cputune.iothread_period) < -1) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("can't parse cputune iothread period value"));
+        goto error;
+    }
+
+    if (def->cputune.iothread_period > 0 &&
+        (def->cputune.iothread_period < 1000 ||
+         def->cputune.iothread_period > 1000000)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Value of cputune iothread_period must be in range "
+                         "[1000, 1000000]"));
+        goto error;
+    }
+
+    if (virXPathLongLong("string(./cputune/iothread_quota[1])", ctxt,
+                         &def->cputune.iothread_quota) < -1) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("can't parse cputune iothread quota value"));
+        goto error;
+    }
+
+    if (def->cputune.iothread_quota > 0 &&
+        (def->cputune.iothread_quota < 1000 ||
+         def->cputune.iothread_quota > 18446744073709551LL)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Value of cputune iothread_quota must be in range "
+                         "[1000, 18446744073709551]"));
+        goto error;
+    }
+
     if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0)
         goto error;
 
@@ -22812,6 +22844,16 @@ virDomainCputuneDefFormat(virBufferPtr buf,
                           "</emulator_quota>\n",
                           def->cputune.emulator_quota);
 
+    if (def->cputune.iothread_period)
+        virBufferAsprintf(&childrenBuf, "<iothread_period>%llu"
+                          "</iothread_period>\n",
+                          def->cputune.iothread_period);
+
+    if (def->cputune.iothread_quota)
+        virBufferAsprintf(&childrenBuf, "<iothread_quota>%lld"
+                          "</iothread_quota>\n",
+                          def->cputune.iothread_quota);
+
     for (i = 0; i < def->maxvcpus; i++) {
         char *cpumask;
         virDomainVcpuDefPtr vcpu = def->vcpus[i];
index da61ee09aa13fcbd379d98b97cb0d22d6795b2cc..b2e905dd94b739d5bb17a027eee817ec02f69910 100644 (file)
@@ -2033,6 +2033,8 @@ struct _virDomainCputune {
     long long global_quota;
     unsigned long long emulator_period;
     long long emulator_quota;
+    unsigned long long iothread_period;
+    long long iothread_quota;
     virBitmapPtr emulatorpin;
 };
 
index 9595903cd5992f132250ccd7f3107a12fb2057b1..e6ef51dc27bfda993a0d3abb5877929e86e8db03 100644 (file)
@@ -10,6 +10,8 @@
     <quota>-1</quota>
     <global_period>1000000</global_period>
     <global_quota>-1</global_quota>
+    <iothread_period>1000000</iothread_period>
+    <iothread_quota>-1</iothread_quota>
     <vcpupin vcpu='0' cpuset='0'/>
     <vcpupin vcpu='1' cpuset='1'/>
     <emulatorpin cpuset='1'/>
index baf17797b6e5e622fc330695ecdf79078ba9dd01..7a1f50dfcf76f7ec24f4628afd50a9d0f8b232e8 100644 (file)
@@ -10,6 +10,8 @@
     <quota>-1</quota>
     <global_period>1000000</global_period>
     <global_quota>-1</global_quota>
+    <iothread_period>1000000</iothread_period>
+    <iothread_quota>-1</iothread_quota>
     <vcpupin vcpu='0' cpuset='0'/>
     <vcpupin vcpu='1' cpuset='1'/>
     <emulatorpin cpuset='1'/>
index fc6a680b534f18c27eb202b47b3c614b684ec28d..97d16c516548bce14917c9b26921a163d3b80969 100644 (file)
@@ -1937,7 +1937,7 @@ available for each hypervisor are:
 LXC (posix scheduler) : cpu_shares, vcpu_period, vcpu_quota
 
 QEMU/KVM (posix scheduler): cpu_shares, vcpu_period, vcpu_quota,
-emulator_period, emulator_quota
+emulator_period, emulator_quota, iothread_quota, iothread_period
 
 Xen (credit scheduler): weight, cap
 
@@ -1955,9 +1955,10 @@ values 0 and 1 are automatically converted to a minimal value of 2.
 B<Note>: The weight and cap parameters are defined only for the
 XEN_CREDIT scheduler and are now I<DEPRECATED>.
 
-B<Note>: The vcpu_period/emulator_period parameters have a valid value range
-of 1000-1000000 or 0, and the vcpu_quota/emulator_quota parameters have a
-valid value range of 1000-18446744073709551 or less than 0. The value 0 for
+B<Note>: The vcpu_period, emulator_period, and iothread_period parameters
+have a valid value range of 1000-1000000 or 0, and the vcpu_quota,
+emulator_quota, and iothread_quota parameters have a valid value range of
+1000-18446744073709551 or less than 0. The value 0 for
 either parameter is the same as not specifying that parameter.
 
 =item B<screenshot> I<domain> [I<imagefilepath>] [I<--screen> B<screenID>]