Skip to content

Conversation

@quanwenli
Copy link
Contributor

@quanwenli quanwenli commented Jan 15, 2026

  1. Fix netdst conversion: convert 'private' to 'atbr0' for host IP lookup
  2. Fix MAC address: use tap device mac instead of default gateway mac
  3. Fix pktgen package installation on host when session_serial is none

ID: LIBVIRTAT-22252, LIBVIRTAT-22254, LIBVIRTAT-22256

Summary by CodeRabbit

  • Bug Fixes

    • Ensures VMs are started and verified alive before network operations.
    • Improves host IP resolution for private-network scenarios.
    • Makes host interface detection for packet-generation traffic more reliable.
  • Tests

    • Adds a VM-alive pre-check to avoid test failures when the VM is down.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Walkthrough

Make VM startup conditional in a pktgen burst-mode test: call vm.start() only when the VM is not alive (no verify_alive() call added). Adjust host IP resolution by cloning params and, if netdst == "private", override it with priv_brname (default "atbr0") before computing the host IP. In pktgen utilities, add an import for virttest.utils_test.libvirt, switch host transmit interface resolution to libvirt.get_ifname_host(vm.name, guest_mac), and modify install_package to execute install/clean commands with shell=True when session_serial is not provided.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 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 clearly summarizes the main changes: netdst conversion, MAC address handling, and installation/startup issues across both test and utility files.
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 docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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

🤖 Fix all issues with AI agents
In `@provider/virtual_network/pktgen_utils.py`:
- Line 44: The code calls libvirt.get_ifname_host(...) inside configure_pktgen
(when pkt_cate == "tx") but libvirt is not imported; add the missing import
alongside the other virttest imports at the top of the file, e.g. add "from
virttest import libvirt" (or the existing project import style for
virttest.libvirt) so that libvirt.get_ifname_host and any other libvirt
references resolve at runtime.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03bfa09 and f8dc89a.

📒 Files selected for processing (2)
  • libvirt/tests/src/virtual_network/qemu/pktgen_burst_mode_test.py
  • provider/virtual_network/pktgen_utils.py
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: qiankehan
Repo: autotest/tp-libvirt PR: 6652
File: libvirt/tests/cfg/virtual_network/passt/passt_function.cfg:106-106
Timestamp: 2025-11-24T10:44:47.801Z
Learning: In libvirt/tests/cfg/virtual_network/passt/passt_function.cfg, passt test cases have only one interface, so running `dhcpcd` without specifying an interface is safe and doesn't cause network disruption.
📚 Learning: 2025-11-24T10:44:47.801Z
Learnt from: qiankehan
Repo: autotest/tp-libvirt PR: 6652
File: libvirt/tests/cfg/virtual_network/passt/passt_function.cfg:106-106
Timestamp: 2025-11-24T10:44:47.801Z
Learning: In libvirt/tests/cfg/virtual_network/passt/passt_function.cfg, passt test cases have only one interface, so running `dhcpcd` without specifying an interface is safe and doesn't cause network disruption.

Applied to files:

  • provider/virtual_network/pktgen_utils.py
  • libvirt/tests/src/virtual_network/qemu/pktgen_burst_mode_test.py
📚 Learning: 2025-11-18T08:47:14.465Z
Learnt from: smitterl
Repo: autotest/tp-libvirt PR: 6072
File: libvirt/tests/src/passthrough/pci/libvirt_pci_passthrough_hotplug.py:239-241
Timestamp: 2025-11-18T08:47:14.465Z
Learning: In tp-libvirt tests, `utils_test.ping` is a valid function that exists in the avocado-vt framework (virttest.utils_test module). It is an alias to `utils_net.ping` and supports parameters including dest, count, interface, timeout, and session.

Applied to files:

  • libvirt/tests/src/virtual_network/qemu/pktgen_burst_mode_test.py
🪛 Ruff (0.14.11)
provider/virtual_network/pktgen_utils.py

44-44: Undefined name libvirt

(F821)

🔇 Additional comments (2)
libvirt/tests/src/virtual_network/qemu/pktgen_burst_mode_test.py (2)

64-66: LGTM!

Good defensive check to ensure the VM is running before proceeding with the test. The flow correctly handles the case where the VM might not be alive by starting it and then verifying.


101-104: LGTM!

Good approach to handle the "private" netdst case. Creating a copy of params avoids side effects on the original configuration, and the fallback to "atbr0" provides a sensible default.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@quanwenli quanwenli changed the title Fix pktgen tx test MAC address and VM startup issues Fix pktgen tx test netdst conversion, mac address and vm startup issues Jan 15, 2026
@quanwenli
Copy link
Contributor Author

@nanli1 could you help review this patch? thanks a lot.

@quanwenli quanwenli force-pushed the pktgen branch 2 times, most recently from 61e7385 to c19bc0e Compare January 15, 2026 10:08
@nanli1
Copy link
Contributor

nanli1 commented Jan 20, 2026

@yanglei-rh @nanli1

pktgen_utils.install_package(host_ver)

test.log.debug("TEST_STEP 2: Test with guest and host connectivity")
vm.start()
Copy link
Contributor

Choose a reason for hiding this comment

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

The latest code already removed this step, please according to the latest code to update your patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pktgen_burst_mode_test.py file was modified after I submitted the pr, I have remove it.

vm.copy_files_to(local_path, remote_path)
utils_misc.cmd_status_output(cmd_install, session=session_serial)
utils_misc.cmd_status_output(cmd_clean, session=session_serial)
utils_misc.cmd_status_output(cmd_install, session=session_serial)
Copy link
Contributor

Choose a reason for hiding this comment

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

But according to the code design session_serial will not be none. VM can not copy file if it is None, because the package download to host, you will copy the package via vm.copy_files_to(local_path, remote_path). Therefore, if this section code have a problem, you need to consider re-design this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is required because the host-side pktgen/rx workflow needs the module on host, while guest-side pktgen needs it in guest. otherwise pktgen_utils.install_package(host_ver) will fail. please check issue LIBVIRTAT-22256

Copy link
Contributor

Choose a reason for hiding this comment

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

Got your point.

1. Fix netdst conversion: convert 'private' to 'atbr0' for host IP lookup
2. Fix mac address: use tap device mac instead of default gateway mac
3. Fix pktgen package installation on host when session_serial is none

Signed-off-by: Wenli Quan <[email protected]>
@quanwenli quanwenli changed the title Fix pktgen tx test netdst conversion, mac address and vm startup issues Fix pktgen tx test netdst conversion, mac address and install issue Jan 20, 2026
Copy link
Contributor

@yanglei-rh yanglei-rh left a comment

Choose a reason for hiding this comment

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

LGTM

@nanli1
Copy link
Contributor

nanli1 commented Jan 21, 2026

We need to add test result for failed reason before fix, and case result after this patch

@quanwenli
Copy link
Contributor Author

The failed results were in the LIBVIRTAT-22252, LIBVIRTAT-22254, LIBVIRTAT-22256

The passed result:

avocado run --vt-type libvirt --vt-machine-type q35 --vt-guest-os RHEL.9.7 --vt-extra-params os_variant=rhel-unknown --vt-extra-params "$(cat /root/extra_params_pktgen.cfg)" virtual_network.qemu_test.pktgen_burst_mode_test

JOB ID : a6433bc954e6b86d7fc638d46760570b839b288a
JOB LOG : /root/avocado/job-results/job-2026-01-22T00.41-a6433bc/job.log
(1/1) type_specific.io-github-autotest-libvirt.virtual_network.qemu_test.pktgen_burst_mode_test: STARTED
(1/1) type_specific.io-github-autotest-libvirt.virtual_network.qemu_test.pktgen_burst_mode_test: PASS (112.75 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML : /root/avocado/job-results/job-2026-01-22T00.41-a6433bc/results.html
JOB TIME : 114.97 s

@nanli1 nanli1 merged commit 0b4c929 into autotest:master Jan 22, 2026
2 checks passed
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