Virtual Console =============== #ident "@(#)vconsole-spec.txt 1.16 06/11/03 SMI" 1. Introduction =============== This project is proposed to provide virtual console[1](aka virtual terminal) feature to Solaris. Virtual console is to provide additional console terminals (/dev/vt/#) besides the existing system console(/dev/console), and user can navigate among these virtual consoles and system console. It also provides a set of virtual console programming interfaces for applications(e.g. Xserver) so that applications can take advantages of virtual console. For example, users can switch between consoles and Xserver. 1.1 The Problems --------------- "Multiple consoles are needed for Solaris." "The X server is still less than perfect. Sometimes, due to a problem with an APPLICATION, the entire X server will lockup. If the machine is not networked(due to security reasons), there is then no choice but to reset the server. This is unacceptable. It can result in the loss of valuable work." "Support of nomadic clients often require access to a command line login. It is something that we (SunIT) will need to effectively support an iWork client on Solaris x86." "We need this functionality for Command Line login before we can replace dtlogin with GDM." "Even in tipline, we still need local consoles." 1.2 Solution ------------ To solve the problems, this project proposes the following areas of changes: . workstation console driver extension with a set of ioctls . greenline service for virtual console . Xorg update to support virtual console Based on this project, there will be several follow-on projects we can do to achieve more, like scrollable console, kmdb while Xserver running on x86. 1.3 Scope --------- This project can be thought of as an evolution of PSARC/1995/068 (Solaris Core - Console Driver and Virtual Terminal Interface) and LSARC/1996/291 (x86 X Server VT Support). Previously virtual console was available only on x86 with Xsun. Now after coherent console (PSARC/2003/432) project, virtual console framework is also available on SPARC, though the real functionality depends on the underlying framebuffer driver support. Currently only pfb for XVR-100 supports coherent console. Now we only propose to update Xorg to support virtual console. 2. Technical Description ======================== 2.1 Basic concept ----------------- The basic kernel console architecture looks as followings: /dev/console .-------. | cn | (System console) .-------. | .----------------. | | | | /dev/ttya /dev/vt/1 /dev/vt/2 /dev/vt/n .---------. .------------. .------------. .------------. | tipline | | wc(minor 0)| | wc(minor 1)| ... | wc(minor n)| .---------. .------------. .------------. .------------. Serial Workstation Virtual Virtual Console Console Console Console System console: the file /dev/console still refers to the system console device, as stated in console(7D). Serial console: the system console is redirected to tipline. Workstation: the file /dev/vt/1, alias for /dev/wscons, still console refers to the workstation console, which consists of a workstation keyboard and frame buffer that act together to emulate an ASCII terminal, as stated wscons(7D). Virtual console: the files /dev/vt/# (# is from 2 to n) are additional workstation console terminals with the same functionalities as the workstation console. Notes: a) Console messages via /dev/console will only go to the workstation console or tipline. b) We can call the system console/the workstation console as virtual console 1 in non-tipline case, thus sometimes we use virtual console exclusively for the system console and all virtual consoles. c) /dev/vt will also be added into /etc/ttysrch. 2.2 Components -------------- .------------------------. .--------------. | login smf services | | Xorg | .------------------------. .--------------. U | | virtual console | /dev/console, /dev/vt/# | ioctls -------------------------------------------------------------- K | .---------. | cn | .---------. | .-----------------------------. | | .---------. .---------. | tipline | | iwscn | .---------. .---------. | .---------------------------. | wc | | (virtual console manager) | .---------------------------. ^ | | input V output .---------------. .------------. |keyboard driver| |video driver| .---------------. .------------. 2.3 Usage --------- Virtual consoles are managed by intercepting keyboard sequences: . The sequence AltL(left "Alt" key) + F#(# is 1 to 12) are used to select virtual console 1-12; AltGraph(right "Alt" key) + F#(# is 1 to 12) are for virtual console 13-24. Note that "Alt + F1" chooses the system console (also known as virtual console 1). . Alt + n or "->"(directional arrow) selects the next virtual console in a circular ring fashion; Alt + p or "<-" (directional arrow) changes to the previous virtual console in a circular fashion. And Alt + l or "^"(up arrow) is for last used console. By default, there are only five virtual console instances login prompts running on /dev/vt/# (# is 2 to 6) besides the system console running on /dev/console, so normally Xorg uses the seventh virtual console (/dev/vt/7), and users will use Alt + F7 to switch from consoles to Xorg. On Xorg, users can use some keyboard sequences(e.g. Alt + Ctrl + F#) to switch to consoles from Xserver without exiting Xserver. . Alt + Ctrl + F#(# is 1 to 12) to switch to virtual console 1-12. Note that "Alt + Ctrl + F1" will switch to the system console. 2.4 Ioctls ---------- This project also proposes a set of ioctls with which Xservers can be updated, so as to switch between consoles and Xservers. And the ioctls can also be used for other purposes, like locking all the consoles. See Exported Interfaces below for more details. 2.5 Internal Implementation --------------------------- Virtual console provides multiple text screens on a single display. Each virtual console has an ID number, from 1 to the maximum count of virtual consoles, and it is associated with a different session independent from the others. wscons(7D) is extended to support the virtual console manager, which is responsible for managing all the virtual consoles(/dev/vt/#) and the system workstation console(/dev/vt/1), and providing switch functionality. Each virtual console is associated with a kernel screen buffer saving the character state on the screen. All virtual console screens are maintained by managing and updating screen buffers associated with each virtual console. Virtual console screens are made visible by intercepting specific keyboard sequences in the kernel and passing commands to the virtual console manager. The virtual console manager is then responsible for saving the current state for the current active virtual console, redrawing the screen with the new virtual console screen buffer, and enabling the new virtual console state to redirect I/O as appropriate. 2.6 console devices in /etc/logindevperm ---------------------------------------- In /etc/logindevperm, if the "console" field is set to /dev/console, the ownership/permissions will be set up based on users logging in/out on /dev/console or /dev/vt/#. the first user, either root or non-root, who logs into system on the device indicated by the "console" field, owns all these console devices (keyboard, mouse, audio, etc) until all of the same name users log out. When this first user logs out, the ownership will return to root. 2.7 SMF Service --------------- The console-login service is extended to support multiple instances, for the system console running on /dev/console and for all virtual consoles running on /dev/vt/# (# is 2 to 6 by default). Users can modify properties/disable/enable and remove/add virtual consoles using smf(5). The virtual console instances is only available in the global zone. # svcs | grep login online 17:49:11 svc:/system/console-login:default online 17:49:11 svc:/system/console-login:vt2 online 17:49:11 svc:/system/console-login:vt3 online 17:49:11 svc:/system/console-login:vt4 online 17:49:11 svc:/system/console-login:vt5 online 17:49:11 svc:/system/console-login:vt6 console-login:default is for the system console, others for virtual consoles. Note that there's a limitation of smf to inherit some properties, especially property group. Ideally, uses can simply run: # svccfg -s console-login add vt8 # svccfg -s console-login:vt8 setprop ttymon/device="/dev/vt/8" to add another virtual console instance. But currently users have to manually add ttymon property group and set some properties after adding an instance. 2.8 Tipline ----------- In the tipline case, only the system console(/dev/console) is redirected to tipline. All virtual consoles are still available on the local screen, and users can switch between them, but users cannot switch to the system console (/dev/console) any more, since it's always available in the tipline. 2.9 kmdb -------- Virtual console is not aware of kmdb, though kmdb and panic will always run into the current active virtual console through the polled-io routines. The virtual console functionality is not available in kmdb. 2.10 Security/permissions ------------------------ The IOCTLs of modify operations(VT_SETMODE, VT_RELDISP, VT_ACTIVATE, VT_WAITACTIVE, KDSETMODE) checks if the virtual console is the controlling tty of the calling process. If not, then enforces the sys_devices privilege. There is no controlling tty and privilege check for query/view operations. 2.11 Xorg update ---------------- . Xorg picks the first available virtual console that it can locate unless a specified virtual console device number is given by vtXX command line option. . Update input kbd driver to check virtual console switch special keys. . Enable the switch between consoles and Xorg. . Xorg keeps IOPL privilege throughout its whole life until it exits. . Xorg keeps opening kbd/mouse until it exits, and it will not read data from kbd/mouse while it's inactive (switched away). 3. Exported Interfaces ====================== Interface Stability Name Classification Comments -------------------- -------------- ------------ VT_AVAILABLE Committed see vt.7i VT_OPENQRY Committed see vt.7i VT_GETMODE Committed see vt.7i VT_SETMODE Committed see vt.7i VT_RELDISP Committed see vt.7i VT_ACTIVATE Committed see vt.7i VT_WAITACTIVE Committed see vt.7i VT_GETSTATE Committed see vt.7i KDGETMODE Committed see vt.7i KDSETMODE Committed see vt.7i Footnotes ========= [1] Solaris Core - Console Driver and Virtual Terminal Interface http://sac.sfbay.sun.com/Archives/CaseLog/arc/PSARC/1995/068/ [2] x86 X Server VT Support http://sac.sfbay.sun.com/Archives/CaseLog/arc/LSARC/1996/291/ [3] CR4309501: Need additional local 'terminal' [4] Manpages - in case directory: materials/vt.7i materials/logindevperm.4 materials/logindevperm.4.diff