render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
9119d9
From 25c7be693aac6ed11d3a0f16ed19e0244619df74 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <25c7be693aac6ed11d3a0f16ed19e0244619df74@dist-git>
9119d9
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
9119d9
Date: Wed, 5 Nov 2014 13:21:02 +0100
9119d9
Subject: [PATCH] Require at least one console for LXC domain
9119d9
MIME-Version: 1.0
9119d9
Content-Type: text/plain; charset=UTF-8
9119d9
Content-Transfer-Encoding: 8bit
9119d9
9119d9
A domain without a console quietly dies soon after start,
9119d9
because we try to set /dev/null as a controlling TTY
9119d9
2014-10-30 15:10:59.705+0000: 1: error : lxcContainerSetupFDs:283 :
9119d9
ioctl(TIOCSCTTY) failed: Inappropriate ioctl for device
9119d9
9119d9
Report an error early instead of trying to start it.
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1155410
9119d9
(cherry picked from commit 44686f6523cb30a174c052a242fa15f6a2b364e5)
9119d9
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/lxc/lxc_container.c | 6 ++++--
9119d9
 src/lxc/lxc_process.c   | 6 ++++++
9119d9
 2 files changed, 10 insertions(+), 2 deletions(-)
9119d9
9119d9
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
9119d9
index 1cf2c8f..f3230fa 100644
9119d9
--- a/src/lxc/lxc_container.c
9119d9
+++ b/src/lxc/lxc_container.c
9119d9
@@ -2088,8 +2088,10 @@ static int lxcContainerChild(void *data)
9119d9
         if (virAsprintf(&ttyPath, "%s/%s.devpts/%s",
9119d9
                         LXC_STATE_DIR, vmDef->name, tty) < 0)
9119d9
             goto cleanup;
9119d9
-    } else if (VIR_STRDUP(ttyPath, "/dev/null") < 0) {
9119d9
-            goto cleanup;
9119d9
+    } else {
9119d9
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
9119d9
+                       _("At least one tty is required"));
9119d9
+        goto cleanup;
9119d9
     }
9119d9
 
9119d9
     VIR_DEBUG("Container TTY path: %s", ttyPath);
9119d9
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
9119d9
index 3353dc1..6420c0d 100644
9119d9
--- a/src/lxc/lxc_process.c
9119d9
+++ b/src/lxc/lxc_process.c
9119d9
@@ -1144,6 +1144,12 @@ int virLXCProcessStart(virConnectPtr conn,
9119d9
                                       vm->def, NULL) < 0)
9119d9
         goto cleanup;
9119d9
 
9119d9
+    if (vm->def->nconsoles == 0) {
9119d9
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
9119d9
+                       _("At least one PTY console is required"));
9119d9
+        goto cleanup;
9119d9
+    }
9119d9
+
9119d9
     for (i = 0; i < vm->def->nconsoles; i++) {
9119d9
         char *ttyPath;
9119d9
         if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
9119d9
-- 
9119d9
2.1.3
9119d9