diff --git a/common/include/villas/kernel/vfio.hpp b/common/include/villas/kernel/vfio.hpp deleted file mode 100644 index 058374134..000000000 --- a/common/include/villas/kernel/vfio.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/** VFIO Kernel module loader - * - * Author: Pascal Bauer - * SPDX-FileCopyrightText: 2017 Institute for Automation of Complex Power Systems, RWTH Aachen University - * SPDX-License-Identifier: Apache-2.0 - *********************************************************************************/ - -//TODO: Move to cmake args -//#define FPGA_PLATFORM -#define FPGA_PCI - -#if defined(FPGA_PLATFORM) -#define KERNEL_MODULE_VFIO -#endif - -#if defined(FPGA_PCI) -#define KERNEL_MODULE_VFIO -#define KERNEL_MODULE_VFIO_PCI -#define KERNEL_MODULE_VFIO_IOMMU_TYPE1 -#endif - -static constexpr const char *const requiredKernelModules[] = { -#if defined(KERNEL_MODULE_VFIO) - "vfio", -#endif // KERNEL_MODULE_VFIO_PCI - -#if defined(KERNEL_MODULE_VFIO_PCI) - "vfio_pci", -#endif // KERNEL_MODULE_VFIO_PCI - -#if defined(KERNEL_MODULE_VFIO_IOMMU_TYPE1) - "vfio_iommu_type1" -#endif // KERNEL_MODULE_VFIO_IOMMU_TYPE1 -}; \ No newline at end of file diff --git a/common/include/villas/kernel/vfio_container.hpp b/common/include/villas/kernel/vfio_container.hpp index 510f5f00e..d728ffc93 100644 --- a/common/include/villas/kernel/vfio_container.hpp +++ b/common/include/villas/kernel/vfio_container.hpp @@ -35,7 +35,7 @@ static constexpr size_t EXTENSION_SIZE = VFIO_NOIOMMU_IOMMU + 1; class Container { public: - Container(); + Container(std::vector required_modules = {"vfio", "vfio_pci", "vfio_iommu_type1"}); // No copying allowed because we manage the vfio state in constructor and destructors Container(Container const &) = delete; diff --git a/common/lib/kernel/vfio_container.cpp b/common/lib/kernel/vfio_container.cpp index 709b8ef51..224c92366 100644 --- a/common/lib/kernel/vfio_container.cpp +++ b/common/lib/kernel/vfio_container.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -65,11 +64,11 @@ static std::array construct_vfio_extension_str() { static std::array VFIO_EXTENSION_STR = construct_vfio_extension_str(); -Container::Container() +Container::Container(std::vector required_modules) : fd(-1), version(0), extensions(), iova_next(0), hasIommu(false), groups(), log(logging.get("kernel:vfio:container")) { - for (const char *module : requiredKernelModules) { - if (kernel::loadModule(module) != 0) { + for (auto module : required_modules) { + if (kernel::loadModule(module.c_str()) != 0) { throw RuntimeError("Kernel module '{}' required but could not be loaded. " "Please load manually!", module);