Skip to content

Commit

Permalink
Allow destroying vms via monitor upon recreation
Browse files Browse the repository at this point in the history
In some cases the vm's memory and its images are known to be clean
of corruption and we can save up to 2 minutes per test (for thousands
of tests) if we destroy the vm faster before recreating it anew.

We can use this when restoring the vm from a file as we make sure
the vm is paused before recreating it and thus no vm image will be
harmed in the process.

Signed-off-by: Plamen Dimitrov <[email protected]>
  • Loading branch information
pevogam committed Nov 21, 2022
1 parent 82b9d47 commit 0b9e7c5
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 @@ -294,6 +294,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 0b9e7c5

Please sign in to comment.