Skip to content

Commit

Permalink
Merge pull request avocado-framework#3533 from pevogam/fast-qemu-vm-r…
Browse files Browse the repository at this point in the history
…ecreation

Allow destroying vms via monitor upon recreation
  • Loading branch information
YongxueHong authored Nov 23, 2022
2 parents 6827c6d + 0b9e7c5 commit a99eb31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ def preprocess_vm(test, params, env, name):
vm.update_vm_id()
vm.virtnet = utils_net.VirtNet(params, name, vm.instance)
# Start the VM (or restart it if it's already up)
if vm.is_alive():
vm.destroy(free_mac_addresses=False)
if params.get("reuse_previous_config", "no") == "no":
vm.create(name, params, test.bindir,
timeout=int(params.get("vm_create_timeout", 90)),
Expand Down
2 changes: 1 addition & 1 deletion virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,7 +2943,6 @@ def create(self, name=None, params=None, root_dir=None,
:raise PrivateBridgeError: If fail to bring the private bridge
"""
error_context.context("creating '%s'" % self.name)
self.destroy(free_mac_addresses=False)

if name is not None:
self.name = name
Expand Down Expand Up @@ -4934,6 +4933,7 @@ def restore_from_file(self, path):
"""
if self.is_alive():
self.verify_status('paused') # Throws exception if not
self.destroy(gracefully=False, free_mac_addresses=False)
LOG.debug("Restoring VM %s from %s" % (self.name, path))
# Rely on create() in incoming migration mode to do the 'right thing'
self.create(name=self.name, params=self.params, root_dir=self.root_dir,
Expand Down

0 comments on commit a99eb31

Please sign in to comment.