mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
make it possible to specify a search path in PcieCard::make so we can use relative paths in config files
Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
parent
c05ae4d282
commit
d9e60e22b1
3 changed files with 24 additions and 8 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
#include <jansson.h>
|
||||
#include <filesystem>
|
||||
|
||||
#include <villas/plugin.hpp>
|
||||
#include <villas/memory.hpp>
|
||||
|
@ -78,8 +79,10 @@ protected:
|
|||
class PCIeCardFactory : public plugin::Plugin {
|
||||
public:
|
||||
|
||||
static
|
||||
std::list<std::shared_ptr<PCIeCard>> make(json_t *json, std::shared_ptr<kernel::pci::DeviceList> pci, std::shared_ptr<kernel::vfio::Container> vc);
|
||||
static std::list<std::shared_ptr<PCIeCard>> make(json_t *json,
|
||||
std::shared_ptr<kernel::pci::DeviceList> pci,
|
||||
std::shared_ptr<kernel::vfio::Container> vc,
|
||||
const std::filesystem::path& searchPath = std::filesystem::path());
|
||||
|
||||
static
|
||||
PCIeCard* make()
|
||||
|
|
|
@ -27,7 +27,10 @@ static PCIeCardFactory PCIeCardFactoryInstance;
|
|||
|
||||
static const kernel::pci::Device defaultFilter((kernel::pci::Id(FPGA_PCI_VID_XILINX, FPGA_PCI_PID_VFPGA)));
|
||||
|
||||
std::list<std::shared_ptr<PCIeCard>> PCIeCardFactory::make(json_t *json, std::shared_ptr<kernel::pci::DeviceList> pci, std::shared_ptr<kernel::vfio::Container> vc)
|
||||
std::list<std::shared_ptr<PCIeCard>> PCIeCardFactory::make(json_t *json,
|
||||
std::shared_ptr<kernel::pci::DeviceList> pci,
|
||||
std::shared_ptr<kernel::vfio::Container> vc,
|
||||
const std::filesystem::path& searchPath)
|
||||
{
|
||||
std::list<std::shared_ptr<PCIeCard>> cards;
|
||||
auto logger = getStaticLogger();
|
||||
|
@ -87,11 +90,19 @@ std::list<std::shared_ptr<PCIeCard>> PCIeCardFactory::make(json_t *json, std::sh
|
|||
}
|
||||
|
||||
// Load IPs from a separate json file
|
||||
if (json_is_string(json_ips)) {
|
||||
auto json_ips_fn = json_string_value(json_ips);
|
||||
json_ips = json_load_file(json_ips_fn, 0, nullptr);
|
||||
if (json_ips == nullptr)
|
||||
throw ConfigError(json_ips, "node-config-fpga-ips", "Failed to load FPGA IP cores from {}", json_ips_fn);
|
||||
if (json_is_string(json_ips) && !searchPath.empty()) {
|
||||
std::filesystem::path json_ips_path = searchPath / json_string_value(json_ips);
|
||||
json_ips = json_load_file(json_ips_path.c_str(), 0, nullptr);
|
||||
if (json_ips == nullptr) {
|
||||
logger->debug("FPGA IP cores config not found in {} looking elsewhere...", json_ips_path);
|
||||
}
|
||||
}
|
||||
if (json_is_string(json_ips) && json_ips == nullptr) {
|
||||
json_ips = json_load_file(json_string_value(json_ips), 0, nullptr);
|
||||
if (json_ips == nullptr) {
|
||||
logger->debug("FPGA IP cores config not found in {}", json_string_value(json_ips));
|
||||
throw ConfigError(json_ips, "node-config-fpga-ips", "Failed to find FPGA IP cores config");
|
||||
}
|
||||
}
|
||||
|
||||
if (not json_is_object(json_ips))
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <algorithm>
|
||||
#include <jansson.h>
|
||||
#include <regex>
|
||||
#include <filesystem>
|
||||
|
||||
#include <CLI11.hpp>
|
||||
#include <rang.hpp>
|
||||
|
@ -168,6 +169,7 @@ fpga::setupFpgaCard(const std::string &configFile, const std::string &fpgaName)
|
|||
pciDevices = std::make_shared<kernel::pci::DeviceList>();
|
||||
|
||||
auto vfioContainer = std::make_shared<kernel::vfio::Container>();
|
||||
auto configDir = std::filesystem::path(configFile).parent_path();
|
||||
|
||||
// Parse FPGA configuration
|
||||
FILE* f = fopen(configFile.c_str(), "r");
|
||||
|
|
Loading…
Add table
Reference in a new issue