Commit Graph

77 Commits

Author SHA1 Message Date
Yin Fengwei 73ab727434 dm: set correct thread name
When issue happen, we could identify which thread is impacted.
This could help stability issue debugging.

Tracked-On: #2037
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-14 19:50:50 +08:00
Yan, Like 04fef4f363 tools: acrn-manager: change path of vm conf files
The path of vm conf files changed from "/opt/acrn/conf" to "/usr/share/acrn/conf",
since "/opt" is not generally used on clearlinux.

Tracked-On: #2040
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-13 09:09:41 +08:00
yuhong.tao@intel.com bc5b27a73d tools: acrnctl: increase STOP_TIMEOUT to 30s when reset VM
The 'acrnctl reset' is implemented by a stop/start sequence. Reset failure was
observed since UOS is not able to shutdown within default 10s timeout.
This commit increased the default timeout to be 30s, and added an explicit error
message if 'acrnctl reset' due to UOS shutdown timeout.

Tracked-On: #2016
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
2018-12-12 15:41:13 +08:00
yuhong.tao@intel.com 7ee0e2e2a4 tools: acrnctl: Fix path error when run "acrnctl add" cmd
There is a bug to run 'acrnctl add /[path]/script.sh', when the
launch script has an absolute path. Acrnctl will generate wrong path
for temp files and fail to add VM.

And message '/opt/acrn/conf: No such file or directory' always comes
out, until user once successfully run 'acrnctl add' cmd. That is reported
by _scan_added_vm(), because 'opt/acrn' is missing, only 'acrnctl add'
can create it, we should also check it in _scan_added_vm().

Tracked-On: #2013
Acked-by: Yan, Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-12-10 09:26:08 +08:00
yuhong.tao@intel.com 2f33d1bcf2 tools: acrn-manager: Fix acrnctl mistake displaying suspended to paused
When UOS is sleeping, 'acrnctl list' command show it is 'paused', not
'suspended'. That is not correct. Because pausing an UOS means to block
its VCPUs immediately, otherwise suspending an UOS means to put it to
sleep.

Tracked-On: #1910
Acked-by: Yan, Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-11-28 13:42:27 +08:00
Ming Liu 7978188c1d tools: acrn-manager: set MAX_NAME_LEN to 32
I am currently using Yocto build and deploy UOS images, it would be
much more convenient to let the VMs to have the same names with when
they are being built. For instance, a typical image name in Yocto is
like: uos-image-weston, but it can not show the name completely with
'acrnctl list', since the length limit is 16.

Increasing the limit to 32 would fix this problem.

Tracked-On: #1837
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
2018-11-19 12:52:46 +08:00
Yan, Like d49a6f6fca capture acrnd AaaG booting messages to journald
It's for AaaG boot time measurement only.

Tracked-On: #1759
Signed-off-by: Yan, Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-11-08 15:14:15 +08:00
Tianhua Sun 313941e853 tools: acrn-manager: remove unsafe api sscanf
function sscanf is banned according to the security
requirements. So remove sscanf api.

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Tao, Yuhong <yuhong.tao@intel.com>
2018-11-05 09:50:04 +08:00
Tianhua Sun b12c7b741b tools: acrn-manager: remove usage of banned APIs
1, replace strlen with strnlen
2, Return value check for strncpy function

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kaige Fu <kaige.fu@intel.com>
2018-11-01 11:22:26 +08:00
Tianhua Sun af760f8dce tools: acrn-manager: refine the usage of api 'snprintf'
Return value check for snprintf function

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kaige Fu <kaige.fu@intel.com>
2018-11-01 11:22:26 +08:00
Kaige Fu d29937374a tools: acrnd: Stop all vms when SOS shutdown/reboot
When SOS shutdown/reboot, systemd will send SIGTERM to acrnd. We should catch up
this signal and stop all vms gracefully.

BTW, this path also fix the following error when stop acrnd service by removing
ExecStop config. Systemd will send SIGTERM signal to process by default.

systemd[9378]: acrnd.service: Failed to execute command: No such file or directory
systemd[9378]: acrnd.service: Failed at step EXEC spawning /usr/bin/killall: No such file or directory
-- Subject: Process /usr/bin/killall could not be executed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /usr/bin/killall could not be executed and failed.
--
-- The error number returned by this process is 2.

Tracked-On: #1563
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
2018-10-25 13:30:14 +08:00
yuhong.tao@intel.com a853c05546 tools: acrnctl: fix: resume default wakeup reason is CBC_WK_RSN_BTN
UOS requires an wakeup reason when resumed from S3 suspend. If user
use "acrnctl resume [VMNAME]" without an reason, 0x0 will be used
as default reason, and this is not work. We can use CBC_WK_RSN_BTN
instead.

Tracked-On: #1550
Signed-off-by: Tao, Yuhong <yuhong.tao@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
2018-10-24 18:13:10 +08:00
Yan, Like 4ce80e5ccc tools: acrn-manager: fix a potential compiler warning
Tracked-On: #1479
Signed-off-by: Yan, Like <like.yan@intel.com>
2018-10-22 09:03:19 +08:00
Yan, Like e8c86566b1 tools: acrn-manager: fix a potential NULL pointer dereference
check the return value of vmmngr_find() before dereference in wait_vm_stop()

Tracked-On: #1479
Signed-off-by: Yan, Like <like.yan@intel.com>
2018-10-22 09:03:19 +08:00
Kaige Fu da3b02702f tools: acrnd: Ignore null line reading from timer_list
Error msg "Invalid vmname from timer list file" will be print out when we read
a null line of file timer_list. It is a litte bit confusing. So, ignore null line
silently to avoid such confusing msg.

Tracked-On: #1517
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
2018-10-20 23:43:39 +08:00
Kaige Fu a45d961bf8 tools: acrnd: check weakup reason first in init_vm
This patch is mainly for:
  1. Check weakup reason first and only load timer list when reason is CBC_WK_RSN_RTC.
  2. If failing to load timer list or reason != CBC_WK_RSN_RTC, activate all vms.
  3. Add info about when we are about to activate vms reading from timer_list file.

Tracked-On: #1517
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
2018-10-20 23:43:39 +08:00
Kaige Fu 193da97103 tools: acrnd: Refine log msg to avoid confusing.
When guest enter S5, its monitor socket will be closed. If we try to use it to
query the vm state, an error msg will be print out. Acctually, we should not take
it as an error.

So, this patch refine the log msg to show more details when guest trying to enter
S3/S5.

Tracked-On: #1506
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
2018-10-19 22:30:17 +08:00
Yan, Like eb97b2f082 tools: acrn-manager: remove assumption of fd num less than 1024
mngr_send_msg() could take mngr descriptor or real socket fd as argument based on
an assuption that real socket fd is less than 1024, which may be an issue.
This commit takes the real socket fd as descriptor, to avoid the conversion between them.

Tracked-On: #1477
Signed-off-by: Tao, Yuhong <yuhong.tao@intel.com>
Signed-off-by: Yan, Like <like.yan@intel.com>
2018-10-16 11:31:57 +08:00
Yan, Like f582757dd4 tools: acrn-manager: fix fd leaking
close dir to avoid fd leaking.

Tracked-On: #1477
Signed-off-by: Tao, Yuhong <yuhong.tao@intel.com>
Signed-off-by: Yan, Like <like.yan@intel.com>
2018-10-16 11:31:57 +08:00
Yan, Like 398ac203ca Update acrn_vm_ops.c 2018-09-27 16:55:50 +08:00
Yan, Like e6c3ea3b3b tools: acrn-manager: init vmmngr_head with LIST_HEAD_INITIALIZER
To fix the issue that vmmngr_head may be used uninitialized.

Tracked-On: #1157
Signed-off-by: Yan, Like <like.yan@intel.com>
2018-09-27 16:55:50 +08:00
Yan, Like 1b9a3b3e71 tools: acrn-manager: update Makefile
Update the Makefiel to sync the compiler options with devicemode
and enable options to harden software.

Tracked-On: #1122
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-25 13:09:41 +08:00
Yan, Like 227a8c436b tools: acrn-manager: fix warnings before updating Makefile
- Print warning if string truncated to avoid the warning generated
  by -Wformat-truncation by GCC 7.0 and newer version;
- fixed strncpy size.

Tracked-On: #1122
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-25 13:09:41 +08:00
yuhong.tao@intel.com 270a833283 tools: acrnd: bugfix: service lack of prerequisition
As a system service, acrnd will launch UOS, that must be done
after all required services and conditions are ready, such as
acrnprobe, weston, etc.

Tracked-On: #1278
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-09-25 13:08:54 +08:00
Yan, Like 4ae88bb676 tools: acrn-manager: fix acrnctl reset issue
Wait for targeting VM stopping before starting it again

Tracked-On: projectacrn/acrn-hypervisor#926
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-09-11 08:41:47 +08:00
Yan, Like f42209c567 tools: acrn-manager: remove unnecessary "current" field
Remove the unnecessary "current" field when store/load timer list.

Tracked-On: #927
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-09-11 08:41:47 +08:00
Yan, Like 0ca90ba6be tools: acrn-manager: rework acrnd resume flow
This commit reworked the resume flow:
 - generate RSN_RTC wakeup reason to resume_vm();
 - clear timer_list in memory once it's saved to fs;
 - wakeup the suspended VMs only if wakeup by ignition button.

Tracked-On: #927
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-09-11 08:41:47 +08:00
Yan, Like 26b8b3b28b tool: acrn-manager: do not wakeup SOS in advance
There is no need to wakeup SOS in advance since UOS wakeup time is
not required to be that exact.

Tracked-On: #927
Signed-off-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Liu Yuan <yuan1.liu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-09-11 08:41:47 +08:00
wenshelx 25dacc5c19 security: Enable '-fpie, -pie' options
To be sure hypervisor and DM are position independent
and executable.

Tracked-On: #1122
Signed-off-by: wenshelx <wenshengx.wang@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-08-31 11:18:26 +08:00
Yan, Like da4c95ba57 tools: acrn-manager: fix several warnings
This commit eliminates several compiler warnings via:
 - added 'const' quilifier to the 1st argument of send_msg();
 - added 'const' quilifier to vm ops functions.

Signed-off-by: Yan, Like <like.yan@intel.com>
2018-08-27 09:51:02 +08:00
yuhong.tao@intel.com a86a25f369 tools: acrnd: Fixed get_sos_wakeup_reason()
get_sos_wakeup_reason() runs into error branch without any error, so
no wakeup reason will be returend.

Acked-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-08-15 11:16:54 +08:00
yuhong.tao@intel.com 2d802d0afe tools: vm_resume() requires wakeup reason
DM need to know wakeup reason when resume the VM, so
vm_resume(char *name) is updated to vm_resume(char *name, unsigned reason),
in acrn_vm_ops.c

Acked-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-08-15 11:16:54 +08:00
Tan Yew Wayne 8af90e0154 misc: Remove unnecessary ExecStop in systemd services
From systemd documentation: https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStop=
> If this option is not specified, the process is terminated by sending the signal specified in KillSignal= when service stop is requested.

https://www.freedesktop.org/software/systemd/man/systemd.kill.html#KillSignal=
> Defaults to SIGTERM.

Signed-off-by: Tan Yew Wayne <yew.wayne.tan@intel.com>
2018-08-09 08:58:12 +08:00
Yuan Liu 66814d8449 tools: fix resuming vm issue in acrnctl
This patch changes vm resuming condition from VM_STARTED to VM_PAUSED

Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Yuhong Tao <yuhong.tao@intel.com>
Reviewed-by: Like Yan <like.yan@intel.com>
2018-08-06 12:29:20 +08:00
Yuan Liu 7b34ae84fa tools: fix resuming vm issue in acrnd
This patch resolves vm state mismatch between vm and acrnd
which causes vm resuming failure

Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Yuhong Tao <yuhong.tao@intel.com>
Reviewed-by: Like Yan <like.yan@intel.com>
2018-08-06 12:29:20 +08:00
Yuan Liu 6cd6e3d3cc tools: fix an issue acrnd does not notify the vm stop state to cbc lifecycle service
This patch resolves acrnd does not notify vm stop state(suspend/shutdown) to
cbc_lifecycle after SOS enters suspend/shutdown, that causes cbc_lifecycle
cannot trigger SOS suspend/shutdown flow.

Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Like Yan <like.yan@intel.com>
2018-08-06 12:29:20 +08:00
Yuan Liu 331300d8b9 tools: fix an invalid parameter of send_msg in query_state
The issue is "acrnctl list" command always returns error with "no vmname
provided" information.

The rootcause is that vmname is an invalid parameter, which does not contain
any vm information.

Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Yuhong Tao <yuhong.tao@intel.com>
Reviewed-by: Like Yan <like.yan@intel.com>
2018-08-06 12:29:20 +08:00
Alek Du 64f62959dc acrn-manager: create acrn-hypervisor-dev package
As first step to separate misc folder into github/intel/ioc-cbc-tools we
need let acrn create devel package. This package will let ioc-cbc-tools
use acrn manager interface API to control lifecycle.

The Clear Linux autospec script will *detect* /usr/include/acrn/*.h and
thus help us create the devel package. This devel pacakge will be in the
build_req for ioc-cbc-tools autospec.

Signed-off-by: Alek Du <alek.du@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Like Yan <like.yan@intel.com>
2018-08-01 15:55:10 +08:00
David B. Kinder e2ad788f63 doc: clean up tools docs
Made the titles consistent across the tools (some had capital letters).
Fixed heading levels in acrnctl/acrnd doc  (had two H1 headings).
Changed a text-based drawing to use graphviz.
Some general grammar tweaks as well.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-07-20 11:42:21 -07:00
yuhong.tao@intel.com 9695d3bd15 tools: replace payload[0] of struct mngr_msg with an union
acrn-manager message structure has a flexible member
payload[0], that risks to out-of-boundary memory access,
and usage of uninitialized variable.
And the req/ack message pairs has various types, which
extend mngr_msg. mngr_send_msg() requires programmer cast
the type of input messages to struct mngr_msg, that is
inconvenient.
We replace payload[0] with an union, which contains all
payload data. So that type cast for mngr_send_msg() is no
longer needed. And we can avoid potential out-of-boundary
memory accessing and using of uninitialized variable

Acked-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-19 11:08:18 +08:00
yuhong.tao@intel.com ec860097d1 tools: acrn-manager: code cleanup
remove test code in acrn_mngr.h

Acked-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-19 11:08:18 +08:00
yuhong.tao@intel.com be80086706 tools: Makefile: fix lack of dependence for acrm_mngr.h
$(OUT_DIR)/acrm_mngr.h miss dependence of ./acrm_mngr.h, that can
cause build problems.
DM & SOS-LCS are built with $(OUT_DIR)/acrm_mngr.h, which is a
copy of tools/acrn-manager/acrm_mngr.h. So when
tools/acrn-manager/acrm_mngr.h is modified, $(OUT_DIR)/acrm_mngr.h
should be updated too.

Acked-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-19 11:08:18 +08:00
yuhong.tao@intel.com dc6d7755e4 tools: acrnd: update README.rst
Reviewed-by: Yan Like <like.yan@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-18 09:20:13 -07:00
yuhong.tao@intel.com 7706e5cef4 tools: acrnd: store/load timer list
When system is going to shutdown, or someone kills Acrnd, and
Acrnd still hold some UOS works in its timer list. Thus Acrnd need
to store UOS timer works to file, so that Acrnd can load and
continue these uncompleted works as it is restarted.

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00
yuhong.tao@intel.com e435f03eda tools: acrnd: handle timer request from UOS
DM can send ACRND_TIMER to Acrnd, then acrnd will setup a timer
for it. When this time is expired, acrnd will try to make this
UOS run again.

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00
yuhong.tao@intel.com ee9ec9d3bf tools: acrnd: the acrnd work list
Acrnd can and put delayed work functions in a work list.

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00
yuhong.tao@intel.com f5e9c768e3 tools: acrnd: handle resume request from SOS-LCS
SOS-Life-Cycle-Service can send ACRND_RESUME to Acrnd. Acrnd first
check If there is a timer list to be load. Then check wakeup reason,
just wait timer works to expire when wakeup reason is RTC, or acrnd
will start/resume all VMs.

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00
yuhong.tao@intel.com 04ed916f26 tools: acrnd: handle stop request from SOS-LCS
SOS-Life-Cycle-Service can ask acrnd to stop UOSs, by sending
ACRND_STOP to Acrnd. Acrnd handles this request by:
1. Try stop all running VMs, and return the result to SOS-LCS.
2. Store pending works of restarting/resuming VMs to file

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00
yuhong.tao@intel.com bcb101f4f0 tools: acrnd: the deamon for acrn-manager
There will be a daemon running on SOS: to forward wakeup_reason to
acrn-dm; to co-ordinate the lifecycle of VMs and SOS; to handle
ioc-timed wakeup/poweron.

1.to forward wakeup_reason to acrn-dm
acrnd is responsible to retrive wakeup_reason from SOS lifecycle
service and attach the wakeup_reason to acrn-dm parameter for ioc-dm;

2.co-ordinate the lifecycle of VMs and SOS
When SOS is about to suspend/shutdown, SOS lifecycle service will
send a request to acrnd to guarantee all guest VMs are suspended
or shutdown before SOS suspending/shutdown process continue. On
receiver the request, acrnd starts polling the guest VMs state, and
notify SOS lifecycle service when all guest VMs are put in proper
state gracefully.

3.handle ioc-timed wakeup/poweron
For vechile specific mode like garage mode, guest UOS may need to
wakeup/poweron in a future time for tasks such as map updating etc.
To setup a timed wakeup/poweron, ioc-dm will send request to acrnd,
acrnd maintains a list of timed requests from guest VMs, and acrnd
selects the nearest request and send it to SOS lifecycle service
who will setup the physical IOC.

Reviewed-by: Yan Like <like.yan@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00
yuhong.tao@intel.com c4f9a2fd70 tools: rework on vm ops
There are some problems to use VM operations in a deamon process,
such as Acrnd.  the list_vm() does not return VM informations, it
just print VM information to stdio, so we have get_vm_list()
to get VM list head vmngr_head; get_vm_list() always creates a
new fresh vm list every time, and must use put_vm_list() to delete
old list. So Acrnd need to create and destroy vm list frequently.
In fact we just need the vmngr_head to be an extern variable. And
to make it refreshable.We can insert new VMs, remove dead ones,
and update their state.

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00