mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
qemu: Fix improper logic of qemuCgroupSetup
It throws errors as long as the cgroup controller is not available, regardless of whether we really want to use it to do setup or not, which is not what we want, fixing it with throwing error when need to use the controller. And change "VIR_WARN" to "qemuReportError" for memory controller incidentally.
This commit is contained in:
parent
e206946da7
commit
0ca16a78af
@ -294,8 +294,8 @@ int qemuSetupCgroup(struct qemud_driver *driver,
|
||||
}
|
||||
}
|
||||
|
||||
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) {
|
||||
if (vm->def->blkio.weight != 0) {
|
||||
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) {
|
||||
rc = virCgroupSetBlkioWeight(cgroup, vm->def->blkio.weight);
|
||||
if(rc != 0) {
|
||||
virReportSystemError(-rc,
|
||||
@ -303,12 +303,15 @@ int qemuSetupCgroup(struct qemud_driver *driver,
|
||||
vm->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Block I/O tuning is not available on this host"));
|
||||
}
|
||||
}
|
||||
|
||||
if (vm->def->mem.hard_limit != 0 ||
|
||||
vm->def->mem.soft_limit != 0 ||
|
||||
vm->def->mem.swap_hard_limit != 0) {
|
||||
if ((rc = qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_MEMORY))) {
|
||||
if (vm->def->mem.hard_limit != 0) {
|
||||
rc = virCgroupSetMemoryHardLimit(cgroup, vm->def->mem.hard_limit);
|
||||
@ -339,12 +342,13 @@ int qemuSetupCgroup(struct qemud_driver *driver,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
VIR_WARN("Memory cgroup is disabled in qemu configuration file: %s",
|
||||
vm->def->name);
|
||||
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Memory cgroup is not available on this host"));
|
||||
}
|
||||
}
|
||||
|
||||
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
|
||||
if (vm->def->cputune.shares != 0) {
|
||||
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
|
||||
rc = virCgroupSetCpuShares(cgroup, vm->def->cputune.shares);
|
||||
if(rc != 0) {
|
||||
virReportSystemError(-rc,
|
||||
@ -352,11 +356,11 @@ int qemuSetupCgroup(struct qemud_driver *driver,
|
||||
vm->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("CPU tuning is not available on this host"));
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
virCgroupFree(&cgroup);
|
||||
|
Loading…
Reference in New Issue
Block a user