Commit a5c3034f authored by Lennart Poettering's avatar Lennart Poettering
Browse files

swap: refuse start/stop of swaps in container

parent 024f268d
......@@ -39,6 +39,7 @@
#include "exit-status.h"
#include "def.h"
#include "path-util.h"
#include "virt.h"
static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
[SWAP_DEAD] = UNIT_INACTIVE,
......@@ -797,6 +798,9 @@ static int swap_start(Unit *u) {
assert(s->state == SWAP_DEAD || s->state == SWAP_FAILED);
if (detect_container(NULL) > 0)
return -EPERM;
s->result = SWAP_SUCCESS;
swap_enter_activating(s);
return 0;
......@@ -817,6 +821,9 @@ static int swap_stop(Unit *u) {
assert(s->state == SWAP_ACTIVATING ||
s->state == SWAP_ACTIVE);
if (detect_container(NULL) > 0)
return -EPERM;
swap_enter_deactivating(s);
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment