<shares>2048</shares>
<period>1000000</period>
<quota>-1</quota>
+ <emulator_period>1000000</period>
+ <emulator_quota>-1</quota>
</cputune>
...
</domain>
<span class="since">Only QEMU driver support since 0.9.4, LXC since
0.9.10</span>
</dd>
+
+ <dt><code>emulator_period</code></dt>
+ <dd>
+ The optional <code>emulator_period</code> element specifies the enforcement
+ interval(unit: microseconds). Within <code>emulator_period</code>, emulator
+ threads(those excluding vcpus) of the domain will not be allowed to consume
+ more than <code>emulator_quota</code> worth of runtime. The value should be
+ in range [1000, 1000000]. A period with value 0 means no value.
+ <span class="since">Only QEMU driver support since 0.10.0</span>
+ </dd>
+ <dt><code>emulator_quota</code></dt>
+ <dd>
+ The optional <code>emulator_quota</code> element specifies the maximum
+ allowed bandwidth(unit: microseconds) for domain's emulator threads(those
+ excluding vcpus). A domain with <code>emulator_quota</code> as any negative
+ value indicates that the domain has infinite bandwidth for emulator threads
+ (those excluding vcpus), which means that it is not bandwidth controlled.
+ The value should be in range [1000, 18446744073709551] or less than 0. A
+ quota with value 0 means no value.
+ <span class="since">Only QEMU driver support since 0.10.0</span>
+ </dd>
+
</dl>
<ref name="cpuquota"/>
</element>
</optional>
+ <optional>
+ <element name="emulator_period">
+ <ref name="cpuperiod"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="emulator_quota">
+ <ref name="cpuquota"/>
+ </element>
+ </optional>
<zeroOrMore>
<element name="vcpupin">
<attribute name="vcpu">
&def->cputune.quota) < 0)
def->cputune.quota = 0;
+ if (virXPathULongLong("string(./cputune/emulator_period[1])", ctxt,
+ &def->cputune.emulator_period) < 0)
+ def->cputune.emulator_period = 0;
+
+ if (virXPathLongLong("string(./cputune/emulator_quota[1])", ctxt,
+ &def->cputune.emulator_quota) < 0)
+ def->cputune.emulator_quota = 0;
+
if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0) {
goto error;
}
if (def->cputune.shares || def->cputune.vcpupin ||
def->cputune.period || def->cputune.quota ||
- def->cputune.emulatorpin)
+ def->cputune.emulatorpin ||
+ def->cputune.emulator_period || def->cputune.emulator_quota)
virBufferAddLit(buf, " <cputune>\n");
if (def->cputune.shares)
if (def->cputune.quota)
virBufferAsprintf(buf, " <quota>%lld</quota>\n",
def->cputune.quota);
+
+ if (def->cputune.emulator_period)
+ virBufferAsprintf(buf, " <emulator_period>%llu"
+ "</emulator_period>\n",
+ def->cputune.emulator_period);
+
+ if (def->cputune.emulator_quota)
+ virBufferAsprintf(buf, " <emulator_quota>%lld"
+ "</emulator_quota>\n",
+ def->cputune.emulator_quota);
+
if (def->cputune.vcpupin) {
for (i = 0; i < def->cputune.nvcpupin; i++) {
virBufferAsprintf(buf, " <vcpupin vcpu='%u' ",
if (def->cputune.shares || def->cputune.vcpupin ||
def->cputune.period || def->cputune.quota ||
- def->cputune.emulatorpin)
+ def->cputune.emulatorpin ||
+ def->cputune.emulator_period || def->cputune.emulator_quota)
virBufferAddLit(buf, " </cputune>\n");
if (def->numatune.memory.nodemask ||
unsigned long shares;
unsigned long long period;
long long quota;
+ unsigned long long emulator_period;
+ long long emulator_quota;
int nvcpupin;
virDomainVcpuPinDefPtr *vcpupin;
virDomainVcpuPinDefPtr emulatorpin;
}
if (priv->nvcpupids == 0 || priv->vcpupids[0] == vm->pid) {
- /* If we does not know VCPU<->PID mapping or all vcpus run in the same
+ /* If we don't know VCPU<->PID mapping or all vcpu runs in the same
* thread, we cannot control each vcpu.
*/
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virCgroupPtr cgroup = NULL;
virCgroupPtr cgroup_emulator = NULL;
virDomainDefPtr def = vm->def;
+ unsigned long long period = vm->def->cputune.emulator_period;
+ long long quota = vm->def->cputune.emulator_quota;
int rc, i;
if (driver->cgroup == NULL)
qemuSetupCgroupEmulatorPin(cgroup_emulator, def->cputune.emulatorpin) < 0)
goto cleanup;
+ if (period || quota) {
+ if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
+ if (qemuSetupCgroupVcpuBW(cgroup_emulator, period, quota) < 0)
+ goto cleanup;
+ }
+ }
+
virCgroupFree(&cgroup_emulator);
virCgroupFree(&cgroup);
return 0;