This function accesses the number of connected clients while properly
locking the server it returns the data about.
Signed-off-by: Martin Kletzander <mkletzan(a)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 e6ca041ea8e1..8ddb10ed7b31 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -99,6 +99,7 @@ virNetServerAddClient;
virNetServerAddProgram;
virNetServerAddService;
virNetServerClose;
+virNetServerGetNClients;
virNetServerHasClients;
virNetServerKeepAliveRequired;
virNetServerNew;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 60a9714f6096..1f4fbaed3c99 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -884,3 +884,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 5c28182ffd15..e0852843f05c 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -90,4 +90,6 @@ void virNetServerUpdateServices(virNetServerPtr srv, bool enabled);
int virNetServerStart(virNetServerPtr srv);
+size_t virNetServerGetNClients(virNetServerPtr srv);
+
#endif /* __VIR_NET_SERVER_H__ */
--
2.4.3