Skip to content

Conversation

@smitterl
Copy link
Contributor

@smitterl smitterl commented Dec 9, 2025

Depends on avocado-framework/avocado-vt#4280

We previously enabled configuration for host face selection for bridge setup to account for environments where it's not the default interface (the first one). However, the test case also requires this for the remote host as it's a migration test case.

Add this option and the same setting logic as for 'host_iface'.

Summary by CodeRabbit

  • New Features

    • Added support for explicit remote host interface configuration in network migration tests.
  • Tests

    • Enhanced bridge creation logic for both Linux and OVS bridge types with improved remote session handling.
    • Refactored test code with improved parameter formatting and control flow.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

This change introduces explicit remote interface handling to a virtual network migration test. A new configuration key remote_host_iface is added to the CFG file, and the corresponding Python test module is updated to resolve and persist this remote interface identifier during setup and teardown flows. The bridge creation logic for both linux and ovs network types is modified to utilize this remote interface parameter. Additionally, string literals are converted from single to double quotes, and minor formatting adjustments are applied throughout.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • The setup and teardown flow modifications for explicit remote_host_iface resolution require careful verification to ensure proper remote session handling and parameter persistence
  • Bridge creation logic changes for both linux and ovs paths should be validated against expected network configuration behavior
  • The heterogeneous nature of logic changes combined with formatting updates across multiple code paths increases review complexity
  • String literal conversions are mechanical and lower-risk, but the mix with functional logic changes necessitates careful attention to avoid conflating cosmetic and behavioral modifications

Pre-merge checks and finishing touches

✅ 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 describes the main change: enabling remote host interface configuration for the virtual_network migrate_with_bridge test case, which aligns with the actual changes to both config and source files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

We previously enabled configuration for host face selection for bridge
setup to account for environments where it's not the default interface
(the first one). However, the test case also requires this for the
remote host as it's a migration test case.

Add this option and the same setting logic as for 'host_iface'.
For this, the setting logic has to be brought further up in the
execution where the variable is defined.

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
@smitterl smitterl force-pushed the vn_add_remote_iface_config branch from c0b31a0 to 25e5d62 Compare December 9, 2025 16:11
@smitterl
Copy link
Contributor Author

smitterl commented Dec 9, 2025

# avocado run --vt-type libvirt --vt-omit-data-loss --vt-machine-type s390-virtio virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_interface.precopy_migration.linux_bridge --job-timeout 1200 --vt-conn
ect-uri qemu:///system --vt-extra-params "host_iface = enc2                                                                                                                                                                                                                               
remote_host_iface = enc2"
JOB ID     : 9019ee600f3d73383e05f2c1eadf11f3a8688d1d
JOB LOG    : /var/log/avocado/job-results/job-2025-12-09T11.06-9019ee6/job.log
 (1/1) type_specific.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_interface.precopy_migration.linux_bridge: STARTED
 (1/1) type_specific.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_interface.precopy_migration.linux_bridge:  PASS (259.13 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/log/avocado/job-results/job-2025-12-09T11.06-9019ee6/results.html
JOB TIME   : 260.43 s

@smitterl smitterl requested review from cliping and nanli1 December 9, 2025 16:43
@smitterl smitterl added the depend on The PR has dependency on other PRs label Dec 9, 2025
The ovs bridge must be created with a specific host interface that
provides DHCP which in our case isn't the default.

If the value is not configured the behavior is unchanged.

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
@smitterl
Copy link
Contributor Author

smitterl commented Dec 9, 2025

# avocado run --vt-type libvirt --vt-omit-data-loss --vt-machine-type s390-virtio virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_interface.precopy_migration.ovs_bridge --job-timeout 1200 --vt-connect-uri qemu:///system --vt-extra-params "host_iface = enc2
remote_host_iface = enc2
outside_ip = 192.168.126.1"
No python imaging library installed. Screendump and Windows guest BSOD detection are disabled. In order to enable it, please install python-imaging or the equivalent for your distro.
JOB ID     : e401b8903fed2bc9b3ecab8e1c9f9b553ccfb18b
JOB LOG    : /var/log/avocado/job-results/job-2025-12-09T12.05-e401b89/job.log
 (1/1) type_specific.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_interface.precopy_migration.ovs_bridge: STARTED
 (1/1) type_specific.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_interface.precopy_migration.ovs_bridge:  PASS (262.46 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/log/avocado/job-results/job-2025-12-09T12.05-e401b89/results.html
JOB TIME   : 263.84 s
``

Our test server with dhcp doesn't have external connection, so use gateway for ping.

@smitterl smitterl marked this pull request as ready for review December 9, 2025 17:15
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

🧹 Nitpick comments (3)
libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py (3)

175-179: Consider using the variable directly for consistency.

While params.get("remote_host_iface") works correctly, using the remote_host_iface variable directly (as done in the OVS teardown at line 189) would be more consistent and clearer.

Apply this diff for consistency:

         utils_net.delete_linux_bridge_tmux(
             bridge_name,
-            iface_name=params.get("remote_host_iface"),
+            iface_name=remote_host_iface,
             session=remote_session,
         )

220-220: Consider removing unused variable.

The variable src_uri is assigned but never used in the code. If it's not needed for future use, consider removing it.

-    src_uri = params.get("virsh_migrate_connect_uri")
     dest_uri = params.get("virsh_migrate_desturi")

233-233: Consider removing unused variable.

The variable new_xml is assigned but never used in the code. If it's not needed for future use, consider removing it.

     vm = env.get_vm(vm_name)
-    new_xml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c99bc09 and 63ba582.

📒 Files selected for processing (2)
  • libvirt/tests/cfg/virtual_network/migrate/migrate_with_bridge_type_interface.cfg (1 hunks)
  • libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py (6 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 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:

  • libvirt/tests/cfg/virtual_network/migrate/migrate_with_bridge_type_interface.cfg
  • libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.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/migrate/migrate_with_bridge_type_interface.py
📚 Learning: 2025-09-24T08:01:27.899Z
Learnt from: hholoubk
Repo: autotest/tp-libvirt PR: 6579
File: libvirt/tests/src/sriov/vIOMMU/iommu_device_lifecycle.py:95-97
Timestamp: 2025-09-24T08:01:27.899Z
Learning: In the libvirt test framework used in tp-libvirt, VM cleanup including destroying running VMs is handled by the teardown method (test_obj.teardown_iommu_test()) called in the finally block, so explicit VM destroy calls on timeout are not necessary according to the maintainers.

Applied to files:

  • libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py
🧬 Code graph analysis (1)
libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py (2)
provider/virtual_network/network_base.py (1)
  • ping_check (98-149)
provider/guest_os_booting/guest_os_booting_base.py (1)
  • get_vm (18-56)
🪛 Ruff (0.14.8)
libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py

220-220: Local variable src_uri is assigned to but never used

Remove assignment to unused variable src_uri

(F841)


222-222: Use of possibly insecure function; consider using ast.literal_eval

(S307)


223-223: Use of possibly insecure function; consider using ast.literal_eval

(S307)


233-233: Local variable new_xml is assigned to but never used

Remove assignment to unused variable new_xml

(F841)

🔇 Additional comments (4)
libvirt/tests/cfg/virtual_network/migrate/migrate_with_bridge_type_interface.cfg (1)

30-30: LGTM! Configuration addition aligns with PR objectives.

The new remote_host_iface configuration key provides the expected capability for specifying the remote host interface during migration tests, mirroring the existing host_iface parameter.

libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py (3)

182-195: LGTM! OVS teardown correctly mirrors the setup logic.

The cleanup properly removes both local and remote OVS bridges with explicit interface names, and deletes networks on both hosts using the remote_args parameter.


113-126: OVS bridge and network setup correctly extended for remote host.

The changes properly configure both local and remote OVS bridges with explicit interface names, and the network is created on both hosts using the remote_args parameter.


107-110: Verify create_linux_bridge_tmux supports the iface_name and session parameters.

Lines 108-110 pass iface_name=remote_host_iface and session=remote_session to create_linux_bridge_tmux(). Confirm these parameters are accepted by the function signature in the utils_net module to ensure the remote bridge creation will work as intended.

Comment on lines +235 to +243
remote_session = aexpect.remote.remote_login(
"ssh", server_ip, "22", server_user, server_pwd, r"[$#%]"
)
remote_host_iface = params.get("remote_host_iface")
if not remote_host_iface:
remote_host_iface = utils_net.get_default_gateway(
iface_name=True, session=remote_session, force_dhcp=False, json=True
)
params.update({"remote_host_iface": remote_host_iface})
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Search for get_default_gateway function definition
ast-grep --pattern 'def get_default_gateway($$$)'

Repository: autotest/tp-libvirt

Length of output: 182


🏁 Script executed:

# Also search with rg for broader context
rg "def get_default_gateway" -A 15

Repository: autotest/tp-libvirt

Length of output: 182


🌐 Web query:

utils_net.get_default_gateway session parameter autotest libvirt

💡 Result:

There is no utils_net.get_default_gateway that takes a session. Use virttest.utils_net.get_host_default_gateway() (host default gateway — no session param). For guest-side lookups use virttest.utils_net.get_guest_ip_addr(session, mac_addr, ...), which does accept a session. [1][2]

Sources:

  • virttest.utils_net API (get_host_default_gateway, get_guest_ip_addr). [1]
  • virttest documentation index showing utils_net functions. [2]

Fix incorrect API call: get_default_gateway does not support the session parameter.

The code at lines 235-242 calls utils_net.get_default_gateway() with a session parameter for remote execution, but this function does not accept a session parameter. For remote gateway resolution, use utils_net.get_guest_ip_addr(session, mac_addr, ...) instead, which is designed to work with session objects. Alternatively, if you need the host default gateway on the remote machine, you may need to execute the appropriate command directly over the remote session.

🤖 Prompt for AI Agents
In
libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py
around lines 235-243, the call to utils_net.get_default_gateway(...,
session=remote_session, ...) is invalid because get_default_gateway does not
accept a session; replace this with a remote-capable call: either call
utils_net.get_guest_ip_addr(remote_session, mac_addr, ...) (provide the
appropriate mac_addr from test params or obtained from the VM) to resolve the
remote address, or run the host command over remote_session to extract the
default gateway (e.g., parse `ip route` / `route -n`) and assign that result to
remote_host_iface; finally update params with the obtained value and remove the
invalid session argument from get_default_gateway usage.

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

Labels

depend on The PR has dependency on other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants