]> git.proxmox.com Git - qemu-server.git/commitdiff
config: pending network: avoid undef-warning on old/new comparison
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 10 Mar 2024 17:12:21 +0000 (18:12 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 10 Mar 2024 17:27:22 +0000 (18:27 +0100)
A network device of a VM does not necessarily has to be connected to
an actual bridge, so when a new pending value is set we need to use
the undef-safe compare helpers when checking if there was a change
between old and new value, as otherwise one gets ugly "use of
uninitialized value in string ne" warnings.

Link: https://forum.proxmox.com/threads/143072/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/QemuServer.pm

index 68142fd4374a5d19d5eb1640e1033df092393386..594d50f3e02b0786b28321ea4b485aae2565a45d 100644 (file)
@@ -5206,8 +5206,10 @@ sub vmconfig_apply_pending {
                    if ($conf->{$opt}){
                        my $old_net = PVE::QemuServer::parse_net($conf->{$opt});
 
-                       if ($old_net->{bridge} ne $new_net->{bridge} ||
-                           $old_net->{macaddr} ne $new_net->{macaddr}) {
+                       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});
                        }
                   }