It is not possible to blindly call virNetDaemonGetServer()
because in a post-exec restart scenario, some servers may
not exist and this method will pollute the error logs.
Signed-off-by: Daniel P. Berrange <berrange(a)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 a181c4cf7f..fab6ab9dff 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -69,6 +69,7 @@ virNetDaemonClose;
virNetDaemonGetServer;
virNetDaemonGetServers;
virNetDaemonHasClients;
+virNetDaemonHasServer;
virNetDaemonIsPrivileged;
virNetDaemonNew;
virNetDaemonNewPostExecRestart;
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 8c21414897..5d61a255c6 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -195,6 +195,19 @@ virNetDaemonGetServer(virNetDaemonPtr dmn,
return srv;
}
+bool
+virNetDaemonHasServer(virNetDaemonPtr dmn,
+ const char *serverName)
+{
+ void *ent;
+
+ virObjectLock(dmn);
+ ent = virHashLookup(dmn->servers, serverName);
+ virObjectUnlock(dmn);
+
+ return ent != NULL;
+}
+
struct collectData {
virNetServerPtr **servers;
diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h
index 211009c503..72c1df69b4 100644
--- a/src/rpc/virnetdaemon.h
+++ b/src/rpc/virnetdaemon.h
@@ -83,5 +83,7 @@ bool virNetDaemonHasClients(virNetDaemonPtr dmn);
virNetServerPtr virNetDaemonGetServer(virNetDaemonPtr dmn,
const char *serverName);
ssize_t virNetDaemonGetServers(virNetDaemonPtr dmn, virNetServerPtr **servers);
+bool virNetDaemonHasServer(virNetDaemonPtr dmn,
+ const char *serverName);
#endif /* __VIR_NET_DAEMON_H__ */
--
2.14.3