[PATCH 1/2] rpc: Add virNetDaemonHasClients

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

 



So callers don't have to iterate over each server.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/libvirt_remote.syms |  1 +
 src/rpc/virnetdaemon.c  | 13 +++++++++++++
 src/rpc/virnetdaemon.h  |  2 ++
 3 files changed, 16 insertions(+)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index e6ca041ea8e1..6bfdcfa819bf 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -65,6 +65,7 @@ virNetDaemonAddSignalHandler;
 virNetDaemonAutoShutdown;
 virNetDaemonClose;
 virNetDaemonGetServer;
+virNetDaemonHasClients;
 virNetDaemonIsPrivileged;
 virNetDaemonNew;
 virNetDaemonNewPostExecRestart;
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 67dff147be60..6b132823274c 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -747,3 +747,16 @@ virNetDaemonClose(virNetDaemonPtr dmn)

     virObjectUnlock(dmn);
 }
+
+bool
+virNetDaemonHasClients(virNetDaemonPtr dmn)
+{
+    size_t i = 0;
+
+    for (i = 0; i < dmn->nservers; i++) {
+        if (virNetServerHasClients(dmn->servers[i]))
+            return true;
+    }
+
+    return false;
+}
diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h
index 9e176d65ca6a..bb320539a887 100644
--- a/src/rpc/virnetdaemon.h
+++ b/src/rpc/virnetdaemon.h
@@ -76,6 +76,8 @@ void virNetDaemonQuit(virNetDaemonPtr dmn);

 void virNetDaemonClose(virNetDaemonPtr dmn);

+bool virNetDaemonHasClients(virNetDaemonPtr dmn);
+
 virNetServerPtr virNetDaemonGetServer(virNetDaemonPtr dmn,
                                       int subServerID);

-- 
2.4.5

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