]> git.proxmox.com Git - qemu-server.git/commitdiff
fix #5619: honor link-down setting when hot-plugging NIC
authorStefan Hanreich <s.hanreich@proxmox.com>
Tue, 23 Jul 2024 14:24:07 +0000 (16:24 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 24 Jul 2024 08:27:31 +0000 (10:27 +0200)
When detaching and attaching the network device on update, the
link_down setting is not considered and the network device always gets
attached to the guest - even if link_down is set.

Fixes: 3f14f206 ("nic online bridge/vlan change: link disconnect/reconnect")
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/QemuServer.pm

index e885b32af7a62fcd18df823d24c7e3e2094db4be..f9ec0a84ac423e613ac6844f1c9d1c2d3e98fbcc 100644 (file)
@@ -5340,20 +5340,18 @@ sub vmconfig_update_net {
                    PVE::Network::tap_plug($iface, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall}, $newnet->{trunks}, $newnet->{rate});
                }
 
-               #set link_up in guest if bridge or vlan change to notify guest (dhcp renew for example)
-               if (safe_string_ne($oldnet->{bridge}, $newnet->{bridge}) ||
-                   safe_num_ne($oldnet->{tag}, $newnet->{tag})
-               ) {
-                   qemu_set_link_status($vmid, $opt, 1);
-               }
-
            } elsif (safe_num_ne($oldnet->{rate}, $newnet->{rate})) {
                # Rate can be applied on its own but any change above needs to
                # include the rate in tap_plug since OVS resets everything.
                PVE::Network::tap_rate_limit($iface, $newnet->{rate});
            }
 
-           if (safe_string_ne($oldnet->{link_down}, $newnet->{link_down})) {
+           # set link_down on changed bridge/tag as well, because we detach the
+           # network device in the section above if the bridge or tag changed
+           if (safe_string_ne($oldnet->{link_down}, $newnet->{link_down})
+               || safe_string_ne($oldnet->{bridge}, $newnet->{bridge})
+               || safe_num_ne($oldnet->{tag}, $newnet->{tag})
+           ) {
                qemu_set_link_status($vmid, $opt, !$newnet->{link_down});
            }