提交 dad3b078 编写于 作者: M Martin Kletzander

server: Store server name in server object

At first I did not want to do this, but after trying to implement some
newer feaures in the admin API I realized we need that to make our lives
easier.  On the other hand they are not saved redundantly and the
virNetServer objects are still kept in a hash table.
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 b04e39ff
......@@ -1382,7 +1382,8 @@ int main(int argc, char **argv) {
goto cleanup;
}
if (!(srv = virNetServerNew(config->min_workers,
if (!(srv = virNetServerNew("libvirtd",
config->min_workers,
config->max_workers,
config->prio_workers,
config->max_clients,
......@@ -1456,7 +1457,8 @@ int main(int argc, char **argv) {
goto cleanup;
}
if (!(srvAdm = virNetServerNew(config->admin_min_workers,
if (!(srvAdm = virNetServerNew("admin",
config->admin_min_workers,
config->admin_max_workers,
0,
config->admin_max_clients,
......
......@@ -160,7 +160,8 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
return NULL;
}
if (!(srv = virNetServerNew(1, 1, 0, config->max_clients,
if (!(srv = virNetServerNew("virtlockd",
1, 1, 0, config->max_clients,
config->max_clients, -1, 0,
NULL,
virLockDaemonClientNew,
......
......@@ -150,7 +150,8 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged)
return NULL;
}
if (!(logd->srv = virNetServerNew(1, 1, 0, config->max_clients,
if (!(logd->srv = virNetServerNew("virtlogd",
1, 1, 0, config->max_clients,
config->max_clients, -1, 0,
NULL,
virLogDaemonClientNew,
......
......@@ -928,7 +928,8 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
LXC_STATE_DIR, ctrl->name) < 0)
return -1;
if (!(srv = virNetServerNew(0, 0, 0, 1,
if (!(srv = virNetServerNew("LXC",
0, 0, 0, 1,
0, -1, 0,
NULL,
virLXCControllerClientPrivateNew,
......
......@@ -276,6 +276,7 @@ virNetDaemonAddServerPostExec(virNetDaemonPtr dmn,
}
srv = virNetServerNewPostExecRestart(object,
serverName,
clientPrivNew,
clientPrivNewPostExecRestart,
clientPrivPreExecRestart,
......
......@@ -49,6 +49,8 @@ struct _virNetServerJob {
struct _virNetServer {
virObjectLockable parent;
char *name;
virThreadPoolPtr workers;
char *mdnsGroupName;
......@@ -304,7 +306,8 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc,
}
virNetServerPtr virNetServerNew(size_t min_workers,
virNetServerPtr virNetServerNew(const char *name,
size_t min_workers,
size_t max_workers,
size_t priority_workers,
size_t max_clients,
......@@ -332,6 +335,9 @@ virNetServerPtr virNetServerNew(size_t min_workers,
srv)))
goto error;
if (VIR_STRDUP(srv->name, name) < 0)
goto error;
srv->nclients_max = max_clients;
srv->nclients_unauth_max = max_anonymous_clients;
srv->keepaliveInterval = keepaliveInterval;
......@@ -359,6 +365,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
const char *name,
virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivNewPostExecRestart clientPrivNewPostExecRestart,
virNetServerClientPrivPreExecRestart clientPrivPreExecRestart,
......@@ -427,7 +434,8 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
goto error;
}
if (!(srv = virNetServerNew(min_workers, max_workers,
if (!(srv = virNetServerNew(name,
min_workers, max_workers,
priority_workers, max_clients,
max_anonymous_clients,
keepaliveInterval, keepaliveCount,
......@@ -734,6 +742,8 @@ void virNetServerDispose(void *obj)
virNetServerPtr srv = obj;
size_t i;
VIR_FREE(srv->name);
for (i = 0; i < srv->nservices; i++)
virNetServerServiceToggle(srv->services[i], false);
......@@ -861,3 +871,9 @@ virNetServerStart(virNetServerPtr srv)
return virNetServerMDNSStart(srv->mdns);
}
const char *
virNetServerGetName(virNetServerPtr srv)
{
return srv->name;
}
......@@ -34,7 +34,8 @@
# include "virjson.h"
virNetServerPtr virNetServerNew(size_t min_workers,
virNetServerPtr virNetServerNew(const char *name,
size_t min_workers,
size_t max_workers,
size_t priority_workers,
size_t max_clients,
......@@ -48,6 +49,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
void *clientPrivOpaque);
virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
const char *name,
virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivNewPostExecRestart clientPrivNewPostExecRestart,
virNetServerClientPrivPreExecRestart clientPrivPreExecRestart,
......@@ -85,4 +87,6 @@ void virNetServerUpdateServices(virNetServerPtr srv, bool enabled);
int virNetServerStart(virNetServerPtr srv);
const char *virNetServerGetName(virNetServerPtr srv);
#endif /* __VIR_NET_SERVER_H__ */
......@@ -28,7 +28,7 @@
#if defined(HAVE_SOCKETPAIR) && defined(WITH_YAJL)
static virNetServerPtr
testCreateServer(const char *host, int family)
testCreateServer(const char *server_name, const char *host, int family)
{
virNetServerPtr srv = NULL;
virNetServerServicePtr svc1 = NULL, svc2 = NULL;
......@@ -49,7 +49,8 @@ testCreateServer(const char *host, int family)
goto cleanup;
}
if (!(srv = virNetServerNew(10, 50, 5, 100, 10,
if (!(srv = virNetServerNew(server_name,
10, 50, 5, 100, 10,
120, 5,
mdns_group,
NULL,
......@@ -155,7 +156,8 @@ static char *testGenerateJSON(const char *server_name)
if (!has_ipv4 && !has_ipv6)
return NULL;
if (!(srv = testCreateServer(has_ipv4 ? "127.0.0.1" : "::1",
if (!(srv = testCreateServer(server_name,
has_ipv4 ? "127.0.0.1" : "::1",
has_ipv4 ? AF_INET : AF_INET6)))
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册