By adding these elements, we'll be able to represent the servers on
client side. This is merely because when listing clients or managing
clients, it would be convenient to know which server they're connected
to. Also reflect this change in virnetdaemontest as well.
---
daemon/libvirtd.c | 2 ++
src/locking/lock_daemon.c | 2 +-
src/lxc/lxc_controller.c | 2 +-
src/rpc/virnetdaemon.c | 1 +
src/rpc/virnetserver.c | 18 +++++++++++++++++-
src/rpc/virnetserver.h | 1 +
tests/virnetdaemontest.c | 2 +-
7 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 250094b..de4953d 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1390,6 +1390,7 @@ int main(int argc, char **argv) {
config->keepalive_interval,
config->keepalive_count,
config->mdns_adv ? config->mdns_name : NULL,
+ "libvirtd",
remoteClientInitHook,
NULL,
remoteClientFreeFunc,
@@ -1464,6 +1465,7 @@ int main(int argc, char **argv) {
config->admin_keepalive_interval,
config->admin_keepalive_count,
NULL,
+ "admin",
remoteAdmClientInitHook,
NULL,
remoteAdmClientFreeFunc,
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index ae3a507..8c07fd6 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -150,7 +150,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
if (!(srv = virNetServerNew(1, 1, 0, config->max_clients,
config->max_clients, -1, 0,
- NULL,
+ NULL, "virtlockd",
virLockDaemonClientNew,
virLockDaemonClientPreExecRestart,
virLockDaemonClientFree,
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 48a3597..0984be0 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -926,7 +926,7 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
if (!(srv = virNetServerNew(0, 0, 0, 1,
0, -1, 0,
- NULL,
+ NULL, "LXC",
virLXCControllerClientPrivateNew,
NULL,
virLXCControllerClientPrivateFree,
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 910f266..bdfcfb7 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -69,6 +69,7 @@ struct _virNetDaemon {
int sigwrite;
int sigwatch;
+ unsigned int nextSrvId;
size_t nservers;
virNetServerPtr *servers;
virJSONValuePtr srvObject;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 80b5588..ffc1b0d 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -36,6 +36,7 @@
VIR_LOG_INIT("rpc.netserver");
+static unsigned int nextServerId;
typedef struct _virNetServerJob virNetServerJob;
typedef virNetServerJob *virNetServerJobPtr;
@@ -49,6 +50,8 @@ struct _virNetServerJob {
struct _virNetServer {
virObjectLockable parent;
+ char *name;
+ unsigned int id;
virThreadPoolPtr workers;
char *mdnsGroupName;
@@ -312,6 +315,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
int keepaliveInterval,
unsigned int keepaliveCount,
const char *mdnsGroupName,
+ const char *serverName,
virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivPreExecRestart
clientPrivPreExecRestart,
virFreeCallback clientPrivFree,
@@ -332,6 +336,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
srv)))
goto error;
+ srv->id = nextServerId++;
srv->nclients_max = max_clients;
srv->nclients_unauth_max = max_anonymous_clients;
srv->keepaliveInterval = keepaliveInterval;
@@ -341,6 +346,9 @@ virNetServerPtr virNetServerNew(size_t min_workers,
srv->clientPrivFree = clientPrivFree;
srv->clientPrivOpaque = clientPrivOpaque;
+ if (VIR_STRDUP(srv->name, serverName) < 0)
+ goto error;
+
if (VIR_STRDUP(srv->mdnsGroupName, mdnsGroupName) < 0)
goto error;
if (srv->mdnsGroupName) {
@@ -378,6 +386,7 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr
object,
unsigned int keepaliveInterval;
unsigned int keepaliveCount;
const char *mdnsGroupName = NULL;
+ const char *serverName = NULL;
if (virJSONValueObjectGetNumberUint(object, "min_workers",
&min_workers) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -431,7 +440,7 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr
object,
priority_workers, max_clients,
max_anonymous_clients,
keepaliveInterval, keepaliveCount,
- mdnsGroupName,
+ mdnsGroupName, serverName,
clientPrivNew, clientPrivPreExecRestart,
clientPrivFree, clientPrivOpaque)))
goto error;
@@ -525,6 +534,13 @@ virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv)
if (!(object = virJSONValueNewObject()))
goto error;
+ if (srv->name &&
+ virJSONValueObjectAppendString(object, "name", srv->name) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot set name data in JSON document"));
+ goto error;
+ }
+
if (virJSONValueObjectAppendNumberUint(object, "min_workers",
virThreadPoolGetMinWorkers(srv->workers))
< 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 89d8db9..fb04aa3 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -42,6 +42,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
int keepaliveInterval,
unsigned int keepaliveCount,
const char *mdnsGroupName,
+ const char *serverName,
virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivPreExecRestart
clientPrivPreExecRestart,
virFreeCallback clientPrivFree,
diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c
index bc0a080..89d3ca1 100644
--- a/tests/virnetdaemontest.c
+++ b/tests/virnetdaemontest.c
@@ -51,7 +51,7 @@ testCreateServer(const char *host, int family)
if (!(srv = virNetServerNew(10, 50, 5, 100, 10,
120, 5,
- mdns_group,
+ mdns_group, "test-server",
NULL,
NULL,
NULL,
--
2.4.3