Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
- migration.migration_with_stress.network_load_on_host:
type = network_load_on_host
migration_setup = 'yes'
storage_type = 'nfs'
setup_local_nfs = 'yes'
disk_type = "file"
disk_source_protocol = "netfs"
mnt_path_name = ${nfs_mount_dir}
# Console output can only be monitored via virsh console output
only_pty = True
take_regular_screendumps = no
# Extra options to pass after <domain> <desturi>
virsh_migrate_extra = ''
# SSH connection time out
ssh_timeout = 60
# Local URI
virsh_migrate_connect_uri = 'qemu:///system'
image_convert = 'no'
server_ip = "${migrate_dest_host}"
server_user = "root"
server_pwd = "${migrate_dest_pwd}"
client_ip = "${migrate_source_host}"
status_error = "no"
migrate_desturi_port = "16509"
migrate_desturi_type = "tcp"
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
start_vm = "yes"
virsh_migrate_options = '--live --p2p --verbose --undefinesource --persistent --postcopy'
virsh_migrate_dest_state = "running"
virsh_migrate_src_state = "nonexist"
netperf_port = "12865"
netperf_data_port = "5000"
Comment on lines +31 to +32
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

🧩 Analysis chain

🏁 Script executed:

rg -n "\bnetperf_port\b|\bnetperf_data_port\b" libvirt/tests/src/migration/migration_with_stress/network_load_on_host.py -A 2 -B 2

Repository: autotest/tp-libvirt

Length of output: 306


🏁 Script executed:

rg -n "netperf_port|netperf_data_port" libvirt/tests/src/migration/migration_with_stress/network_load_on_host.py

Repository: autotest/tp-libvirt

Length of output: 170


🏁 Script executed:

rg -n "netperf\b" libvirt/tests/src/migration/migration_with_stress/network_load_on_host.py -B 2 -A 2

Repository: autotest/tp-libvirt

Length of output: 1374


Remove unused port parameters or pass them to netperf/netserver commands.

The netperf_port and netperf_data_port parameters are retrieved at lines 72-73 but never used anywhere in the test. The netperf invocations at lines 46 and 49 (netperf -H {ip} -l 600000000) don't specify these ports with the -p and -P flags. Either configure the commands to use these ports or remove the unused parameters from the config.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Redhat
#
# SPDX-License-Identifier: GPL-2.0
#
# Author: Liping Cheng <lcheng@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

from avocado.utils import process

from virttest import remote
from virttest import utils_package

from provider.migration import base_steps


def run(test, params, env):
"""
This case is to verify that migration can succeed in high-speed network env
with heavy nework load

"""
def setup_test():
"""
Setup steps

"""
client_ip = params.get("client_ip")

test.log.info("Setup steps.")
if not utils_package.package_install('netperf'):
test.error('Failed to install netperf on source host.')
if not utils_package.package_install('netperf', remote_session):
test.error('Failed to install netperf on target host.')

process.run("systemctl stop firewalld", shell=True, verbose=True)
remote.run_remote_cmd("systemctl stop firewalld", params)

src_netserver_cmd = f"nohup netserver >/dev/null 2>&1 &"
process.run(src_netserver_cmd, shell=True, verbose=True)
dst_netserver_cmd = f"nohup netserver >/dev/null 2>&1 &"
remote.run_remote_cmd(dst_netserver_cmd, params, ignore_status=False)

src_netperf_cmd = f"nohup netperf -H {server_ip} -l 600000000 >/dev/null 2>&1 &"
process.run(src_netperf_cmd, shell=True, verbose=True)

dst_netperf_cmd = f"nohup netperf -H {client_ip} -l 600000000 >/dev/null 2>&1 &"
remote.run_remote_cmd(dst_netperf_cmd, params, ignore_status=False)

migration_obj.setup_connection()

def cleanup_test():
"""
Cleanup steps

"""
test.log.info("Cleanup steps.")
migration_obj.cleanup_connection()
process.run("pkill netserver", shell=True, verbose=True, ignore_status=True)
remote.run_remote_cmd("pkill netserver", params, ignore_status=True)
process.run("pkill netperf", shell=True, verbose=True, ignore_status=True)
remote.run_remote_cmd("pkill netperf", params, ignore_status=True)
process.run("systemctl start firewalld", shell=True, verbose=True)
remote.run_remote_cmd("systemctl start firewalld", params)

vm_name = params.get("migrate_main_vm")
server_ip = params.get("server_ip")
server_user = params.get("server_user", "root")
server_pwd = params.get("server_pwd")
netperf_port = params.get("netperf_port")
netperf_data_port = params.get("netperf_data_port")
Comment on lines +72 to +73
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

Unused port configuration parameters.

The netperf_port and netperf_data_port parameters are retrieved but never used. If these ports should be configured for netperf (using the -p flag), please add them to the netperf commands in setup_test(). Otherwise, these lines and the corresponding config parameters can be removed.

Related to the unused parameters in the config file at lines 31-32.

🧰 Tools
🪛 Ruff (0.14.8)

72-72: Local variable netperf_port is assigned to but never used

Remove assignment to unused variable netperf_port

(F841)


73-73: Local variable netperf_data_port is assigned to but never used

Remove assignment to unused variable netperf_data_port

(F841)

🤖 Prompt for AI Agents
In libvirt/tests/src/migration/migration_with_stress/network_load_on_host.py
around lines 72-73, the params netperf_port and netperf_data_port are retrieved
but never used; either include them in the netperf invocation inside
setup_test() (add the control port and data port via the netperf -p
control_port,data_port flag where the netperf client/server commands are
constructed and ensure defaults or validation for None) or remove these two
params and their corresponding entries in the test config (and any related
docstring) so they are not fetched; update setup_test() to use the params when
present and add a small validation/conditional to avoid injecting empty flags.


vm = env.get_vm(vm_name)
migration_obj = base_steps.MigrationBase(test, vm, params)
remote_runner = remote.RemoteRunner(host=server_ip,
username=server_user,
password=server_pwd)
remote_session = remote_runner.session
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

Unused remote_session variable.

The remote_session variable is created but never used in the test. If it's not needed, consider removing it. If it should be passed to utils_package.package_install() on line 35, ensure it's in scope.

     remote_runner = remote.RemoteRunner(host=server_ip,
                                         username=server_user,
                                         password=server_pwd)
-    remote_session = remote_runner.session
📝 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
remote_session = remote_runner.session
🤖 Prompt for AI Agents
In libvirt/tests/src/migration/migration_with_stress/network_load_on_host.py
around line 80, the local variable remote_session is assigned but never used;
either remove the remote_session assignment to eliminate the unused variable, or
if the intention was to supply the remote session to
utils_package.package_install() (called on line 35), update that call to pass
remote_session (and ensure remote_session is defined before line 35 or move the
package_install call after its assignment) so the variable is actually used.


try:
setup_test()
migration_obj.run_migration()
migration_obj.verify_default()
finally:
cleanup_test()