mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-28 10:04:14 +00:00
In the config module, the following functions are implemented: - load_config Provide one interface to load lifecycle manager configuration from config file (life_mngr.conf), in the config file, user can specify the VM type of VM which lifecycle manager will run in, the VM name, the communication device name, and the device name in service VM which is used to communicate with the VM which is allowed to send system shutdown request. - check_dir Check folder exist or not, if not, create the folder - get_allow_s5_config Get the name of the device which is allowed to trigger system shutdown. v1-->v2: Add comments in head file. v2-->v3: Update some log message. v3-->v6: Simply configuration item parsing logic. Add get_allow_s5_config interface. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
63 lines
1.9 KiB
C
63 lines
1.9 KiB
C
/*
|
|
* Copyright (C)2021 Intel Corporation
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
#ifndef _CONFIG_H_
|
|
#define _CONFIG_H_
|
|
/**
|
|
* @brief Number of seconds we're willing to retry to send shutdown request to a guest.
|
|
* If this is 0, then there is no retry (use with caution, as guests might miss shutdown
|
|
* command from service VM). The default value is 3.
|
|
*/
|
|
#define VM_SHUTDOWN_RETRY_TIMES 5
|
|
/**
|
|
* @brief Number of seconds we're willing to wait for all guests to shutdown. If this is 0,
|
|
* then there is no time out (use with caution, as guests might not respond to a shutdown
|
|
* request). The default value is 300 seconds (5 minutes).
|
|
*/
|
|
#define SHUTDOWN_TIMEOUT 300
|
|
|
|
#define LIFE_MNGR_CONFIG_PATH "/etc/life_mngr/life_mngr.conf"
|
|
#define LIFE_MNGR_CONFIG_FOLDER "/etc/life_mngr"
|
|
#define MAX_FILE_LINE_LEN 120
|
|
#define VM_TYPE "VM_TYPE"
|
|
#define VM_NAME "VM_NAME"
|
|
#define DEV_NAME "DEV_NAME"
|
|
#define ALLOW_TRIGGER_S5 "ALLOW_TRIGGER_S5"
|
|
#define MAX_CONFIG_VALUE_LEN 128
|
|
|
|
#define CHK_CREAT 1 /* create a directory, if it does not exist */
|
|
#define CHK_ONLY 0 /* check if the directory exist only */
|
|
|
|
struct life_mngr_config {
|
|
char vm_type[MAX_CONFIG_VALUE_LEN];
|
|
char vm_name[MAX_CONFIG_VALUE_LEN];
|
|
char dev_names[MAX_CONFIG_VALUE_LEN];
|
|
char allow_trigger_s5[MAX_CONFIG_VALUE_LEN];
|
|
};
|
|
extern struct life_mngr_config life_conf;
|
|
|
|
/**
|
|
* @brief Get the name of the device which is allowed to trigger system shutdown
|
|
*/
|
|
static inline char *get_allow_s5_config(struct life_mngr_config *conf)
|
|
{
|
|
return conf->allow_trigger_s5;
|
|
}
|
|
/**
|
|
* @brief Load configuration item from config file
|
|
*
|
|
* @param conf_path config file path
|
|
* @return true Load configuration items successfully
|
|
* @return false fail to load configuration items
|
|
*/
|
|
bool load_config(char *conf_path);
|
|
/**
|
|
* @brief Check folder exist or not, if not, create the folder
|
|
*
|
|
* @param path the folder path
|
|
* @param flags the folder attribute
|
|
*/
|
|
int check_dir(const char *path, int flags);
|
|
#endif
|