[PATCH v2 4/8] remote: use a separate connection for network APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx>
Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/remote/remote_daemon.h          |  1 +
 src/remote/remote_daemon_dispatch.c | 19 +++++++++++--------
 src/rpc/gendispatch.pl              |  6 ++++++
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 31f433c15d..60be78fe0b 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -75,6 +75,7 @@ struct daemonClientPrivate {
      */
     virConnectPtr conn;
     virConnectPtr interfaceConn;
+    virConnectPtr networkConn;
 
     daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 34c140e613..bc26bccf65 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1704,7 +1704,7 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
     DEREG_CB(priv->conn, priv->domainEventCallbacks,
              priv->ndomainEventCallbacks,
              virConnectDomainEventDeregisterAny, "domain");
-    DEREG_CB(priv->conn, priv->networkEventCallbacks,
+    DEREG_CB(priv->networkConn, priv->networkEventCallbacks,
              priv->nnetworkEventCallbacks,
              virConnectNetworkEventDeregisterAny, "network");
     DEREG_CB(priv->conn, priv->storageEventCallbacks,
@@ -1747,6 +1747,8 @@ void remoteClientFree(void *data)
         virConnectClose(priv->conn);
     if (priv->interfaceConn)
         virConnectClose(priv->interfaceConn);
+    if (priv->networkConn)
+        virConnectClose(priv->networkConn);
 
     VIR_FREE(priv);
 }
@@ -1820,6 +1822,7 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     priv->interfaceConn = virObjectRef(priv->conn);
+    priv->networkConn = virObjectRef(priv->conn);
 
     /* force update the @readonly attribute which was inherited from the
      * virNetServerService object - this is important for sockets that are RW
@@ -5716,7 +5719,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
         virNetServerClientGetPrivateData(client);
     virNetworkPtr net = NULL;
 
-    if (!priv->conn) {
+    if (!priv->networkConn) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
@@ -5724,7 +5727,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
     virMutexLock(&priv->lock);
 
     if (args->net &&
-        !(net = get_nonnull_network(priv->conn, *args->net)))
+        !(net = get_nonnull_network(priv->networkConn, *args->net)))
         goto cleanup;
 
     if (args->eventID >= VIR_NETWORK_EVENT_ID_LAST || args->eventID < 0) {
@@ -5750,7 +5753,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
                            callback) < 0)
         goto cleanup;
 
-    if ((callbackID = virConnectNetworkEventRegisterAny(priv->conn,
+    if ((callbackID = virConnectNetworkEventRegisterAny(priv->networkConn,
                                                         net,
                                                         args->eventID,
                                                         networkEventCallbacks[args->eventID],
@@ -5789,7 +5792,7 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr server ATTRIBUTE_
     struct daemonClientPrivate *priv =
         virNetServerClientGetPrivateData(client);
 
-    if (!priv->conn) {
+    if (!priv->networkConn) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
@@ -5807,7 +5810,7 @@ remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr server ATTRIBUTE_
         goto cleanup;
     }
 
-    if (virConnectNetworkEventDeregisterAny(priv->conn, args->callbackID) < 0)
+    if (virConnectNetworkEventDeregisterAny(priv->networkConn, args->callbackID) < 0)
         goto cleanup;
 
     VIR_DELETE_ELEMENT(priv->networkEventCallbacks, i,
@@ -6470,12 +6473,12 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr server ATTRIBUTE_UNUSED,
     virNetworkPtr net = NULL;
     int nleases = 0;
 
-    if (!priv->conn) {
+    if (!priv->networkConn) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
-    if (!(net = get_nonnull_network(priv->conn, args->net)))
+    if (!(net = get_nonnull_network(priv->networkConn, args->net)))
         goto cleanup;
 
     if ((nleases = virNetworkGetDHCPLeases(net,
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 88fcd46c45..51faa899c6 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -128,6 +128,9 @@ sub get_conn_arg {
         if ($type =~ /remote_nonnull_interface/) {
             return "priv->interfaceConn";
         }
+        if ($type =~ /remote_nonnull_network/) {
+            return "priv->networkConn";
+        }
     }
 
     # This is for the few virConnect APIs that
@@ -136,6 +139,9 @@ sub get_conn_arg {
     if ($proc =~ /Connect.*Interface/ || $proc =~ /InterfaceChange/) {
         return "priv->interfaceConn";
     }
+    if ($proc =~ /Connect.*Network/) {
+        return "priv->networkConn";
+    }
 
     return "priv->conn";
 }
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux