[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/3] storage conf: Support setting RADOS options in RBD storage backend



From: Wido den Hollander <wido 42on com>

This way users can manually set options in librados which might suite
their needs better.
---
 docs/schemas/storagepool.rng             |    1 +
 src/storage/storage_backend_rbd.c        |   16 ++++++++++++++++
 tests/storagepoolxml2xmlin/pool-rbd.xml  |    3 +++
 tests/storagepoolxml2xmlout/pool-rbd.xml |    3 +++
 4 files changed, 23 insertions(+)

diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 7b38dce..0cd119c 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -568,6 +568,7 @@
         <ref name='sourceinfohost'/>
         <optional>
           <ref name='sourceinfoauth'/>
+          <ref name='sourceinfooptions'/>
         </optional>
       </interleave>
     </element>
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 5d4ef79..3cb5b85 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -216,6 +216,22 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
     VIR_DEBUG("Setting RADOS option rados_osd_op_timeout to %s", osd_op_timeout);
     rados_conf_set(ptr->cluster, "rados_osd_op_timeout", osd_op_timeout);
 
+    if (pool->def->source.noptions > 0) {
+        for (i = 0; i < pool->def->source.noptions; i++) {
+            if (pool->def->source.options[i].name != NULL &&
+                pool->def->source.options[i].value != NULL) {
+                VIR_DEBUG("Setting RADOS option %s to %s",
+                        pool->def->source.options[i].name,
+                        pool->def->source.options[i].value);
+                if (rados_conf_set(ptr->cluster, pool->def->source.options[i].name,
+                    pool->def->source.options[i].value) < 0) {
+                    virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to set RADOS option %s"),
+                                   pool->def->source.options[i].name);
+                }
+            }
+        }
+    }
+
     ptr->starttime = time(0);
     r = rados_connect(ptr->cluster);
     if (r < 0) {
diff --git a/tests/storagepoolxml2xmlin/pool-rbd.xml b/tests/storagepoolxml2xmlin/pool-rbd.xml
index 056ba6e..05991fc 100644
--- a/tests/storagepoolxml2xmlin/pool-rbd.xml
+++ b/tests/storagepoolxml2xmlin/pool-rbd.xml
@@ -7,5 +7,8 @@
     <auth username='admin' type='ceph'>
       <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
     </auth>
+    <option name='client_mount_timeout' value='30'/>
+    <option name='rados_mon_op_timeout' value='30'/>
+    <option name='rados_osd_op_timeout' value='30'/>
   </source>
 </pool>
diff --git a/tests/storagepoolxml2xmlout/pool-rbd.xml b/tests/storagepoolxml2xmlout/pool-rbd.xml
index 4fe2fce..cb9969e 100644
--- a/tests/storagepoolxml2xmlout/pool-rbd.xml
+++ b/tests/storagepoolxml2xmlout/pool-rbd.xml
@@ -11,5 +11,8 @@
     <auth type='ceph' username='admin'>
       <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
     </auth>
+    <option name='client_mount_timeout' value='30'/>
+    <option name='rados_mon_op_timeout' value='30'/>
+    <option name='rados_osd_op_timeout' value='30'/>
   </source>
 </pool>
-- 
1.7.9.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]