Bug 2210044

Summary: Better error message for SRIOV failure on `min-rx-rate`
Product: Red Hat Enterprise Linux 9 Reporter: Gris Ge <fge>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED MIGRATED QA Contact: Mingyu Shi <mshi>
Severity: low Docs Contact:
Priority: unspecified    
Version: 9.2CC: ferferna, jiji, jishi, network-qe, sfaye, till
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-08-17 13:08:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gris Ge 2023-05-25 14:54:39 UTC
Description of problem:

When applying a desire state of nmstate setting SR-IOV `min-rx-rate` on some i40e card, user get failure like:

```
NmstateError: VerificationError: Verification failure: ens1f0.interface.ethernet.sr-iov.total-vfs desire '5', current '0'
```

This give user a wrong impression that nmstate/NetworkManager failure to activate the SR-IOV.

But the actual failure is:

```
kernel: i40e 0000:3b:00.0: Invalid min tx rate (100) (greater than 0) specified for VF 2.
```

When NetworkManager failed to set SR-IOV parameters, NM will disable SRIOV setting which lead to nmstate found SR-IOV been disabled during verification stage.

Version-Release number of selected component (if applicable):
nmstate-2.2.10-3.el9

How reproducible:
100%

Steps to Reproduce:
1. Apply this desire state on i40e card which does not support setting `min-tx-rate`:

```
interfaces:
- name: ens1f0
  type: ethernet
  description: Change QOS on VF0
  state: up
  ethernet:
    sr-iov:
      total-vfs: 5
      vfs:
      - id: 2
        min-tx-rate: 100
        max-tx-rate: 200
```


Actual results:

 VerificationError: Verification failure: ens1f0.interface.ethernet.sr-iov.total-vfs desire '5', current '0'


Expected results:

InvalidArgument: Invalid SR-IOV parameter for interface ens1f0: kernel: i40e 0000:3b:00.0: Invalid min tx rate (100) (greater than 0) specified for VF 2.

Additional info:

Comment 1 Gris Ge 2023-05-25 14:57:55 UTC
Design A: nmstate collect kernel logs

1. On verification error of SR-IOV, nmstate check `NmDeviceStateReason` to
   confirm whether it is a `NM_DEVICE_STATE_REASON_SRIOV_CONFIGURATION_FAILED`.
2. Parse kernel dmesg and collect all warning+ message for failed
   interface(matched PCI address in this case)
3. Show above kernel logs as nmstate log along with `InvalidArgument` error.