feat: Add possibility of assigning a MAC address to VM's VF#16
Open
KTokarze wants to merge 1 commit into
Open
Conversation
Signed-off-by: Kacper Tokarzewski <kacper.tokarzewski@intel.com>
There was a problem hiding this comment.
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_xmlto accept an optionalmac_addressand 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 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 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 |
adrianlasota
requested changes
May 25, 2026
| template_path: Union[Path, str] = Path(__file__).parent / "vf_template.xml", | ||
| file_to_save: str, | ||
| pci_address: "PCIAddress", | ||
| mac_address: Optional[MACAddress] = None, |
Contributor
There was a problem hiding this comment.
use new typehints, "MACAddress" | None
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for specifying a MAC address when generating the Virtual Function (VF) XML configuration for QEMU in the
mfd_kvmhypervisor 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:
prepare_vf_xmlmethod inhypervisor.pyto accept an optionalmac_addressparameter. If provided, the method uses a new template (vf_template_with_mac.xml) that includes the MAC address in the generated XML.vf_template_with_mac.xml, which defines the structure for a VF with a MAC address.Testing improvements:
test_prepare_vf_xml_with_mac_address) intest_hypervisor.pyto verify that the MAC address is correctly rendered in the generated XML when provided.