Skip to content

feat: Add possibility of assigning a MAC address to VM's VF#16

Open
KTokarze wants to merge 1 commit into
intel:mainfrom
KTokarze:add_mac_address_of_vf
Open

feat: Add possibility of assigning a MAC address to VM's VF#16
KTokarze wants to merge 1 commit into
intel:mainfrom
KTokarze:add_mac_address_of_vf

Conversation

@KTokarze
Copy link
Copy Markdown
Contributor

This pull request adds support for specifying a MAC address when generating the Virtual Function (VF) XML configuration for QEMU in the mfd_kvm hypervisor module. The implementation includes changes to the XML generation logic, a new template, and an additional unit test to ensure correct behavior.

Enhancements to VF XML generation:

  • Updated the prepare_vf_xml method in hypervisor.py to accept an optional mac_address parameter. If provided, the method uses a new template (vf_template_with_mac.xml) that includes the MAC address in the generated XML.
  • Added a new XML template file, vf_template_with_mac.xml, which defines the structure for a VF with a MAC address.

Testing improvements:

  • Added a unit test (test_prepare_vf_xml_with_mac_address) in test_hypervisor.py to verify that the MAC address is correctly rendered in the generated XML when provided.

Signed-off-by: Kacper Tokarzewski <kacper.tokarzewski@intel.com>
Copilot AI review requested due to automatic review settings May 21, 2026 08:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for optionally injecting a MAC address into the generated VF (Virtual Function) XML used by the mfd_kvm QEMU/libvirt configuration path.

Changes:

  • Extend prepare_vf_xml to accept an optional mac_address and render a different XML template when present
  • Add a new VF XML template that includes a <mac .../> element
  • Add a unit test verifying MAC rendering in the produced XML

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/unit/test_mfd_kvm/test_hypervisor.py Adds unit coverage for VF XML generation when a MAC address is provided
mfd_kvm/vf_template_with_mac.xml Introduces a dedicated libvirt hostdev template including a <mac> element
mfd_kvm/hypervisor.py Updates VF XML generation logic to optionally include MAC via a new template

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mfd_kvm/hypervisor.py
Comment on lines +783 to +788
if mac_address is not None:
data_for_template["mac_address"] = str(mac_address)
template_path_with_mac = Path(__file__).parent / "vf_template_with_mac.xml"
file_to_save = self._render_file(file_to_save, data_for_template, template_path_with_mac)
else:
file_to_save = self._render_file(file_to_save, data_for_template, template_path)
Comment thread mfd_kvm/hypervisor.py
Comment on lines 772 to +775
:param template_path: Path to template config
:param file_to_save: Path to destination directory
:param pci_address: PCI Address of VF
:param mac_address: MAC address of VF, if needed to set in config
Comment thread mfd_kvm/hypervisor.py
template_path: Union[Path, str] = Path(__file__).parent / "vf_template.xml",
file_to_save: str,
pci_address: "PCIAddress",
mac_address: Optional[MACAddress] = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use new typehints, "MACAddress" | None

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