提交 e4fc4f0c 编写于 作者: D Daniel P. Berrange

lxc: more logging during startup paths

Add more logging to the lxc controller and container files to
facilitate debugging startup problems. Also make it clear when
the container is going to close stdout and thus no longer do
any logging.
上级 4acb01e4
...@@ -274,6 +274,10 @@ static int lxcContainerSetupFDs(int *ttyfd, ...@@ -274,6 +274,10 @@ static int lxcContainerSetupFDs(int *ttyfd,
size_t i; size_t i;
size_t j; size_t j;
VIR_DEBUG("Logging from the container init will now cease "
"as the FDs are about to be closed for exec of "
"the container init process");
if (setsid() < 0) { if (setsid() < 0) {
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
_("setsid failed")); _("setsid failed"));
...@@ -2250,6 +2254,7 @@ static int lxcContainerChild(void *data) ...@@ -2250,6 +2254,7 @@ static int lxcContainerChild(void *data)
if (virSecurityManagerSetProcessLabel(argv->securityDriver, vmDef) < 0) if (virSecurityManagerSetProcessLabel(argv->securityDriver, vmDef) < 0)
goto cleanup; goto cleanup;
VIR_DEBUG("Setting up inherited FDs");
VIR_FORCE_CLOSE(argv->handshakefd); VIR_FORCE_CLOSE(argv->handshakefd);
VIR_FORCE_CLOSE(argv->monitor); VIR_FORCE_CLOSE(argv->monitor);
if (lxcContainerSetupFDs(&ttyfd, if (lxcContainerSetupFDs(&ttyfd,
...@@ -2264,11 +2269,13 @@ static int lxcContainerChild(void *data) ...@@ -2264,11 +2269,13 @@ static int lxcContainerChild(void *data)
VIR_FORCE_CLOSE(argv->handshakefd); VIR_FORCE_CLOSE(argv->handshakefd);
if (ret == 0) { if (ret == 0) {
VIR_DEBUG("Executing init binary");
/* this function will only return if an error occurred */ /* this function will only return if an error occurred */
ret = virCommandExec(cmd); ret = virCommandExec(cmd);
} }
if (ret != 0) { if (ret != 0) {
VIR_DEBUG("Tearing down container");
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
if (err && err->message) if (err && err->message)
fprintf(stderr, "%s\n", err->message); fprintf(stderr, "%s\n", err->message);
...@@ -2379,6 +2386,7 @@ int lxcContainerStart(virDomainDefPtr def, ...@@ -2379,6 +2386,7 @@ int lxcContainerStart(virDomainDefPtr def,
cflags |= CLONE_NEWNET; cflags |= CLONE_NEWNET;
} }
VIR_DEBUG("Cloning container init process");
pid = clone(lxcContainerChild, stacktop, cflags, &args); pid = clone(lxcContainerChild, stacktop, cflags, &args);
VIR_FREE(stack); VIR_FREE(stack);
VIR_DEBUG("clone() completed, new container PID is %d", pid); VIR_DEBUG("clone() completed, new container PID is %d", pid);
......
...@@ -693,6 +693,8 @@ static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl) ...@@ -693,6 +693,8 @@ static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl)
virBitmapPtr nodeset = NULL; virBitmapPtr nodeset = NULL;
virDomainNumatuneMemMode mode; virDomainNumatuneMemMode mode;
VIR_DEBUG("Setting up process resource limits");
if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0) if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0)
goto cleanup; goto cleanup;
...@@ -1263,9 +1265,12 @@ static int virLXCControllerSetupUserns(virLXCControllerPtr ctrl) ...@@ -1263,9 +1265,12 @@ static int virLXCControllerSetupUserns(virLXCControllerPtr ctrl)
int ret = -1; int ret = -1;
/* User namespace is disabled for container */ /* User namespace is disabled for container */
if (ctrl->def->idmap.nuidmap == 0) if (ctrl->def->idmap.nuidmap == 0) {
VIR_DEBUG("No uid map, skipping userns setup");
return 0; return 0;
}
VIR_DEBUG("Setting up userns maps");
if (virAsprintf(&uid_map, "/proc/%d/uid_map", ctrl->initpid) < 0) if (virAsprintf(&uid_map, "/proc/%d/uid_map", ctrl->initpid) < 0)
goto cleanup; goto cleanup;
...@@ -1866,9 +1871,12 @@ static int lxcSetPersonality(virDomainDefPtr def) ...@@ -1866,9 +1871,12 @@ static int lxcSetPersonality(virDomainDefPtr def)
{ {
virArch altArch; virArch altArch;
VIR_DEBUG("Checking for 32-bit personality");
altArch = lxcContainerGetAlt32bitArch(virArchFromHost()); altArch = lxcContainerGetAlt32bitArch(virArchFromHost());
if (altArch && if (altArch &&
(def->os.arch == altArch)) { (def->os.arch == altArch)) {
VIR_DEBUG("Setting personality to %s",
virArchToString(altArch));
if (personality(PER_LINUX32) < 0) { if (personality(PER_LINUX32) < 0) {
virReportSystemError(errno, _("Unable to request personality for %s on %s"), virReportSystemError(errno, _("Unable to request personality for %s on %s"),
virArchToString(altArch), virArchToString(altArch),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册