mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
lxc: Drop container stdio as late as possible
Makes it more likely we get useful error output in the logs
This commit is contained in:
parent
02e86910e2
commit
eee1763c8c
@ -751,9 +751,9 @@ static int lxcContainerChild( void *data )
|
|||||||
{
|
{
|
||||||
lxc_child_argv_t *argv = data;
|
lxc_child_argv_t *argv = data;
|
||||||
virDomainDefPtr vmDef = argv->config;
|
virDomainDefPtr vmDef = argv->config;
|
||||||
int ttyfd;
|
int ttyfd = -1;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *ttyPath;
|
char *ttyPath = NULL;
|
||||||
virDomainFSDefPtr root;
|
virDomainFSDefPtr root;
|
||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
|
|
||||||
@ -786,16 +786,8 @@ static int lxcContainerChild( void *data )
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to open tty %s"),
|
_("Failed to open tty %s"),
|
||||||
ttyPath);
|
ttyPath);
|
||||||
VIR_FREE(ttyPath);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(ttyPath);
|
|
||||||
|
|
||||||
if (lxcContainerSetStdio(argv->monitor, ttyfd) < 0) {
|
|
||||||
VIR_FORCE_CLOSE(ttyfd);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
VIR_FORCE_CLOSE(ttyfd);
|
|
||||||
|
|
||||||
if (lxcContainerSetupMounts(vmDef, root) < 0)
|
if (lxcContainerSetupMounts(vmDef, root) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -806,17 +798,28 @@ static int lxcContainerChild( void *data )
|
|||||||
|
|
||||||
/* rename and enable interfaces */
|
/* rename and enable interfaces */
|
||||||
if (lxcContainerRenameAndEnableInterfaces(argv->nveths,
|
if (lxcContainerRenameAndEnableInterfaces(argv->nveths,
|
||||||
argv->veths) < 0)
|
argv->veths) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* drop a set of root capabilities */
|
/* drop a set of root capabilities */
|
||||||
if (lxcContainerDropCapabilities() < 0)
|
if (lxcContainerDropCapabilities() < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (lxcContainerSetStdio(argv->monitor, ttyfd) < 0) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(ttyPath);
|
||||||
|
VIR_FORCE_CLOSE(ttyfd);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
/* this function will only return if an error occured */
|
/* this function will only return if an error occured */
|
||||||
ret = virCommandExec(cmd);
|
ret = virCommandExec(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user