libmpathpersist: factor out initialization and teardown