diff mbox series

[v2,1/4] kernel-shark: Define addPlugins method for KsPluginManager

Message ID 20190313150717.21345-2-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit f053ff6ae15343d3d8950f4ef66f7221b6170514
Headers show
Series Add dialog for loading user-defined plugins | expand

Commit Message

Yordan Karadzhov March 13, 2019, 3:07 p.m. UTC
The method can be used to register and load user-defined plugins.
All other previously loaded plugins will be reinitialized and the
data will be reloaded.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsUtils.cpp | 23 +++++++++++++++++++++++
 kernel-shark/src/KsUtils.hpp |  3 +++
 2 files changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp
index 3585cca..6af0c66 100644
--- a/kernel-shark/src/KsUtils.cpp
+++ b/kernel-shark/src/KsUtils.cpp
@@ -596,6 +596,29 @@  void KsPluginManager::unregisterPlugin(const QString &plugin)
 	}
 }
 
+/** @brief Add to the list and initialize user-provided plugins. All other
+ *	   previously loaded plugins will be reinitialized and the data will be
+ *	   reloaded.
+ *
+ * @param fileNames: the library files (.so) of the plugins.
+*/
+void KsPluginManager::addPlugins(const QStringList &fileNames)
+{
+	kshark_context *kshark_ctx(nullptr);
+
+	if (!kshark_instance(&kshark_ctx))
+		return;
+
+	kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_CLOSE);
+
+	for (auto const &p: fileNames)
+		registerPlugin(p);
+
+	kshark_handle_plugins(kshark_ctx, KSHARK_PLUGIN_INIT);
+
+	emit dataReload();
+}
+
 /** Unload all plugins. */
 void KsPluginManager::unloadAll()
 {
diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp
index cb95b4f..c8b5e88 100644
--- a/kernel-shark/src/KsUtils.hpp
+++ b/kernel-shark/src/KsUtils.hpp
@@ -210,6 +210,9 @@  public:
 
 	void registerPlugin(const QString &plugin);
 	void unregisterPlugin(const QString &plugin);
+
+	void addPlugins(const QStringList &fileNames);
+
 	void unloadAll();
 
 	void updatePlugins(QVector<int> pluginId);