Skip to content

installer: Update network config for the IPs order issue#4443

Open
heywji wants to merge 1 commit intoautotest:masterfrom
heywji:add_ip_order_case
Open

installer: Update network config for the IPs order issue#4443
heywji wants to merge 1 commit intoautotest:masterfrom
heywji:add_ip_order_case

Conversation

@heywji
Copy link
Contributor

@heywji heywji commented Feb 15, 2026

This MR includes the following improvements:

  1. Support multiple static IPs and DNS servers in test configuration.
  2. Update check_network_config to verify all configured IPs and DNS entries.
  3. Refactor network setup to use netsh for adding multiple addresses.

Summary by CodeRabbit

Release Notes

  • New Features

    • Support for configuring and validating multiple IP addresses and DNS servers in network tests.
    • Automatic restoration of default network settings after validation completes.
  • Improvements

    • Enhanced network validation logic to verify primary IP, gateway, and all additional addresses.
    • Expanded logging throughout network operations for improved diagnostics.

This MR includes the following improvements:
1. Support multiple static IPs and DNS servers in test configuration.
2. Update `check_network_config` to verify all configured IPs and DNS entries.
3. Refactor network setup to use `netsh` for adding multiple addresses.

Signed-off-by: Wenkang Ji <wji@redhat.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

Walkthrough

The changes refactor the network configuration and validation process for Windows VirtIO driver installation tests. A configuration file shifts from a single static IP/DNS setup to a multi-address approach with separate commands for IP, DNS, and DHCP management. The test file adds netsh-based network information extraction, implements ordered IP list verification with timeout polling, supports multiple IP addresses with optional masks, replaces single DNS checks with list-based validation, and introduces network restoration to DHCP after testing completes. Enhanced logging is added throughout network operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (81 files):

⚔️ .pre-commit-config.yaml (content)
⚔️ generic/tests/cfg/linux_stress.cfg (content)
⚔️ generic/tests/cfg/trans_hugepage.cfg (content)
⚔️ generic/tests/nfs_corrupt.py (content)
⚔️ generic/tests/pktgen_perf.py (content)
⚔️ provider/ansible.py (content)
⚔️ provider/win_driver_installer_test.py (content)
⚔️ provider/win_driver_utils.py (content)
⚔️ provider/win_dump_utils.py (content)
⚔️ qemu/deps/sev-snp/regular_attestation_workflow.sh (content)
⚔️ qemu/tests/balloon_check.py (content)
⚔️ qemu/tests/balloon_uniqueness.py (content)
⚔️ qemu/tests/block_performance_test.py (content)
⚔️ qemu/tests/cfg/balloon_in_use.cfg (content)
⚔️ qemu/tests/cfg/balloon_stress.cfg (content)
⚔️ qemu/tests/cfg/block_check_memory_leak.cfg (content)
⚔️ qemu/tests/cfg/block_iothread_test.cfg (content)
⚔️ qemu/tests/cfg/block_iscsi_with_specical_max_sectors.cfg (content)
⚔️ qemu/tests/cfg/block_performance_test.cfg (content)
⚔️ qemu/tests/cfg/block_transfer_parameters_check.cfg (content)
⚔️ qemu/tests/cfg/blockdev_mirror_src_no_space.cfg (content)
⚔️ qemu/tests/cfg/device_option_check.cfg (content)
⚔️ qemu/tests/cfg/disk_extension.cfg (content)
⚔️ qemu/tests/cfg/driver_load_stress.cfg (content)
⚔️ qemu/tests/cfg/edk2_check_mor.cfg (content)
⚔️ qemu/tests/cfg/fwcfg.cfg (content)
⚔️ qemu/tests/cfg/fwcfg_enable.cfg (content)
⚔️ qemu/tests/cfg/guest_iommu_test.cfg (content)
⚔️ qemu/tests/cfg/hotplug_mem_migration.cfg (content)
⚔️ qemu/tests/cfg/hotplug_memory.cfg (content)
⚔️ qemu/tests/cfg/hotplug_virtio_mem.cfg (content)
⚔️ qemu/tests/cfg/hugepage_reset.cfg (content)
⚔️ qemu/tests/cfg/hv_avic.cfg (content)
⚔️ qemu/tests/cfg/hv_enforce_cpuid_msr_check.cfg (content)
⚔️ qemu/tests/cfg/hv_flag_cpuid_check.cfg (content)
⚔️ qemu/tests/cfg/ksm_ksmtuned.cfg (content)
⚔️ qemu/tests/cfg/migration_virtio_mem_ignore_shared.cfg (content)
⚔️ qemu/tests/cfg/netkvm_buffer_shortage.cfg (content)
⚔️ qemu/tests/cfg/nmi_bsod_catch.cfg (content)
⚔️ qemu/tests/cfg/pvpanic_basic.cfg (content)
⚔️ qemu/tests/cfg/pvpanic_event_check.cfg (content)
⚔️ qemu/tests/cfg/qemu_guest_agent.cfg (content)
⚔️ qemu/tests/cfg/qemu_img.cfg (content)
⚔️ qemu/tests/cfg/s390x_cpu_model.cfg (content)
⚔️ qemu/tests/cfg/single_driver_install.cfg (content)
⚔️ qemu/tests/cfg/snp_basic_config.cfg (content)
⚔️ qemu/tests/cfg/snp_cpu_model.cfg (content)
⚔️ qemu/tests/cfg/snp_multi_vm.cfg (content)
⚔️ qemu/tests/cfg/throttle_block_set_io_throttle.cfg (content)
⚔️ qemu/tests/cfg/uefi_boot_from_device.cfg (content)
⚔️ qemu/tests/cfg/uefi_check_resolution.cfg (content)
⚔️ qemu/tests/cfg/uefi_secureboot.cfg (content)
⚔️ qemu/tests/cfg/vdpa_sim_blk_test.cfg (content)
⚔️ qemu/tests/cfg/virt_firmware_check_phys_bits.cfg (content)
⚔️ qemu/tests/cfg/virtio_aer_opt.cfg (content)
⚔️ qemu/tests/cfg/virtio_driver_sign_check.cfg (content)
⚔️ qemu/tests/cfg/virtio_fs_multi_vms.cfg (content)
⚔️ qemu/tests/cfg/virtio_fs_share_data_multi_backend.cfg (content)
⚔️ qemu/tests/cfg/win_sigverif.cfg (content)
⚔️ qemu/tests/cfg/win_virtio_driver_install_by_installer.cfg (content)
⚔️ qemu/tests/cfg/win_virtio_driver_update_test.cfg (content)
⚔️ qemu/tests/disable_win_update.py (content)
⚔️ qemu/tests/hv_avic.py (content)
⚔️ qemu/tests/hv_flag_cpuid_check.py (content)
⚔️ qemu/tests/netkvm_buffer_shortage.py (content)
⚔️ qemu/tests/pvpanic.py (content)
⚔️ qemu/tests/qemu_guest_agent.py (content)
⚔️ qemu/tests/qemu_nobody.py (content)
⚔️ qemu/tests/single_driver_install.py (content)
⚔️ qemu/tests/snp_basic_config.py (content)
⚔️ qemu/tests/snp_cpu_model.py (content)
⚔️ qemu/tests/snp_multi_vm.py (content)
⚔️ qemu/tests/thin_provision_guest_fstrim.py (content)
⚔️ qemu/tests/uefi_boot_from_device.py (content)
⚔️ qemu/tests/uefi_check_resolution.py (content)
⚔️ qemu/tests/uefi_secureboot.py (content)
⚔️ qemu/tests/uefishell.py (content)
⚔️ qemu/tests/virtio_port_hotplug.py (content)
⚔️ qemu/tests/win_virtio_driver_installer_uninstall.py (content)
⚔️ qemu/tests/win_virtio_driver_update_by_installer.py (content)
⚔️ qemu/tests/x86_cpu_flag_nonstop_tsc.py (content)

These conflicts must be resolved before merging into master.
Resolve conflicts locally and push changes to this branch.
✅ 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 addresses the main change: updating network configuration to handle multiple IP addresses in order, which is the core objective across both config and Python test files.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% 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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch add_ip_order_case
  • Post resolved changes as copyable diffs in a comment

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

@heywji
Copy link
Contributor Author

heywji commented Feb 15, 2026

Test Results:

(1/2) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2016.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35: STARTED
 (1/2) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2016.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35:  PASS (757.74 s)
 (2/2) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2016.x86_64.io-github-autotest-qemu.win_virtio_driver_install_by_installer.driver_update.from_old_installer.q35: STARTED
 (2/2) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2016.x86_64.io-github-autotest-qemu.win_virtio_driver_install_by_installer.driver_update.from_old_installer.q35:  PASS (776.05 s)
RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0

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 `@qemu/tests/win_virtio_driver_update_by_installer.py`:
- Around line 135-148: The code calls utils_net.get_windows_nic_attribute into
static_dns_address and then uses "in" which will TypeError if
DNSServerSearchOrder is None; before iterating params.get("static_dns_list",
"").split(), add a null/empty guard for static_dns_address (e.g., if
static_dns_address is None or empty string) and handle it explicitly: either
normalize static_dns_address to an empty string/list so the membership checks
are safe, or call test.fail with a clear message that DNSServerSearchOrder is
missing; update the block around static_dns_address and the subsequent for-loop
(referencing static_dns_address, params.get("static_dns_list", ""),
utils_net.get_windows_nic_attribute, and test.fail) accordingly.

Comment on lines 135 to +148
static_dns_address = utils_net.get_windows_nic_attribute(
session_serial,
global_switch="nicconfig",
key="MACAddress",
value=f"{virtio_nic_mac}",
target="DNSServerSearchOrder",
)
static_dns_address = static_dns_address.strip("{}").strip('"')
if static_dns_address != params["static_dns"]:
test.fail(
"Static dns is lost after upgrade driver, current dns "
"is %s" % static_dns_address
)
test.log.info("Current guest DNS servers: %s", static_dns_address)
for dns in params.get("static_dns_list", "").split():
if dns not in static_dns_address:
test.fail(
"Static dns is lost after upgrade driver, current dns "
"is %s" % static_dns_address
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guard against missing DNS attributes.
If DNSServerSearchOrder is None, the in check will raise TypeError. Add a null/empty guard before iterating.

🩹 Suggested fix
         static_dns_address = utils_net.get_windows_nic_attribute(
             session_serial,
             global_switch="nicconfig",
             key="MACAddress",
             value=f"{virtio_nic_mac}",
             target="DNSServerSearchOrder",
         )
         test.log.info("Current guest DNS servers: %s", static_dns_address)
+        if not static_dns_address:
+            test.fail("No DNS servers found on the NIC after upgrade")
         for dns in params.get("static_dns_list", "").split():
             if dns not in static_dns_address:
                 test.fail(
                     "Static dns is lost after upgrade driver, current dns "
                     "is %s" % static_dns_address
                 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
static_dns_address = utils_net.get_windows_nic_attribute(
session_serial,
global_switch="nicconfig",
key="MACAddress",
value=f"{virtio_nic_mac}",
target="DNSServerSearchOrder",
)
static_dns_address = static_dns_address.strip("{}").strip('"')
if static_dns_address != params["static_dns"]:
test.fail(
"Static dns is lost after upgrade driver, current dns "
"is %s" % static_dns_address
)
test.log.info("Current guest DNS servers: %s", static_dns_address)
for dns in params.get("static_dns_list", "").split():
if dns not in static_dns_address:
test.fail(
"Static dns is lost after upgrade driver, current dns "
"is %s" % static_dns_address
)
static_dns_address = utils_net.get_windows_nic_attribute(
session_serial,
global_switch="nicconfig",
key="MACAddress",
value=f"{virtio_nic_mac}",
target="DNSServerSearchOrder",
)
test.log.info("Current guest DNS servers: %s", static_dns_address)
if not static_dns_address:
test.fail("No DNS servers found on the NIC after upgrade")
for dns in params.get("static_dns_list", "").split():
if dns not in static_dns_address:
test.fail(
"Static dns is lost after upgrade driver, current dns "
"is %s" % static_dns_address
)
🤖 Prompt for AI Agents
In `@qemu/tests/win_virtio_driver_update_by_installer.py` around lines 135 - 148,
The code calls utils_net.get_windows_nic_attribute into static_dns_address and
then uses "in" which will TypeError if DNSServerSearchOrder is None; before
iterating params.get("static_dns_list", "").split(), add a null/empty guard for
static_dns_address (e.g., if static_dns_address is None or empty string) and
handle it explicitly: either normalize static_dns_address to an empty
string/list so the membership checks are safe, or call test.fail with a clear
message that DNSServerSearchOrder is missing; update the block around
static_dns_address and the subsequent for-loop (referencing static_dns_address,
params.get("static_dns_list", ""), utils_net.get_windows_nic_attribute, and
test.fail) accordingly.

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.

1 participant