Multi-seat configuration with MergedFB and Xephyr

Based on this HOWTO

Obligatory disclaimer

Use at your own risk!

0. Known to work with

video cards:

01:00.0 VGA compatible controller: ATI Technologies Inc RV280 [Radeon 9200 PRO] (rev 01) (prog-if 00 [VGA])
       Subsystem: ASUSTeK Computer Inc. Unknown device 004e
       Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
       Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
       Latency: 32 (2000ns min), Cache Line Size: 32 bytes
       Interrupt: pin A routed to IRQ 10
       Region 0: Memory at d0000000 (32-bit, prefetchable) [size=128M]
       Region 1: I/O ports at 9000 [size=256]
       Region 2: Memory at e5000000 (32-bit, non-prefetchable) [size=64K]
       [virtual] Expansion ROM at e4000000 [disabled] [size=128K]
06:00.0 VGA compatible controller: ATI Technologies Inc RV370 5B60 [Radeon X300 (PCIE)] (prog-if 00 [VGA])
        Subsystem: PC Partner Limited Unknown device 0490
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR-
        Latency: 0, Cache Line Size: 16 bytes
        Interrupt: pin A routed to IRQ 3
        Region 0: Memory at d8000000 (32-bit, prefetchable) [size=128M]
        Region 1: I/O ports at e000 [size=256]
        Region 2: Memory at d7fe0000 (32-bit, non-prefetchable) [size=64K]
        Expansion ROM at d7fc0000 [disabled] [size=128K]
        Capabilities: [50] Power Management version 2
                Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [58] Express Endpoint IRQ 0
                Device: Supported: MaxPayload 128 bytes, PhantFunc 0, ExtTag+
                Device: Latency L0s <256ns, L1 <4us
                Device: AtnBtn- AtnInd- PwrInd-
                Device: Errors: Correctable- Non-Fatal- Fatal- Unsupported-
                Device: RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
                Device: MaxPayload 128 bytes, MaxReadReq 128 bytes
                Link: Supported Speed 2.5Gb/s, Width x16, ASPM L0s L1, Port 0
                Link: Latency L0s <256ns, L1 <2us
                Link: ASPM Disabled RCB 64 bytes CommClk- ExtSynch-
                Link: Speed 2.5Gb/s, Width x16
        Capabilities: [80] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
                Address: 0000000000000000  Data: 0000

monitor: ViewSonic PF775

OS/distribution: Debian GNU/Linux 4.0 (a.k.a. "etch")

I. Set up udev rules for keyboards/mice.

I've got a lot of PS/2 keyboards and USB mice, so the box has two PS/2 keyboards and two USB mice plugged in. I make use of udev rules (included in my tarball) to match between the physical input devices and their device nodes. USB devices can be distinguished by ATTRS{idProduct} or ATTRS{phys}, PS/2 devices -- by ATTRS{phys}, respectively.

More details about writing udev rules can be found here.

2. Set up "real" X server to use MergedFB.

Install necessary drivers:
aptitude install xserver-xorg-video-ati xserver-xorg-input-void
RTFM:
man 4 radeon
Use my /etc/X11/xorg.conf.dualhead as a template.

WARNING:

if you use my config files unmodified, X server won't input anything from keyboard/mouse. This is necessary to prevent two different X servers (Xorg and Xephyr) from controlling the same piece of hardware, so you need remote access to test if the configuration works:
[login via ssh]
# X -config /etc/X11/xorg.conf.dualhead
[^C to terminate it]

3. Set up Xephyr

Xephyr is an X server that can be run inside another X server. Since xserver-xephyr shipped with etch does not support evdev, one need to download patched Xephyr from this site. However, it looks for configs, xkb data, etc. in non-standard locations, so you might want to try my tarball. It contains Xephyr binary, symlinks to binaries/xkb data/directories necessary for Xephyr, XKB configuration files for Xephyr, Xorg configuration file, udev rules, xdm configuration files, and runit run scripts. If you want to use keyboard layout other than Russian, please modify /usr/lib/X11/xkb/X[12]-config.keyboard to suit your needs. Check if Xephyr works for you:

[login via ssh]
# X -config /etc/X11/xorg.conf.dualhead &
# /usr/local/bin/Xephyr.sh --display=:0 vt7 \
     -keyboard /dev/keyboard_two -mouse /dev/usb_mouse_2,5 -use-evdev \
     -geometry 1280x1024+0+0 :2 &
# /usr/local/bin/Xephyr.sh --display=:0 vt7 \
     -keyboard /dev/keyboard_one -mouse /dev/usb_mouse_1,5 -use-evdev \
     -geometry 1024x768+1280+0 :1 &
[kill 'em all]
N.B.: if you have modified Xorg configuration file, don't forget adjust -geometry argument here too.

4. Configure xdm to use two Xephyrs

Here are configuration files I use

Adjust if necessary and test with:

[in ssh session]
# X -config /etc/X11/xorg.conf.dualhead &
# xdm -nodaemon -config /etc/X11/xdm/xdm-config.dualhead
[kill 'em all]

5. Putting things together

Now it is necessary to setup startup scripts to launch Xorg before xdm. I use runit to control [almost all] services, run scripts are included in my tarball.

And the story ends

Good luck!