Commit graph

166 commits

Author SHA1 Message Date
Lennart Poettering 8f8f05a919 bus: add sd_bus_track object for tracking peers, and port core over to it
This is primarily useful for services that need to track clients which
reference certain objects they maintain, or which explicitly want to
subscribe to certain events. Something like this is done in a large
number of services, and not trivial to do. Hence, let's unify this at
one place.

This also ports over PID 1 to use this to ensure that subscriptions to
job and manager events are correctly tracked. As a side-effect this
makes sure we properly serialize and restore the track list across
daemon reexec/reload, which didn't work correctly before.

This also simplifies how we distribute messages to broadcast to the
direct busses: we only track subscriptions for the API bus and
implicitly assume that all direct busses are subscribed. This should be
a pretty OK simplification since clients connected via direct bus
connections are shortlived anyway.
2014-03-03 02:34:13 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Zbigniew Jędrzejewski-Szmek 4daf54a851 journald: log provenience of signals 2014-02-11 19:14:47 -05:00
Zbigniew Jędrzejewski-Szmek 49888ca9ef manager: fix initialization of plymouth socket
I'm not sure why this makes a difference...
2014-02-08 16:19:22 -05:00
Zbigniew Jędrzejewski-Szmek 2ba110900a core: use automatic cleanup in two functions 2014-02-08 13:07:39 -05:00
Lennart Poettering 5ba6985b6c core: allow PIDs to be watched by two units at the same time
In some cases it is interesting to map a PID to two units at the same
time. For example, when a user logs in via a getty, which is reexeced to
/sbin/login that binary will be explicitly referenced as main pid of the
getty service, as well as implicitly referenced as part of the session
scope.
2014-02-07 15:14:36 +01:00
Lennart Poettering a911bb9ab2 core: watch SIGCHLD more closely to track processes of units with no reliable cgroup empty notifier
When a process dies that we can associate with a specific unit, start
watching all other processes of that unit, so that we can associate
those processes with the unit too.

Also, for service units start doing this as soon as we get the first
SIGCHLD for either control or main process, so that we can follow the
processes of the service from one to the other, as long as process that
remain are processes of the ones we watched that died and got reassigned
to us as parent.

Similar, for scope units start doing this as soon as the scope
controller abandons the unit, and thus management entirely reverts to
systemd. To abandon a unit introduce a new Abandon() scope unit method
call.
2014-02-07 15:14:36 +01:00
Zbigniew Jędrzejewski-Szmek 75cb8502df transaction: print more information about conflicting jobs
Also remove some debug statement that should not have been committed.
2014-02-06 00:46:15 -05:00
Kay Sievers 486e99a387 bus: update kdbus.h (ABI break) 2014-02-01 17:21:36 +01:00
Zbigniew Jędrzejewski-Szmek 6b02bce759 manager: remove "debugging" "feature" 2014-01-28 21:57:42 -05:00
Zbigniew Jędrzejewski-Szmek e5723c894d manager: requeue the cylon eye for 5s later when a job finishes
We'd reqeue the next status update very soon after. Change it so that we wait
for full 5s without any job status changes until we print anything.
2014-01-28 19:07:13 -05:00
Zbigniew Jędrzejewski-Szmek 8bb310c3c6 manager: print ephemeral information about running jobs' timeouts (v2)
This reverts commit 28c758de94
but makes job_coldplug smarter.

In (v1) I changed the job start timestamp to be always set, so the
start time can be reported in the cylon eye message.  The bug was that
when deserializing jobs, they would be ignored if their start
timestamp was unset which was synonymous with no timeout. But after
the change, jobs would have a start timestamp set despite having no
timeout. After deserialization they would be considered immediately
expired. Fix this by checking if the timeout is not zero when
considering jobs for expiration.
2014-01-28 19:07:13 -05:00
Kay Sievers 28c758de94 Revert "manager: print ephemeral information about running jobs' timeouts"
This reverts commit 2cba2e0352.

It breaks bootup with dracut, the transition to the real rootfs fails.
2014-01-28 12:03:23 +01:00
Zbigniew Jędrzejewski-Szmek cb8ccb2271 manager: also turn on output on unit failure 2014-01-27 23:17:03 -05:00
Zbigniew Jędrzejewski-Szmek d450b6f2a9 manager: add systemd.show_status=auto mode
When set to auto, status will shown when the first ephemeral message
is shown (a job has been running for five seconds). Then until the
boot or shutdown ends, status messages will be shown.

No indication about the switch is done: I think it should be clear
for the user that first the cylon eye and the ephemeral messages appear,
and afterwards messages are displayed.

The initial arming of the event source was still wrong, but now should
really be fixed.
2014-01-27 23:17:03 -05:00
Zbigniew Jędrzejewski-Szmek 8e33886ec5 Replace mkostemp+unlink with open(O_TMPFILE)
This will only work on Linux >= 3.11, and probably not on all
filesystems. Fallback code is provided.
2014-01-27 23:17:02 -05:00
Zbigniew Jędrzejewski-Szmek fd08a8403f manager: rearm jobs timer
It would fire just once.

Also fix units from sec to usec as appropriate.

Decrease the switching interval to 1/3 s, so that when the time
remaining is displayed with 1s precision, it doesn't jump by 2s every
once in a while. Also, the system is feels noticably faster when the
status changes couple of times per second instead of every few
seconds.
2014-01-27 01:23:16 -05:00
Zbigniew Jędrzejewski-Szmek 2cba2e0352 manager: print ephemeral information about running jobs' timeouts
Produces output like:
[  *** ] (1 of 2) A start job is running for slow.service (33s / 1min 30s)

The first nubmer is the time since job start, the second is the job timeout.
2014-01-27 01:23:16 -05:00
Lennart Poettering f069efb471 core: don't allow setting NOTIFY_SOCKET and similar env vars we need ourselves via SetEnvironment bus calls
We just quietly eat them up, so that simple environment importing still
works without error.
2014-01-12 20:10:40 +08:00
Lennart Poettering 43d03a8376 core: clean up environment block for --user instances a bit 2014-01-12 19:41:57 +08:00
Zbigniew Jędrzejewski-Szmek 5bf348d77e core: fix unused variable 2014-01-11 10:07:22 -05:00
Zbigniew Jędrzejewski-Szmek a2cc4a6c96 core: fix lack of notifications after reload 2014-01-09 20:50:49 -05:00
Kay Sievers fcc81ea361 core: --user -- move generator directories from /tmp to $XDG_RUNTIME_DIR 2014-01-07 01:35:13 +08:00
Kay Sievers 88c59cb3c1 bus: always create --user bus when kdbus is active
We set the variable in the unit file for --user, so this check is
always true.
2014-01-03 02:59:05 +01:00
Zbigniew Jędrzejewski-Szmek ccd06097c7 Use format patterns for usec_t, pid_t, nsec_t, usec_t
It is nicer to predefine patterns using configure time check instead of
using casts everywhere.

Since we do not need to use any flags, include "%" in the format instead
of excluding it like PRI* macros.
2014-01-02 19:45:47 -05:00
Zbigniew Jędrzejewski-Szmek a9244623f7 core/manager: print info about interesting signals
Information about signals which are not routinely received by systemd
are printed at info level. This should make it easier to see what is
happening in the system.
2014-01-02 19:45:47 -05:00
Zbigniew Jędrzejewski-Szmek f78e6385dc Use enums to make it obvious what boolean params mean
Suggested-by: Russ Allbery <rra@debian.org>
2013-12-26 15:49:54 -05:00
Lennart Poettering f2769777c8 bus: make system bus kdbus node world-accessible 2013-12-26 03:08:15 +01:00
Lennart Poettering be04cbca6c core: when we close the notify fd, we also need to free its event source 2013-12-23 21:01:32 +01:00
Lennart Poettering 9bf3b53533 shared: switch our hash table implementation over to SipHash
SipHash appears to be the new gold standard for hashing smaller strings
for hashtables these days, so let's make use of it.
2013-12-22 21:12:25 +01:00
Lennart Poettering d86f9d5285 core: pass notify fd across reexecs
That way we the random socket name stays stable across reexec and we
won't lose client messages.
2013-12-21 00:53:22 +01:00
Lennart Poettering fa28bc2df7 core: priorize notification fd processing over notification fd process via sd-event's logic 2013-12-18 18:21:27 +01:00
Lennart Poettering d003f514da core: always create /dev/kdbus/ns (and make it private 0700) after setting up the kdbus system bus 2013-12-17 01:05:37 +01:00
Lennart Poettering 7b77ed8cf3 event: be more conservative when returning errors from event handler callbacks
We really should return errors from event handlers if we have a
continous problem and don't know any other solution.
2013-12-13 04:06:43 +01:00
Shawn Landden 9a636ed809 core: epoll and signalfd has been moved into sd event loop 2013-12-10 22:50:29 +00:00
Shawn Landden 145b1f799f core/manager: remove infinite loop 2013-12-10 18:08:25 +00:00
Zbigniew Jędrzejewski-Szmek 2b6bf07dd2 Get rid of our reimplementation of basename
The only problem is that libgen.h #defines basename to point to it's
own broken implementation instead of the GNU one. This can be fixed
by #undefining basename.
2013-12-06 21:29:55 -05:00
Lennart Poettering a6aa89122d bus: don't make use of the private bus socket if kdbus is available 2013-12-03 19:55:51 +01:00
Lennart Poettering 8bf9fcf488 core: extra paranoia when deserializing kdbus fd 2013-12-02 23:32:34 +01:00
Lennart Poettering 626851be97 bus: do kdbus only if this is enabled on the configure switch
Since we want to retain the ability to break kernel ←→ userspace ABI
after the next release, let's not make use by default of kdbus, so that
people with future kernels will not suddenly break with current systemd
versions.

kdbus support is left in all builds but must now be explicitly requested
at runtime (for example via setting $DBUS_SESSION_BUS). Via a configure
switch the old behaviour can be restored. In fact, we change autogen.sh
to do this, so that git builds (which run autogen.sh) get kdbus by
default, but tarball builds (which ue the configure defaults) do not get
it, and hence this stays out of the distros by default.
2013-11-30 20:18:48 +01:00
Lennart Poettering 9bd37b40fa nspawn: set up a kdbus namespace when starting a container 2013-11-30 16:36:46 +01:00
Lennart Poettering e3dd987cfc core: allocate a kdbus bus for each systemd instance, if we can 2013-11-30 03:53:42 +01:00
Daniel Buch f5f6d0e255 tree-wide usage of %m specifier instead of strerror(errno)
Also for log_error() except where a specific error is specified

e.g. errno ? strerror(errno) : "Some user specified message"
2013-11-26 21:07:46 +10:00
Lennart Poettering 9670d583d3 swap: always track the current real device node of all swap devices, even when not active
This way, we can avoid executing two /bin/swapon jobs to be dispatched
for the same swap device if it is configured for two different paths.

Previously we were just tracking the device nodes of active swap
devices, which would not allow us to recognize the identity of two swap
devices before they are active.

https://bugs.freedesktop.org/show_bug.cgi?id=69835
2013-11-25 22:10:22 +01:00
Lennart Poettering 290837072b core: set some event source priorities to enforce dispatching order 2013-11-25 17:40:53 +01:00
Lennart Poettering 752b590500 core: dispatch run queue only if there's nothing else to do
Always read all external events before we decide what we do next.
2013-11-25 17:40:53 +01:00
Kay Sievers 828db5d84a core: set finish_timestamp only after all jobs have finished 2013-11-24 19:18:36 +01:00
Lennart Poettering 9d5a3757c3 manager: always sort environment block, it's prettier 2013-11-21 21:12:36 +01:00
Lennart Poettering 3772995afa manager: don't do plymouth in a container
Given that plymouth listens on an abstract namespace socket and if
CLONE_NEWNET is not used the abstract namespace is shared with the host
we might actually end up send plymouth data to the host.
2013-11-20 20:58:17 +01:00
Lennart Poettering 718db96199 core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the
dependency on libdbus. The only remaining code using libdbus is a test
case that validates our bus marshalling against libdbus' marshalling,
and this dependency can be turned off.

This patch also adds a couple of things to libsystem-bus, that are
necessary to make the port work:

- Synthesizing of "Disconnected" messages when bus connections are
  severed.

- Support for attaching multiple vtables for the same interface on the
  same path.

This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus
calls which used an inappropriate signature.

As a side effect we will now generate PropertiesChanged messages which
carry property contents, rather than just invalidation information.
2013-11-20 20:52:36 +01:00