Sometimes (e.g. in guest_s4) we want to destroy and restart a VM without changing its MAC addresses. Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> --- client/tests/kvm/kvm_vm.py | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 0c355da..0403569 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -690,7 +690,7 @@ class VM: @raise VMPAError: If no PCI assignable devices could be assigned """ error.context("creating '%s'" % self.name) - self.destroy() + self.destroy(free_mac_addresses=False) if name is not None: self.name = name @@ -903,7 +903,7 @@ class VM: lockfile.close() - def destroy(self, gracefully=True): + def destroy(self, gracefully=True, free_mac_addresses=True): """ Destroy the VM. @@ -911,9 +911,11 @@ class VM: command. Then, attempt to destroy the VM via the monitor with a 'quit' command. If that fails, send SIGKILL to the qemu process. - @param gracefully: Whether an attempt will be made to end the VM + @param gracefully: If True, an attempt will be made to end the VM using a shell command before trying to end the qemu process with a 'quit' or a kill signal. + @param free_mac_addresses: If True, the MAC addresses used by the VM + will be freed. """ try: # Is it already dead? @@ -985,9 +987,10 @@ class VM: os.unlink(self.migration_file) except OSError: pass - num_nics = len(self.params.objects("nics")) - for vlan in range(num_nics): - self.free_mac_address(vlan) + if free_mac_addresses: + num_nics = len(self.params.objects("nics")) + for vlan in range(num_nics): + self.free_mac_address(vlan) @property -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html