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

[libvirt] [EXAMPLE PATCH 11/13] rpc: Add virNetServerGetNClients



This function accesses the number of connected clients while properly
locking the server it returns the data about.

Signed-off-by: Martin Kletzander <mkletzan redhat com>
---
 src/libvirt_remote.syms |  1 +
 src/rpc/virnetserver.c  | 10 ++++++++++
 src/rpc/virnetserver.h  |  2 ++
 3 files changed, 13 insertions(+)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index ac12807..7cd0cf3 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -96,6 +96,7 @@ xdr_virNetMessageError;
 virNetServerAddProgram;
 virNetServerAddService;
 virNetServerClose;
+virNetServerGetNClients;
 virNetServerHasClients;
 virNetServerKeepAliveRequired;
 virNetServerNew;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index df844d9..af7f87b 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -882,3 +882,13 @@ virNetServerStart(virNetServerPtr srv)

     return virNetServerMDNSStart(srv->mdns);
 }
+
+size_t
+virNetServerGetNClients(virNetServerPtr srv)
+{
+    size_t ret = 0;
+    virObjectLock(srv);
+    ret = srv->nclients;
+    virObjectUnlock(srv);
+    return ret;
+}
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 3e312c0..0316610 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -87,4 +87,6 @@ void virNetServerUpdateServices(virNetServerPtr srv, bool enabled);

 int virNetServerStart(virNetServerPtr srv);

+size_t virNetServerGetNClients(virNetServerPtr srv);
+
 #endif /* __VIR_NET_SERVER_H__ */
--
2.4.0


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