dm:set pm-vuart attritutes

set the attributes during pm-vuart initialization
to avoid the pm-vuart in an indefinite state.

Currently we have implemented S5 triggered by SOS,
these patch series both support S5 triggered by SOS and RTVM.

the fully steps for S5 triggered by SOS:
1) S5-Trigger: it initiates the  platform shutdown actions;
   it calls “acrnctl stop vmX” to do that,
   and check the VM's status, power-off SOS itself.
2) acrnctl will send “stop” to “acrn-dm”
3) acrn-dm will send “shutdown” command to VMx by v-UART.
4) when life-cycle manager in VMx receives the “shutdown” command,
   it will give an “acked” to acrn-dm, and then poweroff itself.

the fully steps for S5 triggered by RTVM:
1) S5-Trigger in RTVM:  it initiates the  platform shutdown actions;
   it’ll send shutdown command for platform shutdown to
   life-cycle manager
2) when life-cycle manager in RTVM receive the message,
   it will send “shutdown” command to acrn-dm in SOS by v-UART.
3) when acrn-dm receives the “shutdown” command from RTVM,
   it will give an “acked” to RTVM, RTVM’s life-cycle manager can
   power off itself
4) acrn-dm will send  “shutdown” command to its own life-cycle manager
   by socket.
5) when life-cycle manager in SOS receives the “shutdown” command,
   it can call “s5_trigger” script to shutdown platform.

Tracked-On: #4446
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Mingqiang Chi
2020-03-03 16:22:24 +08:00
committed by wenlingz
parent 790614e952
commit 7e9b7a8c34

View File

@@ -18,6 +18,7 @@
#include <fcntl.h>
#include <assert.h>
#include <pthread.h>
#include <termios.h>
#include "vmmapi.h"
#include "monitor.h"
@@ -84,14 +85,55 @@ int parse_pm_by_vuart(const char *opts)
return error;
}
static int set_tty_attr(int fd, int speed)
{
struct termios tty;
if (tcgetattr(fd, &tty) < 0) {
pr_err("error from tcgetattr\n");
return -1;
}
cfsetospeed(&tty, (speed_t)speed);
cfsetispeed(&tty, (speed_t)speed);
/* set input-mode */
tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK |
ISTRIP | INLCR | IGNCR | ICRNL | IXON);
/* set output-mode */
tty.c_oflag &= ~OPOST;
/* set control-mode */
tty.c_cflag |= (CLOCAL | CREAD | CS8);
tty.c_cflag &= ~(CSIZE | PARENB | CSTOPB | CRTSCTS);
/* set local-mode */
tty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
/* block until one char read, set next char's timeout */
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 1;
tcflush(fd, TCIOFLUSH);
if (tcsetattr(fd, TCSANOW, &tty) != 0) {
pr_err("error from tcsetattr\n");
return -1;
}
return 0;
}
void pm_by_vuart_init(struct vmctx *ctx)
{
assert(node_index < MAX_NODE_CNT);
pr_info("%s idx: %d, path: %s\r\n", __func__, node_index, node_path);
if (node_index == PTY_NODE) {
node_fd = pty_open_virtual_uart(node_path);
} else if (node_index == TTY_NODE) {
node_fd = open(node_path, O_RDWR | O_NOCTTY | O_NONBLOCK);
set_tty_attr(node_fd, B115200);
}
if (node_fd > 0) {