提交 44686f65 编写于 作者: J Ján Tomko

Require at least one console for LXC domain

A domain without a console quietly dies soon after start,
because we try to set /dev/null as a controlling TTY
2014-10-30 15:10:59.705+0000: 1: error : lxcContainerSetupFDs:283 :
ioctl(TIOCSCTTY) failed: Inappropriate ioctl for device

Report an error early instead of trying to start it.

https://bugzilla.redhat.com/show_bug.cgi?id=1155410
上级 7ead1a5d
...@@ -2093,8 +2093,10 @@ static int lxcContainerChild(void *data) ...@@ -2093,8 +2093,10 @@ static int lxcContainerChild(void *data)
if (virAsprintf(&ttyPath, "%s/%s.devpts/%s", if (virAsprintf(&ttyPath, "%s/%s.devpts/%s",
LXC_STATE_DIR, vmDef->name, tty) < 0) LXC_STATE_DIR, vmDef->name, tty) < 0)
goto cleanup; goto cleanup;
} else if (VIR_STRDUP(ttyPath, "/dev/null") < 0) { } else {
goto cleanup; virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("At least one tty is required"));
goto cleanup;
} }
VIR_DEBUG("Container TTY path: %s", ttyPath); VIR_DEBUG("Container TTY path: %s", ttyPath);
......
...@@ -1144,6 +1144,12 @@ int virLXCProcessStart(virConnectPtr conn, ...@@ -1144,6 +1144,12 @@ int virLXCProcessStart(virConnectPtr conn,
vm->def, NULL) < 0) vm->def, NULL) < 0)
goto cleanup; goto cleanup;
if (vm->def->nconsoles == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("At least one PTY console is required"));
goto cleanup;
}
for (i = 0; i < vm->def->nconsoles; i++) { for (i = 0; i < vm->def->nconsoles; i++) {
char *ttyPath; char *ttyPath;
if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册