]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
add ephemeral to nspawn-settings.
authorJiuyang liu <liujiuyang1994@gmail.com>
Mon, 22 Oct 2018 17:26:05 +0000 (01:26 +0800)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Oct 2018 08:22:20 +0000 (10:22 +0200)
man/systemd.nspawn.xml
src/nspawn/nspawn-gperf.gperf
src/nspawn/nspawn-settings.h
src/nspawn/nspawn.c

index 9ca6d9db2a6674bbf30b46cf026ff6baa3ee21c3..f978fef235ef3aafae55ce997a014232cc449a06 100644 (file)
         <filename>systemd-nspawn@.service</filename> template unit file is used.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><varname>Ephemeral=</varname></term>
+
+        <listitem><para>Takes a boolean argument, which defaults to off, If enabled, the container is run with
+        a temporary snapshot of its file system that is removed immediately when the container terminates.
+        This is equivalent to the <option>--ephemeral</option> command line switch. See
+        <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> for details
+        about the specific options supported.</para></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>ProcessTwo=</varname></term>
 
index 6029686ee9a7f8d70fd38669c0d2f27005c0fe0a..dec53a06f3b18af58884c94f4d14049dd1bc49e0 100644 (file)
@@ -19,6 +19,7 @@ struct ConfigPerfItem;
 %includes
 %%
 Exec.Boot,                    config_parse_boot,           0,                 0
+Exec.Ephemeral,               config_parse_bool,           0,                 offsetof(Settings, ephemeral)
 Exec.ProcessTwo,              config_parse_pid2,           0,                 0
 Exec.Parameters,              config_parse_strv,           0,                 offsetof(Settings, parameters)
 Exec.Environment,             config_parse_strv,           0,                 offsetof(Settings, environment)
index d522f3cb3633289b80126fc0b67a01d990e8f682..ba83826bbb4582c5a75484adcf38ba56d781f962 100644 (file)
@@ -84,9 +84,10 @@ typedef enum SettingsMask {
         SETTING_RESOLV_CONF       = UINT64_C(1) << 21,
         SETTING_LINK_JOURNAL      = UINT64_C(1) << 22,
         SETTING_TIMEZONE          = UINT64_C(1) << 23,
-        SETTING_RLIMIT_FIRST      = UINT64_C(1) << 24, /* we define one bit per resource limit here */
-        SETTING_RLIMIT_LAST       = UINT64_C(1) << (24 + _RLIMIT_MAX - 1),
-        _SETTINGS_MASK_ALL        = (UINT64_C(1) << (24 + _RLIMIT_MAX)) -1,
+        SETTING_EPHEMERAL         = UINT64_C(1) << 24,
+        SETTING_RLIMIT_FIRST      = UINT64_C(1) << 25, /* we define one bit per resource limit here */
+        SETTING_RLIMIT_LAST       = UINT64_C(1) << (25 + _RLIMIT_MAX - 1),
+        _SETTINGS_MASK_ALL        = (UINT64_C(1) << (25 + _RLIMIT_MAX)) -1,
         _SETTING_FORCE_ENUM_WIDTH = UINT64_MAX
 } SettingsMask;
 
@@ -102,6 +103,7 @@ assert_cc(sizeof(SETTING_RLIMIT_LAST) == 8);
 typedef struct Settings {
         /* [Run] */
         StartMode start_mode;
+        bool ephemeral;
         char **parameters;
         char **environment;
         char *user;
index ca80483205712cccb8938b3e49f0e7fe2a273225..fb6b603040a5a7ae66c9b12cc0614961162b3cbd 100644 (file)
@@ -574,6 +574,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'x':
                         arg_ephemeral = true;
+                        arg_settings_mask |= SETTING_EPHEMERAL;
                         break;
 
                 case 'u':
@@ -3380,6 +3381,9 @@ static int merge_settings(Settings *settings, const char *path) {
                 strv_free_and_replace(arg_parameters, settings->parameters);
         }
 
+        if ((arg_settings_mask & SETTING_EPHEMERAL) == 0)
+                arg_ephemeral = settings->ephemeral;
+
         if ((arg_settings_mask & SETTING_PIVOT_ROOT) == 0 &&
             settings->pivot_root_new) {
                 free_and_replace(arg_pivot_root_new, settings->pivot_root_new);