diff mbox

[KVM-AUTOTEST,25/26] KVM test: VM.destroy(): allow keeping the MAC addresses

Message ID 1294751618-21631-25-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Jan. 11, 2011, 1:13 p.m. UTC
None
diff mbox

Patch

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