]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Ignore missing files on pool refresh
authorJán Tomko <jtomko@redhat.com>
Thu, 20 Mar 2014 15:35:00 +0000 (16:35 +0100)
committerJán Tomko <jtomko@redhat.com>
Thu, 10 Apr 2014 07:30:06 +0000 (09:30 +0200)
If we cannot stat/open a file on pool refresh, returning -1 aborts
the refresh and the pool is undefined.

Only treat missing files as fatal unless VolOpenCheckMode is called
with the VIR_STORAGE_VOL_OPEN_ERROR flag. If this flag is missing
(when it's called from virStorageBackendProbeTarget in
virStorageBackendFileSystemRefresh), only emit a warning and return
-2 to let the caller skip over the file.

https://bugzilla.redhat.com/show_bug.cgi?id=977706
(cherry picked from commit ee640f444bbdc976bdaed305f0d64d241d275376)

src/storage/storage_backend.c

index fd6c69a131c8b4e173085c5240ad6b7203974d42..e522a0686cb6084ebc2abe757188eeed059b56ad 100644 (file)
@@ -1130,6 +1130,10 @@ virStorageBackendVolOpenCheckMode(const char *path, struct stat *sb,
     char *base = last_component(path);
 
     if (lstat(path, sb) < 0) {
+        if (errno == ENOENT && !(flags & VIR_STORAGE_VOL_OPEN_ERROR)) {
+            VIR_WARN("ignoring missing file '%s'", path);
+            return -2;
+        }
         virReportSystemError(errno,
                              _("cannot stat file '%s'"),
                              path);
@@ -1150,6 +1154,10 @@ virStorageBackendVolOpenCheckMode(const char *path, struct stat *sb,
             VIR_WARN("ignoring dangling symlink '%s'", path);
             return -2;
         }
+        if (errno == ENOENT && !(flags & VIR_STORAGE_VOL_OPEN_ERROR)) {
+            VIR_WARN("ignoring missing file '%s'", path);
+            return -2;
+        }
 
         virReportSystemError(errno,
                              _("cannot open volume '%s'"),