Skip to content

Commit 935acf1

Browse files
authored
CR-1032457 Display warning if OS or Kernel isn't officially supported (#3373)
1 parent 7992bd3 commit 935acf1

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/runtime_src/core/pcie/tools/xbutil/xbutil.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,35 @@ static int str2index(const char *arg, unsigned& index)
8989
return 0;
9090
}
9191

92+
static bool
93+
check_os_release(const std::vector<std::string> kernel_versions, std::ostream &ostr)
94+
{
95+
const std::string release = sensor_tree::get<std::string>("system.release");
96+
for (const auto& ver : kernel_versions) {
97+
if (release.find(ver) != std::string::npos)
98+
return true;
99+
}
100+
ostr << "WARNING: Kernel verison " << release << " is not officially supported. "
101+
<< kernel_versions.back() << " is the latest supported version" << std::endl;
102+
return false;
103+
}
104+
105+
static bool
106+
is_supported_kernel_version(std::ostream &ostr)
107+
{
108+
std::vector<std::string> ubuntu_kernel_versions =
109+
{ "4.4.0", "4.13.0", "4.15.0", "4.18.0", "5.0.0" };
110+
std::vector<std::string> centos_rh_kernel_versions =
111+
{ "3.10.0-693", "3.10.0-862", "3.10.0-957", "3.10.0-1062" };
112+
const std::string os = sensor_tree::get<std::string>("system.linux", "N/A");
113+
114+
if(os.find("Ubuntu") != std::string::npos)
115+
return check_os_release(ubuntu_kernel_versions, ostr);
116+
else if(os.find("Red Hat") != std::string::npos || os.find("CentOS") != std::string::npos)
117+
return check_os_release(centos_rh_kernel_versions, ostr);
118+
119+
return true;
120+
}
92121

93122
static void print_pci_info(std::ostream &ostr)
94123
{
@@ -117,6 +146,8 @@ static void print_pci_info(std::ostream &ostr)
117146
ostr << " please also run 'xbmgmt flash --scan --verbose' to further check card details."
118147
<< std::endl;
119148
}
149+
150+
is_supported_kernel_version(ostr);
120151
}
121152

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

14641495
return 0;
14651496
}
1497+
1498+
int xcldev::device::kernelVersionTest(void)
1499+
{
1500+
if (getenv_or_null("INTERNAL_BUILD")) {
1501+
std::cout << "Developer's build. Skipping validation" << std::endl;
1502+
return -EOPNOTSUPP;
1503+
}
1504+
if (!is_supported_kernel_version(std::cout)) {
1505+
return 1;
1506+
}
1507+
return 0;
1508+
}
1509+
14661510
/*
14671511
* validate
14681512
*/
@@ -1471,6 +1515,12 @@ int xcldev::device::validate(bool quick)
14711515
bool withWarning = false;
14721516
int retVal = 0;
14731517

1518+
retVal = runOneTest("Kernel version check",
1519+
std::bind(&xcldev::device::kernelVersionTest, this));
1520+
withWarning = withWarning || (retVal == 1);
1521+
if (retVal < 0)
1522+
return retVal;
1523+
14741524
retVal = runOneTest("AUX power connector check",
14751525
std::bind(&xcldev::device::auxConnectionTest, this));
14761526
withWarning = withWarning || (retVal == 1);

src/runtime_src/core/pcie/tools/xbutil/xbutil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,7 @@ class device {
17641764
int auxConnectionTest(void);
17651765
int verifyKernelTest(void);
17661766
int bandwidthKernelTest(void);
1767+
int kernelVersionTest(void);
17671768
// testFunc must return 0 for success, 1 for warning, and < 0 for error
17681769
int runOneTest(std::string testName, std::function<int(void)> testFunc);
17691770

0 commit comments

Comments
 (0)