Commit Graph

197 Commits

Author SHA1 Message Date
David Kinder 1ba7cebb1d Update tools/README.rst
Co-Authored-By: gvancuts <geoffroy.vancutsem@intel.com>
2018-11-28 12:24:44 -08:00
Geoffroy Van Cutsem 419feb1a61 Documentation: add a README.rst to the tools/ folder
Add a basic README.rst file to the tools/ folder to give a very brief
introduction and redirect the reader to the online documentation for more
details.

Tracked-On: #1896
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-28 12:24:44 -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
Liu, Xinwu 3d1332f392 tools: acrn-crashlog: refine the log storage
1. remove watching TOMBSTONE in AaaG.
2. add a configurable parameter "foldersize" in MB, sender will drop
   all events when the storaged log size exceeds this parameter.

Tracked-On:#1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Chen Gang <gang.c.chen@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-11-27 14:26:25 +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
zhonghua 9dacc4a57d tools:acrn-crashlog:fix potential issue
this patch fix potential issue of initialization
about local variable in fsutils.c

Tracked-On: #1024
Signed-off-by: Zhonghua <zhonghua.sun@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2018-11-15 16:39:54 +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 e24464a039 tools: acrnlog: remove usage of banned APIs
1, remove unsafe function sscanf
2, replace strlen with strnlen
3, replace atoll with strtoll and replace aoti with strtol

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Tao, Yuhong <yuhong.tao@intel.com>
2018-11-05 09:50:04 +08:00
Liu, Xinwu 3ffa9686ca tools: acrn-crashlog: fix potential issues
Changes include:
1. check the parameter of snprintf
2. remove atoi
3. remove sscanf
4. fix one memleak

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2018-11-02 11:52:01 +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
Tianhua Sun 5493804cab tools: acrnlog: 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
Tianhua Sun a2383b06bf tools: acrntrace: remove unsafe api and return value check for snprintf
1, Return value check for snprintf function
2, Replace 'atoi' with 'strtol'

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
CHEN Gang 2f8c31f6b4 tools: acrn-crashlog: update the documents
This patch updates the documents according to the latest implementation
of crashlogctl.

Tracked-On: #1024
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
2018-10-25 10:03:40 -07:00
xiaojin2 6d076caaa6 tools: acrn-crashlog: remove unsafe apis in usercrash
Since strlen/vsnprintf/ato* api are not safe, so use strnlen instead of
strlen, use vasprintf instead of vsnprintf and use strtol instead of
atoi.

Tracked-On: #1254
Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Huang Yonghua <yonghua.huang@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-25 13:43:04 +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
Liu, Xinwu 9368373fd9 tools: acrn-crashlog: check the pointer after getting sender
get_sender_from_name would return NULL if the name of sender is not
configured in acrnprobe.xml.
This patch check the return value of it.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Huang Yonghua <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-23 09:11:48 +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
Liu, Xinwu 40dbdcde4f tools: acrn-crashlog: remove unsafe strlen in common
Remove strlen in common apis, and change their caller if necessary.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu f25bc50e68 tools: acrn-crashlog: update string operation in acrnprobe
Remove unsafe api strlen except the parameter is a static string.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu 6938caa25f tools: acrn-crashlog: refine the configuration structure
1. get string size when parsing configuration.
2. add 'const' for strings got from configuration.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu fe4d503c3d tools: acrn-crashlog: remove unsafe api sscanf
Use str_split_ere instead of sscanf.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu fb0292846d tools: acrn-crashlog: remove unsafe api sprintf
Using snprintf intead of sprintf.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu 5ecf1078ca tools: acrn-crashlog: remove unsafe apis from android_events.c
1. Refine strings operation.
2. Remove sscanf, sprintf and strlen.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu 48ce01a52f tools: acrn-crashlog: new api in strutils
This patch provides an new api to split string by extended regexp(ere).

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +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
Miguel Bernal Marin b115546b45 crashlog: deprecate acrnprobe_prepare and update Makefile
The `crashlogctl` command is replacing acrnprobe_prepare script.
So, let's remove from the project, and update the Makefile with
the new content.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +08:00
Miguel Bernal Marin f3fc857f56 crashlog: introducing crashlogctl
This patch introduce the command `crashlogctl`,
it is used to enable/disable the ACRN crashlog services.

Also a systemd-tmpfile config file is introduced to create the
/var/log/crashlog directory, and a sysctl config file where
the usercrash-wrapper will be configured at boot time.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +08:00
Miguel Bernal Marin b1a05d17ed crashlog: re-write usercrash-wrapper
Using an O(n^2) function for look up the values from the arguments
simplify the complexity code of the userchrash-wrapper.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +08:00
Miguel Bernal Marin 6981a4dff7 crashlog: do not alter system behavior with watchdog
Instead of installing to systemd config directory, install to
/usr/share/acrn/crashlog. Using this way we not alter the system if it
is not used as a debug platform.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +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
Ming Liu f1cce6710a Makefile: fix cross-compiling issues
Replace all the host paths with a prefix sysroot directory, it defaults
to be empty, but can be overridden by the variable set in
environment(make -e) or being passed to make command.

Tracked-On: #1307
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
2018-09-26 11:04:19 +08:00
Yan, Like 52ee615428 tools: acrnlog: update Makefile
In order 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: Yin Fengwei <fengwei.yin@intel.com>
2018-09-25 13:09:41 +08:00
Yan, Like 74c4d71922 tools: acrnlog: fix several compiler warnings
This commit fixes several compiler warnings before enabling compiler
options to harden software by:
- increase name[] size to avoid string truncation;
- add parentheses around assignment as compiler suggests.

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 c51e213905 tools: acrntrace: 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: Yin Fengwei <fengwei.yin@intel.com>
2018-09-25 13:09:41 +08:00
Yan, Like 5e0acac490 tools: acrntrace: fix several compiler warnings
This commit fixes several compiler warnings before enabling compiler
options to harden software by:
- remove unused variables;
- add parentheses around assignment as compiler suggests;
- print warning if format string is truncated.

Tracked-On: #1122
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-09-25 13:09:41 +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
CHEN Gang 5affe53a9f tools: acrn-crashlog: update Makefile flags
This patch is to sync the compiler options as the Makefile of device model.

Tracked-On: #1122
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
2018-09-25 13:07:43 +08:00
CHEN Gang 726711e27d tools: acrn-crashlog: fix some compiler warnings
This patch is to fix some compiler warnings before enabling the flag to make
compiler warning as compiler error.

The warning message is like:
ignoring return value of ‘write’, declared with attribute warn_unused_result.

Tracked-On: #1122
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
2018-09-25 13:07:43 +08:00
CHEN Gang 33acca5d86 tools: acrn-crashlog: exclude crashlog tool for release version
This patch is to exclude crashlog tool for release version.

Tracked-On: #1024
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-09-20 11:12:52 +08:00