Commit Graph

32 Commits

Author SHA1 Message Date
Xiangyang Wu 1adbf3293b Misc: acrnd: fix acrnd start failure
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>
2022-01-04 18:47:32 +08:00
Xiangyang Wu 44f6804ad0 Misc: acrnctl: update acrnctl readme
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>
2022-01-04 10:58:16 +08:00
Xiangyang Wu 4aeee0bebf Misc: acrnctl: hot fix acrnctl bug
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>
2022-01-04 10:58:16 +08:00
Xiangyang Wu 4f034c99a2 doc: remove suspend and resume command from acrnctl
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>
2021-12-14 09:52:31 +08:00
Xiangyang Wu 982d1565d5 Misc: acrnctl: remove suspend and resume command from acrnctl
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>
2021-12-14 09:52:31 +08:00
Xiangyang Wu deec4b24ef HV: life_mngr: add sync delay for WaaG lifecycle manager
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>
2021-11-24 20:29:43 +08:00
Xiangyang Wu 93d0ad543e HV: life_mngr: refine platform shutdown when User VM fails to shutdown
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>
2021-11-24 20:29:43 +08:00
Mingqiang Chi 4233409c06 misc: use MAX_VM_NAME_LEN
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>
2021-11-16 14:42:59 +08:00
Xiangyang Wu c0b02e802f misc: life_mngr: fix some typo issues
Change macro name:
SCECOND_TO_US --> SECOND_TO_US

Use macro CONF_DIR in Makefile

Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
2021-11-12 11:04:23 +08:00
Xiangyang Wu e7ed68afc8 misc: life_mngr: add script to do user VM shutdown
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu d1cb1aafa0 misc: life_mngr: update Makefile for lifecycle manager
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu e297839fc3 misc: life_mngr: refine lifecycle manager for windows VM
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu 7a5146c2ed misc: life_mngr: refine script to trigger system shutdown request
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu 0d85463abe misc: life_mngr: add monitor module
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu 7fa42ff484 misc: life_mngr: add log module
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu 4e8adc7b14 misc: life_mngr: add config module
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu b1d2f8d931 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-11-12 11:04:23 +08:00
Xiangyang Wu 7158f95bac misc: life_mngr: add command module
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu e195a23f73 misc: life_mngr: add socket moudle
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu baf7982547 misc: life_mngr: add uart channel module
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
2021-11-12 11:04:23 +08:00
Xiangyang Wu 591998e956 misc: life_mngr: add uart module
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
2021-11-12 11:04:23 +08:00
Liu Long 3f4ea38158 ACRN: misc: Unify terminology for service vm/user vm
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>
2021-11-02 10:00:55 +08:00
Liu Long 14c6e21efa ACRN: misc: Unify terminology for sos/uos rin macro
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>
2021-11-02 10:00:55 +08:00
Shuo A Liu 1bccfab3b6 config_tools: Use new HSM driver device node
Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 82fa2d6355 dm: Rename vhm_ioctl_defs.h to hsm_ioctl_defs.h
Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 42989f753e dm: Remove header vmm.h
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>
2021-07-15 11:53:54 +08:00
Helmut Buchsbaum e88955392f Makefile: lifemngr: split linux and windows build
* Split linux and windows build of lifemngr to be able to build
  them independently.
* Install life_mngr.service
* Avoid the following Makefile error output by explicitly checking
  Windows cross compiler availability:

make[4]: x86_64-w64-mingw32-gcc: Command not found
make[4]: [Makefile:47: all-win] Error 127 (ignored)

Tracked-On: #5660
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
2021-05-20 10:02:33 +08:00
Geoffroy Van Cutsem ac091bacba acrn_manager: create acrnctl configuration folder when starting
The creation of the acrn_manager ('acrnctl') configuration folder
is currently done when adding a new VM to the system. This leads to
an error (non-fatal) thrown on the terminal is calling, say 'list'
first without having added a VM yet. This patch moves the creation
of such folder as part of main() thereby ensuring it is created as
soon as the program starts.

Tracked-On: #4898
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2021-03-25 14:37:21 +08:00
Junjie Mao 0edaaa880f Makefile: prefer RELEASE=y|n over RELEASE=0|1
For clarity, we now prefer y|n over 0|1 as the values of boolean options on
make command lines. This patch applies this preference to the Makefile of
the device model and tools, while RELEASE=0|1 is still supported for
backward compatibility.

Tracked-On: #5772
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-03-03 09:13:44 +08:00
Peter Fang d17fdb020a misc: life_mngr: allow only one active socket connection in SOS mode
Monitor the listening socket in SOS mode and close any additional
connections after a socket connection is established. This ensures no
more than one post-launched VM can establish a pm_vuart channel.

Tracked-On: #5736
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-03-01 14:21:43 +08:00
David B. Kinder 0bd384d41b doc: fix all headings to use title case
While we hoped to make the headings consistent over time while doing
other edits, we should instead just make the squirrels happy and do them
all at once or they'll likely never be made consistent.

A python script was used to find the headings, and then a call to
https://pypi.org/project/titlecase to transform the title.  A visual
inspection was used to tweak a few unexpected resulting titles.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2021-02-13 12:37:49 -08:00
Xie, nanlin 0ab5db9cf9 tools: rename and category content into debug tools and services
1. Rename folder name with "_"
2. Category acrn_crashlog, acrn_log, acrn_trace into debug_tools folder and acrn_bridge, life_mngr, acrn_manager into services.

Tracked-On: #5644
Signed-off-by: Xie, nanlin <nanlin.xie@intel.com>
2021-01-27 11:08:28 +08:00