mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Load vfio modules at runtime.
Defines are replaced by constructor parameters. The default parameter makes the function backwards compatible. Signed-off-by: IgnoreWarnings <pascal.bauer@rwth-aachen.de>
This commit is contained in:
parent
7d7e3f8383
commit
fe0bed6f3c
3 changed files with 4 additions and 39 deletions
|
@ -1,34 +0,0 @@
|
|||
/** VFIO Kernel module loader
|
||||
*
|
||||
* Author: Pascal Bauer <pascal.bauer@rwth-aachen.de>
|
||||
* 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
|
||||
};
|
|
@ -35,7 +35,7 @@ static constexpr size_t EXTENSION_SIZE = VFIO_NOIOMMU_IOMMU + 1;
|
|||
|
||||
class Container {
|
||||
public:
|
||||
Container();
|
||||
Container(std::vector<std::string> 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;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include <villas/exceptions.hpp>
|
||||
#include <villas/kernel/kernel.hpp>
|
||||
#include <villas/kernel/vfio.hpp>
|
||||
#include <villas/kernel/vfio_container.hpp>
|
||||
#include <villas/log.hpp>
|
||||
|
||||
|
@ -65,11 +64,11 @@ static std::array<std::string, EXTENSION_SIZE> construct_vfio_extension_str() {
|
|||
static std::array<std::string, EXTENSION_SIZE> VFIO_EXTENSION_STR =
|
||||
construct_vfio_extension_str();
|
||||
|
||||
Container::Container()
|
||||
Container::Container(std::vector<std::string> 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue