In some cases the VM could no longer start when the timeout value was set and afterwards, for example, hibernated. In this case the VM is soft locked in the GUI, because the API would not allow changing the timeout value anymore. (The only way out here would be to change the value manually in the config)
To avoid unwanted side effects, it is possible to change the value for the new 'startoptions' parameter, only if the VM is currently locked with lock 'suspended'. Signed-off-by: Daniel Tschlatscher <d.tschlatsc...@proxmox.com> --- Changes from v2: * Rebased to current master PVE/API2/Qemu.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 8375ab9..a160440 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -11,6 +11,7 @@ use JSON; use URI::Escape; use Crypt::OpenSSL::Random; use Socket qw(SOCK_STREAM); +use List::Util qw(first); use PVE::APIClient::LWP; use PVE::CGroup; @@ -650,6 +651,28 @@ my $check_vm_modify_config_perm = sub { return 1; }; +# Certain parameter fields should still be editable and deletable when the VM is locked +# Returns true only if all parameter fields to be edited or deleted are defined in @allowed +sub skiplock_for_allowed_fields { + my ($param, @deleted) = @_; + + my @allowed = qw"startoptions"; + my $skiplock = 1; + + my @to_check = @deleted; + for (keys %$param) { + push(@to_check, $_); + } + + my $idx = 0; + while ($skiplock && $idx < keys @to_check) { + $skiplock &= defined(first { $_ eq $to_check[$idx] } @allowed); + $idx++; + } + + return $skiplock; +} + __PACKAGE__->register_method({ name => 'vmlist', path => '', @@ -1598,6 +1621,8 @@ my $update_vm_api = sub { push @delete, 'runningcpu' if $conf->{runningcpu}; } + $skiplock |= $conf->{lock} eq "suspended" && skiplock_for_allowed_fields($param, @delete); + PVE::QemuConfig->check_lock($conf) if !$skiplock; foreach my $opt (keys %$revert) { -- 2.30.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel