acrn-hypervisor/misc/services/life_mngr/command_handler.h

141 lines
4.7 KiB
C
Raw Normal View History

misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
/*
* Copyright (C)2021-2022 Intel Corporation.
misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _CMD_HANDLER_H_
#define _CMD_HANDLER_H_
#define SEND_RETRY_TIMES 3
extern struct uart_channel *channel;
extern struct socket_dev *sock_server;
/**
* @brief Get the system shutdown flag
*/
bool get_system_shutdown_flag(void);
/**
* @brief Get the reboot flag
*/
bool get_vm_reboot_flag(void);
misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
/**
* @brief The handler of request system shutdown command on socket in service VM
*/
int socket_req_shutdown_service_vm_handler(void *arg, int fd);
/**
* @brief The handler of request user shutdown command on socket in service VM
*/
int socket_req_user_vm_shutdown_handler(void *arg, int fd);
/**
* @brief The handler of request user reboot command on socket in service VM
*/
int socket_req_user_vm_reboot_handler(void *arg, int fd);
/**
* @brief The handler of request system reboot command on socket in user VM
*/
int socket_req_system_reboot_user_vm_handler(void *arg, int fd);
misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
/**
* @brief The handler of request system shutdown command on socket in user VM
*/
int socket_req_system_shutdown_user_vm_handler(void *arg, int fd);
/**
* @brief The handler of sync command of lifecycle manager in service VM
*
* @param arg uart channel device instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int sync_cmd_handler(void *arg, int fd);
/**
* @brief The handler of system shutdown request command of lifecycle manager in service VM
*
* @param arg uart channel device instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int req_shutdown_handler(void *arg, int fd);
/**
* @brief The handler of system reboot request command of lifecycle manager in service VM
*
* @param arg uart channel device instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int req_reboot_handler(void *arg, int fd);
misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
/**
* @brief The handler of acked poweroff command of lifecycle manager in service VM
*
* @param arg uart channel instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int ack_poweroff_handler(void *arg, int fd);
/**
* @brief The handler of poweroff timeout command of lifecycle manager in service VM
*
* @param arg uart channel instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int ack_timeout_handler(void *arg, int fd);
/**
* @brief The handler of ACK user vm shutdown command of
* lifecycle manager in service VM
*
* @param arg uart channel instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int ack_user_vm_shutdown_cmd_handler(void *arg, int fd);
/**
* @brief The handler of ACK user vm reboot command of
* lifecycle manager in service VM
*
* @param arg uart channel instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int ack_user_vm_reboot_cmd_handler(void *arg, int fd);
misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
/**
* @brief The handler of acked sync command of lifecycle manager in user VM
*
* @param arg uart channel device instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int acked_sync_handler(void *arg, int fd);
/**
* @brief The handler of acked system shutdown request command of lifecycle manager in user VM
*
* @param arg uart channel instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int acked_req_shutdown_reboot_handler(void *arg, int fd);
misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
/**
* @brief The handler of poweroff command of lifecycle manager in user VM
*
* @param arg uart channel device instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int poweroff_cmd_handler(void *arg, int fd);
/**
* @brief The handler of user VM shutdown command of lifecycle manager in user VM
*/
int user_vm_shutdown_cmd_handler(void *arg, int fd);
/**
* @brief The handler of user VM reboot command of lifecycle manager in user VM
*/
int user_vm_reboot_cmd_handler(void *arg, int fd);
misc: life_mngr: add command handler module In this module, the following functions are implemented: For uart channel of service VM, implement handlers for sync command, system shutdown request command, acked poweroff command, vm poweroff timeout command. The uart channel commands of service VM and related actions are described below: Command Actions --------------------------------------------------------------- sync Send acked sync command to uart in user VM ---------------------------------------------------------------- system shutdown If this request is valid, send request poweroff command to each connected user VM through uart, Enable message reseding. ---------------------------------------------------------------- acked poweroff Remove uart of user VM from command connection list, stop message polling, if connection list is empty, will wait for user VM status through check ACRN DM process instance, if all user VMs are shutdown, then shutdown service VM --------------------------------------------------------- ACK timeout If it is timeout of receiving poweroff ACK, the action is similar to acked poweroff. Ohterwise, just disable message reseding. --------------------------------------------------------- For uart channel of user VM, implement handlers for acked sync command, poweroff command, acked system shutdown request command, ACK timeout command. The uart channel commands of user VM and related actions are described below: Command Actions -------------------------------------------------------- acked sync Print log message -------------------------------------------------------- poweroff Disconnect uart channel, exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- user VM shutdown Exit message polling, close unix domain socket, shutdown user VM -------------------------------------------------------- acked system Print log message shutdown request ------------------------------------------------------- ACK timeout Disconnect uart channel, exit message polling, close unix domain socket --------------------------------------------------------- For socket server in each VM, implement handler for system shutdown request. In user VM, forward this command to service VM through uart. In service VM, send poweroff command to each connected user VM through uart. Implement handler for user VM shutdown request in socket server of service VM, send user VM shutdown command to user VM which is specified in the user VM shutdown request message. v1-->v2: Add comments in c file and head file. v2-->v3: Update commit message about allow s5 command and update some log message. v3-->v4: Guest shutdown support. v4-->v5: Update command name. v5-->v6: Move uart channel operations into uart channel module. v6-->v7: Set resend requirement for some commands. Add ACK receiving timeout handler for user VM. v7-->v8: Update message reseding enable, this interface will be called before sending message. v8-->v9: Use strlen to calculate the length of string, this will be the parameter of send_message_by_uart. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
2021-10-19 10:25:19 +08:00
/**
* @brief The handler of ACK timeout command of lifecycle manager in user VM
*
* @param arg uart channel instance
* @param fd the file directory of the uart which receives message
* @return indicate this command is handled successful or not
*/
int ack_timeout_default_handler(void *arg, int fd);
#endif