mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-21 05:29:18 +00:00
cgroup: show error when EINVAL is returned
When EINVAL is returned while changing a cgroups value, tell user that what values are invalid for the field. Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
parent
b8b22d1969
commit
501476fccf
@ -664,12 +664,20 @@ virCgroupSetValueStr(virCgroupPtr group,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *keypath = NULL;
|
char *keypath = NULL;
|
||||||
|
char *tmp = NULL;
|
||||||
|
|
||||||
if (virCgroupPathOfController(group, controller, key, &keypath) < 0)
|
if (virCgroupPathOfController(group, controller, key, &keypath) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VIR_DEBUG("Set value '%s' to '%s'", keypath, value);
|
VIR_DEBUG("Set value '%s' to '%s'", keypath, value);
|
||||||
if (virFileWriteStr(keypath, value, 0) < 0) {
|
if (virFileWriteStr(keypath, value, 0) < 0) {
|
||||||
|
if (errno == EINVAL &&
|
||||||
|
(tmp = strrchr(keypath, '/'))) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("Invalid value '%s' for '%s'"),
|
||||||
|
value, tmp + 1);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to write to '%s'"), keypath);
|
_("Unable to write to '%s'"), keypath);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1829,7 +1837,8 @@ virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight)
|
|||||||
*
|
*
|
||||||
* @group: The cgroup to change io device weight device for
|
* @group: The cgroup to change io device weight device for
|
||||||
* @path: The device with a weight to alter
|
* @path: The device with a weight to alter
|
||||||
* @weight: The new device weight (100-1000), or 0 to clear
|
* @weight: The new device weight (100-1000),
|
||||||
|
* (10-1000) after kernel 2.6.39, or 0 to clear
|
||||||
*
|
*
|
||||||
* device_weight is treated as a write-only parameter, so
|
* device_weight is treated as a write-only parameter, so
|
||||||
* there isn't a getter counterpart.
|
* there isn't a getter counterpart.
|
||||||
|
Loading…
Reference in New Issue
Block a user