[libvirt] [PATCH] storage: silently ignore missing files on pool refresh

Daniel P. Berrange berrange at redhat.com
Wed Jul 10 16:07:16 UTC 2013


On Wed, Jul 10, 2013 at 05:00:59PM +0200, Michal Privoznik wrote:
> On 10.07.2013 16:57, Ján Tomko wrote:
> > From: Wei Zhou <w.zhou at leaseweb.com>
> > 
> > Make virStorageBackendVolOpenCheckMode return -2 instead of
> > -1 if volume file is missing.
> > 
> > https://bugzilla.redhat.com/show_bug.cgi?id=977706
> > ---
> >  src/storage/storage_backend.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
> > index e2527c9..f063601 100644
> > --- a/src/storage/storage_backend.c
> > +++ b/src/storage/storage_backend.c
> > @@ -1084,7 +1084,7 @@ virStorageBackendForType(int type)
> >   * Allows caller to silently ignore files with improper mode
> >   *
> >   * Returns -1 on error, -2 if file mode is unexpected or the
> > - * volume is a dangling symbolic link.
> > + * volume is a dangling symbolic link or file is missing.
> >   */
> >  int
> >  virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
> > @@ -1097,7 +1097,7 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
> >          virReportSystemError(errno,
> >                               _("cannot stat file '%s'"),
> >                               path);
> 
> If we want to *silently* ignore missing file, why do we
> virReportSystemError() here?
> 
> > -        return -1;
> > +        return -2;
> >      }

Well returning -1 vs -2 from this function isn't ignoring the
error. It is just providing the caller a way to detect a specific
error scenario. Thus if the caller decides to ignore the error
when ret == -2, then the caller should call virResetLastError()
to clear it.


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