From 8fea36aa81195d758a29067141afdc4becefe5ae Mon Sep 17 00:00:00 2001 From: Steven Koo Date: Thu, 24 Sep 2020 13:05:34 -0500 Subject: lib: disable non pcie types in find with resource mpmd find doesn't respect the "resource" arg hint and can be detected when "resource" is set. This results in incorrect device selection when using PCIe. This change adds detection for "resource" as a prefix in the device hints for mpmd and the other devices. --- host/lib/types/device_addr.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'host/lib/types') diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp index d5e9ce0d4..3a7f80ed9 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,14 @@ device_addr_t::device_addr_t(const std::map& info) } } +bool device_addr_t::has_key_with_prefix(const std::string& prefix) const +{ + auto dev_keys = this->keys(); + return std::any_of(dev_keys.begin(), dev_keys.end(), [prefix](const auto& key) { + return key.substr(0, prefix.size()) == prefix; + }); +} + std::string device_addr_t::to_pp_string(void) const { if (this->size() == 0) -- cgit v1.2.3