public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 1/3] run env: add hardware-accelerated virtualization support flag
Date: Mon,  3 Jul 2023 09:34:58 +0200	[thread overview]
Message-ID: <20230703073500.290868-2-c.heiss@proxmox.com> (raw)
In-Reply-To: <20230703073500.290868-1-c.heiss@proxmox.com>

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 <c.heiss@proxmox.com>
---
 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 => <short country>,
+#     ipconf = <see Proxmox::Sys::Net::get_ip_config()>,
+#     kernel_cmdline = <contents of /proc/cmdline>,
+#     total_memory = <memory size in MiB>,
+#     hvm_supported = <1 if the CPU supports hardware-accelerated virtualization>,
+#     boot_type = <either 'efi' or 'bios'>,
 #     disks => <see Proxmox::Sys::Block::hd_list()>,
 #     network => {
 #         interfaces => <see query_netdevs()>,
@@ -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





  reply	other threads:[~2023-07-03  7:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03  7:34 [pve-devel] [PATCH installer 0/3] export hvm support flag through runtime env Christoph Heiss
2023-07-03  7:34 ` Christoph Heiss [this message]
2023-07-03  7:34 ` [pve-devel] [PATCH installer 2/3] proxinstall: check hvm support through runtime env info Christoph Heiss
2023-07-03  7:35 ` [pve-devel] [PATCH installer 3/3] tui: check hvm support through runtime env info instead of open-coding Christoph Heiss
2023-07-04  8:27 ` [pve-devel] [PATCH installer 4/4] d/control: drop unused librust-proxmox-sys-dev build dependency Christoph Heiss
2023-07-13 13:50 ` [pve-devel] applied-series: [PATCH installer 0/3] export hvm support flag through runtime env Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230703073500.290868-2-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal