render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c54141
From 3a6d75f3784f62a5a016ea7790e9e41e8f9572d7 Mon Sep 17 00:00:00 2001
c54141
Message-Id: <3a6d75f3784f62a5a016ea7790e9e41e8f9572d7@dist-git>
c54141
From: "xinhua.Cao" <caoxinhua@huawei.com>
c54141
Date: Mon, 20 Aug 2018 10:08:59 -0400
c54141
Subject: [PATCH] remote: Extract common clearing of event callbacks of client
c54141
 private data
c54141
c54141
RHEL 7.6 https://bugzilla.redhat.com/show_bug.cgi?id=1610612
c54141
RHEL 7.5.z https://bugzilla.redhat.com/show_bug.cgi?id=1619206
c54141
c54141
Extract common clearing of event callbacks as remoteClientFreePrivateCallbacks.
c54141
the common function also separation including the sysident handling.
c54141
c54141
(cherry picked from commit 60e8bbc4c5902222d94474ca355ed9d650a38994)
c54141
Signed-off-by: John Ferlan <jferlan@redhat.com>
c54141
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
c54141
---
c54141
 daemon/remote.c | 73 ++++++++++++++++++++++++++-----------------------
c54141
 1 file changed, 39 insertions(+), 34 deletions(-)
c54141
c54141
diff --git a/daemon/remote.c b/daemon/remote.c
c54141
index 806479e72d..70e1227f13 100644
c54141
--- a/daemon/remote.c
c54141
+++ b/daemon/remote.c
c54141
@@ -1688,6 +1688,44 @@ void remoteRelayConnectionClosedEvent(virConnectPtr conn ATTRIBUTE_UNUSED, int r
c54141
         VIR_FREE(eventCallbacks);                                           \
c54141
     } while (0);
c54141
 
c54141
+
c54141
+static void
c54141
+remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
c54141
+{
c54141
+    virIdentityPtr sysident = virIdentityGetSystem();
c54141
+    virIdentitySetCurrent(sysident);
c54141
+
c54141
+    DEREG_CB(priv->conn, priv->domainEventCallbacks,
c54141
+             priv->ndomainEventCallbacks,
c54141
+             virConnectDomainEventDeregisterAny, "domain");
c54141
+    DEREG_CB(priv->conn, priv->networkEventCallbacks,
c54141
+             priv->nnetworkEventCallbacks,
c54141
+             virConnectNetworkEventDeregisterAny, "network");
c54141
+    DEREG_CB(priv->conn, priv->storageEventCallbacks,
c54141
+             priv->nstorageEventCallbacks,
c54141
+             virConnectStoragePoolEventDeregisterAny, "storage");
c54141
+    DEREG_CB(priv->conn, priv->nodeDeviceEventCallbacks,
c54141
+             priv->nnodeDeviceEventCallbacks,
c54141
+             virConnectNodeDeviceEventDeregisterAny, "node device");
c54141
+    DEREG_CB(priv->conn, priv->secretEventCallbacks,
c54141
+             priv->nsecretEventCallbacks,
c54141
+             virConnectSecretEventDeregisterAny, "secret");
c54141
+    DEREG_CB(priv->conn, priv->qemuEventCallbacks,
c54141
+             priv->nqemuEventCallbacks,
c54141
+             virConnectDomainQemuMonitorEventDeregister, "qemu monitor");
c54141
+
c54141
+    if (priv->closeRegistered) {
c54141
+        if (virConnectUnregisterCloseCallback(priv->conn,
c54141
+                                              remoteRelayConnectionClosedEvent) < 0)
c54141
+            VIR_WARN("unexpected close callback event deregister failure");
c54141
+    }
c54141
+
c54141
+    virIdentitySetCurrent(NULL);
c54141
+    virObjectUnref(sysident);
c54141
+}
c54141
+#undef DEREG_CB
c54141
+
c54141
+
c54141
 /*
c54141
  * You must hold lock for at least the client
c54141
  * We don't free stuff here, merely disconnect the client's
c54141
@@ -1701,44 +1739,11 @@ void remoteClientFreeFunc(void *data)
c54141
 
c54141
     /* Deregister event delivery callback */
c54141
     if (priv->conn) {
c54141
-        virIdentityPtr sysident = virIdentityGetSystem();
c54141
-
c54141
-        virIdentitySetCurrent(sysident);
c54141
-
c54141
-        DEREG_CB(priv->conn, priv->domainEventCallbacks,
c54141
-                 priv->ndomainEventCallbacks,
c54141
-                 virConnectDomainEventDeregisterAny, "domain");
c54141
-        DEREG_CB(priv->conn, priv->networkEventCallbacks,
c54141
-                 priv->nnetworkEventCallbacks,
c54141
-                 virConnectNetworkEventDeregisterAny, "network");
c54141
-        DEREG_CB(priv->conn, priv->storageEventCallbacks,
c54141
-                 priv->nstorageEventCallbacks,
c54141
-                 virConnectStoragePoolEventDeregisterAny, "storage");
c54141
-        DEREG_CB(priv->conn, priv->nodeDeviceEventCallbacks,
c54141
-                 priv->nnodeDeviceEventCallbacks,
c54141
-                 virConnectNodeDeviceEventDeregisterAny, "node device");
c54141
-        DEREG_CB(priv->conn, priv->secretEventCallbacks,
c54141
-                 priv->nsecretEventCallbacks,
c54141
-                 virConnectSecretEventDeregisterAny, "secret");
c54141
-        DEREG_CB(priv->conn, priv->qemuEventCallbacks,
c54141
-                 priv->nqemuEventCallbacks,
c54141
-                 virConnectDomainQemuMonitorEventDeregister, "qemu monitor");
c54141
-
c54141
-        if (priv->closeRegistered) {
c54141
-            if (virConnectUnregisterCloseCallback(priv->conn,
c54141
-                                                  remoteRelayConnectionClosedEvent) < 0)
c54141
-                VIR_WARN("unexpected close callback event deregister failure");
c54141
-        }
c54141
-
c54141
+        remoteClientFreePrivateCallbacks(priv);
c54141
         virConnectClose(priv->conn);
c54141
-
c54141
-        virIdentitySetCurrent(NULL);
c54141
-        virObjectUnref(sysident);
c54141
     }
c54141
-
c54141
     VIR_FREE(priv);
c54141
 }
c54141
-#undef DEREG_CB
c54141
 
c54141
 
c54141
 static void remoteClientCloseFunc(virNetServerClientPtr client)
c54141
-- 
c54141
2.18.0
c54141