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>
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;