Re: [PATCH 2/3]cgroup: show error when EINVAL caught

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 11, 2013 at 09:41:23PM +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
> 
> When EINVAL caught, tell user that what values
> are invalid for what field.
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
> ---
>  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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]