Skip to content

Commit

Permalink
Merge pull request #6036 from smitterl/stabilize_autoconverge
Browse files Browse the repository at this point in the history
migrate_options_shared: stabilize auto-converge
  • Loading branch information
dzhengfy authored Dec 15, 2024
2 parents 6dc3db5 + 3aa5cc8 commit 276b27e
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions libvirt/tests/src/migration/migrate_options_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,6 @@ def cleanup_libvirtd_log(log_file):
logging.debug("Delete remote libvirt log file '%s'", log_file)
remote.run_remote_cmd(cmd, cmd_parms, runner_on_target)

def run_stress_in_vm():
"""
The function to load stress in VM
"""
stress_args = params.get("stress_args", "--cpu 8 --io 4 "
"--vm 2 --vm-bytes 128M "
"--timeout 20s")
try:
vm_session.cmd('stress %s' % stress_args)
except Exception as detail:
logging.debug(detail)

def control_migrate_speed(to_speed=1, opts=""):
"""
Control migration duration
Expand Down Expand Up @@ -742,6 +730,23 @@ def check_timeout_postcopy(params):
"be 'running', but '%s' found" % (timeout, vm_state))
remote_virsh_session.close_session()

def help_migration_converge():
"""
This function will allow for more downtime and bandwidth
in order to help the migration converge.
This is useful in cases like auto-converge check where we
usually lower these values a lot so we can cause the
auto-converge feature to kick in.
"""
one_second = 1000
virsh.migrate_setmaxdowntime(vm_name, one_second, **virsh_args)
maxspeed = 8796093022207
opts = ""
if postcopy_options:
opts = postcopy_options
virsh.migrate_setspeed(vm_name, maxspeed, extra=opts, **virsh_args)

def check_converge(params):
"""
Handle option '--auto-converge --auto-converge-initial
Expand All @@ -765,6 +770,7 @@ def check_converge(params):
"is %s", allow_throttle_list)

throttle = 0
old_throttle = 0
jobtype = "None"

while throttle < 100:
Expand All @@ -788,15 +794,20 @@ def check_converge(params):
if key.count("Job type"):
jobtype = line.split(':')[-1].strip()
elif key.count("Auto converge throttle"):
if throttle > 0:
old_throttle = throttle
throttle = int(line.split(':')[-1].strip())
logging.debug("Auto converge throttle:%s", str(throttle))
if old_throttle > 0 and throttle > old_throttle:
help_migration_converge()
if throttle and throttle not in allow_throttle_list:
test.fail("Invalid auto converge throttle "
"value '%s'" % throttle)
if throttle == 99:
logging.debug("'Auto converge throttle' reaches maximum "
"allowed value 99")
break

if jobtype == "None" or jobtype == "Completed":
logging.debug("Jobtype:%s", jobtype)
if not throttle:
Expand Down

0 comments on commit 276b27e

Please sign in to comment.