]> git.proxmox.com Git - qemu-server.git/commitdiff
config: apply pending: code-style & readability improvements
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 10 Mar 2024 17:26:52 +0000 (18:26 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 10 Mar 2024 17:29:26 +0000 (18:29 +0100)
among other things, avoid one indentation level by returning early
from the eval.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/QemuServer.pm

index 594d50f3e02b0786b28321ea4b485aae2565a45d..9bc1156bd4813d4d0c7f240a344a59f3a166a433 100644 (file)
@@ -5201,21 +5201,21 @@ 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) {
-                    my $new_net = PVE::QemuServer::parse_net($conf->{pending}->{$opt});
-                   if ($conf->{$opt}){
-                       my $old_net = PVE::QemuServer::parse_net($conf->{$opt});
-
-                       if (defined($old_net->{bridge}) && defined($old_net->{macaddr}) && (
-                           safe_string_ne($old_net->{bridge}, $new_net->{bridge}) ||
-                           safe_string_ne($old_net->{macaddr}, $new_net->{macaddr})
-                       )) {
-                           PVE::Network::SDN::Vnets::del_ips_from_mac($old_net->{bridge}, $old_net->{macaddr}, $conf->{name});
-                       }
-                  }
-                  #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);
+               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}) {
+                   my $old_net = PVE::QemuServer::parse_net($conf->{$opt});
+
+                   if (defined($old_net->{bridge}) && defined($old_net->{macaddr}) && (
+                       safe_string_ne($old_net->{bridge}, $new_net->{bridge}) ||
+                       safe_string_ne($old_net->{macaddr}, $new_net->{macaddr})
+                   )) {
+                       PVE::Network::SDN::Vnets::del_ips_from_mac($old_net->{bridge}, $old_net->{macaddr}, $conf->{name});
+                   }
                }
+               #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 = $@) {