From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (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 lists.proxmox.com (Postfix) with ESMTPS id CD9D8B852 for ; Mon, 3 Jul 2023 09:35:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B6E2B19317 for ; Mon, 3 Jul 2023 09:35:07 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 3 Jul 2023 09:35:06 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3B070436A0 for ; Mon, 3 Jul 2023 09:35:06 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Mon, 3 Jul 2023 09:34:58 +0200 Message-Id: <20230703073500.290868-2-c.heiss@proxmox.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703073500.290868-1-c.heiss@proxmox.com> References: <20230703073500.290868-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.074 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer 1/3] run env: add hardware-accelerated virtualization support flag X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jul 2023 07:35:07 -0000 Can later be used by the installer frontends, as well as nicely alinging with the 'single source of truth' "policy". Signed-off-by: Christoph Heiss --- Proxmox/Install/RunEnv.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Proxmox/Install/RunEnv.pm b/Proxmox/Install/RunEnv.pm index b9fb139..9878f55 100644 --- a/Proxmox/Install/RunEnv.pm +++ b/Proxmox/Install/RunEnv.pm @@ -35,6 +35,25 @@ sub query_total_memory : prototype() { return $mem_total; } +my $cpu_hvm_support = undef; +sub query_cpu_hvm_support : prototype() { + return $cpu_hvm_support if defined($cpu_hvm_support); + + open (my $CPUINFO, '<', '/proc/cpuinfo'); + + my $res = 0; + while (my $line = <$CPUINFO>) { + if ($line =~ /^flags\s*:.*(vmx|svm)/m) { + $res = 1; + last; + } + } + close($CPUINFO); + + $cpu_hvm_support = $res; + return $cpu_hvm_support; +} + # Returns a hash. # # { @@ -207,6 +226,11 @@ my sub detect_country_tracing_to : prototype($$) { # Returns the entire environment as a hash. # { # country => , +# ipconf = , +# kernel_cmdline = , +# total_memory = , +# hvm_supported = <1 if the CPU supports hardware-accelerated virtualization>, +# boot_type = , # disks => , # network => { # interfaces => , @@ -246,6 +270,7 @@ sub query_installation_environment : prototype() { $output->{kernel_cmdline} = file_read_firstline("/proc/cmdline"); $output->{total_memory} = query_total_memory(); + $output->{hvm_supported} = query_cpu_hvm_support(); $output->{boot_type} = -d '/sys/firmware/efi' ? 'efi' : 'bios'; my $err; -- 2.40.1