WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] PATCH [xenconsoled]: makes pty slave raw early

To: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, tgingold@xxxxxxx, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] PATCH [xenconsoled]: makes pty slave raw early
From: John Levon <levon@xxxxxxxxxxxxxxxxx>
Date: Wed, 16 Jan 2008 12:20:39 +0000
Delivery-date: Wed, 16 Jan 2008 04:21:23 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20080116105707.GD4261@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20080116053004.GA18526@xxxxxxxxxxxxxxxxxxxxx> <20080116105707.GD4261@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
On Wed, Jan 16, 2008 at 10:57:07AM +0000, Samuel Thibault wrote:

> > on my system (Linux 2.6.18.8 - ia64), if a domain write on the xencons
> > before xenconsole is initialized the domain gets back what it wrote.
> 
> Argh, indeed, and it seems to fix things for mini-os as well.  John,
> could you please check that it works correctly on Solaris before Keir
> applies it?

Works fine. Below is the version of the patch that compiles on Solaris.

cheers
john

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -246,7 +246,6 @@ static void domain_close_tty(struct doma
 }
 
 #ifdef __sun__
-/* Once Solaris has openpty(), this is going to be removed. */
 static int openpty(int *amaster, int *aslave, char *name,
                    struct termios *termp, struct winsize *winp)
 {
@@ -278,8 +277,10 @@ static int openpty(int *amaster, int *as
        if (winp)
                ioctl(sfd, TIOCSWINSZ, winp);
 
+       if (termp)
+               tcsetattr(sfd, TCSAFLUSH, termp);
+
        assert(name == NULL);
-       assert(termp == NULL);
 
        return 0;
 
@@ -289,7 +290,20 @@ err:
        close(mfd);
        return -1;
 }
-#endif
+
+void cfmakeraw(struct termios *termios_p)
+{
+       termios_p->c_iflag &=
+           ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+       termios_p->c_oflag &= ~OPOST;
+       termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+       termios_p->c_cflag &= ~(CSIZE|PARENB);
+       termios_p->c_cflag |= CS8;
+
+       termios_p->c_cc[VMIN] = 0;
+       termios_p->c_cc[VTIME] = 0;
+}
+#endif /* __sun__ */
 
 static int domain_create_tty(struct domain *dom)
 {
@@ -299,11 +313,14 @@ static int domain_create_tty(struct doma
        bool success;
        char *data;
        unsigned int len;
+       struct termios term;
 
        assert(dom->slave_fd == -1);
        assert(dom->master_fd == -1);
 
-       if (openpty(&dom->master_fd, &dom->slave_fd, NULL, NULL, NULL) < 0) {
+       cfmakeraw(&term);
+
+       if (openpty(&dom->master_fd, &dom->slave_fd, NULL, &term, NULL) < 0) {
                err = errno;
                dolog(LOG_ERR, "Failed to create tty for domain-%d (errno = %i, 
%s)",
                      dom->domid, err, strerror(err));

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel