}
/* Extract cpu tunables. */
- if (virXPathULong("string(./cputune/shares[1])", ctxt,
- &def->cputune.shares) < -1) {
+ if ((n = virXPathULong("string(./cputune/shares[1])", ctxt,
+ &def->cputune.shares)) < -1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("can't parse cputune shares value"));
goto error;
+ } else if (n == 0) {
+ def->cputune.sharesSpecified = true;
}
if (virXPathULongLong("string(./cputune/period[1])", ctxt,
virBufferAsprintf(buf, " current='%u'", def->vcpus);
virBufferAsprintf(buf, ">%u</vcpu>\n", def->maxvcpus);
- if (def->cputune.shares ||
+ if (def->cputune.sharesSpecified ||
(def->cputune.nvcpupin && !virDomainIsAllVcpupinInherited(def)) ||
def->cputune.period || def->cputune.quota ||
def->cputune.emulatorpin ||
virBufferAddLit(buf, "<cputune>\n");
virBufferAdjustIndent(buf, 2);
- if (def->cputune.shares)
+ if (def->cputune.sharesSpecified)
virBufferAsprintf(buf, "<shares>%lu</shares>\n",
def->cputune.shares);
if (def->cputune.period)
VIR_FREE(cpumask);
}
virBufferAdjustIndent(buf, -2);
- if (def->cputune.shares ||
+ if (def->cputune.sharesSpecified ||
(def->cputune.nvcpupin && !virDomainIsAllVcpupinInherited(def)) ||
def->cputune.period || def->cputune.quota ||
def->cputune.emulatorpin ||
struct {
unsigned long shares;
+ bool sharesSpecified;
unsigned long long period;
long long quota;
unsigned long long emulator_period;
virCgroupPtr cgroup)
{
int ret = -1;
- if (def->cputune.shares != 0 &&
+ if (def->cputune.sharesSpecified &&
virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0)
goto cleanup;
goto cleanup;
vm->def->cputune.shares = params[i].value.ul;
+ vm->def->cputune.sharesSpecified = true;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vmdef->cputune.shares = params[i].value.ul;
+ vmdef->cputune.sharesSpecified = true;
}
} else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
virConfValuePtr value;
if ((value = virConfGetValue(properties, "lxc.cgroup.cpu.shares")) &&
- value->str && virStrToLong_ul(value->str, NULL, 10,
- &def->cputune.shares) < 0)
- goto error;
+ value->str) {
+ if (virStrToLong_ul(value->str, NULL, 10, &def->cputune.shares) < 0)
+ goto error;
+ def->cputune.sharesSpecified = true;
+ }
if ((value = virConfGetValue(properties,
"lxc.cgroup.cpu.cfs_quota_us")) &&
}
if (old->cputune.shares != new->cputune.shares ||
+ old->cputune.sharesSpecified != new->cputune.sharesSpecified ||
old->cputune.period != new->cputune.period ||
old->cputune.quota != new->cputune.quota ||
old->cputune.nvcpupin != new->cputune.nvcpupin) {
qemuDomainObjPrivatePtr priv = vm->privateData;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
- if (vm->def->cputune.shares) {
+ if (vm->def->cputune.sharesSpecified) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("CPU tuning is not available on this host"));
return -1;
}
}
- if (vm->def->cputune.shares &&
+ if (vm->def->cputune.sharesSpecified &&
virCgroupSetCpuShares(priv->cgroup, vm->def->cputune.shares) < 0)
return -1;
goto error;
}
- if (def->cputune.shares || def->cputune.period ||
+ if (def->cputune.sharesSpecified || def->cputune.period ||
def->cputune.quota || def->cputune.emulator_period ||
def->cputune.emulator_quota) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
if (virCgroupSetCpuShares(priv->cgroup, value_ul) < 0)
goto cleanup;
vm->def->cputune.shares = value_ul;
+ vm->def->cputune.sharesSpecified = true;
}
- if (flags & VIR_DOMAIN_AFFECT_CONFIG)
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vmdef->cputune.shares = value_ul;
+ vmdef->cputune.sharesSpecified = true;
+ }
+
} else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD,
"found '%s'"), sched_cpu_shares);
goto cleanup;
}
+ def->cputune.sharesSpecified = true;
}
/* def:lifecycle */
}
/* def:cputune.shares -> vmx:sched.cpu.shares */
- if (def->cputune.shares > 0) {
+ if (def->cputune.sharesSpecified) {
/* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */
if (def->cputune.shares == def->vcpus * 500) {
virBufferAddLit(&buffer, "sched.cpu.shares = \"low\"\n");
--- /dev/null
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 -S -M pc -m 214 -smp 2 -nographic \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>2</vcpu>
+ <cputune>
+ <shares>0</shares>
+ <period>1000000</period>
+ <quota>-1</quota>
+ <vcpupin vcpu='0' cpuset='0'/>
+ <vcpupin vcpu='1' cpuset='1'/>
+ <emulatorpin cpuset='1'/>
+ </cputune>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
DO_TEST("blkiotune", QEMU_CAPS_NAME);
DO_TEST("blkiotune-device", QEMU_CAPS_NAME);
DO_TEST("cputune", QEMU_CAPS_NAME);
+ DO_TEST("cputune-zero-shares", QEMU_CAPS_NAME);
DO_TEST("numatune-memory", NONE);
DO_TEST("numatune-auto-nodeset-invalid", NONE);
DO_TEST("numad", NONE);
DO_TEST("blkiotune");
DO_TEST("blkiotune-device");
DO_TEST("cputune");
+ DO_TEST("cputune-zero-shares");
DO_TEST("smp");
DO_TEST("lease");