From: Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: migration subtest: Handle case where session2 does not exist Date: Sun, 15 Nov 2009 18:39:54 -0200 Message-ID: <1258317594-3858-1-git-send-email-lmr@redhat.com> Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues To: autotest@test.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:64324 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753695AbZKOUjw (ORCPT ); Sun, 15 Nov 2009 15:39:52 -0500 Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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