[EXAMPLE PATCH 11/13] rpc: Add virNetServerGetNClients

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

 



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

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 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

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