]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: permit disabling QCOW migration format support 39622/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 22 Feb 2021 15:23:01 +0000 (10:23 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 23 Feb 2021 12:19:43 +0000 (07:19 -0500)
Downstream Red Hat products do not support the older QCOW format. This
will allow the support for the legacy QCOW format to be disabled for the
new RBD import-only migration support.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
CMakeLists.txt
qa/workunits/rbd/cli_migration.sh
src/include/config-h.in.cmake
src/librbd/migration/QCOWFormat.cc
src/librbd/migration/QCOWFormat.h
src/test/librbd/migration/test_mock_QCOWFormat.cc

index 550f815d220d5afe76caaf544c523f60a2944ea9..8b4effd89bbb576cc043c22e0eee0c297c2940dc 100644 (file)
@@ -232,6 +232,10 @@ CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_LIBURING "Require and build with system libur
 CMAKE_DEPENDENT_OPTION(WITH_BLUESTORE_PMEM "Enable PMDK libraries" OFF
   "WITH_BLUESTORE" OFF)
 
+CMAKE_DEPENDENT_OPTION(WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+  "Enable librbd QCOW v1 migration format support" ON
+  "WITH_RBD" OFF)
+
 CMAKE_DEPENDENT_OPTION(WITH_RBD_RWL "Enable librbd persistent write back cache" OFF
   "WITH_RBD" OFF)
 
index 9e9099850370877846f11d37d740100e20a9e7da..be8e031fd1bc8e12a399eec0073b536dc3aff450 100755 (executable)
@@ -162,8 +162,17 @@ test_import_qcow_format() {
 EOF
     cat ${TEMPDIR}/spec.json
 
+    set +e
     rbd migration prepare --import-only \
         --source-spec-path ${TEMPDIR}/spec.json ${dest_image}
+    local error_code=$?
+    set -e
+
+    if [ $error_code -eq 95 ]; then
+        echo "skipping QCOW test (librbd support disabled)"
+        return 0
+    fi
+    test $error_code -eq 0
 
     compare_images "${base_image}" "${dest_image}"
 
index 9a4e1a6479f5cdbc6c436c8acf9c873b91d9483c..39aa5bbc42799b7f26c0ff692ae22622510a19c5 100644 (file)
 /* Define if unit tests are built. */
 #cmakedefine UNIT_TESTS_BUILT
 
+/* Define if RBD QCOW migration format is enabled */
+#cmakedefine WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
 /* Define if RWL is enabled */
 #cmakedefine WITH_RBD_RWL
 
index 4dfbbf0944caac53f7cc0877bcebb60acf67af55..7bd4a5ef748ee4e0cb8b36a24332e9323581c733 100644 (file)
@@ -901,7 +901,12 @@ void QCOWFormat<I>::handle_probe(int r, Context* on_finish) {
 
   m_bl.clear();
   if (header_probe.version == 1) {
+#ifdef WITH_RBD_MIGRATION_FORMAT_QCOW_V1
     read_v1_header(on_finish);
+#else // WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+    lderr(cct) << "QCOW is not supported" << dendl;
+    on_finish->complete(-ENOTSUP);
+#endif // WITH_RBD_MIGRATION_FORMAT_QCOW_V1
     return;
   } else if (header_probe.version >= 2 && header_probe.version <= 3) {
     read_v2_header(on_finish);
@@ -914,6 +919,8 @@ void QCOWFormat<I>::handle_probe(int r, Context* on_finish) {
   }
 }
 
+#ifdef WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
 template <typename I>
 void QCOWFormat<I>::read_v1_header(Context* on_finish) {
   auto cct = m_image_ctx->cct;
@@ -1014,6 +1021,8 @@ void QCOWFormat<I>::handle_read_v1_header(int r, Context* on_finish) {
   read_l1_table(on_finish);
 }
 
+#endif // WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
 template <typename I>
 void QCOWFormat<I>::read_v2_header(Context* on_finish) {
   auto cct = m_image_ctx->cct;
index 1bceb7df76294d84063caab17a826a73a36c3396..b365067165026565c1febb3106f1e08ecc2bd1c4 100644 (file)
@@ -8,6 +8,7 @@
 #include "librbd/Types.h"
 #include "librbd/migration/FormatInterface.h"
 #include "librbd/migration/QCOW.h"
+#include "acconfig.h"
 #include "json_spirit/json_spirit.h"
 #include <boost/asio/io_context_strand.hpp>
 #include <boost/iostreams/filter/zlib.hpp>
@@ -175,8 +176,10 @@ private:
   void probe(Context* on_finish);
   void handle_probe(int r, Context* on_finish);
 
+#ifdef WITH_RBD_MIGRATION_FORMAT_QCOW_V1
   void read_v1_header(Context* on_finish);
   void handle_read_v1_header(int r, Context* on_finish);
+#endif // WITH_RBD_MIGRATION_FORMAT_QCOW_V1
 
   void read_v2_header(Context* on_finish);
   void handle_read_v2_header(int r, Context* on_finish);
index 3515a0e7aa18ef602d48ca079b7b0dff0ae37c25..6e7225d22430cbdafc08c9f23565812e202fad58 100644 (file)
@@ -8,6 +8,7 @@
 #include "common/ceph_mutex.h"
 #include "librbd/migration/QCOWFormat.h"
 #include "librbd/migration/SourceSpecBuilder.h"
+#include "acconfig.h"
 #include "gtest/gtest.h"
 #include "gmock/gmock.h"
 #include "json_spirit/json_spirit.h"
@@ -291,6 +292,7 @@ TEST_F(TestMockMigrationQCOWFormat, OpenCloseV1) {
 
   expect_stream_open(*mock_stream_interface, 0);
 
+  int expected_open_ret_val = 0;
   QCowHeaderV1 qcow_header;
   memset(&qcow_header, 0, sizeof(qcow_header));
   qcow_header.magic = htobe32(QCOW_MAGIC);
@@ -304,6 +306,8 @@ TEST_F(TestMockMigrationQCOWFormat, OpenCloseV1) {
   probe_bl.append(std::string_view(reinterpret_cast<char*>(&qcow_header), 8));
   expect_stream_read(*mock_stream_interface, {{0, 8}}, probe_bl, 0);
 
+#ifdef WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
   bufferlist header_bl;
   header_bl.append(std::string_view(reinterpret_cast<char*>(&qcow_header),
                                     sizeof(qcow_header)));
@@ -314,6 +318,12 @@ TEST_F(TestMockMigrationQCOWFormat, OpenCloseV1) {
   l1_table_bl.append_zero(16);
   expect_stream_read(*mock_stream_interface, {{1<<20, 16}}, l1_table_bl, 0);
 
+#else // WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
+  expected_open_ret_val = -ENOTSUP;
+
+#endif // WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
   expect_stream_close(*mock_stream_interface, 0);
 
   MockQCOWFormat mock_qcow_format(&mock_image_ctx, json_object,
@@ -321,7 +331,7 @@ TEST_F(TestMockMigrationQCOWFormat, OpenCloseV1) {
 
   C_SaferCond ctx1;
   mock_qcow_format.open(&ctx1);
-  ASSERT_EQ(0, ctx1.wait());
+  ASSERT_EQ(expected_open_ret_val, ctx1.wait());
 
   C_SaferCond ctx2;
   mock_qcow_format.close(&ctx2);
@@ -434,6 +444,8 @@ TEST_F(TestMockMigrationQCOWFormat, ProbeError) {
   ASSERT_EQ(0, ctx2.wait());
 }
 
+#ifdef WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
 TEST_F(TestMockMigrationQCOWFormat, ReadHeaderV1Error) {
   MockTestImageCtx mock_image_ctx(*m_image_ctx);
 
@@ -476,6 +488,8 @@ TEST_F(TestMockMigrationQCOWFormat, ReadHeaderV1Error) {
   ASSERT_EQ(0, ctx2.wait());
 }
 
+#endif // WITH_RBD_MIGRATION_FORMAT_QCOW_V1
+
 TEST_F(TestMockMigrationQCOWFormat, ReadHeaderV2Error) {
   MockTestImageCtx mock_image_ctx(*m_image_ctx);