[libvirt] [PATCH] lxc: new tty for container

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The lxc driver xml parser treats the console element as input when it should be
output only.  This obviously causes problems when anything other than /dev/ptmx
is specified or when a container is shutdown and then restarted without
redefining it (so that the console field is reset).  This patch treats the
console element as output only and always creates a new device when starting a
container.  Also fixed up a string overflow when storing the device name.

Thanks!

-- 
Best Regards,
Dave Leskovec
IBM Linux Technology Center
Open Virtualization
---
 src/lxc_driver.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: b/src/lxc_driver.c
===================================================================
--- a/src/lxc_driver.c	2008-06-04 23:03:00.000000000 -0700
+++ b/src/lxc_driver.c	2008-06-05 11:07:39.000000000 -0700
@@ -41,6 +41,7 @@
 #include "lxc_driver.h"
 #include "driver.h"
 #include "internal.h"
+#include "memory.h"
 #include "util.h"
 
 /* debug macros */
@@ -485,7 +486,7 @@
     char *ptsStr;
 
     if (0 < strlen(vmDef->tty)) {
-        *ttyDev = open(vmDef->tty, O_RDWR|O_NOCTTY|O_NONBLOCK);
+        *ttyDev = posix_openpt(O_RDWR|O_NOCTTY|O_NONBLOCK);
         if (*ttyDev < 0) {
             lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
                      "open() tty failed: %s", strerror(errno));
@@ -514,8 +515,11 @@
             goto setup_complete;
         }
         /* This value needs to be stored in the container configuration file */
-        if (STRNEQ(ptsStr, vmDef->tty)) {
-            strcpy(vmDef->tty, ptsStr);
+        VIR_FREE(vmDef->tty);
+        if (!(vmDef->tty = strdup(ptsStr))) {
+            lxcError(conn, NULL, VIR_ERR_NO_MEMORY,
+                     _("unable to get storage for vm tty name"));
+            goto setup_complete;
         }
 
         /* Enter raw mode, so all characters are passed directly to child */
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]