[libvirt] [PATCH 2/3]cgroup: show error when EINVAL caught
Daniel P. Berrange
berrange at redhat.com
Tue Oct 15 11:23:39 UTC 2013
On Fri, Oct 11, 2013 at 09:41:23PM +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
>
> When EINVAL caught, tell user that what values
> are invalid for what field.
>
> Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
> ---
> src/util/vircgroup.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> index e99caf5..a98bd63 100644
> --- a/src/util/vircgroup.c
> +++ b/src/util/vircgroup.c
> @@ -664,12 +664,21 @@ virCgroupSetValueStr(virCgroupPtr group,
> {
> int ret = -1;
> char *keypath = NULL;
> + char *tmp = NULL;
>
> if (virCgroupPathOfController(group, controller, key, &keypath) < 0)
> return -1;
>
> VIR_DEBUG("Set value '%s' to '%s'", keypath, value);
> if (virFileWriteStr(keypath, value, 0) < 0) {
> + if (errno == EINVAL) {
> + tmp = strrchr(keypath, '/');
> + if (!tmp)
> + goto cleanup;
This would fail to raise an error if '!tmp', so I re-arranged
the code todo
if (errno == EINVAL &&
(tmp = strrchr(keypath, '/'))) {
...
so it falls back to the existing error report
> + virReportSystemError(errno,
> + _("Invalid value '%s' for '%s'"), value, ++tmp);
> + goto cleanup;
> + }
> virReportSystemError(errno,
> _("Unable to write to '%s'"), keypath);
> goto cleanup;
ACK & pushed with the above change
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list