public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server 1/1] fix #5619: honor link_down setting when hot-plugging nic
@ 2024-07-23 13:14 Stefan Hanreich
  2024-07-23 14:00 ` Fiona Ebner
  2024-07-23 14:25 ` Stefan Hanreich
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Hanreich @ 2024-07-23 13:14 UTC (permalink / raw)
  To: pve-devel

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>
---
 PVE/QemuServer.pm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 88c274d..19e59a8 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5339,20 +5339,16 @@ 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})) {
+	    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});
 	    }
 
-- 
2.39.2


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH qemu-server 1/1] fix #5619: honor link_down setting when hot-plugging nic
  2024-07-23 13:14 [pve-devel] [PATCH qemu-server 1/1] fix #5619: honor link_down setting when hot-plugging nic Stefan Hanreich
@ 2024-07-23 14:00 ` Fiona Ebner
  2024-07-23 14:14   ` Stefan Hanreich
  2024-07-23 14:25 ` Stefan Hanreich
  1 sibling, 1 reply; 4+ messages in thread
From: Fiona Ebner @ 2024-07-23 14:00 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stefan Hanreich


Am 23.07.24 um 15:14 schrieb Stefan Hanreich:
> 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")
> 

Please don't use newlines between trailers.

> Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>

> ---
>  PVE/QemuServer.pm | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 88c274d..19e59a8 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -5339,20 +5339,16 @@ 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)

I'd prefer to not remove the comment completely, but adapt and move it
to below. Then nobody needs to wonder why link status is set if only
bridge or tag changes 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})) {
> +	    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});
>  	    }
>  


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH qemu-server 1/1] fix #5619: honor link_down setting when hot-plugging nic
  2024-07-23 14:00 ` Fiona Ebner
@ 2024-07-23 14:14   ` Stefan Hanreich
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hanreich @ 2024-07-23 14:14 UTC (permalink / raw)
  To: Fiona Ebner, Proxmox VE development discussion



On 7/23/24 16:00, Fiona Ebner wrote:
> 
> Am 23.07.24 um 15:14 schrieb Stefan Hanreich:
>> 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")
>>
> 
> Please don't use newlines between trailers.

Yes, I only noticed after sending

> 
>> Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
> 
> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
> 
>> ---
>>  PVE/QemuServer.pm | 12 ++++--------
>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>> index 88c274d..19e59a8 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -5339,20 +5339,16 @@ 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)
> 
> I'd prefer to not remove the comment completely, but adapt and move it
> to below. Then nobody needs to wonder why link status is set if only
> bridge or tag changes for example.

Makes sense, I'll re-add a similar comment in a v2

> 
>> -		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})) {
>> +	    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});
>>  	    }
>>  


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH qemu-server 1/1] fix #5619: honor link_down setting when hot-plugging nic
  2024-07-23 13:14 [pve-devel] [PATCH qemu-server 1/1] fix #5619: honor link_down setting when hot-plugging nic Stefan Hanreich
  2024-07-23 14:00 ` Fiona Ebner
@ 2024-07-23 14:25 ` Stefan Hanreich
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Hanreich @ 2024-07-23 14:25 UTC (permalink / raw)
  To: pve-devel

sent a v2:
https://lists.proxmox.com/pipermail/pve-devel/2024-July/064855.html

On 7/23/24 15:14, Stefan Hanreich wrote:
> 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>
> ---
>  PVE/QemuServer.pm | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 88c274d..19e59a8 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -5339,20 +5339,16 @@ 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})) {
> +	    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});
>  	    }
>  


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-23 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-23 13:14 [pve-devel] [PATCH qemu-server 1/1] fix #5619: honor link_down setting when hot-plugging nic Stefan Hanreich
2024-07-23 14:00 ` Fiona Ebner
2024-07-23 14:14   ` Stefan Hanreich
2024-07-23 14:25 ` Stefan Hanreich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal