KVM test: kvm_vm.py: shorten VM.destroy()
PATCH 1/1 KVM test: kvm_vm.py: shorten VM.destroy()
Call self.pci_assignable.release_devs() in the finally block.
Signed-off-by Michael Goldish <[email protected]>
--- client/tests/kvm/kvm_vm.py | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)
client/tests/kvm/kvm_vm.py +2 -9
@@ -598,8 +598,6 @@ class VM: # Is it already dead? if self.is_dead(): logging.debug("VM is already down") - if self.pci_assignable: - self.pci_assignable.release_devs() return logging.debug("Destroying VM with PID %d..." %
@@ -620,9 +618,6 @@ class VM: return finally: session.close() - if self.pci_assignable: - self.pci_assignable.release_devs() - # Try to destroy with a monitor command logging.debug("Trying to kill VM with monitor command...")
@@ -632,8 +627,6 @@ class VM: # Wait for the VM to be really dead if kvm_utils.wait_for(self.is_dead, 5, 0.5, 0.5): logging.debug("VM is down") - if self.pci_assignable: - self.pci_assignable.release_devs() return # If the VM isn't dead yet...
@@ -643,13 +636,13 @@ class VM: # Wait for the VM to be really dead if kvm_utils.wait_for(self.is_dead, 5, 0.5, 0.5): logging.debug("VM is down") - if self.pci_assignable: - self.pci_assignable.release_devs() return logging.error("Process %s is a zombie!" % self.process.get_pid()) finally: + if self.pci_assignable: + self.pci_assignable.release_devs() if self.process: self.process.close() try:
Signature · 1 line
1.5.4.1
Quoted 1 line · Michael Goldish
Call
self.pci_assignable.release_devs()in the finally block.
Looks good for me. Thanks, Michael, for this cleanup.
Quoted 61 lines
Signed-off-by Michael Goldish <[email protected]>--- client/tests/kvm/kvm_vm.py | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)client/tests/kvm/kvm_vm.py +2
-9@@ -598,8 +598,6 @@ class VM: # Is it already dead? if self.is_dead(): logging.debug("VM is already down") - if self.pci_assignable: - self.pci_assignable.release_devs() return logging.debug("Destroying VM with PID %d..." %@@ -620,9 +618,6 @@ class VM: return finally: session.close() - if self.pci_assignable: - self.pci_assignable.release_devs() - # Try to destroy with a monitor command logging.debug("Trying to kill VM with monitor command...")@@ -632,8 +627,6 @@ class VM: # Wait for the VM to be really dead if kvm_utils.wait_for(self.is_dead, 5, 0.5, 0.5): logging.debug("VM is down") - if self.pci_assignable: - self.pci_assignable.release_devs() return # If the VM isn't dead yet...@@ -643,13 +636,13 @@ class VM: # Wait for the VM to be really dead if kvm_utils.wait_for(self.is_dead, 5, 0.5, 0.5): logging.debug("VM is down") - if self.pci_assignable: - self.pci_assignable.release_devs() return logging.error("Process %s is a zombie!" % self.process.get_pid()) finally: + if self.pci_assignable: + self.pci_assignable.release_devs() if self.process: self.process.close() try:Signature · 6 lines
1.5.4.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html