]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Require at least one console for LXC domain
authorJán Tomko <jtomko@redhat.com>
Fri, 31 Oct 2014 08:51:23 +0000 (09:51 +0100)
committerCole Robinson <crobinso@redhat.com>
Sat, 15 Nov 2014 21:02:08 +0000 (16:02 -0500)
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
(cherry picked from commit 44686f6523cb30a174c052a242fa15f6a2b364e5)

src/lxc/lxc_container.c
src/lxc/lxc_process.c

index 2af267454083ef09ea32b8f94a3a303cadca4ccb..95ee68adef9b0a347082fdf0a8af2ba808441f82 100644 (file)
@@ -2093,8 +2093,10 @@ static int lxcContainerChild(void *data)
         if (virAsprintf(&ttyPath, "%s/%s.devpts/%s",
                         LXC_STATE_DIR, vmDef->name, tty) < 0)
             goto cleanup;
-    } else if (VIR_STRDUP(ttyPath, "/dev/null") < 0) {
-            goto cleanup;
+    } else {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("At least one tty is required"));
+        goto cleanup;
     }
 
     VIR_DEBUG("Container TTY path: %s", ttyPath);
index ed30c37fd12b991921ffceffbd2893785b1e2547..6c83fdb21743936bc422253ee7a1fd501267f8fb 100644 (file)
@@ -1144,6 +1144,12 @@ int virLXCProcessStart(virConnectPtr conn,
                                       vm->def, NULL) < 0)
         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++) {
         char *ttyPath;
         if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {