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 | 17 ++++++++++++++++-
src/rpc/virnetserver.h | 1 +
tests/virnetdaemondata/input-data-admin-nomdns.json | 2 ++
tests/virnetdaemondata/input-data-anon-clients.json | 1 +
tests/virnetdaemondata/input-data-initial-nomdns.json | 1 +
tests/virnetdaemondata/input-data-initial.json | 1 +
tests/virnetdaemontest.c | 2 +-
11 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 250094b..88ad753 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,
+ "default",
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 c035024..6e67620 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -151,7 +151,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
if (!(lockd->srv = virNetServerNew(1, 1, 0, config->max_clients,
config->max_clients, -1, 0,
- NULL,
+ NULL, "virlockd",
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..ae48cbb 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",
@@ -427,11 +436,17 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr
object,
goto error;
}
+ if (!(serverName = virJSONValueObjectGetString(object, "name"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Missing server name in JSON document"));
+ goto error;
+ }
+
if (!(srv = virNetServerNew(min_workers, max_workers,
priority_workers, max_clients,
max_anonymous_clients,
keepaliveInterval, keepaliveCount,
- mdnsGroupName,
+ mdnsGroupName, serverName,
clientPrivNew, clientPrivPreExecRestart,
clientPrivFree, clientPrivOpaque)))
goto error;
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/virnetdaemondata/input-data-admin-nomdns.json
b/tests/virnetdaemondata/input-data-admin-nomdns.json
index 449bcc9..9f2281c 100644
--- a/tests/virnetdaemondata/input-data-admin-nomdns.json
+++ b/tests/virnetdaemondata/input-data-admin-nomdns.json
@@ -8,6 +8,7 @@
"keepaliveInterval": 120,
"keepaliveCount": 5,
"keepaliveRequired": true,
+ "name": "libvirtTestServer0",
"services": [
{
"auth": 0,
@@ -69,6 +70,7 @@
"keepaliveInterval": 120,
"keepaliveCount": 5,
"keepaliveRequired": true,
+ "name": "libvirtTestServer1",
"services": [
{
"auth": 0,
diff --git a/tests/virnetdaemondata/input-data-anon-clients.json
b/tests/virnetdaemondata/input-data-anon-clients.json
index 8a51ff5..3bc84f7 100644
--- a/tests/virnetdaemondata/input-data-anon-clients.json
+++ b/tests/virnetdaemondata/input-data-anon-clients.json
@@ -7,6 +7,7 @@
"keepaliveInterval": 120,
"keepaliveCount": 5,
"keepaliveRequired": true,
+ "name": "libvirtTestServer",
"services": [
{
"auth": 0,
diff --git a/tests/virnetdaemondata/input-data-initial-nomdns.json
b/tests/virnetdaemondata/input-data-initial-nomdns.json
index 02bb427..f755a29 100644
--- a/tests/virnetdaemondata/input-data-initial-nomdns.json
+++ b/tests/virnetdaemondata/input-data-initial-nomdns.json
@@ -6,6 +6,7 @@
"keepaliveInterval": 120,
"keepaliveCount": 5,
"keepaliveRequired": true,
+ "name": "libvirtTestServer",
"services": [
{
"auth": 0,
diff --git a/tests/virnetdaemondata/input-data-initial.json
b/tests/virnetdaemondata/input-data-initial.json
index 7956225..d1c801d 100644
--- a/tests/virnetdaemondata/input-data-initial.json
+++ b/tests/virnetdaemondata/input-data-initial.json
@@ -7,6 +7,7 @@
"keepaliveCount": 5,
"keepaliveRequired": true,
"mdnsGroupName": "libvirtTest",
+ "name": "libvirtTestServer",
"services": [
{
"auth": 0,
diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c
index fb8a6c0..019c8c4 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