By adding this element, we'll be able to reference 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/logging/log_daemon.c | 2 +-
src/lxc/lxc_controller.c | 2 +-
src/rpc/virnetserver.c | 16 ++++++++++++++--
src/rpc/virnetserver.h | 1 +
tests/virnetdaemontest.c | 2 +-
7 files changed, 21 insertions(+), 6 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 a5a40fe..568b657 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -162,7 +162,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/logging/log_daemon.c b/src/logging/log_daemon.c
index 6da5876..ea7bfcf 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -152,7 +152,7 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged)
if (!(logd->srv = virNetServerNew(1, 1, 0, config->max_clients,
config->max_clients, -1, 0,
- NULL,
+ NULL, "virtlogd",
virLogDaemonClientNew,
virLogDaemonClientPreExecRestart,
virLogDaemonClientFree,
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 3e5d2b4..149b6d5 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -930,7 +930,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/virnetserver.c b/src/rpc/virnetserver.c
index 547e52e..d4dc41f 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -36,7 +36,6 @@
VIR_LOG_INIT("rpc.netserver");
-
typedef struct _virNetServerJob virNetServerJob;
typedef virNetServerJob *virNetServerJobPtr;
@@ -49,6 +48,7 @@ struct _virNetServerJob {
struct _virNetServer {
virObjectLockable parent;
+ char *name;
virThreadPoolPtr workers;
char *mdnsGroupName;
@@ -312,6 +312,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
int keepaliveInterval,
unsigned int keepaliveCount,
const char *mdnsGroupName,
+ const char *serverName,
virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivPreExecRestart
clientPrivPreExecRestart,
virFreeCallback clientPrivFree,
@@ -341,6 +342,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 +382,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 +436,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 +530,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 24cbd54..754b6fb 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