All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib: tst_virt: Add option to override virt detection
@ 2021-09-14 15:02 ` Cyril Hrubis
  2021-09-15  4:13     ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2021-09-14 15:02 UTC (permalink / raw)
  To: ltp

There seems to be cases where systemd-detect-virt does not detect
virtualization correctly. To work around this bugs this commit adds a
a support for LTP_VIRT_OVERRIDE environment variable that if set is used
instead of the output from the systemd-detect-virt command.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_virt.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/tst_virt.c b/lib/tst_virt.c
index d23d7f564..0fda20a17 100644
--- a/lib/tst_virt.c
+++ b/lib/tst_virt.c
@@ -100,8 +100,18 @@ static int is_ibmz(int virt_type)
 static int try_systemd_detect_virt(void)
 {
 	FILE *f;
-	char virt_type[64];
+	char virt_buf[64];
 	int ret;
+	char *virt_type = getenv("LTP_VIRT_OVERRIDE");
+
+	if (virt_type) {
+		if (!strcmp("", virt_type))
+			return 0;
+
+		goto cmp;
+	}
+
+	virt_type = virt_buf;
 
 	/* See tst_cmd.c */
 	void *old_handler = signal(SIGCHLD, SIG_DFL);
@@ -129,6 +139,7 @@ static int try_systemd_detect_virt(void)
 	if (ret)
 		return 0;
 
+cmp:
 	if (!strncmp("kvm", virt_type, 3))
 		return VIRT_KVM;
 
-- 
2.26.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] lib: tst_virt: Add option to override virt detection
@ 2021-09-15  4:13     ` Li Wang
  2021-09-15  8:14         ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2021-09-15  4:13 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 465 bytes --]

On Tue, Sep 14, 2021 at 11:02 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> There seems to be cases where systemd-detect-virt does not detect
> virtualization correctly. To work around this bugs this commit adds a
> a support for LTP_VIRT_OVERRIDE environment variable that if set is used
> instead of the output from the systemd-detect-virt command.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
>

Reviewed-by: Li Wang <liwang@redhat.com>

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 1140 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] lib: tst_virt: Add option to override virt detection
@ 2021-09-15  8:14         ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2021-09-15  8:14 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

Hi!
> > There seems to be cases where systemd-detect-virt does not detect
> > virtualization correctly. To work around this bugs this commit adds a
> > a support for LTP_VIRT_OVERRIDE environment variable that if set is used
> > instead of the output from the systemd-detect-virt command.
> >
> > Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> >
> 
> Reviewed-by: Li Wang <liwang@redhat.com>

I've added a description for the variable into doc/user-guide.txt and
pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-15  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 15:02 [LTP] [PATCH] lib: tst_virt: Add option to override virt detection Cyril Hrubis
2021-09-14 15:02 ` Cyril Hrubis
2021-09-15  4:13   ` Li Wang
2021-09-15  4:13     ` Li Wang
2021-09-15  8:14       ` Cyril Hrubis
2021-09-15  8:14         ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.