acrn-hypervisor/misc/services/life_mngr/command_handler.h
Xiangyang Wu ecf99c45a3 Misc: life_mngr: support user VM reboot
Add user VM reboot command and related command handler in
lifecycle manager to support user VM reboot.

Libvirt will send user VM reboot command to lifecycle manager
of service VM through socket, this command is forwarded to the
specified user VM, user VM will execute reboot command to start
reboot itself.

v1-->v2:
	Update some interfaces name to make it reable:
        (1) enable_uart_channel_dev_resend -->
	start_uart_channel_dev_resend
	(2) enable_all_uart_channel_dev_resend -->
	start_all_uart_channel_dev_resend
	(3) disable_uart_channel_dev_resend -->
	stop_uart_channel_dev_resend
	(4) get_reboot_flag --> get_user_vm_reboot_flag

Tracked-On: #5921

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-03-03 14:40:04 +08:00

128 lines
4.3 KiB
C

/*
* Copyright (C)2021 Intel Corporation
* 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_user_vm_reboot_flag(void);
/**
* @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 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 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);
/**
* @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_handler(void *arg, int fd);
/**
* @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);
/**
* @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