Move to kernel style SPDX license identifiers
[babeltrace.git] / src / lib / plugin / plugin-so.c
index 2ecb1a7e3bee22a3de0a2af69f37f2099f587356..6025bdec19ae829ab2922301467d4518fa1d35b9 100644 (file)
@@ -1,26 +1,8 @@
 /*
+ * SPDX-License-Identifier: MIT
+ *
  * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
  * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
 #define BT_LOG_TAG "LIB/PLUGIN-SO"
 #include <babeltrace2/plugin/plugin-dev.h>
 #include "lib/graph/component-class.h"
 #include <babeltrace2/graph/component-class.h>
-#include <babeltrace2/graph/component-class-source.h>
-#include <babeltrace2/graph/component-class-filter.h>
-#include <babeltrace2/graph/component-class-sink.h>
 #include <babeltrace2/types.h>
 #include "common/list.h"
 #include <string.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <glib.h>
 #include <gmodule.h>
 
 #include "plugin.h"
 #include "plugin-so.h"
+#include "lib/func-status.h"
+#include "common/common.h"
 
 #define NATIVE_PLUGIN_SUFFIX           "." G_MODULE_SUFFIX
 #define NATIVE_PLUGIN_SUFFIX_LEN       sizeof(NATIVE_PLUGIN_SUFFIX)
@@ -84,6 +66,11 @@ BT_PLUGIN_MODULE();
  * component class is removed from this list, the shared library handle
  * object's reference count falls to zero and the shared library is
  * finally closed.
+ *
+ * We're not using a GLib linked list here because this destructor is
+ * called after GLib's thread-specific data is destroyed, which contains
+ * the allocated memory for GLib data structures (what's used by
+ * g_slice_alloc()).
  */
 
 static
@@ -102,21 +89,6 @@ void fini_comp_class_list(void)
        BT_LOGD_STR("Released references from all component classes to shared library handles.");
 }
 
-static inline
-const char *bt_self_plugin_status_string(enum bt_self_plugin_status status)
-{
-       switch (status) {
-       case BT_SELF_PLUGIN_STATUS_OK:
-               return "BT_SELF_PLUGIN_STATUS_OK";
-       case BT_SELF_PLUGIN_STATUS_ERROR:
-               return "BT_SELF_PLUGIN_STATUS_ERROR";
-       case BT_SELF_PLUGIN_STATUS_NOMEM:
-               return "BT_SELF_PLUGIN_STATUS_NOMEM";
-       default:
-               return "(unknown)";
-       }
-}
-
 static
 void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
 {
@@ -138,28 +110,33 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
        }
 
        if (shared_lib_handle->module) {
-#ifndef BT_DEBUG_MODE
+#ifdef BT_DEBUG_MODE
                /*
                 * Valgrind shows incomplete stack traces when
                 * dynamically loaded libraries are closed before it
-                * finishes. Use the BABELTRACE_NO_DLCLOSE in a debug
+                * finishes. Use the LIBBABELTRACE2_NO_DLCLOSE in a debug
                 * build to avoid this.
                 */
-               const char *var = getenv("BABELTRACE_NO_DLCLOSE");
+               const char *var = getenv("LIBBABELTRACE2_NO_DLCLOSE");
 
                if (!var || strcmp(var, "1") != 0) {
 #endif
                        BT_LOGI("Closing GModule: path=\"%s\"", path);
 
                        if (!g_module_close(shared_lib_handle->module)) {
+                               /*
+                                * Just log here: we're in a destructor,
+                                * so we cannot append an error cause
+                                * (there's no returned status).
+                                */
                                BT_LOGE("Cannot close GModule: %s: path=\"%s\"",
                                        g_module_error(), path);
                        }
 
                        shared_lib_handle->module = NULL;
-#ifndef BT_DEBUG_MODE
+#ifdef BT_DEBUG_MODE
                } else {
-                       BT_LOGI("Not closing GModule because `BABELTRACE_NO_DLCLOSE=1`: "
+                       BT_LOGI("Not closing GModule because `LIBBABELTRACE2_NO_DLCLOSE=1`: "
                                "path=\"%s\"", path);
                }
 #endif
@@ -174,33 +151,37 @@ void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
 }
 
 static
-struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create(
-               const char *path)
+int bt_plugin_so_shared_lib_handle_create(
+               const char *path,
+               struct bt_plugin_so_shared_lib_handle **shared_lib_handle)
 {
-       struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
-
-       BT_LOGI("Creating shared library handle: path=\"%s\"", path);
-       shared_lib_handle = g_new0(struct bt_plugin_so_shared_lib_handle, 1);
-       if (!shared_lib_handle) {
-               BT_LOGE_STR("Failed to allocate one shared library handle.");
-               goto error;
+       int status = BT_FUNC_STATUS_OK;
+
+       BT_ASSERT(shared_lib_handle);
+       BT_LOGI("Creating shared library handle: path=\"%s\"", path ? path : "(null)");
+       *shared_lib_handle = g_new0(struct bt_plugin_so_shared_lib_handle, 1);
+       if (!*shared_lib_handle) {
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one shared library handle.");
+               status = BT_FUNC_STATUS_MEMORY_ERROR;
+               goto end;
        }
 
-       bt_object_init_shared(&shared_lib_handle->base,
+       bt_object_init_shared(&(*shared_lib_handle)->base,
                bt_plugin_so_shared_lib_handle_destroy);
 
        if (!path) {
                goto end;
        }
 
-       shared_lib_handle->path = g_string_new(path);
-       if (!shared_lib_handle->path) {
-               BT_LOGE_STR("Failed to allocate a GString.");
-               goto error;
+       (*shared_lib_handle)->path = g_string_new(path);
+       if (!(*shared_lib_handle)->path) {
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
+               status = BT_FUNC_STATUS_MEMORY_ERROR;
+               goto end;
        }
 
-       shared_lib_handle->module = g_module_open(path, G_MODULE_BIND_LOCAL);
-       if (!shared_lib_handle->module) {
+       (*shared_lib_handle)->module = g_module_open(path, G_MODULE_BIND_LOCAL);
+       if (!(*shared_lib_handle)->module) {
                /*
                 * INFO-level logging because we're only _trying_ to
                 * open this file as a Babeltrace plugin: if it's not,
@@ -210,21 +191,21 @@ struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create(
                 */
                BT_LOGI("Cannot open GModule: %s: path=\"%s\"",
                        g_module_error(), path);
-               goto error;
+               BT_OBJECT_PUT_REF_AND_RESET(*shared_lib_handle);
+               status = BT_FUNC_STATUS_NOT_FOUND;
+               goto end;
        }
 
        goto end;
 
-error:
-       BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
-
 end:
-       if (shared_lib_handle) {
+       BT_ASSERT(*shared_lib_handle || status != BT_FUNC_STATUS_OK);
+       if (*shared_lib_handle) {
                BT_LOGI("Created shared library handle: path=\"%s\", addr=%p",
-                       pathshared_lib_handle);
+                       path ? path : "(null)", *shared_lib_handle);
        }
 
-       return shared_lib_handle;
+       return status;
 }
 
 static
@@ -271,8 +252,8 @@ void bt_plugin_so_destroy_spec_data(struct bt_plugin *plugin)
  * 6. Freeze the plugin object.
  */
 static
-enum bt_plugin_status bt_plugin_so_init(
-               struct bt_plugin *plugin,
+int bt_plugin_so_init(struct bt_plugin *plugin,
+               bool fail_on_load_error,
                const struct __bt_plugin_descriptor *descriptor,
                struct __bt_plugin_descriptor_attribute const * const *attrs_begin,
                struct __bt_plugin_descriptor_attribute const * const *attrs_end,
@@ -292,34 +273,37 @@ enum bt_plugin_status bt_plugin_so_init(
 
                union {
                        struct {
-                               bt_component_class_source_init_method init;
+                               bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions;
+                               bt_component_class_source_initialize_method init;
                                bt_component_class_source_finalize_method finalize;
                                bt_component_class_source_query_method query;
                                bt_component_class_source_output_port_connected_method output_port_connected;
-                               bt_component_class_source_message_iterator_init_method msg_iter_init;
-                               bt_component_class_source_message_iterator_finalize_method msg_iter_finalize;
-                               bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
-                               bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning;
-                               bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
-                               bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
+                               bt_message_iterator_class_initialize_method msg_iter_initialize;
+                               bt_message_iterator_class_finalize_method msg_iter_finalize;
+                               bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+                               bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning;
+                               bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+                               bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning;
                        } source;
 
                        struct {
-                               bt_component_class_filter_init_method init;
+                               bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions;
+                               bt_component_class_filter_initialize_method init;
                                bt_component_class_filter_finalize_method finalize;
                                bt_component_class_filter_query_method query;
                                bt_component_class_filter_input_port_connected_method input_port_connected;
                                bt_component_class_filter_output_port_connected_method output_port_connected;
-                               bt_component_class_filter_message_iterator_init_method msg_iter_init;
-                               bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize;
-                               bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
-                               bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning;
-                               bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
-                               bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning;
+                               bt_message_iterator_class_initialize_method msg_iter_initialize;
+                               bt_message_iterator_class_finalize_method msg_iter_finalize;
+                               bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin;
+                               bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning;
+                               bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin;
+                               bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning;
                        } filter;
 
                        struct {
-                               bt_component_class_sink_init_method init;
+                               bt_component_class_sink_get_supported_mip_versions_method get_supported_mip_versions;
+                               bt_component_class_sink_initialize_method init;
                                bt_component_class_sink_finalize_method finalize;
                                bt_component_class_sink_query_method query;
                                bt_component_class_sink_input_port_connected_method input_port_connected;
@@ -328,7 +312,7 @@ enum bt_plugin_status bt_plugin_so_init(
                } methods;
        };
 
-       enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
+       int status = BT_FUNC_STATUS_OK;
        struct __bt_plugin_descriptor_attribute const * const *cur_attr_ptr;
        struct __bt_plugin_component_class_descriptor const * const *cur_cc_descr_ptr;
        struct __bt_plugin_component_class_descriptor_attribute const * const *cur_cc_descr_attr_ptr;
@@ -336,6 +320,7 @@ enum bt_plugin_status bt_plugin_so_init(
        GArray *comp_class_full_descriptors;
        size_t i;
        int ret;
+       struct bt_message_iterator_class *msg_iter_class = NULL;
 
        BT_LOGI("Initializing plugin object from descriptors found in sections: "
                "plugin-addr=%p, plugin-path=\"%s\", "
@@ -351,8 +336,8 @@ enum bt_plugin_status bt_plugin_so_init(
        comp_class_full_descriptors = g_array_new(FALSE, TRUE,
                sizeof(struct comp_class_full_descriptor));
        if (!comp_class_full_descriptors) {
-               BT_LOGE_STR("Failed to allocate a GArray.");
-               status = BT_PLUGIN_STATUS_ERROR;
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
+               status = BT_FUNC_STATUS_MEMORY_ERROR;
                goto end;
        }
 
@@ -368,7 +353,7 @@ enum bt_plugin_status bt_plugin_so_init(
                const struct __bt_plugin_descriptor_attribute *cur_attr =
                        *cur_attr_ptr;
 
-               if (cur_attr == NULL) {
+               if (!cur_attr) {
                        continue;
                }
 
@@ -400,21 +385,30 @@ enum bt_plugin_status bt_plugin_so_init(
                                cur_attr->value.version.extra);
                        break;
                default:
-                       /*
-                        * WARN-level logging because this should not
-                        * happen with the appropriate ABI version. If
-                        * we're here, we know that for the reported
-                        * version of the ABI, this attribute is
-                        * unknown.
-                        */
-                       BT_LOGW("Ignoring unknown plugin descriptor attribute: "
-                               "plugin-path=\"%s\", plugin-name=\"%s\", "
-                               "attr-type-name=\"%s\", attr-type-id=%d",
-                               spec->shared_lib_handle->path ?
-                                       spec->shared_lib_handle->path->str :
-                                       NULL,
-                               descriptor->name, cur_attr->type_name,
-                               cur_attr->type);
+                       if (fail_on_load_error) {
+                               BT_LIB_LOGW_APPEND_CAUSE(
+                                       "Unknown plugin descriptor attribute: "
+                                       "plugin-path=\"%s\", plugin-name=\"%s\", "
+                                       "attr-type-name=\"%s\", attr-type-id=%d",
+                                       spec->shared_lib_handle->path ?
+                                               spec->shared_lib_handle->path->str :
+                                               NULL,
+                                       descriptor->name, cur_attr->type_name,
+                                       cur_attr->type);
+                               status = BT_FUNC_STATUS_ERROR;
+                               goto end;
+                       } else {
+                               BT_LIB_LOGW(
+                                       "Ignoring unknown plugin descriptor attribute: "
+                                       "plugin-path=\"%s\", plugin-name=\"%s\", "
+                                       "attr-type-name=\"%s\", attr-type-id=%d",
+                                       spec->shared_lib_handle->path ?
+                                               spec->shared_lib_handle->path->str :
+                                               NULL,
+                                       descriptor->name, cur_attr->type_name,
+                                       cur_attr->type);
+                       }
+
                        break;
                }
        }
@@ -429,7 +423,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        *cur_cc_descr_ptr;
                struct comp_class_full_descriptor full_descriptor = {0};
 
-               if (cur_cc_descr == NULL) {
+               if (!cur_cc_descr) {
                        continue;
                }
 
@@ -452,7 +446,7 @@ enum bt_plugin_status bt_plugin_so_init(
                        *cur_cc_descr_attr_ptr;
                enum bt_component_class_type cc_type;
 
-               if (cur_cc_descr_attr == NULL) {
+               if (!cur_cc_descr_attr) {
                        continue;
                }
 
@@ -483,22 +477,40 @@ enum bt_plugin_status bt_plugin_so_init(
                                cc_full_descr->help =
                                        cur_cc_descr_attr->value.help;
                                break;
-                       case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD:
+                       case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS_METHOD:
+                               switch (cc_type) {
+                               case BT_COMPONENT_CLASS_TYPE_SOURCE:
+                                       cc_full_descr->methods.source.get_supported_mip_versions =
+                                               cur_cc_descr_attr->value.source_get_supported_mip_versions_method;
+                                       break;
+                               case BT_COMPONENT_CLASS_TYPE_FILTER:
+                                       cc_full_descr->methods.filter.get_supported_mip_versions =
+                                               cur_cc_descr_attr->value.filter_get_supported_mip_versions_method;
+                                       break;
+                               case BT_COMPONENT_CLASS_TYPE_SINK:
+                                       cc_full_descr->methods.sink.get_supported_mip_versions =
+                                               cur_cc_descr_attr->value.sink_get_supported_mip_versions_method;
+                                       break;
+                               default:
+                                       bt_common_abort();
+                               }
+                               break;
+                       case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INITIALIZE_METHOD:
                                switch (cc_type) {
                                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                                        cc_full_descr->methods.source.init =
-                                               cur_cc_descr_attr->value.source_init_method;
+                                               cur_cc_descr_attr->value.source_initialize_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_FILTER:
                                        cc_full_descr->methods.filter.init =
-                                               cur_cc_descr_attr->value.filter_init_method;
+                                               cur_cc_descr_attr->value.filter_initialize_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_SINK:
                                        cc_full_descr->methods.sink.init =
-                                               cur_cc_descr_attr->value.sink_init_method;
+                                               cur_cc_descr_attr->value.sink_initialize_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD:
@@ -516,7 +528,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                                cur_cc_descr_attr->value.sink_finalize_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD:
@@ -534,7 +546,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                                cur_cc_descr_attr->value.sink_query_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD:
@@ -548,7 +560,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                                cur_cc_descr_attr->value.sink_input_port_connected_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD:
@@ -562,7 +574,7 @@ enum bt_plugin_status bt_plugin_so_init(
                                                cur_cc_descr_attr->value.filter_output_port_connected_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD:
@@ -572,118 +584,134 @@ enum bt_plugin_status bt_plugin_so_init(
                                                cur_cc_descr_attr->value.sink_graph_is_configured_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
-                       case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD:
+                       case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD:
                                switch (cc_type) {
                                case BT_COMPONENT_CLASS_TYPE_SOURCE:
-                                       cc_full_descr->methods.source.msg_iter_init =
-                                               cur_cc_descr_attr->value.source_msg_iter_init_method;
+                                       cc_full_descr->methods.source.msg_iter_initialize =
+                                               cur_cc_descr_attr->value.msg_iter_initialize_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_FILTER:
-                                       cc_full_descr->methods.filter.msg_iter_init =
-                                               cur_cc_descr_attr->value.filter_msg_iter_init_method;
+                                       cc_full_descr->methods.filter.msg_iter_initialize =
+                                               cur_cc_descr_attr->value.msg_iter_initialize_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD:
                                switch (cc_type) {
                                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                                        cc_full_descr->methods.source.msg_iter_finalize =
-                                               cur_cc_descr_attr->value.source_msg_iter_finalize_method;
+                                               cur_cc_descr_attr->value.msg_iter_finalize_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_FILTER:
                                        cc_full_descr->methods.filter.msg_iter_finalize =
-                                               cur_cc_descr_attr->value.filter_msg_iter_finalize_method;
+                                               cur_cc_descr_attr->value.msg_iter_finalize_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD:
                                switch (cc_type) {
                                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                                        cc_full_descr->methods.source.msg_iter_seek_ns_from_origin =
-                                               cur_cc_descr_attr->value.source_msg_iter_seek_ns_from_origin_method;
+                                               cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_FILTER:
                                        cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin =
-                                               cur_cc_descr_attr->value.filter_msg_iter_seek_ns_from_origin_method;
+                                               cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD:
                                switch (cc_type) {
                                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                                        cc_full_descr->methods.source.msg_iter_seek_beginning =
-                                               cur_cc_descr_attr->value.source_msg_iter_seek_beginning_method;
+                                               cur_cc_descr_attr->value.msg_iter_seek_beginning_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_FILTER:
                                        cc_full_descr->methods.filter.msg_iter_seek_beginning =
-                                               cur_cc_descr_attr->value.filter_msg_iter_seek_beginning_method;
+                                               cur_cc_descr_attr->value.msg_iter_seek_beginning_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD:
                                switch (cc_type) {
                                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                                        cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin =
-                                               cur_cc_descr_attr->value.source_msg_iter_can_seek_ns_from_origin_method;
+                                               cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_FILTER:
                                        cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin =
-                                               cur_cc_descr_attr->value.filter_msg_iter_can_seek_ns_from_origin_method;
+                                               cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD:
                                switch (cc_type) {
                                case BT_COMPONENT_CLASS_TYPE_SOURCE:
                                        cc_full_descr->methods.source.msg_iter_can_seek_beginning =
-                                               cur_cc_descr_attr->value.source_msg_iter_can_seek_beginning_method;
+                                               cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method;
                                        break;
                                case BT_COMPONENT_CLASS_TYPE_FILTER:
                                        cc_full_descr->methods.filter.msg_iter_can_seek_beginning =
-                                               cur_cc_descr_attr->value.filter_msg_iter_can_seek_beginning_method;
+                                               cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method;
                                        break;
                                default:
-                                       abort();
+                                       bt_common_abort();
                                }
                                break;
                        default:
-                               /*
-                                * WARN-level logging because this
-                                * should not happen with the
-                                * appropriate ABI version. If we're
-                                * here, we know that for the reported
-                                * version of the ABI, this attribute is
-                                * unknown.
-                                */
-                               BT_LOGW("Ignoring unknown component class descriptor attribute: "
-                                       "plugin-path=\"%s\", "
-                                       "plugin-name=\"%s\", "
-                                       "comp-class-name=\"%s\", "
-                                       "comp-class-type=%s, "
-                                       "attr-type-name=\"%s\", "
-                                       "attr-type-id=%d",
-                                       spec->shared_lib_handle->path ?
-                                               spec->shared_lib_handle->path->str :
-                                               NULL,
-                                       descriptor->name,
-                                       cur_cc_descr_attr->comp_class_descriptor->name,
-                                       bt_component_class_type_string(
-                                               cur_cc_descr_attr->comp_class_descriptor->type),
-                                       cur_cc_descr_attr->type_name,
-                                       cur_cc_descr_attr->type);
+                               if (fail_on_load_error) {
+                                       BT_LIB_LOGW_APPEND_CAUSE(
+                                               "Unknown component class descriptor attribute: "
+                                               "plugin-path=\"%s\", "
+                                               "plugin-name=\"%s\", "
+                                               "comp-class-name=\"%s\", "
+                                               "comp-class-type=%s, "
+                                               "attr-type-name=\"%s\", "
+                                               "attr-type-id=%d",
+                                               spec->shared_lib_handle->path ?
+                                                       spec->shared_lib_handle->path->str :
+                                                       NULL,
+                                               descriptor->name,
+                                               cur_cc_descr_attr->comp_class_descriptor->name,
+                                               bt_component_class_type_string(
+                                                       cur_cc_descr_attr->comp_class_descriptor->type),
+                                               cur_cc_descr_attr->type_name,
+                                               cur_cc_descr_attr->type);
+                                       status = BT_FUNC_STATUS_ERROR;
+                                       goto end;
+                               } else {
+                                       BT_LIB_LOGW(
+                                               "Ignoring unknown component class descriptor attribute: "
+                                               "plugin-path=\"%s\", "
+                                               "plugin-name=\"%s\", "
+                                               "comp-class-name=\"%s\", "
+                                               "comp-class-type=%s, "
+                                               "attr-type-name=\"%s\", "
+                                               "attr-type-id=%d",
+                                               spec->shared_lib_handle->path ?
+                                                       spec->shared_lib_handle->path->str :
+                                                       NULL,
+                                               descriptor->name,
+                                               cur_cc_descr_attr->comp_class_descriptor->name,
+                                               bt_component_class_type_string(
+                                                       cur_cc_descr_attr->comp_class_descriptor->type),
+                                               cur_cc_descr_attr->type_name,
+                                               cur_cc_descr_attr->type);
+                               }
+
                                break;
                        }
                }
@@ -691,16 +719,29 @@ enum bt_plugin_status bt_plugin_so_init(
 
        /* Initialize plugin */
        if (spec->init) {
-               enum bt_self_plugin_status init_status;
+               enum bt_plugin_initialize_func_status init_status;
 
                BT_LOGD_STR("Calling user's plugin initialization function.");
                init_status = spec->init((void *) plugin);
-               BT_LOGD("User function returned: %s",
-                       bt_self_plugin_status_string(init_status));
+               BT_LOGD("User function returned: status=%s",
+                       bt_common_func_status_string(init_status));
 
                if (init_status < 0) {
-                       BT_LOGW_STR("User's plugin initialization function failed.");
-                       status = BT_PLUGIN_STATUS_ERROR;
+                       if (fail_on_load_error) {
+                               BT_LIB_LOGW_APPEND_CAUSE(
+                                       "User's plugin initialization function failed: "
+                                       "status=%s",
+                                       bt_common_func_status_string(init_status));
+                               status = init_status;
+                               goto end;
+                       } else {
+                               BT_LIB_LOGW(
+                                       "User's plugin initialization function failed: "
+                                       "status=%s",
+                                       bt_common_func_status_string(init_status));
+                               status = BT_FUNC_STATUS_NOT_FOUND;
+                       }
+
                        goto end;
                }
        }
@@ -728,22 +769,111 @@ enum bt_plugin_status bt_plugin_so_init(
                        bt_component_class_type_string(
                                cc_full_descr->descriptor->type));
 
+               if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
+                               cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_FILTER) {
+                       bt_message_iterator_class_next_method next_method;
+                       bt_message_iterator_class_initialize_method init_method;
+                       bt_message_iterator_class_finalize_method fini_method;
+                       bt_message_iterator_class_seek_ns_from_origin_method seek_ns_from_origin_method;
+                       bt_message_iterator_class_seek_beginning_method seek_beginning_method;
+                       bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_ns_from_origin_method;
+                       bt_message_iterator_class_can_seek_beginning_method can_seek_beginning_method;
+
+                       if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE) {
+                               next_method = cc_full_descr->descriptor->methods.source.msg_iter_next;
+                               init_method = cc_full_descr->methods.source.msg_iter_initialize;
+                               fini_method = cc_full_descr->methods.source.msg_iter_finalize;
+                               seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_seek_ns_from_origin;
+                               can_seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin;
+                               seek_beginning_method = cc_full_descr->methods.source.msg_iter_seek_beginning;
+                               can_seek_beginning_method = cc_full_descr->methods.source.msg_iter_can_seek_beginning;
+                       } else {
+                               next_method = cc_full_descr->descriptor->methods.filter.msg_iter_next;
+                               init_method = cc_full_descr->methods.filter.msg_iter_initialize;
+                               fini_method = cc_full_descr->methods.filter.msg_iter_finalize;
+                               seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin;
+                               can_seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin;
+                               seek_beginning_method = cc_full_descr->methods.filter.msg_iter_seek_beginning;
+                               can_seek_beginning_method = cc_full_descr->methods.filter.msg_iter_can_seek_beginning;
+                       }
+
+                       msg_iter_class = bt_message_iterator_class_create(next_method);
+                       if (!msg_iter_class) {
+                               BT_LIB_LOGE_APPEND_CAUSE(
+                                       "Cannot create message iterator class.");
+                               status = BT_FUNC_STATUS_MEMORY_ERROR;
+                               goto end;
+                       }
+
+                       if (init_method) {
+                               ret = bt_message_iterator_class_set_initialize_method(
+                                       msg_iter_class, init_method);
+                               if (ret) {
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set message iterator initialization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
+                                       goto end;
+                               }
+                       }
+
+                       if (fini_method) {
+                               ret = bt_message_iterator_class_set_finalize_method(
+                                       msg_iter_class, fini_method);
+                               if (ret) {
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set message iterator finalization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
+                                       goto end;
+                               }
+                       }
+
+                       if (seek_ns_from_origin_method) {
+                               ret = bt_message_iterator_class_set_seek_ns_from_origin_methods(
+                                       msg_iter_class,
+                                       seek_ns_from_origin_method,
+                                       can_seek_ns_from_origin_method);
+                               if (ret) {
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set message iterator \"seek nanoseconds from origin\" methods.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
+                                       goto end;
+                               }
+                       }
+
+                       if (seek_beginning_method) {
+                               ret = bt_message_iterator_class_set_seek_beginning_methods(
+                                       msg_iter_class,
+                                       seek_beginning_method,
+                                       can_seek_beginning_method);
+                               if (ret) {
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set message iterator \"seek beginning\" methods.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
+                                       goto end;
+                               }
+                       }
+               }
+
                switch (cc_full_descr->descriptor->type) {
                case BT_COMPONENT_CLASS_TYPE_SOURCE:
+                       BT_ASSERT(msg_iter_class);
+
                        src_comp_class = bt_component_class_source_create(
-                               cc_full_descr->descriptor->name,
-                               cc_full_descr->descriptor->methods.source.msg_iter_next);
+                               cc_full_descr->descriptor->name, msg_iter_class);
                        comp_class = bt_component_class_source_as_component_class(
                                src_comp_class);
                        break;
                case BT_COMPONENT_CLASS_TYPE_FILTER:
+                       BT_ASSERT(msg_iter_class);
+
                        flt_comp_class = bt_component_class_filter_create(
-                               cc_full_descr->descriptor->name,
-                               cc_full_descr->descriptor->methods.source.msg_iter_next);
+                               cc_full_descr->descriptor->name, msg_iter_class);
                        comp_class = bt_component_class_filter_as_component_class(
                                flt_comp_class);
                        break;
                case BT_COMPONENT_CLASS_TYPE_SINK:
+                       BT_ASSERT(!msg_iter_class);
+
                        sink_comp_class = bt_component_class_sink_create(
                                cc_full_descr->descriptor->name,
                                cc_full_descr->descriptor->methods.sink.consume);
@@ -751,37 +881,57 @@ enum bt_plugin_status bt_plugin_so_init(
                                sink_comp_class);
                        break;
                default:
-                       /*
-                        * WARN-level logging because this should not
-                        * happen with the appropriate ABI version. If
-                        * we're here, we know that for the reported
-                        * version of the ABI, this component class type
-                        * is unknown.
-                        */
-                       BT_LOGW("Ignoring unknown component class type: "
-                               "plugin-path=\"%s\", plugin-name=\"%s\", "
-                               "comp-class-name=\"%s\", comp-class-type=%d",
-                               spec->shared_lib_handle->path->str ?
-                                       spec->shared_lib_handle->path->str :
-                                       NULL,
-                               descriptor->name,
-                               cc_full_descr->descriptor->name,
-                               cc_full_descr->descriptor->type);
-                       continue;
+                       if (fail_on_load_error) {
+                               BT_LIB_LOGW_APPEND_CAUSE(
+                                       "Unknown component class type: "
+                                       "plugin-path=\"%s\", plugin-name=\"%s\", "
+                                       "comp-class-name=\"%s\", comp-class-type=%d",
+                                       spec->shared_lib_handle->path->str ?
+                                               spec->shared_lib_handle->path->str :
+                                               NULL,
+                                       descriptor->name,
+                                       cc_full_descr->descriptor->name,
+                                       cc_full_descr->descriptor->type);
+                               status = BT_FUNC_STATUS_ERROR;
+                               goto end;
+                       } else {
+                               BT_LIB_LOGW(
+                                       "Ignoring unknown component class type: "
+                                       "plugin-path=\"%s\", plugin-name=\"%s\", "
+                                       "comp-class-name=\"%s\", comp-class-type=%d",
+                                       spec->shared_lib_handle->path->str ?
+                                               spec->shared_lib_handle->path->str :
+                                               NULL,
+                                       descriptor->name,
+                                       cc_full_descr->descriptor->name,
+                                       cc_full_descr->descriptor->type);
+                               continue;
+                       }
                }
 
                if (!comp_class) {
-                       BT_LOGE_STR("Cannot create component class.");
-                       status = BT_PLUGIN_STATUS_ERROR;
+                       BT_LIB_LOGE_APPEND_CAUSE(
+                               "Cannot create component class.");
+                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                        goto end;
                }
 
+               /*
+                * The component class has taken a reference on the message
+                * iterator class, so we can drop ours.  The message iterator
+                * class will get destroyed at the same time as the component
+                * class.
+                */
+               bt_message_iterator_class_put_ref(msg_iter_class);
+               msg_iter_class = NULL;
+
                if (cc_full_descr->description) {
                        ret = bt_component_class_set_description(
                                comp_class, cc_full_descr->description);
                        if (ret) {
-                               BT_LOGE_STR("Cannot set component class's description.");
-                               status = BT_PLUGIN_STATUS_ERROR;
+                               BT_LIB_LOGE_APPEND_CAUSE(
+                                       "Cannot set component class's description.");
+                               status = BT_FUNC_STATUS_MEMORY_ERROR;
                                BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
@@ -791,8 +941,9 @@ enum bt_plugin_status bt_plugin_so_init(
                        ret = bt_component_class_set_help(comp_class,
                                cc_full_descr->help);
                        if (ret) {
-                               BT_LOGE_STR("Cannot set component class's help string.");
-                               status = BT_PLUGIN_STATUS_ERROR;
+                               BT_LIB_LOGE_APPEND_CAUSE(
+                                       "Cannot set component class's help string.");
+                               status = BT_FUNC_STATUS_MEMORY_ERROR;
                                BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                                goto end;
                        }
@@ -800,13 +951,27 @@ enum bt_plugin_status bt_plugin_so_init(
 
                switch (cc_full_descr->descriptor->type) {
                case BT_COMPONENT_CLASS_TYPE_SOURCE:
+                       if (cc_full_descr->methods.source.get_supported_mip_versions) {
+                               ret = bt_component_class_source_set_get_supported_mip_versions_method(
+                                       src_comp_class,
+                                       cc_full_descr->methods.source.get_supported_mip_versions);
+                               if (ret) {
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set source component class's \"get supported MIP versions\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
+                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+                                       goto end;
+                               }
+                       }
+
                        if (cc_full_descr->methods.source.init) {
-                               ret = bt_component_class_source_set_init_method(
+                               ret = bt_component_class_source_set_initialize_method(
                                        src_comp_class,
                                        cc_full_descr->methods.source.init);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's initialization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set source component class's initialization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
                                        goto end;
                                }
@@ -817,8 +982,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        src_comp_class,
                                        cc_full_descr->methods.source.finalize);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's finalization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set source component class's finalization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
                                        goto end;
                                }
@@ -829,8 +995,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        src_comp_class,
                                        cc_full_descr->methods.source.query);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's query method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set source component class's query method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
                                        goto end;
                                }
@@ -841,94 +1008,37 @@ enum bt_plugin_status bt_plugin_so_init(
                                        src_comp_class,
                                        cc_full_descr->methods.source.output_port_connected);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's \"output port connected\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set source component class's \"output port connected\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
                                        goto end;
                                }
                        }
 
-                       if (cc_full_descr->methods.source.msg_iter_init) {
-                               ret = bt_component_class_source_set_message_iterator_init_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_init);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's message iterator initialization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.source.msg_iter_finalize) {
-                               ret = bt_component_class_source_set_message_iterator_finalize_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_finalize);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's message iterator finalization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.source.msg_iter_seek_ns_from_origin) {
-                               ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_seek_ns_from_origin);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's message iterator \"seek nanoseconds from origin\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.source.msg_iter_seek_beginning) {
-                               ret = bt_component_class_source_set_message_iterator_seek_beginning_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_seek_beginning);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's message iterator \"seek beginning\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin) {
-                               ret = bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's message iterator \"can seek nanoseconds from origin\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.source.msg_iter_can_seek_beginning) {
-                               ret = bt_component_class_source_set_message_iterator_can_seek_beginning_method(
-                                       src_comp_class,
-                                       cc_full_descr->methods.source.msg_iter_can_seek_beginning);
+                       break;
+               case BT_COMPONENT_CLASS_TYPE_FILTER:
+                       if (cc_full_descr->methods.filter.get_supported_mip_versions) {
+                               ret = bt_component_class_filter_set_get_supported_mip_versions_method(
+                                       flt_comp_class,
+                                       cc_full_descr->methods.filter.get_supported_mip_versions);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set source component class's message iterator \"can seek beginning\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set filter component class's \"get supported MIP versions\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
+                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
                                }
                        }
 
-                       break;
-               case BT_COMPONENT_CLASS_TYPE_FILTER:
                        if (cc_full_descr->methods.filter.init) {
-                               ret = bt_component_class_filter_set_init_method(
+                               ret = bt_component_class_filter_set_initialize_method(
                                        flt_comp_class,
                                        cc_full_descr->methods.filter.init);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's initialization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set filter component class's initialization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
                                }
@@ -939,8 +1049,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        flt_comp_class,
                                        cc_full_descr->methods.filter.finalize);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's finalization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set filter component class's finalization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
                                }
@@ -951,8 +1062,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        flt_comp_class,
                                        cc_full_descr->methods.filter.query);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's query method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set filter component class's query method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
                                }
@@ -963,8 +1075,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        flt_comp_class,
                                        cc_full_descr->methods.filter.input_port_connected);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's \"input port connected\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set filter component class's \"input port connected\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
                                }
@@ -975,94 +1088,37 @@ enum bt_plugin_status bt_plugin_so_init(
                                        flt_comp_class,
                                        cc_full_descr->methods.filter.output_port_connected);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's \"output port connected\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.filter.msg_iter_init) {
-                               ret = bt_component_class_filter_set_message_iterator_init_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_init);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's message iterator initialization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.filter.msg_iter_finalize) {
-                               ret = bt_component_class_filter_set_message_iterator_finalize_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_finalize);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's message iterator finalization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin) {
-                               ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's message iterator \"seek nanoseconds from origin\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.filter.msg_iter_seek_beginning) {
-                               ret = bt_component_class_filter_set_message_iterator_seek_beginning_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_seek_beginning);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's message iterator \"seek beginning\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
-                                       goto end;
-                               }
-                       }
-
-                       if (cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin) {
-                               ret = bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin);
-                               if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's message iterator \"can seek nanoseconds from origin\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set filter component class's \"output port connected\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
                                        goto end;
                                }
                        }
 
-                       if (cc_full_descr->methods.filter.msg_iter_can_seek_beginning) {
-                               ret = bt_component_class_filter_set_message_iterator_can_seek_beginning_method(
-                                       flt_comp_class,
-                                       cc_full_descr->methods.filter.msg_iter_can_seek_beginning);
+                       break;
+               case BT_COMPONENT_CLASS_TYPE_SINK:
+                       if (cc_full_descr->methods.sink.get_supported_mip_versions) {
+                               ret = bt_component_class_sink_set_get_supported_mip_versions_method(
+                                       sink_comp_class,
+                                       cc_full_descr->methods.sink.get_supported_mip_versions);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set filter component class's message iterator \"can seek beginning\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
-                                       BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set sink component class's \"get supported MIP versions\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
+                                       BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
                                        goto end;
                                }
                        }
 
-                       break;
-               case BT_COMPONENT_CLASS_TYPE_SINK:
                        if (cc_full_descr->methods.sink.init) {
-                               ret = bt_component_class_sink_set_init_method(
+                               ret = bt_component_class_sink_set_initialize_method(
                                        sink_comp_class,
                                        cc_full_descr->methods.sink.init);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set sink component class's initialization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set sink component class's initialization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
                                        goto end;
                                }
@@ -1073,8 +1129,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        sink_comp_class,
                                        cc_full_descr->methods.sink.finalize);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set sink component class's finalization method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set sink component class's finalization method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
                                        goto end;
                                }
@@ -1085,8 +1142,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        sink_comp_class,
                                        cc_full_descr->methods.sink.query);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set sink component class's query method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set sink component class's query method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
                                        goto end;
                                }
@@ -1097,8 +1155,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        sink_comp_class,
                                        cc_full_descr->methods.sink.input_port_connected);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set sink component class's \"input port connected\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set sink component class's \"input port connected\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
                                        goto end;
                                }
@@ -1109,8 +1168,9 @@ enum bt_plugin_status bt_plugin_so_init(
                                        sink_comp_class,
                                        cc_full_descr->methods.sink.graph_is_configured);
                                if (ret) {
-                                       BT_LOGE_STR("Cannot set sink component class's \"graph is configured\" method.");
-                                       status = BT_PLUGIN_STATUS_ERROR;
+                                       BT_LIB_LOGE_APPEND_CAUSE(
+                                               "Cannot set sink component class's \"graph is configured\" method.");
+                                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                                        BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
                                        goto end;
                                }
@@ -1118,7 +1178,7 @@ enum bt_plugin_status bt_plugin_so_init(
 
                        break;
                default:
-                       abort();
+                       bt_common_abort();
                }
 
                /*
@@ -1133,12 +1193,14 @@ enum bt_plugin_status bt_plugin_so_init(
                        (void *) comp_class);
                BT_OBJECT_PUT_REF_AND_RESET(comp_class);
                if (status < 0) {
-                       BT_LOGE("Cannot add component class to plugin.");
+                       BT_LIB_LOGE_APPEND_CAUSE(
+                               "Cannot add component class to plugin.");
                        goto end;
                }
        }
 
 end:
+       bt_message_iterator_class_put_ref(msg_iter_class);
        g_array_free(comp_class_full_descriptors, TRUE);
        return status;
 }
@@ -1158,13 +1220,14 @@ struct bt_plugin *bt_plugin_so_create_empty(
        plugin->destroy_spec_data = bt_plugin_so_destroy_spec_data;
        plugin->spec_data = g_new0(struct bt_plugin_so_spec_data, 1);
        if (!plugin->spec_data) {
-               BT_LOGE_STR("Failed to allocate one SO plugin specific data structure.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one SO plugin specific data structure.");
                goto error;
        }
 
        spec = plugin->spec_data;
        spec->shared_lib_handle = shared_lib_handle;
-       bt_object_get_no_null_check(spec->shared_lib_handle);
+       bt_object_get_ref_no_null_check(spec->shared_lib_handle);
        goto end;
 
 error:
@@ -1192,8 +1255,9 @@ size_t count_non_null_items_in_section(const void *begin, const void *end)
 }
 
 static
-struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
+int bt_plugin_so_create_all_from_sections(
                struct bt_plugin_so_shared_lib_handle *shared_lib_handle,
+               bool fail_on_load_error,
                struct __bt_plugin_descriptor const * const *descriptors_begin,
                struct __bt_plugin_descriptor const * const *descriptors_end,
                struct __bt_plugin_descriptor_attribute const * const *attrs_begin,
@@ -1201,20 +1265,23 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
                struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_begin,
                struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_end,
                struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_begin,
-               struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end)
+               struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end,
+               struct bt_plugin_set **plugin_set_out)
 {
+       int status = BT_FUNC_STATUS_OK;
        size_t descriptor_count;
        size_t attrs_count;
        size_t cc_descriptors_count;
        size_t cc_descr_attrs_count;
        size_t i;
-       struct bt_plugin_set *plugin_set = NULL;
 
+       BT_ASSERT(shared_lib_handle);
+       BT_ASSERT(plugin_set_out);
+       *plugin_set_out = NULL;
        descriptor_count = count_non_null_items_in_section(descriptors_begin, descriptors_end);
        attrs_count = count_non_null_items_in_section(attrs_begin, attrs_end);
        cc_descriptors_count = count_non_null_items_in_section(cc_descriptors_begin, cc_descriptors_end);
        cc_descr_attrs_count =  count_non_null_items_in_section(cc_descr_attrs_begin, cc_descr_attrs_end);
-
        BT_LOGI("Creating all SO plugins from sections: "
                "plugin-path=\"%s\", "
                "descr-begin-addr=%p, descr-end-addr=%p, "
@@ -1230,94 +1297,97 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
                cc_descr_attrs_begin, cc_descr_attrs_end,
                descriptor_count, attrs_count,
                cc_descriptors_count, cc_descr_attrs_count);
-       plugin_set = bt_plugin_set_create();
-       if (!plugin_set) {
-               BT_LOGE_STR("Cannot create empty plugin set.");
+       *plugin_set_out = bt_plugin_set_create();
+       if (!*plugin_set_out) {
+               BT_LIB_LOGE_APPEND_CAUSE("Cannot create empty plugin set.");
+               status = BT_FUNC_STATUS_MEMORY_ERROR;
                goto error;
        }
 
        for (i = 0; i < descriptors_end - descriptors_begin; i++) {
-               enum bt_plugin_status status;
                const struct __bt_plugin_descriptor *descriptor =
                        descriptors_begin[i];
                struct bt_plugin *plugin;
 
-               if (descriptor == NULL) {
+               if (!descriptor) {
                        continue;
                }
 
-               BT_LOGI("Creating plugin object for plugin: "
-                       "name=\"%s\", abi-major=%d, abi-minor=%d",
-                       descriptor->name, descriptor->major, descriptor->minor);
-
-               if (descriptor->major > __BT_PLUGIN_VERSION_MAJOR) {
-                       /*
-                        * INFO-level logging because we're only
-                        * _trying_ to open this file as a compatible
-                        * Babeltrace plugin: if it's not, it's not an
-                        * error. And because this can be tried during
-                        * bt_plugin_find_all_from_dir(), it's not even
-                        * a warning.
-                        */
-                       BT_LOGI("Unknown ABI major version: abi-major=%d",
-                               descriptor->major);
-                       goto error;
-               }
-
+               BT_LOGI("Creating plugin object for plugin: name=\"%s\"",
+                       descriptor->name);
                plugin = bt_plugin_so_create_empty(shared_lib_handle);
                if (!plugin) {
-                       BT_LOGE_STR("Cannot create empty shared library handle.");
+                       BT_LIB_LOGE_APPEND_CAUSE(
+                               "Cannot create empty shared library handle.");
+                       status = BT_FUNC_STATUS_MEMORY_ERROR;
                        goto error;
                }
 
-               if (shared_lib_handle && shared_lib_handle->path) {
-                       bt_plugin_set_path(plugin, shared_lib_handle->path->str);
+               if (shared_lib_handle->path) {
+                       bt_plugin_set_path(plugin,
+                               shared_lib_handle->path->str);
                }
 
-               status = bt_plugin_so_init(plugin, descriptor, attrs_begin,
-                       attrs_end, cc_descriptors_begin, cc_descriptors_end,
+               status = bt_plugin_so_init(plugin, fail_on_load_error,
+                       descriptor, attrs_begin, attrs_end,
+                       cc_descriptors_begin, cc_descriptors_end,
                        cc_descr_attrs_begin, cc_descr_attrs_end);
-               if (status < 0) {
+               if (status == BT_FUNC_STATUS_OK) {
+                       /* Add to plugin set */
+                       bt_plugin_set_add_plugin(*plugin_set_out, plugin);
+                       BT_OBJECT_PUT_REF_AND_RESET(plugin);
+               } else if (status < 0) {
                        /*
-                        * DEBUG-level logging because we're only
-                        * _trying_ to open this file as a compatible
-                        * Babeltrace plugin: if it's not, it's not an
-                        * error. And because this can be tried during
-                        * bt_plugin_find_all_from_dir(), it's not
-                        * even a warning.
+                        * bt_plugin_so_init() handles
+                        * `fail_on_load_error`, so this is a "real"
+                        * error.
                         */
-                       BT_LOGD_STR("Cannot initialize SO plugin object from sections.");
+                       BT_LIB_LOGW_APPEND_CAUSE(
+                               "Cannot initialize SO plugin object from sections.");
                        BT_OBJECT_PUT_REF_AND_RESET(plugin);
                        goto error;
                }
 
-               /* Add to plugin set */
-               bt_plugin_set_add_plugin(plugin_set, plugin);
-               bt_object_put_ref(plugin);
+               BT_ASSERT(!plugin);
+       }
+
+       BT_ASSERT(*plugin_set_out);
+
+       if ((*plugin_set_out)->plugins->len == 0) {
+               BT_OBJECT_PUT_REF_AND_RESET(*plugin_set_out);
+               status = BT_FUNC_STATUS_NOT_FOUND;
        }
 
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
+       BT_ASSERT(status < 0);
+       BT_OBJECT_PUT_REF_AND_RESET(*plugin_set_out);
 
 end:
-       return plugin_set;
+       return status;
 }
 
 BT_HIDDEN
-struct bt_plugin_set *bt_plugin_so_create_all_from_static(void)
+int bt_plugin_so_create_all_from_static(bool fail_on_load_error,
+               struct bt_plugin_set **plugin_set_out)
 {
-       struct bt_plugin_set *plugin_set = NULL;
-       struct bt_plugin_so_shared_lib_handle *shared_lib_handle =
-               bt_plugin_so_shared_lib_handle_create(NULL);
+       int status;
+       struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
 
-       if (!shared_lib_handle) {
+       BT_ASSERT(plugin_set_out);
+       *plugin_set_out = NULL;
+       status = bt_plugin_so_shared_lib_handle_create(NULL,
+               &shared_lib_handle);
+       if (status != BT_FUNC_STATUS_OK) {
+               BT_ASSERT(!shared_lib_handle);
                goto end;
        }
 
+       BT_ASSERT(shared_lib_handle);
        BT_LOGD_STR("Creating all SO plugins from built-in plugins.");
-       plugin_set = bt_plugin_so_create_all_from_sections(shared_lib_handle,
+       status = bt_plugin_so_create_all_from_sections(shared_lib_handle,
+               fail_on_load_error,
                __bt_get_begin_section_plugin_descriptors(),
                __bt_get_end_section_plugin_descriptors(),
                __bt_get_begin_section_plugin_descriptor_attributes(),
@@ -1325,19 +1395,22 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_static(void)
                __bt_get_begin_section_component_class_descriptors(),
                __bt_get_end_section_component_class_descriptors(),
                __bt_get_begin_section_component_class_descriptor_attributes(),
-               __bt_get_end_section_component_class_descriptor_attributes());
+               __bt_get_end_section_component_class_descriptor_attributes(),
+               plugin_set_out);
+       BT_ASSERT((status == BT_FUNC_STATUS_OK && *plugin_set_out &&
+               (*plugin_set_out)->plugins->len > 0) || !*plugin_set_out);
 
 end:
        BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
-
-       return plugin_set;
+       return status;
 }
 
 BT_HIDDEN
-struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
+int bt_plugin_so_create_all_from_file(const char *path,
+               bool fail_on_load_error, struct bt_plugin_set **plugin_set_out)
 {
        size_t path_len;
-       struct bt_plugin_set *plugin_set = NULL;
+       int status;
        struct __bt_plugin_descriptor const * const *descriptors_begin = NULL;
        struct __bt_plugin_descriptor const * const *descriptors_end = NULL;
        struct __bt_plugin_descriptor_attribute const * const *attrs_begin = NULL;
@@ -1358,10 +1431,22 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
        struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
 
        BT_ASSERT(path);
+       BT_ASSERT(plugin_set_out);
+       *plugin_set_out = NULL;
        path_len = strlen(path);
-       BT_ASSERT_PRE(path_len > PLUGIN_SUFFIX_LEN,
-               "Path length is too short: path-length=%zu, min-length=%zu",
-               path_len, PLUGIN_SUFFIX_LEN);
+
+       /*
+        * An SO plugin file must have a known plugin file suffix. So the file
+        * path must be longer than the suffix length.
+        */
+       if (path_len <= PLUGIN_SUFFIX_LEN) {
+               BT_LOGI("Path is too short to be an `.so` or `.la` plugin file:"
+                       "path=%s, path-length=%zu, min-length=%zu",
+                       path, path_len, PLUGIN_SUFFIX_LEN);
+               status = BT_FUNC_STATUS_NOT_FOUND;
+               goto end;
+       }
+
        BT_LOGI("Trying to create all SO plugins from file: path=\"%s\"", path);
        path_len++;
 
@@ -1377,14 +1462,16 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
                NATIVE_PLUGIN_SUFFIX_LEN);
        if (!is_shared_object && !is_libtool_wrapper) {
                /* Name indicates this is not a plugin file; not an error */
-               BT_LOGI("File is not a SO plugin file: path=\"%s\"", path);
+               BT_LOGI("File is not an SO plugin file: path=\"%s\"", path);
+               status = BT_FUNC_STATUS_NOT_FOUND;
                goto end;
        }
 
-       shared_lib_handle = bt_plugin_so_shared_lib_handle_create(path);
-       if (!shared_lib_handle) {
+       status = bt_plugin_so_shared_lib_handle_create(path,
+               &shared_lib_handle);
+       if (status != BT_FUNC_STATUS_OK) {
                /* bt_plugin_so_shared_lib_handle_create() logs more details */
-               BT_LOGD_STR("Cannot create shared library handle.");
+               BT_ASSERT(!shared_lib_handle);
                goto end;
        }
 
@@ -1392,19 +1479,41 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
                        (gpointer *) &get_begin_section_plugin_descriptors)) {
                descriptors_begin = get_begin_section_plugin_descriptors();
        } else {
+               /*
+                * Use this first symbol to know whether or not this
+                * shared object _looks like_ a Babeltrace plugin. Since
+                * g_module_symbol() failed, assume that this is not a
+                * Babeltrace plugin, so it's not an error.
+                */
                BT_LOGI("Cannot resolve plugin symbol: path=\"%s\", "
                        "symbol=\"%s\"", path,
                        "__bt_get_begin_section_plugin_descriptors");
+               status = BT_FUNC_STATUS_NOT_FOUND;
                goto end;
        }
 
+       /*
+        * If g_module_symbol() fails for any of the other symbols, fail
+        * if `fail_on_load_error` is true.
+        */
        if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_plugin_descriptors",
                        (gpointer *) &get_end_section_plugin_descriptors)) {
                descriptors_end = get_end_section_plugin_descriptors();
        } else {
-               BT_LOGI("Cannot resolve plugin symbol: path=\"%s\", "
-                       "symbol=\"%s\"", path,
-                       "__bt_get_end_section_plugin_descriptors");
+               if (fail_on_load_error) {
+                       BT_LIB_LOGW_APPEND_CAUSE(
+                               "Cannot resolve plugin symbol: path=\"%s\", "
+                               "symbol=\"%s\"", path,
+                               "__bt_get_end_section_plugin_descriptors");
+                       status = BT_FUNC_STATUS_ERROR;
+               } else {
+                       BT_LIB_LOGW(
+                               "Cannot resolve plugin symbol: path=\"%s\", "
+                               "symbol=\"%s\"", path,
+                               "__bt_get_end_section_plugin_descriptors");
+                       status = BT_FUNC_STATUS_NOT_FOUND;
+               }
+
                goto end;
        }
 
@@ -1427,13 +1536,28 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
        }
 
        if ((!!attrs_begin - !!attrs_end) != 0) {
-               BT_LOGI("Found section start or end symbol, but not both: "
-                       "path=\"%s\", symbol-start=\"%s\", "
-                       "symbol-end=\"%s\", symbol-start-addr=%p, "
-                       "symbol-end-addr=%p",
-                       path, "__bt_get_begin_section_plugin_descriptor_attributes",
-                       "__bt_get_end_section_plugin_descriptor_attributes",
-                       attrs_begin, attrs_end);
+               if (fail_on_load_error) {
+                       BT_LIB_LOGW_APPEND_CAUSE(
+                               "Found section start or end symbol, but not both: "
+                               "path=\"%s\", symbol-start=\"%s\", "
+                               "symbol-end=\"%s\", symbol-start-addr=%p, "
+                               "symbol-end-addr=%p",
+                               path, "__bt_get_begin_section_plugin_descriptor_attributes",
+                               "__bt_get_end_section_plugin_descriptor_attributes",
+                               attrs_begin, attrs_end);
+                       status = BT_FUNC_STATUS_ERROR;
+               } else {
+                       BT_LIB_LOGW(
+                               "Found section start or end symbol, but not both: "
+                               "path=\"%s\", symbol-start=\"%s\", "
+                               "symbol-end=\"%s\", symbol-start-addr=%p, "
+                               "symbol-end-addr=%p",
+                               path, "__bt_get_begin_section_plugin_descriptor_attributes",
+                               "__bt_get_end_section_plugin_descriptor_attributes",
+                               attrs_begin, attrs_end);
+                       status = BT_FUNC_STATUS_NOT_FOUND;
+               }
+
                goto end;
        }
 
@@ -1456,13 +1580,28 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
        }
 
        if ((!!cc_descriptors_begin - !!cc_descriptors_end) != 0) {
-               BT_LOGI("Found section start or end symbol, but not both: "
-                       "path=\"%s\", symbol-start=\"%s\", "
-                       "symbol-end=\"%s\", symbol-start-addr=%p, "
-                       "symbol-end-addr=%p",
-                       path, "__bt_get_begin_section_component_class_descriptors",
-                       "__bt_get_end_section_component_class_descriptors",
-                       cc_descriptors_begin, cc_descriptors_end);
+               if (fail_on_load_error) {
+                       BT_LIB_LOGW_APPEND_CAUSE(
+                               "Found section start or end symbol, but not both: "
+                               "path=\"%s\", symbol-start=\"%s\", "
+                               "symbol-end=\"%s\", symbol-start-addr=%p, "
+                               "symbol-end-addr=%p",
+                               path, "__bt_get_begin_section_component_class_descriptors",
+                               "__bt_get_end_section_component_class_descriptors",
+                               cc_descriptors_begin, cc_descriptors_end);
+                       status = BT_FUNC_STATUS_ERROR;
+               } else {
+                       BT_LIB_LOGW(
+                               "Found section start or end symbol, but not both: "
+                               "path=\"%s\", symbol-start=\"%s\", "
+                               "symbol-end=\"%s\", symbol-start-addr=%p, "
+                               "symbol-end-addr=%p",
+                               path, "__bt_get_begin_section_component_class_descriptors",
+                               "__bt_get_end_section_component_class_descriptors",
+                               cc_descriptors_begin, cc_descriptors_end);
+                       status = BT_FUNC_STATUS_NOT_FOUND;
+               }
+
                goto end;
        }
 
@@ -1485,26 +1624,42 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
        }
 
        if ((!!cc_descr_attrs_begin - !!cc_descr_attrs_end) != 0) {
-               BT_LOGI("Found section start or end symbol, but not both: "
-                       "path=\"%s\", symbol-start=\"%s\", "
-                       "symbol-end=\"%s\", symbol-start-addr=%p, "
-                       "symbol-end-addr=%p",
-                       path, "__bt_get_begin_section_component_class_descriptor_attributes",
-                       "__bt_get_end_section_component_class_descriptor_attributes",
-                       cc_descr_attrs_begin, cc_descr_attrs_end);
+               if (fail_on_load_error) {
+                       BT_LIB_LOGW_APPEND_CAUSE(
+                               "Found section start or end symbol, but not both: "
+                               "path=\"%s\", symbol-start=\"%s\", "
+                               "symbol-end=\"%s\", symbol-start-addr=%p, "
+                               "symbol-end-addr=%p",
+                               path, "__bt_get_begin_section_component_class_descriptor_attributes",
+                               "__bt_get_end_section_component_class_descriptor_attributes",
+                               cc_descr_attrs_begin, cc_descr_attrs_end);
+                       status = BT_FUNC_STATUS_ERROR;
+               } else {
+                       BT_LIB_LOGW(
+                               "Found section start or end symbol, but not both: "
+                               "path=\"%s\", symbol-start=\"%s\", "
+                               "symbol-end=\"%s\", symbol-start-addr=%p, "
+                               "symbol-end-addr=%p",
+                               path, "__bt_get_begin_section_component_class_descriptor_attributes",
+                               "__bt_get_end_section_component_class_descriptor_attributes",
+                               cc_descr_attrs_begin, cc_descr_attrs_end);
+                       status = BT_FUNC_STATUS_NOT_FOUND;
+               }
+
                goto end;
        }
 
        /* Initialize plugin */
        BT_LOGD_STR("Initializing plugin object.");
-       plugin_set = bt_plugin_so_create_all_from_sections(shared_lib_handle,
+       status = bt_plugin_so_create_all_from_sections(shared_lib_handle,
+               fail_on_load_error,
                descriptors_begin, descriptors_end, attrs_begin, attrs_end,
                cc_descriptors_begin, cc_descriptors_end,
-               cc_descr_attrs_begin, cc_descr_attrs_end);
+               cc_descr_attrs_begin, cc_descr_attrs_end, plugin_set_out);
 
 end:
        BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
-       return plugin_set;
+       return status;
 }
 
 static
@@ -1527,7 +1682,7 @@ void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
 
        bt_list_add(&comp_class->node, &component_class_list);
        comp_class->so_handle = spec->shared_lib_handle;
-       bt_object_get_no_null_check(comp_class->so_handle);
+       bt_object_get_ref_no_null_check(comp_class->so_handle);
 
        /* Add our custom destroy listener */
        bt_component_class_add_destroy_listener(comp_class,
This page took 0.079114 seconds and 4 git commands to generate.