]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: report VIR_ERR_NO_STORAGE_VOL when the file doesn't exist
authorGiuseppe Scrivano <gscrivan@redhat.com>
Fri, 13 Jun 2014 14:48:15 +0000 (16:48 +0200)
committerEric Blake <eblake@redhat.com>
Fri, 13 Jun 2014 16:05:33 +0000 (10:05 -0600)
Report VIR_ERR_NO_STORAGE_VOL instead of a system error when lstat
fails because the file doesn't exist.

Fixes this problem in virt-install:

  https://bugzilla.redhat.com/show_bug.cgi?id=1108922

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
src/storage/storage_backend.c

index 380ca58af584243335a2ccc993b517243044a378..b38af52372e54c01b4dd3846ed82e55f206bf1ef 100644 (file)
@@ -1305,9 +1305,15 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
     bool noerror = (flags & VIR_STORAGE_VOL_OPEN_NOERROR);
 
     if (lstat(path, sb) < 0) {
-        if (errno == ENOENT && noerror) {
-            VIR_WARN("ignoring missing file '%s'", path);
-            return -2;
+        if (errno == ENOENT) {
+            if (noerror) {
+                VIR_WARN("ignoring missing file '%s'", path);
+                return -2;
+            }
+            virReportError(VIR_ERR_NO_STORAGE_VOL,
+                           _("no storage vol with matching path '%s'"),
+                           path);
+            return -1;
         }
         virReportSystemError(errno,
                              _("cannot stat file '%s'"),