Discussion:
systemd -> consolekit, spice-vdagent questions
(too old to reply)
Hans de Goede
2011-09-14 14:26:20 UTC
Permalink
Hi,

The spice guest agent for Linux consists of a system level
process (a daemon) and a per session process (started for
each active xsession).

Currently the linux spice-vdagent is using ConsoleKit to
figure out (for the first seat, it assumes a vm is single seat):

1) Which session is active (including notification of when this changes)
2) Which session each session agent process belongs too

It needs this to figure out to which session agent process to send
copy/paste requests for copy paste between the active session in
the guest and the client.

I've not really searched all that well I must admit, and surprisingly,
I've thus been unable to find low level docs of how this all works
in the systemd replaces consolekit world.

Currently the spice-vdagent makes the following dbus calls, to achieve
the 2 items above:

1) org.freedesktop.ConsoleKit.Seat -> GetActiveSession
2) org.freedesktop.ConsoleKit.Manager -> GetSessionForUnixProcess

And it listens to the org.freedesktop.ConsoleKit.Seat -> ActiveSessionChanged
signal.

What are the equivalents for these now ?

Regards,

Hans
Tomasz Torcz
2011-09-14 14:40:03 UTC
Permalink
Post by Hans de Goede
Currently the linux spice-vdagent is using ConsoleKit to
1) Which session is active (including notification of when this changes)
2) Which session each session agent process belongs too
It needs this to figure out to which session agent process to send
copy/paste requests for copy paste between the active session in
the guest and the client.
What are the equivalents for these now ?
Hans,

I think docs at http://www.freedesktop.org/wiki/Software/systemd/multiseat could
be useful for you.
--
Tomasz Torcz "Never underestimate the bandwidth of a station
xmpp: ***@chrome.pl wagon filled with backup tapes." -- Jim Gray
Hans de Goede
2011-09-15 08:09:41 UTC
Permalink
Hi,
Post by Tomasz Torcz
Post by Hans de Goede
Currently the linux spice-vdagent is using ConsoleKit to
1) Which session is active (including notification of when this changes)
2) Which session each session agent process belongs too
It needs this to figure out to which session agent process to send
copy/paste requests for copy paste between the active session in
the guest and the client.
What are the equivalents for these now ?
Hans,
I think docs at http://www.freedesktop.org/wiki/Software/systemd/multiseat could
be useful for you.
Thanks, but those docs say nothing about the dbus API replacing consolekit...

Regards,

Hans
Matthias Clasen
2011-09-15 12:41:22 UTC
Permalink
Post by Hans de Goede
Hi,
Post by Hans de Goede
Currently the linux spice-vdagent is using ConsoleKit to
1) Which session is active (including notification of when this changes)
2) Which session each session agent process belongs too
It needs this to figure out to which session agent process to send
copy/paste requests for copy paste between the active session in
the guest and the client.
What are the equivalents for these now ?
  Hans,
  I think docs at
http://www.freedesktop.org/wiki/Software/systemd/multiseat could
be useful for you.
Thanks, but those docs say nothing about the dbus API replacing consolekit...
Looks like there is no man page for logind yet, so

gdbus introspect --system --dest org.freedesktop.login1 --object-path
/org/freedesktop/login1

will probably have to suffice for now.
Richard Hughes
2011-09-15 14:28:27 UTC
Permalink
Post by Matthias Clasen
gdbus introspect --system --dest org.freedesktop.login1 --object-path
/org/freedesktop/login1
FWIW, so gnome-settings-daemon could track the active console I added
ConsoleKit support in an abstract way, on the logic that it could
easily be switched to logind when the latter actually worked. If you
want the code, it's in
gnome-settings-daemon/gnome-settings-daemon/gnome-settings-session.[c|h]

Richard.
Hans de Goede
2011-09-16 12:17:42 UTC
Permalink
Hi,
Post by Matthias Clasen
gdbus introspect --system --dest org.freedesktop.login1 --object-path
/org/freedesktop/login1
Hmm that does not seem to offer either a method to get the active session,
nor a method to go from a pid (the pid of the other end of a unix socket
in my case) to the session that belongs too...
Post by Matthias Clasen
FWIW, so gnome-settings-daemon could track the active console I added
ConsoleKit support in an abstract way, on the logic that it could
easily be switched to logind when the latter actually worked. If you
want the code, it's in
gnome-settings-daemon/gnome-settings-daemon/gnome-settings-session.[c|h]
Hmm, I cannot find this in gnome-settings-daemon-3.1.91, also it seems
that in F-16 consolekit is still around and functioning, so I guess I
can postpone fixing this till Fedora 17, at which time the logind
API will hopefully be better documented and have all the necessary
API calls (which going by the introspection results currently it
does not).

Regards,

Hans
Richard Hughes
2011-09-16 13:06:48 UTC
Permalink
Post by Hans de Goede
Hmm, I cannot find this in gnome-settings-daemon-3.1.91
git master, sorry.

Richard.
Lennart Poettering
2011-09-20 01:28:56 UTC
Permalink
Post by Hans de Goede
Hi,
The spice guest agent for Linux consists of a system level
process (a daemon) and a per session process (started for
each active xsession).
Currently the linux spice-vdagent is using ConsoleKit to
1) Which session is active (including notification of when this changes)
2) Which session each session agent process belongs too
It needs this to figure out to which session agent process to send
copy/paste requests for copy paste between the active session in
the guest and the client.
I've not really searched all that well I must admit, and surprisingly,
I've thus been unable to find low level docs of how this all works
in the systemd replaces consolekit world.
Currently the spice-vdagent makes the following dbus calls, to achieve
1) org.freedesktop.ConsoleKit.Seat -> GetActiveSession
2) org.freedesktop.ConsoleKit.Manager -> GetSessionForUnixProcess
And it listens to the org.freedesktop.ConsoleKit.Seat -> ActiveSessionChanged
signal.
What are the equivalents for these now ?
You can either do this via D-Bus (as noted). However, I recommend to use
the simple C API instead when all you are interested in are simple
checks and notifications. This helps keeping our stack thin and is
actually much easier to use for you:

http://cgit.freedesktop.org/systemd/tree/src/sd-login.h

There's no comprehensive documentaiton available about that API since it
is still very new. However, the comments in the header file should cover
most what you need. To be more precise, use something like this:

<snip>
char *session;

r = sd_seat_get_active("seat0", &session, NULL);
if (r < 0)
printf("failed: %s\n", strerror(-r));
else {
printf("Woopie! %s\n", session);
free(session);
}
</snip>

And:

<snip>
char *session;

r = sd_pid_get_session(pid, &session);
if (r < 0)
printf("failed: %s\n", strerror(-r));
else {
printf("Woopie! %s\n", session);
free(session);
}
</snip>

Dead easy, cheap, and synchronous.

For the session change notification use:

<snip>
sd_login_monitor *monitor;

r = sd_login_monitor_new("session", &monitor);
fd = sd_login_monitor_get_fd(monitor);

for (;;) {
/* wait for some kind of event on fd */
poll(...);
sd_login_monitor_flush(monitor);

/* Read changed data ... */
sd_seat_get_active("seat0", ....);
}
</snip>

I am sure you can interpolate the necessary error checking from the
earlier examples...

Lennart
--
Lennart Poettering - Red Hat, Inc.
Continue reading on narkive:
Loading...