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