1 /* 2 * Copyright (C)2021-2022 Intel Corporation. 3 * SPDX-License-Identifier: BSD-3-Clause 4 */ 5 #ifndef _CONFIG_H_ 6 #define _CONFIG_H_ 7 /** 8 * @brief Number of seconds we're willing to retry to send shutdown request to a guest. 9 * If this is 0, then there is no retry (use with caution, as guests might miss shutdown 10 * command from service VM). The default value is 3. 11 */ 12 #define VM_SHUTDOWN_RETRY_TIMES 5 13 /** 14 * @brief Number of seconds we're willing to wait for all guests to shutdown. If this is 0, 15 * then there is no time out (use with caution, as guests might not respond to a shutdown 16 * request). The default value is 300 seconds (5 minutes). 17 */ 18 #define SHUTDOWN_TIMEOUT 300 19 20 #define LIFE_MNGR_CONFIG_PATH "/etc/life_mngr/life_mngr.conf" 21 #define LIFE_MNGR_CONFIG_FOLDER "/etc/life_mngr" 22 #define MAX_FILE_LINE_LEN 120 23 #define VM_TYPE "VM_TYPE" 24 #define VM_NAME "VM_NAME" 25 #define DEV_NAME "DEV_NAME" 26 #define ALLOW_TRIGGER_S5 "ALLOW_TRIGGER_S5" 27 #define ALLOW_TRIGGER_SYSREBOOT "ALLOW_TRIGGER_SYSREBOOT" 28 #define MAX_CONFIG_VALUE_LEN 128 29 30 #define CHK_CREAT 1 /* create a directory, if it does not exist */ 31 #define CHK_ONLY 0 /* check if the directory exist only */ 32 33 struct life_mngr_config { 34 char vm_type[MAX_CONFIG_VALUE_LEN]; 35 char vm_name[MAX_CONFIG_VALUE_LEN]; 36 char dev_names[MAX_CONFIG_VALUE_LEN]; 37 char allow_trigger_s5[MAX_CONFIG_VALUE_LEN]; 38 char allow_trigger_sysreboot[MAX_CONFIG_VALUE_LEN]; 39 }; 40 extern struct life_mngr_config life_conf; 41 42 /** 43 * @brief Get the name of the device which is allowed to trigger system shutdown 44 */ get_allow_s5_config(struct life_mngr_config * conf)45static inline char *get_allow_s5_config(struct life_mngr_config *conf) 46 { 47 return conf->allow_trigger_s5; 48 } 49 /** 50 * @brief Get the name of the device which is allowed to trigger system reboot 51 */ get_allow_sysreboot_config(struct life_mngr_config * conf)52static inline char *get_allow_sysreboot_config(struct life_mngr_config *conf) 53 { 54 return conf->allow_trigger_sysreboot; 55 } 56 /** 57 * @brief Load configuration item from config file 58 * 59 * @param conf_path config file path 60 * @return true Load configuration items successfully 61 * @return false fail to load configuration items 62 */ 63 bool load_config(char *conf_path); 64 /** 65 * @brief Check folder exist or not, if not, create the folder 66 * 67 * @param path the folder path 68 * @param flags the folder attribute 69 */ 70 int check_dir(const char *path, int flags); 71 #endif 72