render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From ce2001d94e099b4d8e6279f70af6d355283279fb Mon Sep 17 00:00:00 2001
Message-Id: <ce2001d94e099b4d8e6279f70af6d355283279fb@dist-git>
From: Martin Kletzander <mkletzan@redhat.com>
Date: Wed, 15 Jul 2015 17:11:55 +0200
Subject: [PATCH] rpc: Add virNetDaemonHasClients

https://bugzilla.redhat.com/show_bug.cgi?id=1240283

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 699faeacb10459fed748d425eb044ef69697e804)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@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.5.0