]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: introduce a new constructor for ImageOptions
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Tue, 14 Mar 2017 09:58:31 +0000 (17:58 +0800)
committerDongsheng Yang <dongsheng.yang@easystack.cn>
Tue, 14 Mar 2017 09:58:31 +0000 (17:58 +0800)
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
src/include/rbd/librbd.hpp
src/librbd/internal.cc
src/librbd/internal.h
src/librbd/librbd.cc

index 3c667d2e871a774a055f813a136fa32ed252dcc6..9110e6d896f9df16d5db1eb229c1b174eca259be 100644 (file)
@@ -183,6 +183,7 @@ class CEPH_RBD_API ImageOptions {
 public:
   ImageOptions();
   ImageOptions(rbd_image_options_t opts);
+  ImageOptions(const ImageOptions &imgopts);
   ~ImageOptions();
 
   int set(int optname, const std::string& optval);
index 3432ae71c4579c3049708f34f6031951cdd46559..6074711ef417df80f6a733e49203dae8bc2ad2e0 100644 (file)
@@ -383,6 +383,31 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     *opts = static_cast<rbd_image_options_t>(opts_);
   }
 
+  void image_options_copy(rbd_image_options_t* opts,
+                         const ImageOptions &orig)
+  {
+    image_options_ref* opts_ = new image_options_ref(new image_options_t());
+
+    *opts = static_cast<rbd_image_options_t>(opts_);
+
+    std::string str_val;
+    uint64_t uint64_val;
+    for (auto &i : IMAGE_OPTIONS_TYPE_MAPPING) {
+      switch (i.second) {
+      case STR:
+       if (orig.get(i.first, &str_val) == 0) {
+         image_options_set(*opts, i.first, str_val);
+       }
+       continue;
+      case UINT64:
+       if (orig.get(i.first, &uint64_val) == 0) {
+         image_options_set(*opts, i.first, uint64_val);
+       }
+       continue;
+      }
+    }
+  }
+
   void image_options_destroy(rbd_image_options_t opts)
   {
     image_options_ref* opts_ = static_cast<image_options_ref*>(opts);
index 65bb5a40eab101fec05cf5a5df9c18d9afa9cd9d..8f91d3c15f2a5b7efade0e15956231d961bbf803 100644 (file)
@@ -79,6 +79,8 @@ namespace librbd {
   void image_options_create(rbd_image_options_t* opts);
   void image_options_create_ref(rbd_image_options_t* opts,
                                rbd_image_options_t orig);
+  void image_options_copy(rbd_image_options_t *opts,
+                         const ImageOptions &orig);
   void image_options_destroy(rbd_image_options_t opts);
   int image_options_set(rbd_image_options_t opts, int optname,
                        const std::string& optval);
index 92704f651382a67da3d8eeeacfe22c5e37b147c1..d4238f907b5961bdb1cd67a9e40d85433985e5ba 100644 (file)
@@ -642,6 +642,11 @@ namespace librbd {
     librbd::image_options_create_ref(&opts, opts_);
   }
 
+  ImageOptions::ImageOptions(const ImageOptions &imgopts)
+  {
+    librbd::image_options_copy(&opts, imgopts);
+  }
+
   ImageOptions::~ImageOptions()
   {
     librbd::image_options_destroy(opts);