提交 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) { ...@@ -1382,7 +1382,8 @@ int main(int argc, char **argv) {
goto cleanup; goto cleanup;
} }
if (!(srv = virNetServerNew(config->min_workers, if (!(srv = virNetServerNew("libvirtd",
config->min_workers,
config->max_workers, config->max_workers,
config->prio_workers, config->prio_workers,
config->max_clients, config->max_clients,
...@@ -1456,7 +1457,8 @@ int main(int argc, char **argv) { ...@@ -1456,7 +1457,8 @@ int main(int argc, char **argv) {
goto cleanup; goto cleanup;
} }
if (!(srvAdm = virNetServerNew(config->admin_min_workers, if (!(srvAdm = virNetServerNew("admin",
config->admin_min_workers,
config->admin_max_workers, config->admin_max_workers,
0, 0,
config->admin_max_clients, config->admin_max_clients,
......
...@@ -160,7 +160,8 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged) ...@@ -160,7 +160,8 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
return NULL; 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, config->max_clients, -1, 0,
NULL, NULL,
virLockDaemonClientNew, virLockDaemonClientNew,
......
...@@ -150,7 +150,8 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged) ...@@ -150,7 +150,8 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged)
return NULL; 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, config->max_clients, -1, 0,
NULL, NULL,
virLogDaemonClientNew, virLogDaemonClientNew,
......
...@@ -928,7 +928,8 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl) ...@@ -928,7 +928,8 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
LXC_STATE_DIR, ctrl->name) < 0) LXC_STATE_DIR, ctrl->name) < 0)
return -1; return -1;
if (!(srv = virNetServerNew(0, 0, 0, 1, if (!(srv = virNetServerNew("LXC",
0, 0, 0, 1,
0, -1, 0, 0, -1, 0,
NULL, NULL,
virLXCControllerClientPrivateNew, virLXCControllerClientPrivateNew,
......
...@@ -276,6 +276,7 @@ virNetDaemonAddServerPostExec(virNetDaemonPtr dmn, ...@@ -276,6 +276,7 @@ virNetDaemonAddServerPostExec(virNetDaemonPtr dmn,
} }
srv = virNetServerNewPostExecRestart(object, srv = virNetServerNewPostExecRestart(object,
serverName,
clientPrivNew, clientPrivNew,
clientPrivNewPostExecRestart, clientPrivNewPostExecRestart,
clientPrivPreExecRestart, clientPrivPreExecRestart,
......
...@@ -49,6 +49,8 @@ struct _virNetServerJob { ...@@ -49,6 +49,8 @@ struct _virNetServerJob {
struct _virNetServer { struct _virNetServer {
virObjectLockable parent; virObjectLockable parent;
char *name;
virThreadPoolPtr workers; virThreadPoolPtr workers;
char *mdnsGroupName; char *mdnsGroupName;
...@@ -304,7 +306,8 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc, ...@@ -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 max_workers,
size_t priority_workers, size_t priority_workers,
size_t max_clients, size_t max_clients,
...@@ -332,6 +335,9 @@ virNetServerPtr virNetServerNew(size_t min_workers, ...@@ -332,6 +335,9 @@ virNetServerPtr virNetServerNew(size_t min_workers,
srv))) srv)))
goto error; goto error;
if (VIR_STRDUP(srv->name, name) < 0)
goto error;
srv->nclients_max = max_clients; srv->nclients_max = max_clients;
srv->nclients_unauth_max = max_anonymous_clients; srv->nclients_unauth_max = max_anonymous_clients;
srv->keepaliveInterval = keepaliveInterval; srv->keepaliveInterval = keepaliveInterval;
...@@ -359,6 +365,7 @@ virNetServerPtr virNetServerNew(size_t min_workers, ...@@ -359,6 +365,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object, virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
const char *name,
virNetServerClientPrivNew clientPrivNew, virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivNewPostExecRestart clientPrivNewPostExecRestart, virNetServerClientPrivNewPostExecRestart clientPrivNewPostExecRestart,
virNetServerClientPrivPreExecRestart clientPrivPreExecRestart, virNetServerClientPrivPreExecRestart clientPrivPreExecRestart,
...@@ -427,7 +434,8 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object, ...@@ -427,7 +434,8 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
goto error; goto error;
} }
if (!(srv = virNetServerNew(min_workers, max_workers, if (!(srv = virNetServerNew(name,
min_workers, max_workers,
priority_workers, max_clients, priority_workers, max_clients,
max_anonymous_clients, max_anonymous_clients,
keepaliveInterval, keepaliveCount, keepaliveInterval, keepaliveCount,
...@@ -734,6 +742,8 @@ void virNetServerDispose(void *obj) ...@@ -734,6 +742,8 @@ void virNetServerDispose(void *obj)
virNetServerPtr srv = obj; virNetServerPtr srv = obj;
size_t i; size_t i;
VIR_FREE(srv->name);
for (i = 0; i < srv->nservices; i++) for (i = 0; i < srv->nservices; i++)
virNetServerServiceToggle(srv->services[i], false); virNetServerServiceToggle(srv->services[i], false);
...@@ -861,3 +871,9 @@ virNetServerStart(virNetServerPtr srv) ...@@ -861,3 +871,9 @@ virNetServerStart(virNetServerPtr srv)
return virNetServerMDNSStart(srv->mdns); return virNetServerMDNSStart(srv->mdns);
} }
const char *
virNetServerGetName(virNetServerPtr srv)
{
return srv->name;
}
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
# include "virjson.h" # include "virjson.h"
virNetServerPtr virNetServerNew(size_t min_workers, virNetServerPtr virNetServerNew(const char *name,
size_t min_workers,
size_t max_workers, size_t max_workers,
size_t priority_workers, size_t priority_workers,
size_t max_clients, size_t max_clients,
...@@ -48,6 +49,7 @@ virNetServerPtr virNetServerNew(size_t min_workers, ...@@ -48,6 +49,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
void *clientPrivOpaque); void *clientPrivOpaque);
virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object, virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
const char *name,
virNetServerClientPrivNew clientPrivNew, virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivNewPostExecRestart clientPrivNewPostExecRestart, virNetServerClientPrivNewPostExecRestart clientPrivNewPostExecRestart,
virNetServerClientPrivPreExecRestart clientPrivPreExecRestart, virNetServerClientPrivPreExecRestart clientPrivPreExecRestart,
...@@ -85,4 +87,6 @@ void virNetServerUpdateServices(virNetServerPtr srv, bool enabled); ...@@ -85,4 +87,6 @@ void virNetServerUpdateServices(virNetServerPtr srv, bool enabled);
int virNetServerStart(virNetServerPtr srv); int virNetServerStart(virNetServerPtr srv);
const char *virNetServerGetName(virNetServerPtr srv);
#endif /* __VIR_NET_SERVER_H__ */ #endif /* __VIR_NET_SERVER_H__ */
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#if defined(HAVE_SOCKETPAIR) && defined(WITH_YAJL) #if defined(HAVE_SOCKETPAIR) && defined(WITH_YAJL)
static virNetServerPtr static virNetServerPtr
testCreateServer(const char *host, int family) testCreateServer(const char *server_name, const char *host, int family)
{ {
virNetServerPtr srv = NULL; virNetServerPtr srv = NULL;
virNetServerServicePtr svc1 = NULL, svc2 = NULL; virNetServerServicePtr svc1 = NULL, svc2 = NULL;
...@@ -49,7 +49,8 @@ testCreateServer(const char *host, int family) ...@@ -49,7 +49,8 @@ testCreateServer(const char *host, int family)
goto cleanup; goto cleanup;
} }
if (!(srv = virNetServerNew(10, 50, 5, 100, 10, if (!(srv = virNetServerNew(server_name,
10, 50, 5, 100, 10,
120, 5, 120, 5,
mdns_group, mdns_group,
NULL, NULL,
...@@ -155,7 +156,8 @@ static char *testGenerateJSON(const char *server_name) ...@@ -155,7 +156,8 @@ static char *testGenerateJSON(const char *server_name)
if (!has_ipv4 && !has_ipv6) if (!has_ipv4 && !has_ipv6)
return NULL; 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))) has_ipv4 ? AF_INET : AF_INET6)))
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册