[pve-devel] [PATCH pve_installer v2] tui: don't abort install if min ram requirement is not met

Christoph Heiss c.heiss at proxmox.com
Mon Jul 10 11:08:45 CEST 2023


On Mon, Jul 10, 2023 at 11:00:58AM +0200, Noel Ullreich wrote:
>
> On 10-07-2023 09:27, Christoph Heiss wrote:
> > On Fri, Jul 07, 2023 at 01:53:46PM +0200, Noel Ullreich wrote:
> > > [..]
> > > @@ -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::<InstallerState>().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::<InstallerState>().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.
Right, did not think about that, even had the same problem occur to me
last week while working on some other patches.

Then it is fine as-is of course, maybe just rename it to `total_memory`
as `mem` is quite generic (but that is really just bike-shedding it this
point).





More information about the pve-devel mailing list