]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: backend: Add possibility to suppress errors from backend lookup
authorPeter Krempa <pkrempa@redhat.com>
Thu, 24 Apr 2014 14:21:20 +0000 (16:21 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2014 07:27:23 +0000 (09:27 +0200)
Add a new function wrapper and tweak the storage file backend lookup
function so that it can be used without reporting error. This will be
useful in the metadata crawler code where we need silently break if
metadata retrieval is not supported for the current storage type.

src/storage/storage_backend.c
src/storage/storage_backend.h

index e016cc828d8ab6c4d6847cb2f2d9dfae0e66aadb..380ca58af584243335a2ccc993b517243044a378 100644 (file)
@@ -1173,8 +1173,9 @@ virStorageBackendForType(int type)
 
 
 virStorageFileBackendPtr
-virStorageFileBackendForType(int type,
-                             int protocol)
+virStorageFileBackendForTypeInternal(int type,
+                                     int protocol,
+                                     bool report)
 {
     size_t i;
 
@@ -1188,6 +1189,9 @@ virStorageFileBackendForType(int type,
         }
     }
 
+    if (!report)
+        return NULL;
+
     if (type == VIR_STORAGE_TYPE_NETWORK) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("missing storage backend for network files "
@@ -1203,6 +1207,14 @@ virStorageFileBackendForType(int type,
 }
 
 
+virStorageFileBackendPtr
+virStorageFileBackendForType(int type,
+                             int protocol)
+{
+    return virStorageFileBackendForTypeInternal(type, protocol, true);
+}
+
+
 struct diskType {
     int part_table_type;
     unsigned short offset;
index 56643fbb2d38ac9926cf50187e9d2edcbe73a0ae..76c1afa52b99ce3b3b10d469961f4620d59c960d 100644 (file)
@@ -203,7 +203,9 @@ typedef int
                                int mode);
 
 virStorageFileBackendPtr virStorageFileBackendForType(int type, int protocol);
-
+virStorageFileBackendPtr virStorageFileBackendForTypeInternal(int type,
+                                                              int protocol,
+                                                              bool report);
 
 
 struct _virStorageFileBackend {