[systemd-devel] logind: session management

David Herrmann dh.herrmann at googlemail.com
Wed May 16 07:01:23 PDT 2012


Hi

I am currently working on kmscon, a user-space VT replacement. In it's
current state, it simply runs a console emulator on a VT but in the
end we want it to fully replace CONFIG_VT. To make it multi-seat
capable I used sd-login.h and it correctly assigns drm-connectors and
input devices to all available seats. However, I have several
questions regarding session management (see below).

The idea is to have a single process run all the terminals for all
available seats. We listen for new and going seats and correctly
reassign available devices. The user can now use chvt to change
between their xserver, wayland, kmscon or some other VT. That is, if
kmscon is not active on seat0, we drop drmMaster (and other devices)
for seat0 and reqacuire them only when the user switches to kmscon
again. However, all seats are supposed to be independent in respect to
VT management (we eventually want to drop it entirely)!

1) Is there any documentation of the logind DBus API? When kmscon is
started on a seat, the user can open multiple terminals (similar to
tabbed windows in terminal emulators). Should I register a session
with logind for each terminal that is opened?

2) How does multi-seat handle VT switches? If two seats are active, I
guess the xservers share a single VT (lets say vt-7). If one user
performs a "chvt 1", does that switch to vt-1 for all users? In other
words, if one user switches to kmscon, then all users are switched to
kmscon as kmscon and an xserver cannot technically run on the same VT,
right?

3) The idea behind kmscon is to set CONFIG_VT=n (for several different
reasons but mainly to avoid having UI code in the kernel). Does
systemd provide a simple way to replace the VT-switching logic? My
idea was using sd_login_monitor to watch for session changes. If it
changes, I check with sd_session_is_active() whether my session is
still active. If not, I stop using the drm, input, etc. devices and
for instance an xserver can show up. If the user switches to kmscon
again, I am notified via the sd_login_monitor and
sd_session_is_active() will be true again and I can start showing up
again. The interface for switching "VTs"/sessions would then be some
kind of "sd_activate_session" dbus/library call.
However, looking at logind sources it seems the "active" logic is
tightly bound to VTs. I would start working on implementing this,
however, I'd like to get some review on the idea before I spend too
much time in it.

4) Does systemd implement some internal timeouts for device
reassignments? Imagine drm-card0 is assigned to seat5 and the user
reassigns it to seat6. If the xserver starts directly up on seat6, it
might not be able to get drmMaster for the card (xserver crashes in
this case) because the process on seat5 did not release the drmMaster
fast enough. The VT-switching logic uses roundtrips to acknowledge
release/acquire, however, I cannot see something like this for logind
session/device switching.

I think that's it for the moment. I would be glad if you can help me
out with it.
Regards
David


More information about the systemd-devel mailing list