config: apply pending: code-style & readability improvements

among other things, avoid one indentation level by returning early
from the eval.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2024-03-10 18:26:52 +01:00
parent 3fde43d2ec
commit 7c0f763d0c

View File

@ -5201,9 +5201,10 @@ sub vmconfig_apply_pending {
if (defined($conf->{$opt}) && is_valid_drivename($opt)) {
vmconfig_register_unused_drive($storecfg, $vmid, $conf, parse_drive($opt, $conf->{$opt}))
} elsif (defined($conf->{pending}->{$opt}) && $opt =~ m/^net\d+$/) {
if($have_sdn) {
return if !$have_sdn; # return from eval if SDN is not available
my $new_net = PVE::QemuServer::parse_net($conf->{pending}->{$opt});
if ($conf->{$opt}){
if ($conf->{$opt}) {
my $old_net = PVE::QemuServer::parse_net($conf->{$opt});
if (defined($old_net->{bridge}) && defined($old_net->{macaddr}) && (
@ -5216,7 +5217,6 @@ sub vmconfig_apply_pending {
#fixme: reuse ip if mac change && same bridge
PVE::Network::SDN::Vnets::add_next_free_cidr($new_net->{bridge}, $conf->{name}, $new_net->{macaddr}, $vmid, undef, 1);
}
}
};
if (my $err = $@) {
$add_apply_error->($opt, $err);