Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 19, 2025

  • Understand the codebase structure and NIC data collection
  • Modify the NIC info script to detect virtual functions (check for physfn symlink)
  • Add a field to nicInfo struct to track if interface is virtual
  • Update parseNicInfo function to parse virtual function indicator
  • Update nicTableValues to annotate virtual interfaces with "(virtual)"
  • Add tests for virtual function detection
  • Add test for table output with virtual function annotation
  • Verify code quality (format, vet, build)
  • Run security checks (CodeQL)
  • Address code review feedback: Replace HasPrefix + TrimPrefix with CutPrefix

Summary

Successfully implemented virtual function detection for the NIC table. Virtual functions are now identified by checking for the physfn symlink in sysfs and are annotated with "(virtual)" in the interface name column.

Changes Made:

  • Modified NIC info script to detect VFs via /sys/class/net/<ifc>/device/physfn
  • Added IsVirtual field to nicInfo struct
  • Updated parsing to handle "Virtual Function: yes/no" output using modern CutPrefix idiom
  • Modified table rendering to append "(virtual)" to VF interface names
  • Added comprehensive test coverage

Example Output:

Name              | Vendor (ID)        | Model
------------------|--------------------|---------------------------------
eth0 (virtual)    | Intel Corporation  | Ethernet Adaptive Virtual Function
eth1              | Intel Corporation  | Ethernet Controller E810-C

Validation:

  • ✅ All tests passing (173 lines added)
  • ✅ Code formatted with gofmt
  • ✅ Passed go vet checks
  • ✅ Binary builds successfully
  • ✅ No security vulnerabilities (CodeQL)
  • ✅ Code follows modern Go idioms (CutPrefix)

Security Summary

No security vulnerabilities were discovered during implementation. CodeQL analysis returned 0 alerts.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add section for NIC virtual functions</issue_title>
<issue_description>Virtual Functions

Bus Name Associated interface
0000:c0:11.0 Ethernet Adaptive Virtual Function eth0
0000:c0:11.1 Ethernet Adaptive Virtual Function eth0
0000:c0:11.2 Ethernet Adaptive Virtual Function eth0

I see two ways it could be done:

By checking the memory mapping under lshw -c network
physical interfaces on a card share the same iomemory regions (always?), and the bus address start
virtual interfaces use memory regions from physical card's memory space
Using files under /sys/bus/pci/devices in a manner similar to this script https://github.com/OpenVisualCloud/Media-Transport-Library/blob/main/script/nicctl.sh (BSD-3-Clause)

Split from this original Issue: #377

</issue_description>

<agent_instructions>Do not create a new table. Extend NIC table to include virtual functions, if not already included. Identify virtual functions by annotating the interface name with "(virtual)". </agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #523


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 19, 2025 21:59
- Modified NIC info script to detect virtual functions via physfn symlink
- Added IsVirtual field to nicInfo struct
- Updated parseNicInfo to parse Virtual Function field
- Updated nicTableValues to annotate virtual interfaces with "(virtual)"
- Added comprehensive tests for virtual function detection

Co-authored-by: harp-intel <78619061+harp-intel@users.noreply.github.com>
- Added TestNicTableValuesWithVirtualFunction to verify "(virtual)" annotation
- Test ensures virtual functions are properly annotated in table output
- Test ensures physical functions are not annotated

Co-authored-by: harp-intel <78619061+harp-intel@users.noreply.github.com>
Copilot AI changed the title [WIP] Add section for NIC virtual functions Add virtual function detection and annotation to NIC table Oct 19, 2025
Copilot AI requested a review from harp-intel October 19, 2025 22:09
Copilot finished work on behalf of harp-intel October 19, 2025 22:09
@harp-intel harp-intel marked this pull request as ready for review October 19, 2025 22:50
}
// Check if this is a virtual function
if strings.HasPrefix(line, "Virtual Function: ") {
value := strings.TrimSpace(strings.TrimPrefix(line, "Virtual Function: "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot go-modernize is failing. Replace HasPrefix + TrimPrefix with CutPrefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit c8f9d57. Replaced HasPrefix + TrimPrefix with CutPrefix for the virtual function detection logic.

Use CutPrefix instead of HasPrefix followed by TrimPrefix for virtual
function detection, following modern Go idioms.

Co-authored-by: harp-intel <78619061+harp-intel@users.noreply.github.com>
Copilot finished work on behalf of harp-intel October 20, 2025 13:28
Copilot AI requested a review from harp-intel October 20, 2025 13:28
@harp-intel harp-intel merged commit 2a4ad53 into main Oct 20, 2025
8 of 9 checks passed
@harp-intel harp-intel deleted the copilot/add-nic-virtual-functions branch October 22, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add section for NIC virtual functions

2 participants