From: Folke Gleumes <f.gleumes@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 2/3] set correct maximum for hdsize input
Date: Tue, 21 Nov 2023 14:20:20 +0100 [thread overview]
Message-ID: <20231121132021.219504-2-f.gleumes@proxmox.com> (raw)
In-Reply-To: <20231121132021.219504-1-f.gleumes@proxmox.com>
previously, when opening the dialog multiple times, the maximum was
determined by the previous set value, not the maxium possible for the
storage
Signed-off-by: Folke Gleumes <f.gleumes@proxmox.com>
---
proxinstall | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/proxinstall b/proxinstall
index cf8f510..4fc31f8 100755
--- a/proxinstall
+++ b/proxinstall
@@ -985,14 +985,11 @@ my $create_label_widget_grid = sub {
return $grid;
};
-# only relevant for raid with its multipl diskX to diskY mappings.
-my $get_selected_hdsize = sub {
- my $hdsize = shift;
- return $hdsize if defined($hdsize);
-
- # compute the smallest disk size of the actually selected disks
+# only returns a value when using raid, undef otherwise
+my $get_max_hdsize = sub {
my $cached_disks = get_cached_disks();
my $disk_count = scalar(@$cached_disks);
+ my $hdsize;
for (my $i = 0; $i < $disk_count; $i++) {
my $cur_hd = $gtk_state->{disk_selection}->{$i} // next;
my $disksize = int(@$cur_hd[2] / (2 * 1024 * 1024.0)); # size in GB
@@ -1000,6 +997,16 @@ my $get_selected_hdsize = sub {
$hdsize = $disksize if $disksize < $hdsize;
}
+ return $hdsize;
+};
+
+# only relevant for raid with its multipl diskX to diskY mappings.
+my $get_selected_hdsize = sub {
+ my $hdsize = shift;
+ return $hdsize if defined($hdsize);
+
+ $hdsize = $get_max_hdsize->();
+
if (my $cfg_hdsize = Proxmox::Install::Config::get_hdsize()) {
# had the dialog open previously and set an even lower size than the disk selection allows
$hdsize = $cfg_hdsize if $cfg_hdsize < $hdsize;
@@ -1011,17 +1018,19 @@ my sub update_hdsize_adjustment {
my ($adjustment, $hdsize) = @_;
$hdsize = $get_selected_hdsize->($hdsize);
+ my $max_hdsize = $get_max_hdsize->() // $hdsize;
# expect that lower = 0 and step increments = 1 still are valid
- $adjustment->set_upper($hdsize + 1);
+ $adjustment->set_upper($max_hdsize + 1);
$adjustment->set_value($hdsize);
}
my sub create_hdsize_adjustment {
my ($hdsize) = @_;
$hdsize = $get_selected_hdsize->($hdsize);
+ my $max_hdsize = $get_max_hdsize->() // $hdsize;
my $cfg_hdsize = Proxmox::Install::Config::get_hdsize();
# params are: initial value, lower, upper, step increment, page increment, page size
- return Gtk3::Adjustment->new($cfg_hdsize || $hdsize, 0, $hdsize+1, 1, 1, 1);
+ return Gtk3::Adjustment->new($cfg_hdsize || $hdsize, 0, $max_hdsize+1, 1, 1, 1);
}
my sub get_hdsize_spin_button {
--
2.39.2
next prev parent reply other threads:[~2023-11-21 13:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 13:20 [pve-devel] [PATCH installer 1/3] perform early check on hdsize Folke Gleumes
2023-11-21 13:20 ` Folke Gleumes [this message]
2023-11-21 13:20 ` [pve-devel] [PATCH installer 3/3] only set hdsize when deviating from the maximum Folke Gleumes
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=20231121132021.219504-2-f.gleumes@proxmox.com \
--to=f.gleumes@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal