[PATCH] KVM test: migration subtest: Handle case where session2 does not exist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In one of the code blocks of the migration test, a finally
clause tries to send a command to a session. However, if we
are not successful in actually creating a session, that
object will hold None, which doesn't have an is_alive attribute,
generating an unhandled exception. Fix that by checking
if the session2 object is not None before trying to use the
method is_alive()

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/tests/migration.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/tests/migration.py b/client/tests/kvm/tests/migration.py
index 7b80e51..21df1e2 100644
--- a/client/tests/kvm/tests/migration.py
+++ b/client/tests/kvm/tests/migration.py
@@ -74,9 +74,10 @@ def run_migration(test, params, env):
 
     finally:
         # Kill the background process
-        if session2.is_alive():
-            session2.get_command_output(params.get("migration_bg_kill_command",
-                                                   ""))
+        if session2:
+            if session2.is_alive():
+                session2.get_command_output(
+                                    params.get("migration_bg_kill_command", ""))
 
     session2.close()
     session.close()
-- 
1.6.2.5

--
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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux