Skip to content

Commit

Permalink
migrate_options_shared: stabilize auto-converge
Browse files Browse the repository at this point in the history
The auto-converge test scenarios are brittle. In order to cause
auto-converge to kick in we need to reduce allowed downtime and
bandwidth and increase creation of dirty-pages. However, by setting
unrealisticly restrictive values we might cause the migration
to never converge. Therefore, once auto-converge has kicked in,
reset bandwidth and maxdowntime so that the migration can finish
more easily.

Only help the migration speed up if the auto-converge throttle value has
increased once.

Furthermore, remove function `run_stress_in_vm` as it's not used
anywhere. Instead
avocado-vt/virttest/migration/run_stress_in_vm is used.

Signed-off-by: Sebastian Mitterle <[email protected]>
  • Loading branch information
smitterl committed Dec 3, 2024
1 parent eb340da commit 3aa5cc8
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 3aa5cc8

Please sign in to comment.