Re: [PATCH 1/2] qemu: Report error on unexpected job stats type

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

 



On Fri, Jun 01, 2018 at 06:04:29PM +0200, Jiri Denemark wrote:
> On Fri, Jun 01, 2018 at 17:55:12 +0200, Jiri Denemark wrote:
> > On Fri, Jun 01, 2018 at 17:31:02 +0200, Peter Krempa wrote:
> > > On Fri, Jun 01, 2018 at 10:46:02 +0200, Jiri Denemark wrote:
> > > > If we ever fail to properly set jobinfo->statsType,
> > > > qemuDomainJobInfoToParams would return -1 without setting an error.
> > > > 
> > > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
> > > > ---
> > > >  src/qemu/qemu_domain.c | 8 +++++---
> > > >  1 file changed, 5 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> > > > index 2c51e4c0d8..360379b26c 100644
> > > > --- a/src/qemu/qemu_domain.c
> > > > +++ b/src/qemu/qemu_domain.c
> > > > @@ -717,10 +717,12 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
> > > >          return qemuDomainDumpJobInfoToParams(jobInfo, type, params, nparams);
> > > >  
> > > >      case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
> > > > -        break;
> > > > +    default:
> > > > +        virReportError(VIR_ERR_INTERNAL_ERROR,
> > > > +                       _("unexpected type of job stats: %d"),
> > > > +                       jobInfo->statsType);
> > > 
> > > virReportEnumRangeError?
> > 
> > Right, in that case, I need to split default and NONE branch, and report
> > different errors for each of them.
> 
> Well, I was wrong. Calling virReportEnumRangeError for both cases is OK.

Actally it was really only intended for the case where the enum value
is out of range. ie does not correspond to a known enum contant.

If it is a valid enum value, which is just not applicable in this usage
scenario, something else should be used, which reports the string version
of the error instead of a integer value.

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 :|

--
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]

  Powered by Linux