Skip to content

Improve virtual_network.iface_network.net_pxe to support new test tool#6857

Open
yanglei-rh wants to merge 1 commit into
autotest:masterfrom
yanglei-rh:LIBVIRTAT-22430
Open

Improve virtual_network.iface_network.net_pxe to support new test tool#6857
yanglei-rh wants to merge 1 commit into
autotest:masterfrom
yanglei-rh:LIBVIRTAT-22430

Conversation

@yanglei-rh
Copy link
Copy Markdown
Contributor

@yanglei-rh yanglei-rh commented Apr 8, 2026

1.Setup vms is empty to skip create guest command step
2.Add "only Linux" to limit guest type
3.Add selinux context control for tftp folder when setup netdst
4.Setup netdst to virbr0 becuase this scenario depends on libvirt default network

ID: LIBVIRTAT-22430
Signed-off-by: Lei Yang leiyang@redhat.com

Summary by CodeRabbit

  • New Features
    • Extended PXE/VM provisioning options and lifecycle controls.
    • Enabled cloning and explicit selection/removal of boot images and destination NICs.
  • Improvements
    • Conditional handling for local vs. URL-sourced kernel/initrd assets.
    • More robust TFTP setup with improved file permissions, ownership handling, and SELinux relabel attempts.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

Walkthrough

The PR adds PXE/VM provisioning parameters to the net_pxe variant in the network config (VM lifecycle flags, OVMF NVRAM kill options, master image cloning, removal of image1, explicit kernel/initrd, and netdst_nic1) while leaving existing pxe_boot, tftp_root, and bootp_file entries. In the Python test, prepare_pxe_boot() now ensures tftp_root exists, conditionally copies kernel/initrd from the test data directory when netdst is set (otherwise retains URL download path), selects the PXE syslinux file via bootp_file, and applies conditional permission, ownership, and SELinux relabeling steps after writing PXE config.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: improving the virtual_network.iface_network.net_pxe configuration and code to support a new test tool, with specific enhancements to PXE boot setup, netdst parameter handling, and SELinux context control.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libvirt/tests/src/virtual_network/iface_network.py`:
- Around line 104-107: The loop over reference paths [" /usr/sbin/dnsmasq",
"/usr/libexec/libvirt_leaseshelper"] currently calls process.run("chcon -R
--reference %s %s" % (ref, tftp_root), ...) for every existing ref, causing
multiple relabels; change the loop in iface_network.py so that once a matching
ref is found and chcon is executed successfully you break out of the for-loop
(i.e., after the process.run call) to make the list a true fallback and prevent
subsequent overwrites of tftp_root's SELinux context.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4085034f-4681-4ad1-bc16-c3960193c827

📥 Commits

Reviewing files that changed from the base of the PR and between c96ab65 and 5047b96.

📒 Files selected for processing (2)
  • libvirt/tests/cfg/virtual_network/iface_network.cfg
  • libvirt/tests/src/virtual_network/iface_network.py

Comment thread libvirt/tests/src/virtual_network/iface_network.py
1.Setup vms is empty to skip create guest command step
2.Add "only Linux" to limit guest type
3.Add selinux context control for tftp folder when setup netdst
4.Setup netdst to virbr0 becuase this scenario depends on libvirt
default network

Signed-off-by: Lei Yang <leiyang@redhat.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
libvirt/tests/src/virtual_network/iface_network.py (1)

66-74: Consider validating that kernel/initrd files exist before copying.

The copy operations on lines 73-74 will fail with a non-zero exit status if the source files don't exist, which is appropriate. However, adding an existence check with a clearer error message would improve debuggability when the test data is missing.

Additionally, when guest_name is empty (line 69), the path resolves to <data_dir>/images/vmlinuz rather than a guest-specific directory. Verify this is the intended behavior for the test tool.

💡 Optional: Add validation for clearer error messages
         if params.get("netdst"):
             root_dir = data_dir.get_data_dir()
             # Directly use root_dir/images/guest_name, removing export_dir support
             img_dir = os.path.join(root_dir, "images", params.get("guest_name", ""))
 
             kernel = os.path.join(img_dir, params.get("kernel", ""))
             initrd = os.path.join(img_dir, params.get("initrd", ""))
+            if not os.path.exists(kernel):
+                test.error("Kernel file not found: %s" % kernel)
+            if not os.path.exists(initrd):
+                test.error("Initrd file not found: %s" % initrd)
             process.run("cp -f %s %s/vmlinuz" % (kernel, tftp_root), shell=True, verbose=True)
             process.run("cp -f %s %s/initrd.img" % (initrd, tftp_root), shell=True, verbose=True)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libvirt/tests/src/virtual_network/iface_network.py` around lines 66 - 74,
Check that the kernel and initrd files exist before calling process.run: compute
img_dir using data_dir.get_data_dir() and params.get("guest_name"), then
validate os.path.exists(kernel) and os.path.exists(initrd) (kernel and initrd
are the computed paths) and raise a clear RuntimeError or call
processLogger.error with a descriptive message including the full path if either
is missing instead of letting cp fail; also add a small guard/warning when
params.get("guest_name") is empty (so img_dir resolves to root/images/) and
either refuse/raise or log a warning so test authors know this behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@libvirt/tests/src/virtual_network/iface_network.py`:
- Around line 66-74: Check that the kernel and initrd files exist before calling
process.run: compute img_dir using data_dir.get_data_dir() and
params.get("guest_name"), then validate os.path.exists(kernel) and
os.path.exists(initrd) (kernel and initrd are the computed paths) and raise a
clear RuntimeError or call processLogger.error with a descriptive message
including the full path if either is missing instead of letting cp fail; also
add a small guard/warning when params.get("guest_name") is empty (so img_dir
resolves to root/images/) and either refuse/raise or log a warning so test
authors know this behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b010f83a-caff-4e95-b33d-b35fa35c211d

📥 Commits

Reviewing files that changed from the base of the PR and between 5047b96 and fcc62fc.

📒 Files selected for processing (2)
  • libvirt/tests/cfg/virtual_network/iface_network.cfg
  • libvirt/tests/src/virtual_network/iface_network.py

@harvey0100
Copy link
Copy Markdown

Closing this PR due to current team constraints. This is part of a broader effort to triage all in-flight work across our upstream repos. If this work is still needed, please feel free to reopen and it will be picked up. Apologies for any inconvenience.

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.

2 participants