From patchwork Tue Sep 14 15:02:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1528022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=NEVZql4I; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=iyRKkVTp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H865B5Xjhz9sVq for ; Wed, 15 Sep 2021 01:02:06 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 168353C924F for ; Tue, 14 Sep 2021 17:02:04 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id BB2733C1D8B for ; Tue, 14 Sep 2021 17:02:01 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id AFE2D1A00FB8 for ; Tue, 14 Sep 2021 17:02:00 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A9A141FDFE for ; Tue, 14 Sep 2021 15:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1631631719; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=fcxa6xkok6yCmf6dlR8kLdNjXBbO+JyMy+kQ6NqJZHc=; b=NEVZql4IsAyoi26kbM2YJhbMH9ZJqOFyOL6JaugZ3/Fc7O2h/NkJjhu9EKGl5lSanfO4O6 83eks2guv/ZT+2f6TUj3/jj0LhcZPJrcpJUfIbzB7Shm4R2GP4as3yBK6DU+76t+Rv58IU N8P55OINbmLTevmGrne/JkdPWkuEoag= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1631631719; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=fcxa6xkok6yCmf6dlR8kLdNjXBbO+JyMy+kQ6NqJZHc=; b=iyRKkVTp4oLCOU7qWpOjIAB1Kyav1ZzlmY5Xs/GTP8S6VrFAL+38R9ygPUJ/SrLy9wq/VS gVtqe3n1CneKmkDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 938E213C15 for ; Tue, 14 Sep 2021 15:01:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XiAHI2e5QGFBCAAAMHmgww (envelope-from ) for ; Tue, 14 Sep 2021 15:01:59 +0000 From: Cyril Hrubis To: ltp@lists.linux.it Date: Tue, 14 Sep 2021 17:02:20 +0200 Message-Id: <20210914150220.2467-1-chrubis@suse.cz> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH] lib: tst_virt: Add option to override virt detection X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "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 Reviewed-by: Li Wang --- 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;