[PATCH 31/33] storage: Don't report OOM error on failure of glfs_new

Peter Krempa pkrempa at redhat.com
Wed Feb 24 16:17:06 UTC 2021


OOM isn't the only failure glfs_new can encounter. Report an error which
might give more insight. libgfapi seems to be setting errno but
reporting a system error migt be misleading.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/storage/storage_backend_gluster.c           | 3 ++-
 src/storage_file/storage_file_backend_gluster.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 8de0cb8a6b..e673922df6 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -114,7 +114,8 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool)

     /* Actually connect to glfs */
     if (!(ret->vol = glfs_new(ret->volname))) {
-        virReportOOMError();
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("failed to create glfs object for '%s'"), ret->volname);
         goto error;
     }

diff --git a/src/storage_file/storage_file_backend_gluster.c b/src/storage_file/storage_file_backend_gluster.c
index 9b3b783274..8c7a583886 100644
--- a/src/storage_file/storage_file_backend_gluster.c
+++ b/src/storage_file/storage_file_backend_gluster.c
@@ -120,7 +120,8 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr src)
               (unsigned int)drv->uid, (unsigned int)drv->gid);

     if (!(priv->vol = glfs_new(src->volume))) {
-        virReportOOMError();
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("failed to create glfs object for '%s'"), src->volume);
         goto error;
     }

-- 
2.29.2




More information about the libvir-list mailing list