summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-08-25 23:58:40 +0200
committerDaniel Mack <github@zonque.org>2015-08-25 23:58:40 +0200
commit487ebe593ccc5e02de31130eb2de05478d1b53b0 (patch)
treef302ced9dc6734863f696c8addeb314d788678c6 /src
parent6a18bd1616ceeeb7b3eebf265dd10113c0c8811e (diff)
parentc1521918b48f45a316f0bd034976809ae0ce4dd8 (diff)
Merge pull request #1039 from poettering/nspawn-machine-template
nspawn: make sure --template= and --machine= my be combined
Diffstat (limited to 'src')
-rw-r--r--src/nspawn/nspawn.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index e8a023d023..837947ee28 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -559,9 +559,9 @@ static int parse_argv(int argc, char *argv[]) {
break;
case 'M':
- if (isempty(optarg)) {
+ if (isempty(optarg))
arg_machine = mfree(arg_machine);
- } else {
+ else {
if (!machine_name_is_valid(optarg)) {
log_error("Invalid machine name: %s", optarg);
return -EINVAL;
@@ -4002,6 +4002,17 @@ static int on_orderly_shutdown(sd_event_source *s, const struct signalfd_siginfo
static int determine_names(void) {
int r;
+ if (arg_template && !arg_directory && arg_machine) {
+
+ /* If --template= was specified then we should not
+ * search for a machine, but instead create a new one
+ * in /var/lib/machine. */
+
+ arg_directory = strjoin("/var/lib/machines/", arg_machine, NULL);
+ if (!arg_directory)
+ return log_oom();
+ }
+
if (!arg_image && !arg_directory) {
if (arg_machine) {
_cleanup_(image_unrefp) Image *i = NULL;