[PATCH v2 lkp-tests] lib/env.sh: fix the check result of is_virt

Signed-off-by: Zhang Yu <2134782174@qq.com> --- lib/env.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/env.sh b/lib/env.sh index 78cfd6f57..fc34aaa8d 100755 --- a/lib/env.sh +++ b/lib/env.sh @@ -69,7 +69,8 @@ is_virt() # run as root [ -n "$(virt-what)" ] else - grep -q -w hypervisor /proc/cpuinfo + grep -q -w hypervisor /proc/cpuinfo && return 1 + return 0 fi } -- 2.23.0

On Wed, Dec 16, 2020 at 09:01:17AM +0800, Zhang Yu wrote:
Signed-off-by: Zhang Yu <2134782174@qq.com> --- lib/env.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/env.sh b/lib/env.sh index 78cfd6f57..fc34aaa8d 100755 --- a/lib/env.sh +++ b/lib/env.sh @@ -69,7 +69,8 @@ is_virt() # run as root [ -n "$(virt-what)" ] else - grep -q -w hypervisor /proc/cpuinfo + grep -q -w hypervisor /proc/cpuinfo && return 1
Are you sure? return 1 means false for shell.
+ return 0 fi }
-- 2.23.0

On Wed, Dec 16, 2020 at 11:58:59AM +0800, Zhang Yu wrote:
- grep -q -w hypervisor /proc/cpuinfo + grep -q -w hypervisor /proc/cpuinfo && return 1
Are you sure? return 1 means false for shell.
If grep success, return 1 means it's a physical machine, return 0 means vm
I can read the code. So don't just translate code into English. What does "hypervisor" in cpuinfo mean? You may search and paste in patch changelog. Thanks, Fengguang
participants (2)
-
Wu Fengguang
-
Zhang Yu