diff --git a/misc/services/life_mngr/command_handler.c b/misc/services/life_mngr/command_handler.c index 59c70828d..7dd6a65d5 100644 --- a/misc/services/life_mngr/command_handler.c +++ b/misc/services/life_mngr/command_handler.c @@ -205,6 +205,12 @@ static int is_allowed_s5_channel_dev(struct life_mngr_config *conf, struct chann TTY_PATH_MAX); } +static int is_allowed_sysreboot_channel_dev(struct life_mngr_config *conf, struct channel_dev *c_dev) +{ + return strncmp(get_allow_sysreboot_config(conf), get_uart_dev_path(c_dev->uart_device), + TTY_PATH_MAX); +} + /** * @brief The handler of sync command of lifecycle manager in service VM * @@ -237,7 +243,7 @@ int req_reboot_handler(void *arg, int fd) if (c_dev == NULL) return 0; - if (is_allowed_s5_channel_dev(&life_conf, c_dev)) { + if (is_allowed_sysreboot_channel_dev(&life_conf, c_dev)) { LOG_PRINTF("The user VM (%s) is not allowed to trigger system reboot\n", c_dev->name); return 0; diff --git a/misc/services/life_mngr/config.c b/misc/services/life_mngr/config.c index d44231566..30d87f7b0 100644 --- a/misc/services/life_mngr/config.c +++ b/misc/services/life_mngr/config.c @@ -84,6 +84,9 @@ bool load_config(char *conf_path) else if (strncmp(ALLOW_TRIGGER_S5, (const char *)key_str, sizeof(ALLOW_TRIGGER_S5)) == 0) memcpy(life_conf.allow_trigger_s5, value_str, strlen(value_str)); + else if (strncmp(ALLOW_TRIGGER_SYSREBOOT, (const char *)key_str, + sizeof(ALLOW_TRIGGER_SYSREBOOT)) == 0) + memcpy(life_conf.allow_trigger_sysreboot, value_str, strlen(value_str)); else LOG_PRINTF("Invalid item in the configuration file, key=%s, value=%s\n", key_str, value_str); diff --git a/misc/services/life_mngr/config.h b/misc/services/life_mngr/config.h index c5dc5271b..4a47852f7 100644 --- a/misc/services/life_mngr/config.h +++ b/misc/services/life_mngr/config.h @@ -24,6 +24,7 @@ #define VM_NAME "VM_NAME" #define DEV_NAME "DEV_NAME" #define ALLOW_TRIGGER_S5 "ALLOW_TRIGGER_S5" +#define ALLOW_TRIGGER_SYSREBOOT "ALLOW_TRIGGER_SYSREBOOT" #define MAX_CONFIG_VALUE_LEN 128 #define CHK_CREAT 1 /* create a directory, if it does not exist */ @@ -34,6 +35,7 @@ struct life_mngr_config { char vm_name[MAX_CONFIG_VALUE_LEN]; char dev_names[MAX_CONFIG_VALUE_LEN]; char allow_trigger_s5[MAX_CONFIG_VALUE_LEN]; + char allow_trigger_sysreboot[MAX_CONFIG_VALUE_LEN]; }; extern struct life_mngr_config life_conf; @@ -44,6 +46,13 @@ static inline char *get_allow_s5_config(struct life_mngr_config *conf) { return conf->allow_trigger_s5; } +/** + * @brief Get the name of the device which is allowed to trigger system reboot + */ +static inline char *get_allow_sysreboot_config(struct life_mngr_config *conf) +{ + return conf->allow_trigger_sysreboot; +} /** * @brief Load configuration item from config file * diff --git a/misc/services/life_mngr/life_mngr.conf b/misc/services/life_mngr/life_mngr.conf index d8fb040f7..ab8a85dd8 100644 --- a/misc/services/life_mngr/life_mngr.conf +++ b/misc/services/life_mngr/life_mngr.conf @@ -24,3 +24,9 @@ DEV_NAME=tty:/dev/ttyS8,/dev/ttyS9,/dev/ttyS10,/dev/ttyS11,/dev/ttyS12,/dev/ttyS # s5_trigger.sh. # For user VM, this field is useless. ALLOW_TRIGGER_S5=/dev/ttyS10 + +# The device name of the device which is used to communicate with the VM, +# and this VM is allowed to trigger system reboot through executing +# system_reboot_trigger_win.py. +# For user VM, this field is useless. +ALLOW_TRIGGER_SYSREBOOT=/dev/ttyS10