mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
qemu: Reject unsupported tuning in session mode
When domain is started with setting that cannot be done, i.e. those that require cgroups, there is no error reported and it succeeds without any message whatsoever. When setting with API, virsh, an error is reported, but only due to the fact that no cgroups are mounted (priv->cgroup == NULL). Given the above it seems reasonable to reject such unsupported settings. This patch effectively changes the error message from: $ virsh -c qemu:///session schedinfo dummy Scheduler : Unknown error: Requested operation is not valid: cgroup CPU controller is not mounted to: $ virsh -c qemu:///session schedinfo dummy Scheduler : Unknown error: Operation not supported: CPU tuning is not available in session mode Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1023366 Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
e5cd28c023
commit
45ad1adb4a
@ -7762,6 +7762,32 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
|
|
||||||
emulator = def->emulator;
|
emulator = def->emulator;
|
||||||
|
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
/* If we have no cgroups than we can have no tunings that
|
||||||
|
* require them */
|
||||||
|
|
||||||
|
if (def->mem.hard_limit || def->mem.soft_limit ||
|
||||||
|
def->mem.min_guarantee || def->mem.swap_hard_limit) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Memory tuning is not available in session mode"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (def->blkio.weight || def->blkio.ndevices) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Block I/O tuning is not available in session mode"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (def->cputune.shares || def->cputune.period ||
|
||||||
|
def->cputune.quota || def->cputune.emulator_period ||
|
||||||
|
def->cputune.emulator_quota) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("CPU tuning is not available in session mode"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->ngraphics; ++i) {
|
for (i = 0; i < def->ngraphics; ++i) {
|
||||||
switch (def->graphics[i]->type) {
|
switch (def->graphics[i]->type) {
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||||
|
@ -7432,6 +7432,8 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom,
|
|||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
|
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||||
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
|
||||||
if (!(vm = qemuDomObjFromDomain(dom)))
|
if (!(vm = qemuDomObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -7441,6 +7443,13 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom,
|
|||||||
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
|
_("CPU tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Domain not running, thus no cgroups - return defaults */
|
/* Domain not running, thus no cgroups - return defaults */
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
if (nparams)
|
if (nparams)
|
||||||
@ -7467,6 +7476,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7681,6 +7691,12 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Block I/O tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -7861,6 +7877,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG |
|
VIR_DOMAIN_AFFECT_CONFIG |
|
||||||
@ -7879,6 +7896,13 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
|
|||||||
if (virDomainGetBlkioParametersEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetBlkioParametersEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Block I/O tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -8267,6 +8291,7 @@ cleanup:
|
|||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8314,6 +8339,12 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
|
|||||||
if (virDomainSetMemoryParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetMemoryParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
|
_("Memory tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -8421,6 +8452,7 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG |
|
VIR_DOMAIN_AFFECT_CONFIG |
|
||||||
@ -8437,6 +8469,13 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
|
_("Memory tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -8548,6 +8587,7 @@ cleanup:
|
|||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8973,6 +9013,13 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("CPU tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -9208,6 +9255,7 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
virDomainDefPtr persistentDef;
|
virDomainDefPtr persistentDef;
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG |
|
VIR_DOMAIN_AFFECT_CONFIG |
|
||||||
@ -9224,6 +9272,13 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("CPU tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (*nparams > 1)
|
if (*nparams > 1)
|
||||||
cpu_bw_status = virCgroupSupportsCpuBW(priv->cgroup);
|
cpu_bw_status = virCgroupSupportsCpuBW(priv->cgroup);
|
||||||
|
|
||||||
@ -9318,6 +9373,7 @@ cleanup:
|
|||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15523,11 +15579,17 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
|
|||||||
if (virDomainSetBlockIoTuneEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetBlockIoTuneEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Block I/O tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -15670,6 +15732,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
VIR_DOMAIN_AFFECT_CONFIG |
|
VIR_DOMAIN_AFFECT_CONFIG |
|
||||||
@ -15684,6 +15747,13 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
|
|||||||
if (virDomainGetBlockIoTuneEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetBlockIoTuneEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
if (!cfg->privileged) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Block I/O tuning is not available in session mode"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -15786,6 +15856,7 @@ cleanup:
|
|||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user