From cc7e6da98cc992d2e6d8aa85cd78f02fb8ef8ac3 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Sun, 21 Feb 2021 22:43:57 +0100 Subject: [PATCH 2/5] SR-IOV: Do not create VF profiles automatically As VFs are Ethernet type and Nmstate is automatically adding them to the desired state and marking them as desired, the profile is being created. This is wrong as Nmstate should only wait for verification of the VFs. In order to fix this, the new VF interfaces are being marked as so. This way Nmstate is not creating the profiles anymore. Integration test case added. Signed-off-by: Fernando Fernandez Mancera --- libnmstate/ifaces/ethernet.py | 10 ++++ libnmstate/ifaces/ifaces.py | 1 + libnmstate/nm/applier.py | 5 ++ tests/integration/nm/sriov_test.py | 92 ++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 tests/integration/nm/sriov_test.py diff --git a/libnmstate/ifaces/ethernet.py b/libnmstate/ifaces/ethernet.py index 3e1bdc5d..f1ece5f5 100644 --- a/libnmstate/ifaces/ethernet.py +++ b/libnmstate/ifaces/ethernet.py @@ -25,6 +25,9 @@ from libnmstate.schema import InterfaceState from .base_iface import BaseIface +IS_NEW_SR_IOV_VF = "_is_new_sr_iov_vf" + + class EthernetIface(BaseIface): def merge(self, other): """ @@ -57,6 +60,13 @@ class EthernetIface(BaseIface): .get(Ethernet.SRIOV.TOTAL_VFS, 0) ) + @property + def is_new_sr_iov_vf(self): + return self.raw.get(IS_NEW_SR_IOV_VF) + + def mark_as_new_sr_iov_vf(self): + self.raw[IS_NEW_SR_IOV_VF] = True + def create_sriov_vf_ifaces(self): return [ EthernetIface( diff --git a/libnmstate/ifaces/ifaces.py b/libnmstate/ifaces/ifaces.py index 67ab91c4..a7af9712 100644 --- a/libnmstate/ifaces/ifaces.py +++ b/libnmstate/ifaces/ifaces.py @@ -144,6 +144,7 @@ class Ifaces: for new_iface in iface.create_sriov_vf_ifaces(): if new_iface.name not in self._ifaces: new_iface.mark_as_desired() + new_iface.mark_as_new_sr_iov_vf() new_ifaces.append(new_iface) for new_iface in new_ifaces: self._ifaces[new_iface.name] = new_iface diff --git a/libnmstate/nm/applier.py b/libnmstate/nm/applier.py index 8e38df54..cd319ffb 100644 --- a/libnmstate/nm/applier.py +++ b/libnmstate/nm/applier.py @@ -119,6 +119,11 @@ def apply_changes(context, net_state, save_to_disk): original_desired_iface_state = {} if net_state.ifaces.get(ifname): iface = net_state.ifaces[ifname] + if iface.type == InterfaceType.ETHERNET and iface.is_new_sr_iov_vf: + # For new vfs automatically added to the desired state is just + # for verification, Nmstate should not create a profile for + # them. + continue if iface.is_desired: original_desired_iface_state = iface.original_dict if ( -- 2.29.2