/* Define if RBD QCOW migration format is enabled */
 #cmakedefine WITH_RBD_MIGRATION_FORMAT_QCOW_V1
 
+/* Define if libcephsqlite is enabled */
+#cmakedefine WITH_LIBCEPHSQLITE
+
 /* Define if RWL is enabled */
 #cmakedefine WITH_RBD_RWL
 
 
     mgr_commands.cc
     $<TARGET_OBJECTS:mgr_cap_obj>)
   add_executable(ceph-mgr ${mgr_srcs})
+  if(WITH_LIBCEPHSQLITE)
+    target_link_libraries(ceph-mgr cephsqlite SQLite3::SQLite3)
+  endif()
   target_link_libraries(ceph-mgr
     osdc client heap_profiler
     global-static ceph-common
 
 
 #include <Python.h>
 
+#include <sqlite3.h>
+
 #include "osdc/Objecter.h"
 #include "client/Client.h"
 #include "common/errno.h"
 #include "global/global_context.h"
 #include "global/signal_handler.h"
 
+#ifdef WITH_LIBCEPHSQLITE
+#  include "include/libcephsqlite.h"
+#endif
+
 #include "mgr/MgrContext.h"
 
 #include "DaemonServer.h"
     "Dump mgr status");
   ceph_assert(r == 0);
 
+#ifdef WITH_LIBCEPHSQLITE
+  dout(4) << "Using sqlite3 version: " << sqlite3_libversion() << dendl;
+  /* See libcephsqlite.h for rationale of this code. */
+  sqlite3_auto_extension((void (*)())sqlite3_cephsqlite_init);
+  {
+    sqlite3* db = nullptr;
+    if (int rc = sqlite3_open_v2(":memory:", &db, SQLITE_OPEN_READWRITE, nullptr); rc == SQLITE_OK) {
+      sqlite3_close(db);
+    } else {
+      derr << "could not open sqlite3: " << rc << dendl;
+      ceph_abort();
+    }
+  }
+  {
+    char *ident = nullptr;
+    if (int rc = cephsqlite_setcct(g_ceph_context, &ident); rc < 0) {
+      derr << "could not set libcephsqlite cct: " << rc << dendl;
+      ceph_abort();
+    }
+    entity_addrvec_t addrv;
+    addrv.parse(ident);
+    ident = (char*)realloc(ident, 0);
+    py_module_registry->register_client("libcephsqlite", addrv);
+  }
+#endif
+
   dout(4) << "Complete." << dendl;
   initializing = false;
   initialized = true;