Skip to content

Commit

Permalink
Merge pull request #3518 from pevogam/qemu-resume-fix
Browse files Browse the repository at this point in the history
Wait for proper monitor status before sending cont to monitor
  • Loading branch information
YongxueHong authored Nov 15, 2022
2 parents 5acee59 + 309e4ec commit cc79d0a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions spell.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,7 @@ prebuild
preconfig
precopy
Predefine
prelaunch
prepend
preprocess
preprocessing
Expand Down
33 changes: 22 additions & 11 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4910,16 +4910,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 All @@ -4934,7 +4938,13 @@ def restore_from_file(self, path):
self.create(name=self.name, params=self.params, root_dir=self.root_dir,
timeout=self.MIGRATE_TIMEOUT, migration_mode="exec",
migration_exec_cmd="cat " + path, mac_source=self)
self.verify_status('paused') # Throws exception if not

if utils_misc.wait_for(lambda: not self.monitor.verify_status('inmigrate'),
timeout=self.MIGRATE_TIMEOUT, step=1):
self.verify_status('paused') # Throws exception if not
else:
LOG.error(f"Monitor status {self.monitor.get_status()} is still in migration")
raise ValueError("Still paused inmigrate monitor status")

def savevm(self, tag_name):
"""
Expand Down Expand Up @@ -4966,6 +4976,7 @@ def resume(self, timeout=None):
"""
Resume the VM operation in case it's stopped.
"""
# NOTE: inmigrate, prelaunch, etc. might not register the "cont" command
self.monitor.cmd("cont")
if timeout:
if not self.wait_for_status('running', timeout, step=0.1):
Expand Down

0 comments on commit cc79d0a

Please sign in to comment.