]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
driver: fix handling of error return from finding resource
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 19 Apr 2018 14:25:01 +0000 (15:25 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 24 Apr 2018 16:00:49 +0000 (17:00 +0100)
The virFileFindResource method merely builds up the expected fully
qualified path to the resource. It does not actually check if it exists
on disk. The loadable module callers were mistakenly thinking a NULL
indicates the file doesn't exist on disk, whereas it in fact indicates
an out of memory error.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/driver.c
src/storage/storage_backend.c
src/util/virfile.c

index 4d314b38703c9bf21ea3c81ac58f26526b426565..ddda1e71f752fcceb887d6fe59052965076606d9 100644 (file)
@@ -153,7 +153,7 @@ virDriverLoadModule(const char *name,
                                             abs_topbuilddir "/src/.libs",
                                             DEFAULT_DRIVER_DIR,
                                             "LIBVIRT_DRIVER_DIR")))
-        return 1;
+        return -1;
 
     ret = virDriverLoadModuleFull(modfile, regfunc);
 
index aac2f53b0125b4c05f2531e69f996cca8b134f8f..8c1dcf31b1218bbe15800de52ce1f59492cbe785 100644 (file)
@@ -95,7 +95,7 @@ virStorageDriverLoadBackendModule(const char *name,
                                             abs_topbuilddir "/src/.libs",
                                             STORAGE_BACKEND_MODULE_DIR,
                                             "LIBVIRT_STORAGE_BACKEND_DIR")))
-        return 1;
+        return -1;
 
     if ((ret = virDriverLoadModuleFull(modfile, regfunc)) != 0) {
         if (forceload) {
index 5e9bd2007a52cf32162e396f006a78673794cdde..e12a584ca1c5383ce265d7ede2c0184f729ffee5 100644 (file)
@@ -1736,6 +1736,10 @@ static bool useDirOverride;
  * run from the source tree. Otherwise it will return the
  * path in the installed location.
  *
+ * Note that this function does not actually check whether
+ * the file exists on disk, it merely builds the fully
+ * qualified path where it is supposed to exist.
+ *
  * If @envname is non-NULL it will override all other
  * directory lookup.
  *