render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 699faeacb10459fed748d425eb044ef69697e804 Mon Sep 17 00:00:00 2001
From: Martin Kletzander <mkletzan@redhat.com>
Date: Fri, 10 Jul 2015 10:34:52 +0200
Subject: [PATCH] rpc: Add virNetDaemonHasClients

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 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 e6ca041..6bfdcfa 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 67dff14..6b13282 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 9e176d6..bb32053 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.3