diff mbox series

[1/2] lib/tst_virt: fix detection when systemd-detect-virt returns 1

Message ID 20201106130624.454614-2-egorenar@linux.ibm.com
State Accepted
Headers show
Series lib/tst_virt: support IBM/Z LPAR and z/VM virtualization environments | expand

Commit Message

Alexander Egorenkov Nov. 6, 2020, 1:06 p.m. UTC
From: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>

When systemd-detect-virt detects no virtualization environment,
it returns 1 as exit code. This leads to tst_is_virt not doing any
fallback tests.

The problem can be reproduced inside a IBM System Z LPAR virtualization
environment.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
---
 lib/tst_virt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Cyril Hrubis Nov. 9, 2020, 2:31 p.m. UTC | #1
Hi!
Good catch, applied, thanks.
diff mbox series

Patch

diff --git a/lib/tst_virt.c b/lib/tst_virt.c
index 53d33e69c..914a08d96 100644
--- a/lib/tst_virt.c
+++ b/lib/tst_virt.c
@@ -109,9 +109,9 @@  int tst_is_virt(int virt_type)
 {
 	int ret = try_systemd_detect_virt();
 
-	if (ret >= 0) {
+	if (ret > 0) {
 		if (virt_type == VIRT_ANY)
-			return ret != 0;
+			return 1;
 		else
 			return ret == virt_type;
 	}