phosphor-ipmi-net: Add sysrq handle in netipmid for ipmitool sol.
Send MSG_OOB flag to console server to generate a break.
Tested:
1. Open SOL by ipmitool: ipmitool -H <bmcip> -I lanp -U <user> -P <password> sol activate
2. In SOL terminal, login os and "echo 1 > /proc/sys/kernel/sysrq" to open sysrq function
3. In SOL terminal, Enter ~+B to generate break, then enter "h" in 5 second.
4. Veirfy below message shown in SOL:
root@bytedance:~# ~B [send break]
[ 366.377331] sysrq: HELP : loglevel(0-9) reboot(b) crash(c) terminate-all-tasks(e)
memory-full-oom-kill(f) kill-all-tasks(i) thaw-filesystems(j) sak(k) show-backtrace-all-active-cpus(l)
show-memory-usage(m) nice-all-RT-tasks(n) poweroff(o) show-registers(p) show-all-timers(q) unraw(r)
sync(s) show-task-states(t) unmount(u) force-fb(V) show-blocked-tasks(w) dump-ftrace-buffer(z)
Change-Id: Ieac3ee0c7f964920214aa185a947e0449034726f
Signed-off-by: Tingting Chen <chentingting.2150@bytedance.com>
diff --git a/sol/sol_context.cpp b/sol/sol_context.cpp
index 4702bbe..06dabcc 100644
--- a/sol/sol_context.cpp
+++ b/sol/sol_context.cpp
@@ -82,7 +82,7 @@
}
void Context::processInboundPayload(uint8_t seqNum, uint8_t ackSeqNum,
- uint8_t count, bool status,
+ uint8_t count, bool status, bool isBreak,
const std::vector<uint8_t>& input)
{
uint8_t respAckSeqNum = 0;
@@ -145,10 +145,24 @@
payloadCache.clear();
}
+ if (isBreak && seqNum)
+ {
+ lg2::info("Writing break to console socket descriptor");
+ constexpr uint8_t sysrqValue = 72; // use this to notify sol server
+ const std::vector<uint8_t> test{sysrqValue};
+ auto ret = sol::Manager::get().writeConsoleSocket(test, isBreak);
+ if (ret)
+ {
+ lg2::error("Writing to console socket descriptor failed: {ERROR}",
+ "ERROR", strerror(errno));
+ }
+ }
+
+ isBreak = false;
// Write character data to the Host Console
if (!input.empty() && seqNum)
{
- auto rc = sol::Manager::get().writeConsoleSocket(input);
+ auto rc = sol::Manager::get().writeConsoleSocket(input, isBreak);
if (rc)
{
lg2::error("Writing to console socket descriptor failed: {ERROR}",