[libvirt] [PATCH 4/5] Update remote driver to support the connection close callbacks

Daniel P. Berrange berrange at redhat.com
Thu Jul 19 15:04:39 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

Update the remote driver to use the virNetClient close callback
to trigger the virConnectPtr close callbacks

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 src/remote/remote_driver.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index acae5d0..9db64ef 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -324,6 +324,19 @@ enum virDrvOpenRemoteFlags {
 };
 
 
+static void remoteClientCloseFunc(virNetClientPtr client ATTRIBUTE_UNUSED,
+                                  int reason,
+                                  void *opaque)
+{
+    virConnectPtr conn = opaque;
+
+    if (conn->closeCallback) {
+        VIR_DEBUG("Triggering connection close callback %p reason=%d",
+                  conn->closeCallback, reason);
+        conn->closeCallback(conn, reason, conn->closeOpaque);
+    }
+}
+
 /*
  * URIs that this driver needs to handle:
  *
@@ -671,6 +684,11 @@ doRemoteOpen (virConnectPtr conn,
 #endif /* WIN32 */
     } /* switch (transport) */
 
+
+    virNetClientSetCloseCallback(priv->client,
+                                 remoteClientCloseFunc,
+                                 conn, NULL);
+
     if (!(priv->remoteProgram = virNetClientProgramNew(REMOTE_PROGRAM,
                                                        REMOTE_PROTOCOL_VERSION,
                                                        remoteDomainEvents,
-- 
1.7.10.4




More information about the libvir-list mailing list