[PATCH v2 3/8] remote: use a separate connection for interface 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 |  4 ++++
 src/rpc/gendispatch.pl              | 25 ++++++++++++++++++++++++-
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 4467f71da9..31f433c15d 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -74,6 +74,7 @@ struct daemonClientPrivate {
      * called, it will be set back to NULL if that succeeds.
      */
     virConnectPtr conn;
+    virConnectPtr interfaceConn;
 
     daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 853e63901b..34c140e613 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1745,6 +1745,8 @@ void remoteClientFree(void *data)
 
     if (priv->conn)
         virConnectClose(priv->conn);
+    if (priv->interfaceConn)
+        virConnectClose(priv->interfaceConn);
 
     VIR_FREE(priv);
 }
@@ -1817,6 +1819,8 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
     if (priv->conn == NULL)
         goto cleanup;
 
+    priv->interfaceConn = virObjectRef(priv->conn);
+
     /* force update the @readonly attribute which was inherited from the
      * virNetServerService object - this is important for sockets that are RW
      * by default, but do accept RO flags, e.g. TCP
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index d5e61f5bb8..88fcd46c45 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -111,9 +111,32 @@ sub name_to_TypeName {
 }
 
 sub get_conn_arg {
+    my $proc = shift;
+    my $args = shift;
+    my $rets = shift;
+
     if ($structprefix eq "admin") {
         return "priv->dmn";
     }
+
+    my @types;
+    push @types, @{$args} if $args;
+    push @types, @{$rets} if $rets;
+
+    # This correctly detects most APIs
+    foreach my $type (@types) {
+        if ($type =~ /remote_nonnull_interface/) {
+            return "priv->interfaceConn";
+        }
+    }
+
+    # This is for the few virConnect APIs that
+    # return things which aren't objects. eg list
+    # of pool names, or number of pools.
+    if ($proc =~ /Connect.*Interface/ || $proc =~ /InterfaceChange/) {
+        return "priv->interfaceConn";
+    }
+
     return "priv->conn";
 }
 
@@ -481,7 +504,7 @@ elsif ($mode eq "server") {
         my @free_list = ();
         my @free_list_on_error = ("virNetMessageSaveError(rerr);");
 
-        my $conn = get_conn_arg();
+        my $conn = get_conn_arg($call->{ProcName}, $call->{args_members}, $call->{ret_members});
 
         # handle arguments to the function
         if ($argtype ne "void") {
-- 
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