From ddfc2696e3bbed41b952e75daef00a4629b4f342 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 5 Jun 2025 10:28:07 +0200 Subject: [PATCH] device: allow reapplying the sriov.preserve-on-down property It is useful when there is an already active device and we want to bring it down preserving the SR-IOV VFs. For example: $ nmcli connection add type ethernet ifname eni1np1 sriov.total-vfs 2 ipv4.method disabled ipv6.method disabled $ nmcli connection up ethernet-eni1np1 $ ip link show eni1np1 342: eni1np1: mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 6e:cf:f0:08:74:f4 brd ff:ff:ff:ff:ff:ff vf 0 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ... vf 1 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ... $ nmcli device modify eni1np1 sriov.preserve-on-down yes $ nmcli connection down ethernet-eni1np1 $ ip link show eni1np1 342: eni1np1: mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 6e:cf:f0:08:74:f4 brd ff:ff:ff:ff:ff:ff vf 0 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ... vf 1 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ... (cherry picked from commit 6f219aa649090152388da5f893ea3f0b4f6852ab) --- src/core/devices/nm-device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 35df66ced6..96cacca78e 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -14050,6 +14050,13 @@ can_reapply_change(NMDevice *self, goto out_fail; } + if (nm_streq(setting_name, NM_SETTING_SRIOV_SETTING_NAME)) { + return nm_device_hash_check_invalid_keys(diffs, + NM_SETTING_SRIOV_SETTING_NAME, + error, + NM_SETTING_SRIOV_PRESERVE_ON_DOWN); + } + out_fail: g_set_error(error, NM_DEVICE_ERROR,