Skip to content

Comments

Fix VFIO device path missing from env variables#692

Open
SchSeba wants to merge 1 commit intok8snetworkplumbingwg:masterfrom
SchSeba:add_vfio_device_to_info_provider
Open

Fix VFIO device path missing from env variables#692
SchSeba wants to merge 1 commit intok8snetworkplumbingwg:masterfrom
SchSeba:add_vfio_device_to_info_provider

Conversation

@SchSeba
Copy link
Collaborator

@SchSeba SchSeba commented Jan 12, 2026

The vfioInfoProvider was not including the VFIO device path (e.g., /dev/vfio/162) in the environment variables because GetEnvVal() was called before GetDeviceSpecs() during allocation.

The VFIO device file path was computed in GetDeviceSpecs() and stored in vfioDevContainer, but since GetEnvVal() runs first in the Allocate() flow, the field was always empty when building env vars.

Fix: Move the VFIO device file computation to the constructor (NewVfioInfoProvider) so the values are available immediately for both GetEnvVal() and GetDeviceSpecs() regardless of call order.

Before: {"vfio":{"mount":"/dev/vfio/vfio"}}
After: {"vfio":{"mount":"/dev/vfio/vfio","dev-mount":"/dev/vfio/162"}}

The vfioInfoProvider was not including the VFIO device path
(e.g., /dev/vfio/162) in the environment variables because
GetEnvVal() was called before GetDeviceSpecs() during allocation.

The VFIO device file path was computed in GetDeviceSpecs() and stored
in vfioDevContainer, but since GetEnvVal() runs first in the Allocate()
flow, the field was always empty when building env vars.

Fix: Move the VFIO device file computation to the constructor
(NewVfioInfoProvider) so the values are available immediately for
both GetEnvVal() and GetDeviceSpecs() regardless of call order.

Before: {"vfio":{"mount":"/dev/vfio/vfio"}}
After:  {"vfio":{"mount":"/dev/vfio/vfio","dev-mount":"/dev/vfio/162"}}

Signed-off-by: Author <author@example.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @SchSeba, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in the vfioInfoProvider where the VFIO device path was not consistently included in environment variables. The core problem stemmed from the device path being computed too late in the allocation flow. The solution refactors the initialization logic to pre-compute and store the VFIO device file paths within the constructor, ensuring their availability for all subsequent operations and simplifying related methods. This change guarantees correct environment variable population for VFIO devices.

Highlights

  • VFIO Device Path Fix: Resolved an issue where the VFIO device path was not being included in environment variables due to an incorrect order of operations during device allocation.
  • Constructor Initialization: Moved the computation of VFIO device file paths (vfioDevHost, vfioDevContainer) to the NewVfioInfoProvider constructor.
  • Improved Data Availability: Ensured that VFIO device file paths are available immediately upon vfioInfoProvider instantiation, making them accessible to both GetEnvVal() and GetDeviceSpecs() regardless of call order.
  • Refactored GetDeviceSpecs: Updated GetDeviceSpecs() to utilize the pre-computed device paths, removing redundant computation.
  • Test Case Simplification: Simplified a test case in vfioInfoProvider_test.go by removing an unnecessary call to GetDeviceSpecs(), reflecting the new initialization logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug where the VFIO device path was missing from environment variables due to an incorrect initialization order. By moving the VFIO device file computation to the NewVfioInfoProvider constructor, the device path is now available regardless of the call order of GetEnvVal() and GetDeviceSpecs(). The change is logical, well-explained, and the updated tests properly validate the fix. I have one suggestion regarding error handling that could improve the robustness of the code.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 20917905849

Details

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 74.615%

Totals Coverage Status
Change from base Build 20259041166: 0.05%
Covered Lines: 2134
Relevant Lines: 2860

💛 - Coveralls

Copy link
Member

@zeeke zeeke left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants