]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: replace assert with error check in clone()
authorIlya Dryomov <idryomov@gmail.com>
Thu, 11 Apr 2024 16:56:15 +0000 (18:56 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 13 Jun 2024 12:08:46 +0000 (14:08 +0200)
With an error check for p_snap_name, it doesn't make much sense to
crash if "either p_id or p_name" contract is violated.  Replace the
assert with a similar error check.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/internal.cc

index 3cd699b2c81426df7c882e3f0892da67ebf9b02f..33b9dcfa5afa2fd650be18fa8be4b2ed40d46e2d 100644 (file)
@@ -729,9 +729,13 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
             const std::string &non_primary_global_image_id,
             const std::string &primary_mirror_uuid)
   {
-    ceph_assert((p_id == nullptr) ^ (p_name == nullptr));
-
     CephContext *cct = (CephContext *)p_ioctx.cct();
+
+    if (((p_id == nullptr) ^ (p_name == nullptr)) == 0) {
+      lderr(cct) << "must specify either parent image id or parent image name"
+                 << dendl;
+      return -EINVAL;
+    }
     if (p_snap_name == nullptr) {
       lderr(cct) << "image to be cloned must be a snapshot" << dendl;
       return -EINVAL;