[PATCH 5/9] rpc: virnetserver: Support retrieval of a list of clients

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

 



For now, the list copy is done simply by locking the whole server, walking the
original and increasing the refcount on each object. We may want to change
the list to a lockable object (like list of domains) later in the future if
we discover some performance issues related to locking the whole server in
order to walk the whole list of clients, possibly issuing some 'ForEach'
callback.

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/libvirt_remote.syms |  1 +
 src/rpc/virnetserver.c  | 29 +++++++++++++++++++++++++++++
 src/rpc/virnetserver.h  |  3 +++
 3 files changed, 33 insertions(+)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index c049874..ea92043 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -101,6 +101,7 @@ virNetServerAddClient;
 virNetServerAddProgram;
 virNetServerAddService;
 virNetServerClose;
+virNetServerGetClients;
 virNetServerGetName;
 virNetServerHasClients;
 virNetServerNew;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 8216da6..e52d765 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -943,3 +943,32 @@ virNetServerSetThreadPoolParameters(virNetServerPtr srv,
     virObjectUnlock(srv);
     return ret;
 }
+
+int
+virNetServerGetClients(virNetServerPtr srv,
+                       virNetServerClientPtr **clts)
+{
+    int ret = -1;
+    size_t i;
+    size_t nclients = 0;
+
+    *clts = NULL;
+
+    virObjectLock(srv);
+
+    for (i = 0; i < srv->nclients; i++) {
+        virNetServerClientPtr client = virObjectRef(srv->clients[i]);
+        if (VIR_APPEND_ELEMENT(*clts, nclients, client) < 0) {
+            virObjectUnref(client);
+            goto cleanup;
+        }
+    }
+
+    ret = nclients;
+
+ cleanup:
+    if (ret < 0)
+        virObjectListFreeCount(*clts, nclients);
+    virObjectUnlock(srv);
+    return ret;
+}
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 2ae89ce..f5bb200 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -105,4 +105,7 @@ int virNetServerSetThreadPoolParameters(virNetServerPtr srv,
 
 unsigned long long virNetServerNextClientID(virNetServerPtr srv);
 
+int virNetServerGetClients(virNetServerPtr srv,
+                           virNetServerClientPtr **clients);
+
 #endif /* __VIR_NET_SERVER_H__ */
-- 
2.4.11

--
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]