Skip to content

Commit

Permalink
CR-1032457 Display warning if OS or Kernel isn't officially supported (
Browse files Browse the repository at this point in the history
  • Loading branch information
AShivangi authored May 12, 2020
1 parent 7992bd3 commit 935acf1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/runtime_src/core/pcie/tools/xbutil/xbutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,35 @@ static int str2index(const char *arg, unsigned& index)
return 0;
}

static bool
check_os_release(const std::vector<std::string> kernel_versions, std::ostream &ostr)
{
const std::string release = sensor_tree::get<std::string>("system.release");
for (const auto& ver : kernel_versions) {
if (release.find(ver) != std::string::npos)
return true;
}
ostr << "WARNING: Kernel verison " << release << " is not officially supported. "
<< kernel_versions.back() << " is the latest supported version" << std::endl;
return false;
}

static bool
is_supported_kernel_version(std::ostream &ostr)
{
std::vector<std::string> ubuntu_kernel_versions =
{ "4.4.0", "4.13.0", "4.15.0", "4.18.0", "5.0.0" };
std::vector<std::string> centos_rh_kernel_versions =
{ "3.10.0-693", "3.10.0-862", "3.10.0-957", "3.10.0-1062" };
const std::string os = sensor_tree::get<std::string>("system.linux", "N/A");

if(os.find("Ubuntu") != std::string::npos)
return check_os_release(ubuntu_kernel_versions, ostr);
else if(os.find("Red Hat") != std::string::npos || os.find("CentOS") != std::string::npos)
return check_os_release(centos_rh_kernel_versions, ostr);

return true;
}

static void print_pci_info(std::ostream &ostr)
{
Expand Down Expand Up @@ -117,6 +146,8 @@ static void print_pci_info(std::ostream &ostr)
ostr << " please also run 'xbmgmt flash --scan --verbose' to further check card details."
<< std::endl;
}

is_supported_kernel_version(ostr);
}

static int xrt_xbutil_version_cmp()
Expand Down Expand Up @@ -1463,6 +1494,19 @@ int xcldev::device::getXclbinuuid(uuid_t &uuid) {

return 0;
}

int xcldev::device::kernelVersionTest(void)
{
if (getenv_or_null("INTERNAL_BUILD")) {
std::cout << "Developer's build. Skipping validation" << std::endl;
return -EOPNOTSUPP;
}
if (!is_supported_kernel_version(std::cout)) {
return 1;
}
return 0;
}

/*
* validate
*/
Expand All @@ -1471,6 +1515,12 @@ int xcldev::device::validate(bool quick)
bool withWarning = false;
int retVal = 0;

retVal = runOneTest("Kernel version check",
std::bind(&xcldev::device::kernelVersionTest, this));
withWarning = withWarning || (retVal == 1);
if (retVal < 0)
return retVal;

retVal = runOneTest("AUX power connector check",
std::bind(&xcldev::device::auxConnectionTest, this));
withWarning = withWarning || (retVal == 1);
Expand Down
1 change: 1 addition & 0 deletions src/runtime_src/core/pcie/tools/xbutil/xbutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ class device {
int auxConnectionTest(void);
int verifyKernelTest(void);
int bandwidthKernelTest(void);
int kernelVersionTest(void);
// testFunc must return 0 for success, 1 for warning, and < 0 for error
int runOneTest(std::string testName, std::function<int(void)> testFunc);

Expand Down

0 comments on commit 935acf1

Please sign in to comment.