KVM test: migration subtest: Handle case where session2 does not exist
PATCH 1/1 KVM test: migration subtest: Handle case where session2 does not exist
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 <[email protected]>
--- client/tests/kvm/tests/migration.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
client/tests/kvm/tests/migration.py +4 -3
@@ -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()
Signature · 1 line
1.6.2.5