mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
nspawn: hook up --image=/--directory=/--template= with vpick logic
This commit is contained in:
parent
9e61ed1115
commit
300a03bec3
@ -112,6 +112,7 @@
|
||||
#include "umask-util.h"
|
||||
#include "unit-name.h"
|
||||
#include "user-util.h"
|
||||
#include "vpick.h"
|
||||
|
||||
/* The notify socket inside the container it can use to talk to nspawn using the sd_notify(3) protocol */
|
||||
#define NSPAWN_NOTIFY_SOCKET_PATH "/run/host/notify"
|
||||
@ -2911,14 +2912,72 @@ static int on_request_stop(sd_bus_message *m, void *userdata, sd_bus_error *erro
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pick_paths(void) {
|
||||
int r;
|
||||
|
||||
if (arg_directory) {
|
||||
_cleanup_(pick_result_done) PickResult result = PICK_RESULT_NULL;
|
||||
PickFilter filter = pick_filter_image_dir;
|
||||
|
||||
filter.architecture = arg_architecture;
|
||||
|
||||
r = path_pick_update_warn(
|
||||
&arg_directory,
|
||||
&filter,
|
||||
PICK_ARCHITECTURE|PICK_TRIES,
|
||||
&result);
|
||||
if (r < 0) {
|
||||
/* Accept ENOENT here so that the --template= logic can work */
|
||||
if (r != -ENOENT)
|
||||
return r;
|
||||
} else
|
||||
arg_architecture = result.architecture;
|
||||
}
|
||||
|
||||
if (arg_image) {
|
||||
_cleanup_(pick_result_done) PickResult result = PICK_RESULT_NULL;
|
||||
PickFilter filter = pick_filter_image_raw;
|
||||
|
||||
filter.architecture = arg_architecture;
|
||||
|
||||
r = path_pick_update_warn(
|
||||
&arg_image,
|
||||
&filter,
|
||||
PICK_ARCHITECTURE|PICK_TRIES,
|
||||
&result);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
arg_architecture = result.architecture;
|
||||
}
|
||||
|
||||
if (arg_template) {
|
||||
_cleanup_(pick_result_done) PickResult result = PICK_RESULT_NULL;
|
||||
PickFilter filter = pick_filter_image_dir;
|
||||
|
||||
filter.architecture = arg_architecture;
|
||||
|
||||
r = path_pick_update_warn(
|
||||
&arg_template,
|
||||
&filter,
|
||||
PICK_ARCHITECTURE,
|
||||
&result);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
arg_architecture = result.architecture;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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. */
|
||||
/* If --template= was specified then we should not search for a machine, but instead create a
|
||||
* new one in /var/lib/machine. */
|
||||
|
||||
arg_directory = path_join("/var/lib/machines", arg_machine);
|
||||
if (!arg_directory)
|
||||
@ -5406,6 +5465,10 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
r = pick_paths();
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
||||
r = determine_names();
|
||||
if (r < 0)
|
||||
goto finish;
|
||||
|
Loading…
Reference in New Issue
Block a user