Skip to content

[libvirt_manager] Add predictable network interface names via --target#3891

Open
holser wants to merge 1 commit intoopenstack-k8s-operators:mainfrom
holser:feat_pnin
Open

[libvirt_manager] Add predictable network interface names via --target#3891
holser wants to merge 1 commit intoopenstack-k8s-operators:mainfrom
holser:feat_pnin

Conversation

@holser
Copy link
Copy Markdown
Contributor

@holser holser commented Apr 24, 2026

Assign deterministic TAP device names on the host by passing --target
to virsh attach-interface, so interface names survive VM reboots and
re-creations instead of getting arbitrary vnetN names from libvirt.

Naming convention: {vm_short}p{net_index} (e.g. compute0p0,
controller0p1). Controlled by cifmw_libvirt_manager_predictable_nic_names
(defaults to true).

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 24, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tosky for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Assign deterministic TAP device names on the host by passing --target
to virsh attach-interface, so interface names survive VM reboots and
re-creations instead of getting arbitrary vnetN names from libvirt.

Naming convention: {vm_short}p{net_index} (e.g. compute0p0,
controller0p1). Controlled by cifmw_libvirt_manager_predictable_nic_names
(defaults to true).

Jira: OSPRH-29381

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergii Golovatiuk <sgolovat@redhat.com>
@evallesp
Copy link
Copy Markdown
Contributor

LGTM, asked for a TP.

@danpawlik danpawlik requested a review from a team April 28, 2026 06:05
{{
(vm_item | default(_clean_vm)) | replace('-', '')
}}
_target_dev: >-
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.

(praise) Great improvement adding --target for predictable NIC naming.
(Question) : _target_dev is currently computed as (_vm_short ~ 'p' ~ (net_idx|int))[:15]. Because this relies on truncation to satisfy the 15‑char limit, there’s a chance of collisions for VMs with similar prefixes. Just another thing to mention, once net_idx goes to 2+ digits (p9 → p10), the suffix length changes and the truncation point shifts, which increases the chance of two different inputs collapsing to the same 15‑char string.

Would you be up for considering a slightly more collision‑resistant naming scheme that still stays within 15 characters (for example a fixed layout like <vm_prefix><short_hash_of _clean_vm>, using only letters and numbers)? Alternatively, a small guard/assert to catch duplicate targets early could also work nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants