1. using sockets_req_system_shutdown_user_vm_handler and sockets_req_system_reboot_user_vm_handler
wrapping function req_user_vm_shutdown_reboot
2. Modify the variable names SHUTDOWN_REQ to SYS_REBOOT_REQ
3. Add a handler for "ACK_REQ_SYS_REBOOT"
Tracked-On: #8431
Signed-off-by: Gaofei Sun <gaofeix.sun@intel.com>
Reviewed-by: Li Fei <fei1.li@intel.com>
Only Windows virtual machines can restart ACRN through life_mngr.
Added Linux and rtvm to restart acrn in life_mngr.
Tracked-On: #8431
Signed-off-by: Gaofei Sun <gaofeix.sun@intel.com>
Reviewed-by: Li Fei <fei1.li@intel.com>
Linker option "-z,relro" will be automatically added to LDFLAGS when
building debian packages. Since x86_64-w64-mingw32-ld does not support
"-z" option, it causes failure in building the life_mngr windows exe.
And compared with ld, only "-z" option is not supported. This patch
fixes it by skipping the windows build of life_mngr if LDFLAGS contains
any "-z" option.
Tracked-On: #8399
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
LIST_FOREACH() doesn't allow var to be removed or freed within the
loop, but c_dev is freed inside the loop here. gcc 12 also reports
error on it. This patch uses list_foreach_safe() macro instead for
freeing var within the loop safely.
Tracked-On: #8382
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
Modified the copyright year range in code, and corrected "int32_tel"
into "Intel" in two "hypervisor/include/debug/profiling.h" and
"hypervisor/include/debug/profiling_internal.h".
Tracked-On: #7559
Signed-off-by: Ziheng Li <ziheng.li@intel.com>
On some extreme circumstances, the client can't send the whole message out
in a short time. In this case, the server can't receive the whole message
because now server didn't check the integrity of the message.
This patch add this by checking the terminal character of the message.
Tracked-On: #7215
Signed-off-by: Fei Li <fei1.li@intel.com>
The comparison ((argv + 1)) will always evaluate as 'true' for the pointer
operand in 'argv + 8' must not be NULL.
Tracked-On: #7453
Signed-off-by: Fei Li <fei1.li@intel.com>
1. enlarge receive Service VM message time to 10s. Now in some extreme
environments, Service VM will takes more than 1s to ACK the User VM's
requirements.
2. fix a bug to calculate string pointer size.
Tracked-On: #7215
Signed-off-by: Fei Li <fei1.li@intel.com>
Many of the license and Intel copyright headers include the "All rights
reserved" string. It is not relevant in the context of the BSD-3-Clause
license that the code is released under. This patch removes those strings
throughout the code (hypervisor, devicemodel and misc).
Tracked-On: #7254
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Now reuse allow_trigger_s5 in life_mngr_config to allow WAAG to trigger
system reboot.
Tracked-On: #7215
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Signed-off-by: Fei Li <fei1.li@intel.com>
Add a new common function to handle socket request, this will make
it is easy to add more socket request in windows lifecycle manager.
Tracked-On: #7215
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Signed-off-by: Fei Li <fei1.li@intel.com>
acrnd servie should start after life_mngr.service, otherwise,
lifecycle manager in service VM will start after lifecycle
manager in User VM.
Tracked-On: #6994
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Signed-off-by: Fei Li <fei1.li@intel.com>
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>
Currently, if user starts acrnd service, acrnd service will fail to
find the folder "/sys/kernel/gvt" in Service VM, fail to start.
Root cause is GVT-g is not supported in current ACRN, the folder
"/sys/kernel/gvt" will not be created in Service VM.
This patch updates acrnd service to remove this condition check.
v1-->v2:
Weston service is optional for ACRN, acrnd should not depend
on it, so remove weston service dependency in acrnd service.
Tracked-On: #6994
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
User should make sure acrnd service has been started
before running acrnctl.
This patch add note about this.
v2-->v3:
Update document about acrnd service enabling.
Tracked-On: #6991
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Currently, while there is no running post-launched User VM and
user executes acrnctl command, he or she will get failure and
error message is "/run/acrn/mngr doesn't exist".
Root cause of this failure is acrnctl only check whether the folder
"/run/acrn/mngr" exist or not, if this folder doesn't exist, will
report failure.
acrnd service will create the folder "/run/acrn/mngr", user should
make sure acrnd service is started before using acrnctl
This patch will update log message while the folder "/run/acrn/mngr"
doesn't exist.
v1-->v2:
Update log message to make it clearer.
Tracked-On: #6991
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Currently, the command "acrnctl suspend" and "acrnctl resume"
is not used by user. This patch removes related code.
Tracked-On: #5921
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Currently, the command "acrnctl suspend" and "acrnctl resume"
is not used by user. This patch removes related code.
v1-->v2:
Remove vm_suspend.
Tracked-On: #5921
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
The lifecycle manager in Service VM checks sync message every
5 seconds, so need add 5 seconds to sync delay for WaaG
lifecycle manager to avoid unnecessary sync resending.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Currently, the lifecycle manager in Service VM will issue poweroff
command to shutdown service VM when User VM fails to shutdown. The
post-launched RTVM with virtio device may hang after Service VM
shutdown.
In this patch, the lifecycle manager in Service VM will stop to
shut down service VM when User VM fails to shutdown. Users have
chance to fix User VM shutdown failure (such as forcelly shutdown
User VM or execute poweroff command in User VM), after the failure
is fixed, user can trigger S5 in service VM to shutdown platform
gracefully.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
replace MAX_VMNAME_LEN with MAX_VM_NAME_LEN
to keep sync with HV and devicemodel
Tracked-On: #6685
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
COM2 in user VM is used by acrnctl to do user VM
shutdown.
In this patch series, COM2 in user VM is used as uart
channel device for new lifecycle manager. So acrnctl
can't be used to do user VM shutdown.
This patch provides a script to user to do guest
shutdown in service VM. Lifecycle manager in service
VM will send user VM shutdown command to user VM directly.
TODO: When user VM shutdown is supported in libvirt, this
script will be removed.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
The old lifecycle manager will not be used and remove it,
update Makefile to build and install new lifecycle manager.
v1-->v2:
Copy s5_trigger_win.py into build directory;
Add compiler parameter (-lwsock32) to build
life_mngr_win.c.
v3-->v4:
Update Makefile for s5_trigger_linux.py
v4-->v5:
Inlcude paths.make at the top-level folder.
Generate life_mngr.service according to bindir
variable.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
Refine lifecycle manager for windows VM since new commands
are introduced in the lifecycle manager.
v1-->v2:
Implement socket service to receive system shutdown
request command through local host socket.
Add one python script to trigger system shutdown
request in windows VM.
v2-->v3:
Update log message.
v3-->v4:
Support guest shutdown.
v4-->v5:
Update command name.
v5-->v7:
Add resend message logic.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
Provide a script to user to trigger system shutdown request
in service VM or user VM.
System shutdown logic have been integrated in the lifecycle
manager, only need to send system shutdown request command
through unix domain socket in this script.
v3-->v4:
Rewirte system shutdown trigger script using python
since phython script have better portability.
v4-->v5:
Update command name and copyright header.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
In the monitor module, the following functions are implemented:
-Implement main function of lifecycle manager, it will initialize
other module through invoking related interfaces, wait threads in
the uart module exit.
Todo:
Will refine the name of
init_socket_server_and_shutdown_commands,
init_uart_channel_devs_and_shutdown_commands.
v1-->v2:
Add comments in c file.
v2-->v3:
Update some log message.
v3-->v6:
Update monitior module for modulization.
v6-->v7:
Regiester command handler for ACK receiving timeout case
in user VM.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
In the log module, the following functions are implemented:
- open_log
Provide one interface to open log file;
-close_log
Provide one interface to close log file;
- LOG_PRINTF LOG_WRITE
Provide interfaces to write log message to log file.
v1-->v3:
Add timestamp in the log message.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
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
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
In the command module, the following functions are implemented:
- register_command_handler
Provide one interface to register command handler, other module
can use this interface to register multiple handler for one command.
- find_command
Provide one interface to find a command instance by name;
- dispatch_command_handlers
Provide one interface to dispatch the command and invoke registered
handler.
v1-->v2:
Add comments in head file.
v2-->v3:
Update interface name since "dm" prefix is useless.
Update some log message.
v3-->v4:
Support guest shutdown.
v4-->v5:
Refine command name and add parameter check for interface.
v5-->v6:
Remove allow s5 command.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
This module is to implement unix domain socket server, operator
can connect this server to send system shutdown request, or
guest shutdown command.
In the socket module, the following functions are implemented:
- open_socket
Provide one interface to open one unix domain socket server,
in this interface, initialize a socket, create one thread to
listen to client, another thread to poll message from client;
- close_socket
Provide one interface to close one unix domain socket server;
- write_socket_char
Provide one interface to send message to client.
- find_socket_client
Find socket client instance according to fd
- init_socket
Initialize a socket
- deinit_socket
Deinit a socket
v1-->v3:
Update interface name, only unix domain socket
server is implemented in this module.
v3-->v4:
Add socket client name to support guest shutdown
v4-->v6:
Add find_socket_client, init_socket, deinit_socket
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
In the uart module, the following functions are implemented:
- init_uart_channel
Initialize each field of uart channel instance.
- create_uart_channel_dev
Create one channel device instance to store information about
one uart channel device which will be opened.
- wait_uart_channel_devs_threads
Wait uart channel devices threads to exit
- destroy_uart_channel
Destroy uart channel and release channel device instance
- listen_uart_channel_dev
Wait to connect device in uart channel
- connect_uart_channel_dev
Send sync message every 5 second
- poll_and_dispatch_uart_channel_events
Poll and dispatch message received from uart channel
- find_uart_channel_dev
Find uart channel device instance according to fd
- find_uart_channel_dev_by_name
Find uart channel device instance according to device name
- disconnect_uart_channel_dev
Disconnect uart channel device instance
- stop_listen_uart_channel_dev
Stop to listen uart channel device
- enable_uart_channel_dev_resend
Set the uart channel device resending buffer and
resending time
- enable_all_uart_channel_dev_resend
Enable resend for all connected uart channel devices
- disable_uart_channel_dev_resend
Clear the uart channel device resending buffer and
resending time
- notify_all_connected_uart_channel_dev
Send message to each connected uart channel device
- check_uart_channel_connection_list_empty
Check whether uart channel connection list is empty or not
TODO:
Will refine resending logic in the
poll_and_dispatch_uart_channel_events, and add
SYNC command resending.
v3-->v4:
Initialize each field of uart channel instance.
Add one flag indicating master channel device.
Update interface names.
v4-->v5:
Refine interface name.
v5-->v6:
Move uart channel operations from command handler module
v6-->v7:
Add enable_uart_channel_dev_resend and
disable_uart_channel_dev_resend;
Fix bugs about receiving message timeout.
v7-->v8:
Add enable_all_uart_channel_dev_resend interface.
v8-->v9:
Update error handling.
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
In the uart module, the following functions are implemented:
- init_uart_dev
Allocate UART device instance and initialize UART device
according to device name.
- deinit_uart_dev
Close UART devcie and free UART device instance.
- send_message_by_uart
Set handler to handle received message.
- receive_message_by_uart
Receive message and retry RETRY_RECV_TIMES time to
avoid miss message in some cases.
- get_uart_dev_fd
Get the file descriptor of a UART device
- get_uart_dev_path
Get the name of a UART device
v1-->v2:
Update sync logic between uart in service VM and uart in
user VM, lifecycle manager will not depend on VM boot order.
Add code comments.
v2-->v3:
This module only includes UART device operations, move other
logic into uart channel module.
v3-->v4:
Add parameters check for interface and refine some names.
v4-->v5:
Refine interface parameter type, error value.
v5-->v6:
Update condition check format of deinit_uart_dev.
Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
Rename SOS_VM type to SERVICE_VM
rename UOS to User VM in XML description
rename uos_thread_pid to user_vm_thread_pid
rename devname_uos to devname_user_vm
rename uosid to user_vmid
rename UOS_ACK to USER_VM_ACK
rename SOS_VM_CONFIG_CPU_AFFINITY to SERVICE_VM_CONFIG_CPU_AFFINITY
rename SOS_COM to SERVICE_VM_COM
rename SOS_UART1_VALID_NUM" to SERVICE_VM_UART1_VALID_NUM
rename SOS_BOOTARGS_DIFF to SERVICE_VM_BOOTARGS_DIFF
rename uos to user_vm in launch script and xml
Tracked-On: #6744
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Rename SOS_VM_NUM to SERVICE_VM_NUM.
rename SOS_SOCKET_PORT to SERVICE_VM_SOCKET_PORT.
rename PROCESS_RUN_IN_SOS to PROCESS_RUN_IN_SERVICE_VM.
rename PCI_DEV_TYPE_SOSEMUL to PCI_DEV_TYPE_SERVICE_VM_EMUL.
rename SHUTDOWN_REQ_FROM_SOS to SHUTDOWN_REQ_FROM_SERVICE_VM.
rename PROCESS_RUN_IN_SOS to PROCESS_RUN_IN_SERVICE_VM.
rename SHUTDOWN_REQ_FROM_UOS to SHUTDOWN_REQ_FROM_USER_VM.
rename UOS_SOCKET_PORT to USER_VM_SOCKET_PORT.
rename SOS_CONSOLE to SERVICE_VM_OS_CONSOLE.
rename SOS_LCS_SOCK to SERVICE_VM_LCS_SOCK.
rename SOS_VM_BOOTARGS to SERVICE_VM_OS_BOOTARGS.
rename SOS_ROOTFS to SERVICE_VM_ROOTFS.
rename SOS_IDLE to SERVICE_VM_IDLE.
rename SEVERITY_SOS to SEVERITY_SERVICE_VM.
rename SOS_VM_UUID to SERVICE_VM_UUID.
rename SOS_REQ to SERVICE_VM_REQ.
rename RTCT_NATIVE_FILE_PATH_IN_SOS to RTCT_NATIVE_FILE_PATH_IN_SERVICE_VM.
rename CBC_REQ_T_UOS_ACTIVE to CBC_REQ_T_USER_VM_ACTIVE.
rename CBC_REQ_T_UOS_INACTIVE to CBC_REQ_T_USER_VM_INACTIV.
rename uos_active to user_vm_active.
Tracked-On: #6744
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
vmm.h has some unused definitions.
Keep the useful definitions and delete vmm.h
Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>