Skip to content

Commit

Permalink
Reuse some more logic from the already implemented VM migrate methods
Browse files Browse the repository at this point in the history
As we updated the restore_from_file with logic that was already implemented
there we may do so now also for the save_to_file method.

Signed-off-by: Plamen Dimitrov <[email protected]>
  • Loading branch information
pevogam committed Nov 9, 2022
1 parent 790ef1a commit 309e4ec
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4839,16 +4839,20 @@ def save_to_file(self, path):
LOG.debug("Saving VM %s to %s" % (self.name, path))
# Can only check status if background migration
self.monitor.migrate("exec:cat>%s" % path, wait=False)
utils_misc.wait_for(
# no monitor.migrate-status method
lambda:
re.search("(status.*completed)",
str(self.monitor.info("migrate")), re.M),
self.MIGRATE_TIMEOUT, 2, 2,
"Waiting for save to %s to complete" % path)
# Restore the speed and downtime to default values
qemu_migration.set_speed(self, str(32 << 20))
qemu_migration.set_downtime(self, 0.3)
try:
if not utils_misc.wait_for(
# no monitor.migrate-status method
lambda:
re.search("(status.*completed)",
str(self.monitor.info("migrate")), re.M),
self.MIGRATE_TIMEOUT, 2, 2,
"Waiting for save to %s to complete" % path):
raise virt_vm.VMMigrateTimeoutError("Timeout expired while waiting"
" for saving to %s to finish" % path)
finally:
# Restore the speed and downtime to default values
qemu_migration.set_speed(self, str(32 << 20))
qemu_migration.set_downtime(self, 0.3)
# Base class defines VM must be off after a save
self.monitor.cmd("system_reset")
self.verify_status('paused') # Throws exception if not
Expand Down

0 comments on commit 309e4ec

Please sign in to comment.