Skip to content

Improve migrate_with_bridge_type_interface to adapt to new testing tools#6806

Open
yanglei-rh wants to merge 1 commit intoautotest:masterfrom
yanglei-rh:LIBVIRTAT-22320
Open

Improve migrate_with_bridge_type_interface to adapt to new testing tools#6806
yanglei-rh wants to merge 1 commit intoautotest:masterfrom
yanglei-rh:LIBVIRTAT-22320

Conversation

@yanglei-rh
Copy link
Contributor

@yanglei-rh yanglei-rh commented Feb 14, 2026

1.Add some parameters to allow the framework provide guest xml
2.Change the method for specifying different bridge types via the test command intead of case cfg varaint
3.Add "only Linux" to limit guest type

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

Summary by CodeRabbit

  • Tests
    • Simplified and standardized bridge/interface configuration and naming in migration tests.
    • Added VM lifecycle controls for create/kill and no-reboot scenarios.
    • Improved automatic OVS bridge detection and handling.
    • Removed legacy bridge/bootstore setup and teardown steps from test flows.
    • Consolidated interface attribute handling, renamed migration step identifiers, and preserved precopy/postcopy/cancel variants.

@coderabbitai
Copy link

coderabbitai bot commented Feb 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7ea69c and d46715c.

📒 Files selected for processing (2)
  • libvirt/tests/cfg/virtual_network/migrate/migrate_with_bridge_type_interface.cfg
  • libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • libvirt/tests/cfg/virtual_network/migrate/migrate_with_bridge_type_interface.cfg

Walkthrough

The PR updates the migrate_with_bridge_type_interface config and test: adds VM lifecycle controls and a Linux-only gate; replaces per-bridge variant blocks with top-level bridge_name and iface_type="bridge"; renames flow steps start_with_interface → start_with_iface and hotplug_interface → hotplug_iface; adjusts migration variant structures. In the Python test, iface_dict is replaced by iface_attrs, network_base.setup_ovs_bridge_attrs() is invoked for OVS handling, iface_attrs is passed to create_vm_device_by_type and modify_vm_device, and prior bridge creation/teardown and NVRAM cleanup logic are removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 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 directly describes the main change: improving the migrate_with_bridge_type_interface test to work with new testing tools, which aligns with the core refactoring across both config and source 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 (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py (2)

101-108: 🛠️ Refactor suggestion | 🟠 Major

Remove unused cleanup_nvram function.

This function is defined but never called anywhere in the test. The NVRAM cleanup is now handled by the framework via kill_vm_libvirt_options = --nvram in the config file for OVMF guests.

🗑️ Suggested removal
-    def cleanup_nvram():
-        """
-        Clean up NVRAM file to avoid UEFI boot issues
-        """
-        nvram_file = f"/var/lib/libvirt/qemu/nvram/{vm_name}_VARS.fd"
-        if os.path.exists(nvram_file):
-            test.log.info(f"Removing NVRAM file: {nvram_file}")
-            os.remove(nvram_file)
-

167-169: 🛠️ Refactor suggestion | 🟠 Major

Remove unused variables: bridge_type, ovs_bridge_name, network_dict.

These variables are retrieved from params but never used in the test logic. They appear to be remnants of the removed legacy bridge setup code.

🗑️ Suggested removal
     outside_ip = params.get("outside_ip")
-    bridge_type = params.get("bridge_type")
-    ovs_bridge_name = params.get("ovs_bridge_name")
-    network_dict = eval(params.get("network_dict", "{}"))
     interface_timing = params.get("interface_timing")
🤖 Fix all issues with AI agents
In
`@libvirt/tests/cfg/virtual_network/migrate/migrate_with_bridge_type_interface.cfg`:
- Around line 36-38: The config defines iface_base_attrs but the test builds
iface_attrs directly (see iface_attrs usage in the Python test), so either
remove the unused iface_base_attrs entry or document its purpose; to fix, delete
the iface_base_attrs = {...} line from migrate_with_bridge_type_interface.cfg if
it’s not used, or prepend a one-line comment explaining it’s a
placeholder/example for future tests, or alternatively update the test to read
and use iface_base_attrs when constructing iface_attrs (referencing the
iface_base_attrs symbol in the config) so the config and test stay consistent.
🧹 Nitpick comments (3)
libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py (3)

76-80: Consider defensive handling for empty netdst parameter.

If netdst is empty or not set, bridge_name becomes an empty string, resulting in {'bridge': ''} being set in iface_attrs['source']. This could cause issues during interface attachment.

Consider adding validation:

🛡️ Suggested defensive check
         bridge_name = params.get('netdst', '').split(',')[0]
+        if not bridge_name:
+            test.error("netdst parameter is required but not set")
         iface_attrs['source'] = {'bridge': bridge_name}

196-196: Remove unused variable new_xml.

This variable is assigned but never used in the test.

🗑️ Suggested removal
     vm = env.get_vm(vm_name)
-    new_xml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)

11-11: os import will be unused after removing cleanup_nvram.

If the unused cleanup_nvram function is removed as suggested, this import should also be removed.

🗑️ Conditional removal
 import aexpect.remote
 import re
-import os

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
`@libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py`:
- Around line 70-97: The code currently derives bridge_name only from
params.get('netdst') which can be empty; update the logic that sets bridge_name
so it first uses params.get('bridge_name') (or params['bridge_name'] if you want
fail-fast) and falls back to params.get('netdst').split(',')[0] only if
bridge_name is still empty, and if no bridge name is found raise/abort early
with a clear error before assigning iface_attrs['source']; adjust the place that
sets iface_attrs (the iface_attrs dict creation and the line setting
iface_attrs['source']) and ensure network_base.setup_ovs_bridge_attrs(params,
iface_attrs) still runs after a valid source is set.

@yanglei-rh
Copy link
Contributor Author

Test pass.

 (1/6) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.start_with_iface.precopy_migration.q35: PASS (194.53 s)
 (2/6) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.start_with_iface.postcopy_migration.q35: PASS (157.96 s)
 (3/6) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.start_with_iface.cancel_migration.q35: PASS (107.10 s)
 (4/6) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_iface.precopy_migration.q35: PASS (192.23 s)
 (5/6) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_iface.postcopy_migration.q35: PASS (149.35 s)
 (6/6) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-libvirt.virtual_network.migrate.migrate_with_bridge_type_interface.hotplug_iface.cancel_migration.q35: PASS (103.50 s)

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.

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

196-196: new_xml is assigned but never used.

new_xml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) is a leftover from the old implementation. It makes an unnecessary libvirt call and also makes from virttest.libvirt_xml import vm_xml (line 15) redundant given the direct VMXML import on line 17.

♻️ Proposed cleanup
-    new_xml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
-
     remote_session = aexpect.remote.remote_login(

And remove the now-redundant module-level import:

-from virttest.libvirt_xml import vm_xml
 from virttest.libvirt_xml.vm_xml import VMXML
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py`
at line 196, Remove the unused assignment new_xml =
vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) and any dead call to
vm_xml.VMXML.new_from_inactive_dumpxml in this file, and delete the
now-redundant module import "from virttest.libvirt_xml import vm_xml" since
VMXML is already imported directly; update imports and usages so only the direct
VMXML symbol is used.

101-108: cleanup_nvram() is dead code — remove it (and import os).

The function is defined but never invoked anywhere in run(). NVRAM cleanup is now delegated to the framework via kill_vm_libvirt_options = --nvram in the cfg. Removing it also makes import os (line 11) unused.

♻️ Proposed removal
-import os
-
 ...
-    def cleanup_nvram():
-        """
-        Clean up NVRAM file to avoid UEFI boot issues
-        """
-        nvram_file = f"/var/lib/libvirt/qemu/nvram/{vm_name}_VARS.fd"
-        if os.path.exists(nvram_file):
-            test.log.info(f"Removing NVRAM file: {nvram_file}")
-            os.remove(nvram_file)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py`
around lines 101 - 108, Remove the dead cleanup_nvram() helper and the
now-unused import os: delete the cleanup_nvram() function definition (it’s never
called from run()) and remove the corresponding import os at the top of the
file; NVRAM cleanup is handled via kill_vm_libvirt_options = --nvram so no
additional code is required.

163-169: Remove unused local variables left over from old bridge-setup code.

bridge_type, ovs_bridge_name, and network_dict are assigned but never referenced after these lines. network_base.setup_ovs_bridge_attrs(params, iface_attrs) reads them directly from params, so local extractions are unnecessary.

♻️ Proposed cleanup
-    bridge_type = params.get("bridge_type")
-    ovs_bridge_name = params.get("ovs_bridge_name")
-    network_dict = eval(params.get("network_dict", "{}"))
     interface_timing = params.get("interface_timing")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py`
around lines 163 - 169, Remove the unused local extractions left from the old
bridge setup: delete the assignments for bridge_type, ovs_bridge_name, and
network_dict (the lines that set bridge_type = params.get("bridge_type"),
ovs_bridge_name = params.get("ovs_bridge_name"), and network_dict =
eval(params.get("network_dict", "{}")));
network_base.setup_ovs_bridge_attrs(params, iface_attrs) reads these values
directly from params so keeping local copies is redundant; keep the needed
server_ip/server_user/server_pwd/outside_ip assignments but remove the three
unused variables to clean up the code.
🤖 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/migrate/migrate_with_bridge_type_interface.py`:
- Line 196: Remove the unused assignment new_xml =
vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) and any dead call to
vm_xml.VMXML.new_from_inactive_dumpxml in this file, and delete the
now-redundant module import "from virttest.libvirt_xml import vm_xml" since
VMXML is already imported directly; update imports and usages so only the direct
VMXML symbol is used.
- Around line 101-108: Remove the dead cleanup_nvram() helper and the now-unused
import os: delete the cleanup_nvram() function definition (it’s never called
from run()) and remove the corresponding import os at the top of the file; NVRAM
cleanup is handled via kill_vm_libvirt_options = --nvram so no additional code
is required.
- Around line 163-169: Remove the unused local extractions left from the old
bridge setup: delete the assignments for bridge_type, ovs_bridge_name, and
network_dict (the lines that set bridge_type = params.get("bridge_type"),
ovs_bridge_name = params.get("ovs_bridge_name"), and network_dict =
eval(params.get("network_dict", "{}")));
network_base.setup_ovs_bridge_attrs(params, iface_attrs) reads these values
directly from params so keeping local copies is redundant; keep the needed
server_ip/server_user/server_pwd/outside_ip assignments but remove the three
unused variables to clean up the code.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8cce947 and e7ea69c.

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

1.Add some parameters to allow the framework provide guest xml
2.Change the method for specifying different bridge types via the test
command intead of case cfg varaint
3.Add "only Linux" to limit guest type

Signed-off-by: Lei Yang <leiyang@redhat.com>
'driver': {'driver_attr': {'queues': str(iface_queues)}}
}

bridge_name = params.get('netdst', '').split(',')[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @yanglei-rh
Please refer to #6796 (comment), which we discussed.
Thanks.

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