if (opts.get(RBD_IMAGE_OPTION_FORMAT, &format) != 0) {
opts.set(RBD_IMAGE_OPTION_FORMAT, format);
}
- if (format == 1) {
- lderr(cct) << "old format not supported for destination image" << dendl;
+ if (format != 2) {
+ lderr(cct) << "unsupported destination image format: " << format << dendl;
return -EINVAL;
}
uint64_t stripe_unit = src->stripe_unit;
uint64_t format = 0;
m_opts.get(RBD_IMAGE_OPTION_FORMAT, &format);
- if (format < 2) {
- lderr(m_cct) << "format 2 or later required for clone" << dendl;
+ if (format != 2) {
+ lderr(m_cct) << "unsupported format for clone: " << format << dendl;
complete(-EINVAL);
return;
}
}
}
+ if (m_clone_format < 1 || m_clone_format > 2) {
+ lderr(m_cct) << "unsupported clone format: " << m_clone_format << dendl;
+ complete(-EINVAL);
+ return;
+ }
+
if (m_clone_format == 1 &&
m_parent_io_ctx.get_namespace() != m_ioctx.get_namespace()) {
ldout(m_cct, 1) << "clone v2 required for cross-namespace clones" << dendl;
uint64_t format;
if (opts.get(RBD_IMAGE_OPTION_FORMAT, &format) != 0)
format = cct->_conf.get_val<uint64_t>("rbd_default_format");
+
+ if (format < 1 || format > 2) {
+ lderr(cct) << "unsupported format: " << format << dendl;
+ return -EINVAL;
+ }
bool old_format = format == 1;
// make sure it doesn't already exist, in either format
def test_clone_format(self):
clone_name2 = get_temp_image_name()
+ assert_raises(InvalidArgument, self.rbd.clone, ioctx, image_name,
+ 'snap1', ioctx, clone_name2, features, clone_format=0)
+ assert_raises(InvalidArgument, self.rbd.clone, ioctx, image_name,
+ 'snap1', ioctx, clone_name2, features, clone_format=3)
+
self.rbd.clone(ioctx, image_name, 'snap1', ioctx, clone_name2,
features, clone_format=1)
with Image(ioctx, clone_name2) as clone2: