[PATCH v2 lkp-tests] tests: fix error when running host-info in vm or docker

[why] Error: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory [how] Run ipmi command only on physical machines Signed-off-by: Zhang Yu <2134782174@qq.com> --- tests/host-info | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/host-info b/tests/host-info index 84f796dcb..6ac20c120 100755 --- a/tests/host-info +++ b/tests/host-info @@ -1,5 +1,7 @@ #!/bin/bash +. $LKP_SRC/lib/env.sh + get_memory() { memory_total=$(cat /proc/meminfo |grep MemTotal | awk '{print $2}') @@ -101,8 +103,9 @@ get_ipmi_ip() # 802.1q VLAN ID : Disabled # RMCP+ Cipher Suites : 0,1,2,3,17 # Cipher Suite Priv Max : XuuaXXXXXXXXXXX + is_virt || is_docker && return local ip=$(ipmitool lan print | awk 'NR==3{print $4}') - [ -n "$ip" ] && echo "ipmi_ip:" $ip + [ -n "$ip" ] && echo "ipmi_ip: $ip" } -- 2.23.0

On Mon, Dec 14, 2020 at 02:16:00PM +0800, Zhang Yu wrote:
[why] Error: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No
Then should detect those devices, not docker.
+ is_virt || is_docker && return
Don't mix || and && in same line. Thanks, Fengguang

On Mon, Dec 14, 2020 at 02:50:58PM +0800, Wu Fengguang wrote:
On Mon, Dec 14, 2020 at 02:16:00PM +0800, Zhang Yu wrote:
[why] Error: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No
Then should detect those devices, not docker.
it's not safe when vm could use ipmitool connect to bmc os, for example, use `ipmitool power reset`, the host machine will be reboot.
+ is_virt || is_docker && return
Don't mix || and && in same line.
Thanks, Fengguang

On Tue, Dec 15, 2020 at 03:12:57PM +0800, Zhang Dewan wrote:
On Mon, Dec 14, 2020 at 02:50:58PM +0800, Wu Fengguang wrote:
On Mon, Dec 14, 2020 at 02:16:00PM +0800, Zhang Yu wrote:
[why] Error: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No
Then should detect those devices, not docker.
it's not safe when vm could use ipmitool connect to bmc os, for example, use `ipmitool power reset`, the host machine will be reboot.
I mean such test [[ -e /dev/ipmi0 ]] || [[ -e /dev/ipmi/0 ]] || [[ -e /dev/ipmidev/0 ]] ||
+ is_virt || is_docker && return
Don't mix || and && in same line.
Thanks, Fengguang

On Wed, Dec 16, 2020 at 10:56:29AM +0800, Wu Fengguang wrote:
On Tue, Dec 15, 2020 at 03:12:57PM +0800, Zhang Dewan wrote:
On Mon, Dec 14, 2020 at 02:50:58PM +0800, Wu Fengguang wrote:
On Mon, Dec 14, 2020 at 02:16:00PM +0800, Zhang Yu wrote:
[why] Error: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No
Then should detect those devices, not docker.
it's not safe when vm could use ipmitool connect to bmc os, for example, use `ipmitool power reset`, the host machine will be reboot.
I mean such test
[[ -e /dev/ipmi0 ]] || [[ -e /dev/ipmi/0 ]] || [[ -e /dev/ipmidev/0 ]] ||
I misunderstood! Thanks, Dewan
+ is_virt || is_docker && return
Don't mix || and && in same line.
Thanks, Fengguang
participants (3)
-
Wu Fengguang
-
Zhang Dewan
-
Zhang Yu