public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [KVM-AUTOTEST PATCH 1/1] KVM test: kvm_vm.py: shorten VM.destroy()
@ 2010-02-03 11:21 Michael Goldish
  2010-02-04  5:18 ` Yolkfull Chow
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Goldish @ 2010-02-03 11:21 UTC (permalink / raw)
  To: autotest, kvm

Call self.pci_assignable.release_devs() in the finally block.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 6731927..db903a0 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -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:
-- 
1.5.4.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [KVM-AUTOTEST PATCH 1/1] KVM test: kvm_vm.py: shorten VM.destroy()
  2010-02-03 11:21 [KVM-AUTOTEST PATCH 1/1] KVM test: kvm_vm.py: shorten VM.destroy() Michael Goldish
@ 2010-02-04  5:18 ` Yolkfull Chow
  0 siblings, 0 replies; 2+ messages in thread
From: Yolkfull Chow @ 2010-02-04  5:18 UTC (permalink / raw)
  To: Michael Goldish; +Cc: autotest, kvm

On Wed, Feb 03, 2010 at 01:21:12PM +0200, Michael Goldish wrote:
> Call self.pci_assignable.release_devs() in the finally block.

Looks good for me. Thanks, Michael, for this cleanup.

> 
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
>  client/tests/kvm/kvm_vm.py |   11 ++---------
>  1 files changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 6731927..db903a0 100755
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -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:
> -- 
> 1.5.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-04  5:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-03 11:21 [KVM-AUTOTEST PATCH 1/1] KVM test: kvm_vm.py: shorten VM.destroy() Michael Goldish
2010-02-04  5:18 ` Yolkfull Chow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox