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 9644DCA8E for ; Mon, 10 Jul 2023 11:01:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 76FDD3C9D5 for ; Mon, 10 Jul 2023 11:01:01 +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, 10 Jul 2023 11:00:59 +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 9658342503 for ; Mon, 10 Jul 2023 11:00:59 +0200 (CEST) Message-ID: <4ae70068-d2f9-f094-7475-26848564db69@proxmox.com> Date: Mon, 10 Jul 2023 11:00:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: Christoph Heiss , Proxmox VE development discussion References: <20230707115346.50279-1-n.ullreich@proxmox.com> <7457acytclvuaeemho4c2bd5g4zlohdihlawwyhtrs4rf6lyiv@z6umwzo45pca> Content-Language: en-US From: Noel Ullreich In-Reply-To: <7457acytclvuaeemho4c2bd5g4zlohdihlawwyhtrs4rf6lyiv@z6umwzo45pca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.295 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_ASCII_DIVIDERS 0.8 Email that uses ascii formatting dividers and possible spam tricks KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.09 Looks like a legit reply (A) 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: Re: [pve-devel] [PATCH pve_installer v2] tui: don't abort install if min ram requirement is not met 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, 10 Jul 2023 09:01:01 -0000 On 10-07-2023 09:27, Christoph Heiss wrote: > On Fri, Jul 07, 2023 at 01:53:46PM +0200, Noel Ullreich wrote: >> [..] >> >> diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs >> index 64f21fa..99a4a11 100644 >> --- a/proxmox-tui-installer/src/main.rs >> +++ b/proxmox-tui-installer/src/main.rs >> @@ -209,6 +209,8 @@ fn main() { >> in_test_mode, >> }); >> >> + installer_setup_late(&mut siv); >> + > Please remove this, it does not have any (visible) effect here anyway. > installer_setup_late() is already called by switch_to_next_screen(), > as otherwise dialogs will get layered over it by the main content. > >> switch_to_next_screen(&mut siv, InstallerStep::Licence, &license_dialog); >> siv.run(); >> } >> @@ -243,8 +245,6 @@ fn installer_setup(in_test_mode: bool) -> Result<(LocaleInfo, RuntimeInfo), Stri >> .map_err(|err| format!("Failed to retrieve runtime environment info: {err}"))? >> }; >> >> - system::has_min_requirements(&runtime_info)?; >> - >> runtime_info.disks.sort(); >> if runtime_info.disks.is_empty() { >> Err("The installer could not find any supported hard disks.".to_owned()) >> @@ -256,6 +256,7 @@ fn installer_setup(in_test_mode: bool) -> Result<(LocaleInfo, RuntimeInfo), Stri >> /// Anything that can be done late in the setup and will not result in fatal errors. >> fn installer_setup_late(siv: &mut Cursive) { >> let state = siv.user_data::().unwrap(); >> + let mem = state.runtime_info.total_memory; > Nit: Can be folded into the `if` condition directly. It isn't terribly > long nor the condition complicated, and it results in a nice "isolated" > block. This doesn't work: ``` error[E0499]: cannot borrow `*siv` as mutable more than once at a time    --> proxmox-tui-installer/src/main.rs:263:39     | 256 |     let state = siv.user_data::().unwrap();     |                 --------------------------------- first mutable borrow occurs here ... 263 |                 display_setup_warning(siv, &format!("Failed to apply keyboard layout: {err}"));     |                                       ^^^ second mutable borrow occurs here ... 268 |     if state.runtime_info.total_memory < 1024 {     |        ------------------------------- first borrow later used here For more information about this error, try `rustc --explain E0499`. error: could not compile `proxmox-tui-installer` due to previous error ``` That's why I created this extra variable. > >> if !state.in_test_mode { >> let kmap_id = &state.options.timezone.kb_layout; >> @@ -266,6 +267,15 @@ fn installer_setup_late(siv: &mut Cursive) { >> } >> } >> >> + if mem < 1024 { >> + display_setup_warning( >> + siv, >> + concat!( >> + "Less than 1 GiB of usable memory detected, installation will probably fail.\n\n", >> + "See 'System Requirements' in the documentation."), >> + ); >> + } > Formatting is completely off here - just let rustfmt have a go at it :^) > >> + >> if setup_info().config.product == setup::ProxmoxProduct::PVE { >> let cpu_hvm = procfs::read_cpuinfo().map(|info| info.hvm).unwrap_or(false); >> if !cpu_hvm { >> diff --git a/proxmox-tui-installer/src/system.rs b/proxmox-tui-installer/src/system.rs >> index baceab9..7378dba 100644 >> --- a/proxmox-tui-installer/src/system.rs >> +++ b/proxmox-tui-installer/src/system.rs >> @@ -1,18 +1,6 @@ >> use std::{fs::OpenOptions, io::Write, process::Command}; >> >> -use crate::setup::{KeyboardMapping, RuntimeInfo}; >> - >> -pub fn has_min_requirements(info: &RuntimeInfo) -> Result<(), String> { >> - if info.total_memory < 1024 { >> - return Err(concat!( >> - "Less than 1 GiB of usable memory detected, installation will probably fail.\n\n", >> - "See 'System Requirements' in the documentation." >> - ) >> - .to_owned()); >> - } >> - >> - Ok(()) >> -} >> +use crate::setup::{KeyboardMapping}; > Nit: Drop the extra { } pair. Something like that is also automatically > fixed by rustfmt. > >> pub fn set_keyboard_layout(kmap: &KeyboardMapping) -> Result<(), String> { >> Command::new("setxkbmap") >> -- >> 2.39.2 >> >> >> >> _______________________________________________ >> pve-devel mailing list >> pve-devel@lists.proxmox.com >> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >> >>