On Thu, Sep 03, 2020 at 11:03:52AM +0200, Markus Armbruster wrote:
> Daniel P. Berrangé <berra...@redhat.com> writes:
> 
> > Instead of relying on the limited information from errno, we can now
> > also provide detailed error messages to callers that ask for it.
> >
> > Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>
> > ---
> >  util/osdep.c | 14 ++++++++++++--
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/util/osdep.c b/util/osdep.c
> > index dd34b58bb7..28aa89adc9 100644
> > --- a/util/osdep.c
> > +++ b/util/osdep.c
> > @@ -298,7 +298,7 @@ static int qemu_open_cloexec(const char *name, int 
> > flags, mode_t mode)
> >   * Opens a file with FD_CLOEXEC set
> >   */
> >  static int
> > -qemu_open_internal(const char *name, int flags, mode_t mode)
> > +qemu_open_internal(const char *name, int flags, mode_t mode, Error **errp)
> >  {
> >      int ret;
> >  
> > @@ -312,12 +312,15 @@ qemu_open_internal(const char *name, int flags, 
> > mode_t mode)
> >  
> >          fdset_id = qemu_parse_fdset(fdset_id_str);
> >          if (fdset_id == -1) {
> > +            error_setg(errp, "Could not parse fdset %s", name);
> >              errno = EINVAL;
> >              return -1;
> >          }
> >  
> >          dupfd = monitor_fdset_dup_fd_add(fdset_id, flags);
> >          if (dupfd == -1) {
> > +            error_setg_errno(errp, errno, "Could not dup FD for %s flags 
> > %x",
> > +                             name, flags);
> 
> You kept the reporting of flags here.  Intentional?

I think it is useful because one of the failure reasons for
monitor_fdset_dup_fd_add is mis-matching flags. So if we ever
get a bug report mentioning this error message it'd be useful
to have the flags present.

> > @@ -343,7 +353,7 @@ int qemu_open_old(const char *name, int flags, ...)
> >      }
> >      va_end(ap);
> >  
> > -    ret = qemu_open_internal(name, flags, mode);
> > +    ret = qemu_open_internal(name, flags, mode, NULL);
> >  
> >  #ifdef O_DIRECT
> >      if (ret == -1 && errno == EINVAL && (flags & O_DIRECT)) {
> 
> Reviewed-by: Markus Armbruster <arm...@redhat.com>

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to