From 9ad4d7936afcc1da3d032f5486b856e932d04a4d Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 26 Oct 2020 21:25:02 -0400 Subject: [PATCH] librbd/migration: fix issue with prepare-import and native-format When preparing an import, the native format can not expect to have the child image opened since it hasn't been created yet. Signed-off-by: Jason Dillaman --- src/librbd/migration/NativeFormat.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/librbd/migration/NativeFormat.cc b/src/librbd/migration/NativeFormat.cc index b6046d0d2d146..cb3b5164abb2b 100644 --- a/src/librbd/migration/NativeFormat.cc +++ b/src/librbd/migration/NativeFormat.cc @@ -109,11 +109,13 @@ void NativeFormat::open(Context* on_finish) { m_image_ctx->id = m_image_id; } - // set rados flags for reading the parent image - if (m_image_ctx->child->config.template get_val("rbd_balance_parent_reads")) { - m_image_ctx->set_read_flag(librados::OPERATION_BALANCE_READS); - } else if (m_image_ctx->child->config.template get_val("rbd_localize_parent_reads")) { - m_image_ctx->set_read_flag(librados::OPERATION_LOCALIZE_READS); + if (m_image_ctx->child != nullptr) { + // set rados flags for reading the parent image + if (m_image_ctx->child->config.template get_val("rbd_balance_parent_reads")) { + m_image_ctx->set_read_flag(librados::OPERATION_BALANCE_READS); + } else if (m_image_ctx->child->config.template get_val("rbd_localize_parent_reads")) { + m_image_ctx->set_read_flag(librados::OPERATION_LOCALIZE_READS); + } } // open the source RBD image -- 2.39.5