]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
lxc: Move console checks in LXCProcessStart
authorLuyao Huang <lhuang@redhat.com>
Thu, 12 Feb 2015 19:43:26 +0000 (14:43 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 13 Feb 2015 18:44:52 +0000 (13:44 -0500)
https://bugzilla.redhat.com/show_bug.cgi?id=1176503

Move the two console checks - one for zero nconsoles present and the
other for an invalid console type to earlier in the processing rather than
getting after performing some setup that has to be undone for what amounts
to an invalid configuration.

This resolves the above bug since it's not not possible to have changed
the security labels when we cause the configuration check failure.

src/lxc/lxc_process.c

index 52b7f41357d9e132b7bbd79db15625d280413389..f1b36f162215c495da0c2f10637642f87f1e827d 100644 (file)
@@ -1050,6 +1050,20 @@ int virLXCProcessStart(virConnectPtr conn,
     }
     virCgroupFree(&selfcgroup);
 
+    if (vm->def->nconsoles == 0) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("At least one PTY console is required"));
+        return -1;
+    }
+
+    for (i = 0; i < vm->def->nconsoles; i++) {
+        if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Only PTY console types are supported"));
+            return -1;
+        }
+    }
+
     if (virFileMakePath(cfg->logDir) < 0) {
         virReportSystemError(errno,
                              _("Cannot create log directory '%s'"),
@@ -1149,19 +1163,8 @@ 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) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("Only PTY console types are supported"));
-            goto cleanup;
-        }
 
         if (virFileOpenTty(&ttyFDs[i], &ttyPath, 1) < 0) {
             virReportSystemError(errno, "%s",