diff options
author | Martin Kletzander <mkletzan@redhat.com> | 2015-03-16 15:02:41 +0100 |
---|---|---|
committer | Martin Kletzander <mkletzan@redhat.com> | 2015-06-16 13:46:19 +0200 |
commit | fa14207368820b264123ba8429927b62258f996e (patch) | |
tree | 95b98a5ad59850a78e8fd8d9be9c753ac85ec2e3 /src/lxc | |
parent | 387cb8c6b2e684aae47c14a166851c299cc0a329 (diff) | |
download | libvirt-fa14207368820b264123ba8429927b62258f996e.tar.gz |
Move daemon-related parts of virNetServer to virNetDaemon
This allows to have more servers in one daemon which helps isolating
some resources.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Diffstat (limited to 'src/lxc')
-rw-r--r-- | src/lxc/lxc_controller.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 9b6f0c8d86..5f59867408 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014 Red Hat, Inc. + * Copyright (C) 2010-2015 Red Hat, Inc. * Copyright IBM Corp. 2008 * * lxc_controller.c: linux container process controller @@ -65,7 +65,7 @@ #include "virprocess.h" #include "virnuma.h" #include "virdbus.h" -#include "rpc/virnetserver.h" +#include "rpc/virnetdaemon.h" #include "virstring.h" #define VIR_FROM_THIS VIR_FROM_LXC @@ -93,7 +93,7 @@ struct _virLXCControllerConsole { size_t fromContLen; char fromContBuf[1024]; - virNetServerPtr server; + virNetDaemonPtr daemon; }; typedef struct _virLXCController virLXCController; @@ -128,8 +128,7 @@ struct _virLXCController { virSecurityManagerPtr securityManager; - /* Server socket */ - virNetServerPtr server; + virNetDaemonPtr daemon; bool firstClient; virNetServerClientPtr client; virNetServerProgramPtr prog; @@ -152,7 +151,7 @@ static void virLXCControllerQuitTimer(int timer ATTRIBUTE_UNUSED, void *opaque) virLXCControllerPtr ctrl = opaque; VIR_DEBUG("Triggering event loop quit"); - virNetServerQuit(ctrl->server); + virNetDaemonQuit(ctrl->daemon); } @@ -283,7 +282,7 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl) if (ctrl->timerShutdown != -1) virEventRemoveTimeout(ctrl->timerShutdown); - virObjectUnref(ctrl->server); + virObjectUnref(ctrl->daemon); virLXCControllerFreeFuse(ctrl); VIR_FREE(ctrl->nbdpids); @@ -301,7 +300,7 @@ static int virLXCControllerAddConsole(virLXCControllerPtr ctrl, { if (VIR_EXPAND_N(ctrl->consoles, ctrl->nconsoles, 1) < 0) return -1; - ctrl->consoles[ctrl->nconsoles-1].server = ctrl->server; + ctrl->consoles[ctrl->nconsoles-1].daemon = ctrl->daemon; ctrl->consoles[ctrl->nconsoles-1].hostFd = hostFd; ctrl->consoles[ctrl->nconsoles-1].hostWatch = -1; @@ -902,6 +901,7 @@ static void *virLXCControllerClientPrivateNew(virNetServerClientPtr client, static int virLXCControllerSetupServer(virLXCControllerPtr ctrl) { + virNetServerPtr srv = NULL; virNetServerServicePtr svc = NULL; char *sockpath; @@ -909,13 +909,13 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl) LXC_STATE_DIR, ctrl->name) < 0) return -1; - if (!(ctrl->server = virNetServerNew(0, 0, 0, 1, - 0, -1, 0, false, - NULL, - virLXCControllerClientPrivateNew, - NULL, - virLXCControllerClientPrivateFree, - ctrl))) + if (!(srv = virNetServerNew(0, 0, 0, 1, + 0, -1, 0, false, + NULL, + virLXCControllerClientPrivateNew, + NULL, + virLXCControllerClientPrivateFree, + ctrl))) goto error; if (virSecurityManagerSetSocketLabel(ctrl->securityManager, ctrl->def) < 0) @@ -936,7 +936,7 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl) if (virSecurityManagerClearSocketLabel(ctrl->securityManager, ctrl->def) < 0) goto error; - if (virNetServerAddService(ctrl->server, svc, NULL) < 0) + if (virNetServerAddService(srv, svc, NULL) < 0) goto error; virObjectUnref(svc); svc = NULL; @@ -947,14 +947,19 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl) virLXCMonitorNProcs))) goto error; - virNetServerUpdateServices(ctrl->server, true); + if (!(ctrl->daemon = virNetDaemonNew()) || + virNetDaemonAddServer(ctrl->daemon, srv) < 0) + goto error; + + virNetDaemonUpdateServices(ctrl->daemon, true); VIR_FREE(sockpath); return 0; error: VIR_FREE(sockpath); - virObjectUnref(ctrl->server); - ctrl->server = NULL; + virObjectUnref(srv); + virObjectUnref(ctrl->daemon); + ctrl->daemon = NULL; virObjectUnref(svc); return -1; } @@ -982,7 +987,7 @@ static bool wantReboot; static virMutex lock = VIR_MUTEX_INITIALIZER; -static void virLXCControllerSignalChildIO(virNetServerPtr server, +static void virLXCControllerSignalChildIO(virNetDaemonPtr daemon, siginfo_t *info ATTRIBUTE_UNUSED, void *opaque) { @@ -993,7 +998,7 @@ static void virLXCControllerSignalChildIO(virNetServerPtr server, ret = waitpid(-1, &status, WNOHANG); VIR_DEBUG("Got sig child %d vs %lld", ret, (unsigned long long)ctrl->initpid); if (ret == ctrl->initpid) { - virNetServerQuit(server); + virNetDaemonQuit(daemon); virMutexLock(&lock); if (WIFSIGNALED(status) && WTERMSIG(status) == SIGHUP) { @@ -1052,7 +1057,7 @@ static void virLXCControllerConsoleUpdateWatch(virLXCControllerConsolePtr consol VIR_DEBUG(":fail"); virReportSystemError(errno, "%s", _("Unable to add epoll fd")); - virNetServerQuit(console->server); + virNetDaemonQuit(console->daemon); goto cleanup; } console->hostEpoll = events; @@ -1064,7 +1069,7 @@ static void virLXCControllerConsoleUpdateWatch(virLXCControllerConsolePtr consol virReportSystemError(errno, "%s", _("Unable to remove epoll fd")); VIR_DEBUG(":fail"); - virNetServerQuit(console->server); + virNetDaemonQuit(console->daemon); goto cleanup; } console->hostEpoll = 0; @@ -1090,7 +1095,7 @@ static void virLXCControllerConsoleUpdateWatch(virLXCControllerConsolePtr consol virReportSystemError(errno, "%s", _("Unable to add epoll fd")); VIR_DEBUG(":fail"); - virNetServerQuit(console->server); + virNetDaemonQuit(console->daemon); goto cleanup; } console->contEpoll = events; @@ -1102,7 +1107,7 @@ static void virLXCControllerConsoleUpdateWatch(virLXCControllerConsolePtr consol virReportSystemError(errno, "%s", _("Unable to remove epoll fd")); VIR_DEBUG(":fail"); - virNetServerQuit(console->server); + virNetDaemonQuit(console->daemon); goto cleanup; } console->contEpoll = 0; @@ -1131,7 +1136,7 @@ static void virLXCControllerConsoleEPoll(int watch, int fd, int events, void *op continue; virReportSystemError(errno, "%s", _("Unable to wait on epoll")); - virNetServerQuit(console->server); + virNetDaemonQuit(console->daemon); goto cleanup; } @@ -1244,7 +1249,7 @@ static void virLXCControllerConsoleIO(int watch, int fd, int events, void *opaqu virEventRemoveHandle(console->contWatch); virEventRemoveHandle(console->hostWatch); console->contWatch = console->hostWatch = -1; - virNetServerQuit(console->server); + virNetDaemonQuit(console->daemon); virMutexUnlock(&lock); } @@ -1264,7 +1269,7 @@ static int virLXCControllerMain(virLXCControllerPtr ctrl) int rc = -1; size_t i; - if (virNetServerAddSignalHandler(ctrl->server, + if (virNetDaemonAddSignalHandler(ctrl->daemon, SIGCHLD, virLXCControllerSignalChildIO, ctrl) < 0) @@ -1310,7 +1315,7 @@ static int virLXCControllerMain(virLXCControllerPtr ctrl) } } - virNetServerRun(ctrl->server); + virNetDaemonRun(ctrl->daemon); err = virGetLastError(); if (!err || err->code == VIR_ERR_OK) @@ -2284,7 +2289,7 @@ virLXCControllerEventSendExit(virLXCControllerPtr ctrl, VIR_DEBUG("Waiting for client to complete dispatch"); ctrl->inShutdown = true; virNetServerClientDelayedClose(ctrl->client); - virNetServerRun(ctrl->server); + virNetDaemonRun(ctrl->daemon); } VIR_DEBUG("Client has gone away"); return 0; |