]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Set ret = -1 on failures in virStorageBackendUpdateVolTargetInfo
authorJohn Ferlan <jferlan@redhat.com>
Fri, 4 Dec 2015 15:40:06 +0000 (10:40 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 9 Dec 2015 21:31:14 +0000 (16:31 -0500)
While processing the volume for lseek, virFileReadHeaderFD, and
virStorageFileGetMetadataFromBuf - failure would cause an error,
but ret would not be set. That would result in an error message being
sent, but successful status being returned.

src/storage/storage_backend.c

index 1ee83aa30824468abc07d90254fe531fd7b440da..8eb5b04635fb5cf87b949d79477d2d8e1a04e7da 100644 (file)
@@ -1625,16 +1625,19 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
 
         if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
             virReportSystemError(errno, _("cannot seek to start of '%s'"), target->path);
+            ret = -1;
             goto cleanup;
         }
 
         if ((len = virFileReadHeaderFD(fd, len, &buf)) < 0) {
             virReportSystemError(errno, _("cannot read header '%s'"), target->path);
+            ret = -1;
             goto cleanup;
         }
 
         if (!(meta = virStorageFileGetMetadataFromBuf(target->path, buf, len, target->format,
                                                       NULL))) {
+            ret = -1;
             goto cleanup;
         }