[libvirt] [PATCH 1/3] rbd: Add volStorageBackendRBDGetFeatures() for internal calls

Wido den Hollander wido at widodh.nl
Thu Feb 11 16:04:15 UTC 2016


As more and more features are added to RBD volumes we will need to
call this method more often.

By moving it into a internal function we can re-use code inside the
storage backend.

Signed-off-by: Wido den Hollander <wido at widodh.nl>
---
 src/storage/storage_backend_rbd.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 5d73370..5f2469f 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -280,6 +280,24 @@ virStorageBackendRBDCloseRADOSConn(virStorageBackendRBDStatePtr ptr)
 }
 
 static int
+volStorageBackendRBDGetFeatures(rbd_image_t image,
+                                const char *volname,
+                                uint64_t *features)
+{
+    int r, ret = -1;
+
+    if ((r = rbd_get_features(image, features)) < 0) {
+        virReportSystemError(-r, _("failed to get the features of RBD image "
+                                 "%s"), volname);
+        goto cleanup;
+    }
+    ret = 0;
+
+ cleanup:
+    return ret;
+}
+
+static int
 volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
                                    virStoragePoolObjPtr pool,
                                    virStorageBackendRBDStatePtr ptr)
@@ -685,11 +703,8 @@ virStorageBackendRBDImageInfo(rbd_image_t image,
         goto cleanup;
     }
 
-    if ((r = rbd_get_features(image, features)) < 0) {
-        virReportSystemError(-r, _("failed to get the features of RBD image %s"),
-                             volname);
+    if (volStorageBackendRBDGetFeatures(image, volname, features) < 0)
         goto cleanup;
-    }
 
     if ((r = rbd_get_stripe_unit(image, stripe_unit)) < 0) {
         virReportSystemError(-r, _("failed to get the stripe unit of RBD image %s"),
-- 
1.9.1




More information about the libvir-list mailing list