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

Re: [Xen-users] xen console dimensions

Am 24.06.14 16:02, schrieb Austin S Hemmelgarn:
On 2014-06-24 09:30, Ian Campbell wrote:
On Tue, 2014-06-24 at 09:21 -0400, Phillip Susi wrote:
On 6/24/2014 8:39 AM, Ian Campbell wrote:
On Tue, 2014-06-24 at 08:36 -0400, Austin S Hemmelgarn wrote:
I've checked, and it does appear that running resize works to
correct things on Linux, I don't know about NetBSD however (I
don't have any NetBSD guests to test with right now).  The issue
is that COLUMNS and LINES aren't getting set, which makes things
assume 80x25 terminal geometry (for compatibility reasons).

Thanks for checking. Philip does that fix it for you too?

Yes, manually setting it with stty allows for proper operation; it
just seems that this information should be automatically passed to the
guest ( via xenstore? ) by xenconsole, and then hvc driver in the
guest should pass it to the tty core.  Also updating it in response to
SIGWINCH when you resize the terminal.

I'm pretty certain you don't get that level of functionality with a
normal serial port, but patches welcome ;-0


That's generally true, although once you reach userspace, either getty
or init usually set COLUMNS and LINES correctly, I have no idea how they
determine the correct values.  There is an ANSI escape sequence that is
supposed to return hardware/emulator identification, and I think most
VTEs return their geometry through this.  I think I remember reading
somewhere about a non-ANSI escape sequence that returned just the
geometry, I think it was for the vt100 series (and by extension, Linux
console, GNU screen, and xterm compatibles).  IIRC, on Solaris they get
set based on the terminal type that gets passed to getty (or at least on
old Solaris systems)

I was annoyed by this a long time ago and have (back some time) found a workable solution - at least for me. After a lengthy digging excercise through the internet using google I found a small piece of C code somewhere (I can't remember where) which seemd to be what I am after. I downloaded it and compiled it. I called the binary resize, put it under my /usr/local/bin and created an alias for my bash which reads
        alias cd='resize ; cd'
In essence this means it gets fired whenever I issue a cd command. It is quick, so there is no noticeable delay and it resizes the window to whatever the ssh terminal emulator (I use putty) is set to at that time.

You could use every command for the alias, but the cd command is one that I frequently use. The alias sequence therefore updates the window size not constantly, but with a reasonable frequency. Over and above this I have included the following sequence in the global /etc/bash/bashrc file so it gets fired for every login process and sets the size correctly at login:
        if [[ -z "$STY" ]]; then
                /usr/local/bin/resize   # set correct terminal size

Clearly this approach is not fool-proof and it can miss changes from time to time (mostly notable in vi, but then getting out and using cd [or even just start resize] immediately rectifies the situation).

I have attached the source code of this program in the hope that the logic used could somehow be incorporated into XEN to make things automatic. It is only 200 odd lines of code including around 50 lines of headers/comments and around 20 lines of #include statements - so not very complicated for someone who understands terminal emulation.

But I have to admit I am with Ian here: Terminal emulation is a bit of a mystery to me as well ...

Regards Atom2

Xen-users mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.