Blame SOURCES/libvirt-remote-Extract-common-clearing-of-event-callbacks-of-client-private-data.patch

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