summaryrefslogtreecommitdiff
path: root/src/nspawn
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-18 23:35:19 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-18 23:37:27 +0100
commit6afc95b73605833e6e966af1c466b5c08feb953f (patch)
tree28829a42e4ae84dd504988f5f9c8e4f998219565 /src/nspawn
parent0bc8e31b358a872ec2631874bd2109ba4e009ccf (diff)
nspawn: add new --personality= switch to make it easier to run 32bit containers on a 64bit host
Diffstat (limited to 'src/nspawn')
-rw-r--r--src/nspawn/nspawn.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 379ea92355..98e90fe3c9 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -43,6 +43,7 @@
#include <sys/eventfd.h>
#include <net/if.h>
#include <linux/veth.h>
+#include <sys/personality.h>
#ifdef HAVE_SELINUX
#include <selinux/selinux.h>
@@ -138,6 +139,7 @@ static bool arg_keep_unit = false;
static char **arg_network_interfaces = NULL;
static bool arg_network_veth = false;
static char *arg_network_bridge = NULL;
+static unsigned long arg_personality = 0xffffffffLU;
static int help(void) {
@@ -206,6 +208,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_NETWORK_INTERFACE,
ARG_NETWORK_VETH,
ARG_NETWORK_BRIDGE,
+ ARG_PERSONALITY,
};
static const struct option options[] = {
@@ -234,6 +237,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "network-interface", required_argument, NULL, ARG_NETWORK_INTERFACE },
{ "network-veth", no_argument, NULL, ARG_NETWORK_VETH },
{ "network-bridge", required_argument, NULL, ARG_NETWORK_BRIDGE },
+ { "personality", required_argument, NULL, ARG_PERSONALITY },
{}
};
@@ -474,6 +478,16 @@ static int parse_argv(int argc, char *argv[]) {
arg_keep_unit = true;
break;
+ case ARG_PERSONALITY:
+
+ arg_personality = parse_personality(optarg);
+ if (arg_personality == 0xffffffffLU) {
+ log_error("Unknown or unsupported personality '%s'.", optarg);
+ return -EINVAL;
+ }
+
+ break;
+
case '?':
return -EINVAL;
@@ -1983,6 +1997,13 @@ int main(int argc, char *argv[]) {
setup_hostname();
+ if (arg_personality != 0xffffffffLU) {
+ if (personality(arg_personality) < 0) {
+ log_error("personality() failed: %m");
+ goto child_fail;
+ }
+ }
+
eventfd_read(sync_fd, &x);
close_nointr_nofail(sync_fd);
sync_fd = -1;