summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2015-11-07 15:09:31 +0100
committerMichal Schmidt <mschmidt@redhat.com>2015-11-07 15:16:00 +0100
commitc1d9ba9978561b087760bc3b77b1f330bb22e33f (patch)
treeb4d40c93c8c14dd1945e8bb7800b52e778da6095 /src
parent2933d599c242ebfc70ddcffe59163916b02270f1 (diff)
core/timer: in containers OnBootSec should count from container startup
In Fedora dnf-makecache.timer specifies OnBootSec=10min, but it fired during boot in systemd-nspawn, because the clock ticks since the host's boot. Fix it by treating OnBootSec the same as OnStartupSec when running in a container.
Diffstat (limited to 'src')
-rw-r--r--src/core/timer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/timer.c b/src/core/timer.c
index cc2afedabf..c9dc97d4fb 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -34,6 +34,7 @@
#include "unit-name.h"
#include "unit.h"
#include "user-util.h"
+#include "virt.h"
static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = {
[TIMER_DEAD] = UNIT_INACTIVE,
@@ -359,10 +360,14 @@ static void timer_enter_waiting(Timer *t, bool initial) {
break;
case TIMER_BOOT:
- /* CLOCK_MONOTONIC equals the uptime on Linux */
- base = 0;
- break;
-
+ if (detect_container() <= 0) {
+ /* CLOCK_MONOTONIC equals the uptime on Linux */
+ base = 0;
+ break;
+ }
+ /* In a container we don't want to include the time the host
+ * was already up when the container started, so count from
+ * our own startup. Fall through. */
case TIMER_STARTUP:
base = UNIT(t)->manager->userspace_timestamp.monotonic;
break;