| 119 | return 0 |
| 120 | |
| 121 | def __connection_close_callback(self, connection, reason, opaque=None): |
| 122 | self.connection_state_lock.acquire() |
| 123 | try: |
| 124 | # on server shutdown libvirt module gets freed before the close callbacks are called |
| 125 | # so we just check here if it is still present |
| 126 | if libvirt is not None: |
| 127 | if (reason == libvirt.VIR_CONNECT_CLOSE_REASON_ERROR): |
| 128 | self.last_error = 'connection closed: Misc I/O error' |
| 129 | elif (reason == libvirt.VIR_CONNECT_CLOSE_REASON_EOF): |
| 130 | self.last_error = 'connection closed: End-of-file from server' |
| 131 | elif (reason == libvirt.VIR_CONNECT_CLOSE_REASON_KEEPALIVE): |
| 132 | self.last_error = 'connection closed: Keepalive timer triggered' |
| 133 | elif (reason == libvirt.VIR_CONNECT_CLOSE_REASON_CLIENT): |
| 134 | self.last_error = 'connection closed: Client requested it' |
| 135 | else: |
| 136 | self.last_error = 'connection closed: Unknown error' |
| 137 | |
| 138 | # prevent other threads from using the connection (in the future) |
| 139 | self.connection = None |
| 140 | finally: |
| 141 | self.connection_state_lock.release() |
| 142 | |
| 143 | def __connect_tcp(self): |
| 144 | flags = [libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE] |