confile: lxc.rootfs --> lxc.rootfs.path

parent 3e01c200
...@@ -79,7 +79,7 @@ quite restricted. Just to highlight the two most common problems: ...@@ -79,7 +79,7 @@ quite restricted. Just to highlight the two most common problems:
LXC is configured via a simple set of keys. For example, LXC is configured via a simple set of keys. For example,
- `lxc.rootfs` - `lxc.rootfs.path`
- `lxc.mount.entry` - `lxc.mount.entry`
LXC namespaces configuration keys by using single dots. This means complex LXC namespaces configuration keys by using single dots. This means complex
......
...@@ -1042,7 +1042,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -1042,7 +1042,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>
<option>lxc.rootfs</option> <option>lxc.rootfs.path</option>
</term> </term>
<listitem> <listitem>
<para> <para>
...@@ -1076,7 +1076,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -1076,7 +1076,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</term> </term>
<listitem> <listitem>
<para> <para>
where to recursively bind <option>lxc.rootfs</option> where to recursively bind <option>lxc.rootfs.path</option>
before pivoting. This is to ensure success of the before pivoting. This is to ensure success of the
<citerefentry> <citerefentry>
<refentrytitle><command>pivot_root</command></refentrytitle> <refentrytitle><command>pivot_root</command></refentrytitle>
...@@ -1426,7 +1426,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -1426,7 +1426,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<listitem><para> LXC_ROOTFS_MOUNT: the path to the mounted root filesystem. </para></listitem> <listitem><para> LXC_ROOTFS_MOUNT: the path to the mounted root filesystem. </para></listitem>
<listitem><para> LXC_CONFIG_FILE: the path to the container configuration file. </para></listitem> <listitem><para> LXC_CONFIG_FILE: the path to the container configuration file. </para></listitem>
<listitem><para> LXC_SRC_NAME: in the case of the clone hook, this is the original container's name. </para></listitem> <listitem><para> LXC_SRC_NAME: in the case of the clone hook, this is the original container's name. </para></listitem>
<listitem><para> LXC_ROOTFS_PATH: this is the lxc.rootfs entry for the container. Note this is likely not where the mounted rootfs is to be found, use LXC_ROOTFS_MOUNT for that. </para></listitem> <listitem><para> LXC_ROOTFS_PATH: this is the lxc.rootfs.path entry for the container. Note this is likely not where the mounted rootfs is to be found, use LXC_ROOTFS_MOUNT for that. </para></listitem>
</itemizedlist> </itemizedlist>
</para> </para>
<para> <para>
...@@ -1662,7 +1662,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -1662,7 +1662,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<para> <para>
The host relative path to the container root which has been The host relative path to the container root which has been
mounted to the rootfs.mount location. mounted to the rootfs.mount location.
[<option>lxc.rootfs</option>] [<option>lxc.rootfs.path</option>]
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1989,7 +1989,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -1989,7 +1989,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
lxc.cgroup.devices.allow = b 8:0 rw lxc.cgroup.devices.allow = b 8:0 rw
lxc.mount = /etc/fstab.complex lxc.mount = /etc/fstab.complex
lxc.mount.entry = /lib /root/myrootfs/lib none ro,bind 0 0 lxc.mount.entry = /lib /root/myrootfs/lib none ro,bind 0 0
lxc.rootfs = /mnt/rootfs.complex lxc.rootfs.path = dir:/mnt/rootfs.complex
lxc.cap.drop = sys_module mknod setuid net_raw lxc.cap.drop = sys_module mknod setuid net_raw
lxc.cap.drop = mac_override lxc.cap.drop = mac_override
</programlisting> </programlisting>
......
...@@ -91,7 +91,7 @@ lxc_config_define(fstab); ...@@ -91,7 +91,7 @@ lxc_config_define(fstab);
lxc_config_define(rootfs_mount); lxc_config_define(rootfs_mount);
lxc_config_define(rootfs_options); lxc_config_define(rootfs_options);
lxc_config_define(rootfs_backend); lxc_config_define(rootfs_backend);
lxc_config_define(rootfs); lxc_config_define(rootfs_path);
lxc_config_define(uts_name); lxc_config_define(uts_name);
lxc_config_define(hooks); lxc_config_define(hooks);
lxc_config_define(net_type); lxc_config_define(net_type);
...@@ -162,13 +162,17 @@ static struct lxc_config_t config[] = { ...@@ -162,13 +162,17 @@ static struct lxc_config_t config[] = {
{ "lxc.mount", set_config_fstab, get_config_fstab, clr_config_fstab, }, { "lxc.mount", set_config_fstab, get_config_fstab, clr_config_fstab, },
{ "lxc.rootfs.mount", set_config_rootfs_mount, get_config_rootfs_mount, clr_config_rootfs_mount, }, { "lxc.rootfs.mount", set_config_rootfs_mount, get_config_rootfs_mount, clr_config_rootfs_mount, },
{ "lxc.rootfs.options", set_config_rootfs_options, get_config_rootfs_options, clr_config_rootfs_options, }, { "lxc.rootfs.options", set_config_rootfs_options, get_config_rootfs_options, clr_config_rootfs_options, },
{ "lxc.rootfs.path", set_config_rootfs_path, get_config_rootfs_path, clr_config_rootfs_path, },
/* REMOVE IN LXC 3.0 /* REMOVE IN LXC 3.0
legacy rootfs.backend key legacy rootfs.backend key
*/ */
{ "lxc.rootfs.backend", set_config_rootfs_backend, get_config_rootfs_backend, clr_config_rootfs_backend, }, { "lxc.rootfs.backend", set_config_rootfs_backend, get_config_rootfs_backend, clr_config_rootfs_backend, },
{ "lxc.rootfs", set_config_rootfs, get_config_rootfs, clr_config_rootfs, }, /* REMOVE IN LXC 3.0
legacy rootfs key
*/
{ "lxc.rootfs", set_config_rootfs_path, get_config_rootfs_path, clr_config_rootfs_path, },
/* REMOVE IN LXC 3.0 /* REMOVE IN LXC 3.0
legacy utsname key legacy utsname key
...@@ -2035,8 +2039,8 @@ static int set_config_includefiles(const char *key, const char *value, ...@@ -2035,8 +2039,8 @@ static int set_config_includefiles(const char *key, const char *value,
return lxc_config_read(value, lxc_conf, true); return lxc_config_read(value, lxc_conf, true);
} }
static int set_config_rootfs(const char *key, const char *value, static int set_config_rootfs_path(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data) struct lxc_conf *lxc_conf, void *data)
{ {
return set_config_path_item(&lxc_conf->rootfs.path, value); return set_config_path_item(&lxc_conf->rootfs.path, value);
} }
...@@ -3026,8 +3030,8 @@ static int get_config_mount(const char *key, char *retv, int inlen, ...@@ -3026,8 +3030,8 @@ static int get_config_mount(const char *key, char *retv, int inlen,
return fulllen; return fulllen;
} }
static int get_config_rootfs(const char *key, char *retv, int inlen, static int get_config_rootfs_path(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data) struct lxc_conf *c, void *data)
{ {
return lxc_get_conf_str(retv, inlen, c->rootfs.path); return lxc_get_conf_str(retv, inlen, c->rootfs.path);
} }
...@@ -3440,8 +3444,8 @@ static inline int clr_config_fstab(const char *key, struct lxc_conf *c, ...@@ -3440,8 +3444,8 @@ static inline int clr_config_fstab(const char *key, struct lxc_conf *c,
return 0; return 0;
} }
static inline int clr_config_rootfs(const char *key, struct lxc_conf *c, static inline int clr_config_rootfs_path(const char *key, struct lxc_conf *c,
void *data) void *data)
{ {
free(c->rootfs.path); free(c->rootfs.path);
c->rootfs.path = NULL; c->rootfs.path = NULL;
......
...@@ -1071,8 +1071,8 @@ static struct bdev *do_bdev_create(struct lxc_container *c, const char *type, ...@@ -1071,8 +1071,8 @@ static struct bdev *do_bdev_create(struct lxc_container *c, const char *type,
return NULL; return NULL;
} }
if (!c->set_config_item(c, "lxc.rootfs", bdev->src)) { if (!c->set_config_item(c, "lxc.rootfs.path", bdev->src)) {
ERROR("Failed to set config item \"lxc.rootfs\" to \"%s\"", ERROR("Failed to set config item \"lxc.rootfs.path\" to \"%s\"",
bdev->src); bdev->src);
return NULL; return NULL;
} }
...@@ -2936,15 +2936,22 @@ static int copy_storage(struct lxc_container *c0, struct lxc_container *c, ...@@ -2936,15 +2936,22 @@ static int copy_storage(struct lxc_container *c0, struct lxc_container *c,
return -1; return -1;
} }
/* Append a new lxc.rootfs entry to the unexpanded config. */ /* REMOVE IN LXC 3.0
* legacy rootfs key
*/
clear_unexp_config_line(c->lxc_conf, "lxc.rootfs", false); clear_unexp_config_line(c->lxc_conf, "lxc.rootfs", false);
if (!do_append_unexp_config_line(c->lxc_conf, "lxc.rootfs",
/* Append a new lxc.rootfs.path entry to the unexpanded config. */
clear_unexp_config_line(c->lxc_conf, "lxc.rootfs.path", false);
if (!do_append_unexp_config_line(c->lxc_conf, "lxc.rootfs.path",
c->lxc_conf->rootfs.path)) { c->lxc_conf->rootfs.path)) {
ERROR("Error saving new rootfs to cloned config."); ERROR("Error saving new rootfs to cloned config.");
return -1; return -1;
} }
/* Append a new lxc.rootfs.backend entry to the unexpanded config. */ /* REMOVE IN LXC 3.0
* legacy rootfs.backend key
*/
clear_unexp_config_line(c->lxc_conf, "lxc.rootfs.backend", false); clear_unexp_config_line(c->lxc_conf, "lxc.rootfs.backend", false);
if (flags & LXC_CLONE_SNAPSHOT) if (flags & LXC_CLONE_SNAPSHOT)
...@@ -3165,7 +3172,13 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char ...@@ -3165,7 +3172,13 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
fclose(fout); fclose(fout);
goto out; goto out;
} }
/* REMOVE IN LXC 3.0
* legacy rootfs key
*/
clear_unexp_config_line(c->lxc_conf, "lxc.rootfs", false); clear_unexp_config_line(c->lxc_conf, "lxc.rootfs", false);
clear_unexp_config_line(c->lxc_conf, "lxc.rootfs.path", false);
write_config(fout, c->lxc_conf); write_config(fout, c->lxc_conf);
fclose(fout); fclose(fout);
c->lxc_conf->rootfs.path = origroot; c->lxc_conf->rootfs.path = origroot;
......
...@@ -546,7 +546,12 @@ static int ls_get(struct ls **m, size_t *size, const struct lxc_arguments *args, ...@@ -546,7 +546,12 @@ static int ls_get(struct ls **m, size_t *size, const struct lxc_arguments *args,
* need a path-extractor function. We face the same * need a path-extractor function. We face the same
* problem with the ovl_mkdir() function in * problem with the ovl_mkdir() function in
* lxcoverlay.{c,h}. */ * lxcoverlay.{c,h}. */
char *curr_path = ls_get_config_item(c, "lxc.rootfs", running); char *curr_path = ls_get_config_item(c, "lxc.rootfs.path", running);
/* REMOVE IN LXC 3.0
legacy rootfs key
*/
if (!curr_path)
curr_path = ls_get_config_item(c, "lxc.rootfs", running);
if (!curr_path) if (!curr_path)
goto put_and_next; goto put_and_next;
......
...@@ -56,7 +56,7 @@ if [ -f /etc/lsb-release ]; then ...@@ -56,7 +56,7 @@ if [ -f /etc/lsb-release ]; then
fi fi
lxc-create -t download -n $CONTAINER_NAME -B dir -- -d ubuntu -r $release -a $ARCH lxc-create -t download -n $CONTAINER_NAME -B dir -- -d ubuntu -r $release -a $ARCH
CONTAINER_PATH=$(dirname $(lxc-info -n $CONTAINER_NAME -c lxc.rootfs -H) | sed -e 's/dir://') CONTAINER_PATH=$(dirname $(lxc-info -n $CONTAINER_NAME -c lxc.rootfs.path -H) | sed -e 's/dir://')
cp $CONTAINER_PATH/config $CONTAINER_PATH/config.bak cp $CONTAINER_PATH/config $CONTAINER_PATH/config.bak
# Ensure it's not in lxc-autostart # Ensure it's not in lxc-autostart
......
...@@ -109,7 +109,7 @@ EOF ...@@ -109,7 +109,7 @@ EOF
# We need this in 5.conf # We need this in 5.conf
lxc-destroy -n lxctestb || true lxc-destroy -n lxctestb || true
lxc-create -t busybox -n lxctestb -B dir lxc-create -t busybox -n lxctestb -B dir
CONTAINER_PATH=$(dirname $(lxc-info -n lxctestb -c lxc.rootfs -H) | sed 's/dir://') CONTAINER_PATH=$(dirname $(lxc-info -n lxctestb -c lxc.rootfs.path -H) | sed 's/dir://')
lxc-destroy -n lxctestb lxc-destroy -n lxctestb
# No nics, one clone hook in $container # No nics, one clone hook in $container
......
...@@ -503,13 +503,22 @@ int main(int argc, char *argv[]) ...@@ -503,13 +503,22 @@ int main(int argc, char *argv[])
goto non_test_error; goto non_test_error;
} }
/* lxc.rootfs */ /* REMOVE IN LXC 3.0
legacy lxc.rootfs key
*/
if (set_get_compare_clear_save_load(c, "lxc.rootfs", "/some/path", tmpf, if (set_get_compare_clear_save_load(c, "lxc.rootfs", "/some/path", tmpf,
true) < 0) { true) < 0) {
lxc_error("%s\n", "lxc.rootfs"); lxc_error("%s\n", "lxc.rootfs");
goto non_test_error; goto non_test_error;
} }
/* lxc.rootfs.path */
if (set_get_compare_clear_save_load(c, "lxc.rootfs.path", "/some/path", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.rootfs.path");
goto non_test_error;
}
/* lxc.rootfs.mount */ /* lxc.rootfs.mount */
if (set_get_compare_clear_save_load(c, "lxc.rootfs.mount", "/some/path", if (set_get_compare_clear_save_load(c, "lxc.rootfs.mount", "/some/path",
tmpf, true) < 0) { tmpf, true) < 0) {
......
...@@ -483,7 +483,7 @@ readonly MIRROR_URL="${mirror_url:-$DEFAULT_MIRROR_URL}" ...@@ -483,7 +483,7 @@ readonly MIRROR_URL="${mirror_url:-$DEFAULT_MIRROR_URL}"
[ -n "$path" ] || die 1 'Missing required option --path' [ -n "$path" ] || die 1 'Missing required option --path'
if [ -z "$rootfs" ] && [ -f "$path/config" ]; then if [ -z "$rootfs" ] && [ -f "$path/config" ]; then
rootfs="$(sed -nE 's/^lxc.rootfs\s*=\s*(.*)$/\1/p' "$path/config")" rootfs="$(sed -nE 's/^lxc.rootfs.path\s*=\s*(.*)$/\1/p' "$path/config")"
fi fi
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
rootfs="$path/rootfs" rootfs="$path/rootfs"
......
...@@ -274,7 +274,7 @@ copy_configuration() ...@@ -274,7 +274,7 @@ copy_configuration()
{ {
mkdir -p $config_path mkdir -p $config_path
grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo "lxc.rootfs = $rootfs_path" >> $config_path/config grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs_path" >> $config_path/config
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.uts.name = $name lxc.uts.name = $name
lxc.tty = 4 lxc.tty = 4
...@@ -460,10 +460,10 @@ if [ "$(id -u)" != "0" ]; then ...@@ -460,10 +460,10 @@ if [ "$(id -u)" != "0" ]; then
exit 1 exit 1
fi fi
# check for 'lxc.rootfs' passed in through default config by lxc-create # check for 'lxc.rootfs.path' passed in through default config by lxc-create
if [ -z "$rootfs_path" ]; then if [ -z "$rootfs_path" ]; then
if grep -q '^lxc.rootfs' $path/config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $path/config 2>/dev/null ; then
rootfs_path=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $path/config) rootfs_path=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $path/config)
else else
rootfs_path=$path/rootfs rootfs_path=$path/rootfs
fi fi
......
...@@ -151,8 +151,8 @@ copy_configuration() { ...@@ -151,8 +151,8 @@ copy_configuration() {
echo "lxc.uts.name = ${name}" >> "${config}" echo "lxc.uts.name = ${name}" >> "${config}"
grep -q "^lxc.arch" "${config}" 2>/dev/null \ grep -q "^lxc.arch" "${config}" 2>/dev/null \
|| echo "lxc.arch = ${arch}" >> "${config}" || echo "lxc.arch = ${arch}" >> "${config}"
grep -q "^lxc.rootfs" "${config}" 2>/dev/null \ grep -q "^lxc.rootfs.path" "${config}" 2>/dev/null \
|| echo "lxc.rootfs = ${rootfs_path}" >> "${config}" || echo "lxc.rootfs.path = ${rootfs_path}" >> "${config}"
[ -e "${shared_config}" ] \ [ -e "${shared_config}" ] \
&& echo "lxc.include = ${shared_config}" >> "${config}" && echo "lxc.include = ${shared_config}" >> "${config}"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
......
...@@ -339,7 +339,7 @@ copy_configuration() ...@@ -339,7 +339,7 @@ copy_configuration()
rootfs=$2 rootfs=$2
name=$3 name=$3
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config grep -q "^lxc.rootfs.path" $path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs" >> $path/config
cat <<EOF >> $path/config cat <<EOF >> $path/config
lxc.signal.halt = SIGUSR1 lxc.signal.halt = SIGUSR1
lxc.rebootsignal = SIGTERM lxc.rebootsignal = SIGTERM
...@@ -427,8 +427,8 @@ fi ...@@ -427,8 +427,8 @@ fi
# detect rootfs # detect rootfs
config="$path/config" config="$path/config"
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
if grep -q '^lxc.rootfs' $config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then
rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config) rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config)
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -598,8 +598,8 @@ copy_configuration() ...@@ -598,8 +598,8 @@ copy_configuration()
{ {
mkdir -p $config_path mkdir -p $config_path
grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo " grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "
lxc.rootfs = $rootfs_path lxc.rootfs.path = $rootfs_path
" >> $config_path/config " >> $config_path/config
# The following code is to create static MAC addresses for each # The following code is to create static MAC addresses for each
...@@ -861,10 +861,10 @@ fi ...@@ -861,10 +861,10 @@ fi
if [ -z "$rootfs_path" ]; then if [ -z "$rootfs_path" ]; then
rootfs_path=$path/rootfs rootfs_path=$path/rootfs
# check for 'lxc.rootfs' passed in through default config by lxc-create # check for 'lxc.rootfs.path' passed in through default config by lxc-create
if grep -q '^lxc.rootfs' $path/config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $path/config 2>/dev/null ; then
rootfs_path=$(sed -e '/^lxc.rootfs\s*=/!d' -e 's/\s*#.*//' \ rootfs_path=$(sed -e '/^lxc.rootfs.path\s*=/!d' -e 's/\s*#.*//' \
-e 's/^lxc.rootfs\s*=\s*//' -e q $path/config) -e 's/^lxc.rootfs.path\s*=\s*//' -e q $path/config)
fi fi
fi fi
config_path=$path config_path=$path
......
...@@ -118,7 +118,7 @@ copy_configuration() ...@@ -118,7 +118,7 @@ copy_configuration()
cat >> "$path/config" <<EOF cat >> "$path/config" <<EOF
# Template used to create this container: cirros # Template used to create this container: cirros
lxc.rootfs = $rootfs lxc.rootfs.path = $rootfs
lxc.tty = 4 lxc.tty = 4
lxc.pts = 1024 lxc.pts = 1024
......
...@@ -511,7 +511,7 @@ copy_configuration() ...@@ -511,7 +511,7 @@ copy_configuration()
## Add the container-specific config ## Add the container-specific config
echo "" >> "$path/config" echo "" >> "$path/config"
echo "# Container specific configuration" >> "$path/config" echo "# Container specific configuration" >> "$path/config"
grep -q "^lxc.rootfs" "$path/config" 2> /dev/null || echo "lxc.rootfs = $rootfs" >> "$path/config" grep -q "^lxc.rootfs.path" "$path/config" 2> /dev/null || echo "lxc.rootfs.path = $rootfs" >> "$path/config"
cat <<EOF >> $path/config cat <<EOF >> $path/config
lxc.tty = $num_tty lxc.tty = $num_tty
...@@ -787,8 +787,8 @@ fi ...@@ -787,8 +787,8 @@ fi
# detect rootfs # detect rootfs
config="$path/config" config="$path/config"
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
if grep -q '^lxc.rootfs' "$config" 2> /dev/null ; then if grep -q '^lxc.rootfs.path' "$config" 2> /dev/null ; then
rootfs=$(awk -F= '/^lxc.rootfs[ \t]+=/{ print $2 }' "$config") rootfs=$(awk -F= '/^lxc.rootfs.path[ \t]+=/{ print $2 }' "$config")
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -1082,8 +1082,8 @@ copy_configuration() ...@@ -1082,8 +1082,8 @@ copy_configuration()
{ {
mkdir -p $config_path mkdir -p $config_path
grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo " grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "
lxc.rootfs = $rootfs_path lxc.rootfs.path = $rootfs_path
" >> $config_path/config " >> $config_path/config
# The following code is to create static MAC addresses for each # The following code is to create static MAC addresses for each
...@@ -1367,10 +1367,10 @@ fi ...@@ -1367,10 +1367,10 @@ fi
if [ -z "$rootfs_path" ]; then if [ -z "$rootfs_path" ]; then
rootfs_path=$path/rootfs rootfs_path=$path/rootfs
# check for 'lxc.rootfs' passed in through default config by lxc-create # check for 'lxc.rootfs.path' passed in through default config by lxc-create
if grep -q '^lxc.rootfs' $path/config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $path/config 2>/dev/null ; then
rootfs_path=$(sed -e '/^lxc.rootfs\s*=/!d' -e 's/\s*#.*//' \ rootfs_path=$(sed -e '/^lxc.rootfs.path\s*=/!d' -e 's/\s*#.*//' \
-e 's/^lxc.rootfs\s*=\s*//' -e q $path/config) -e 's/^lxc.rootfs.path\s*=\s*//' -e q $path/config)
fi fi
fi fi
config_path=$path config_path=$path
......
...@@ -439,8 +439,8 @@ copy_configuration() ...@@ -439,8 +439,8 @@ copy_configuration()
# include configuration from default.conf if available # include configuration from default.conf if available
grep -q "^lxc." "${lxc_default_conf}" > "${config}" 2>/dev/null grep -q "^lxc." "${lxc_default_conf}" > "${config}" 2>/dev/null
grep -q "^lxc.rootfs" "${config}" 2>/dev/null || echo " grep -q "^lxc.rootfs.path" "${config}" 2>/dev/null || echo "
lxc.rootfs = ${rootfs} lxc.rootfs.path = ${rootfs}
" >> "${config}" " >> "${config}"
# The following code is to create static MAC addresses for each # The following code is to create static MAC addresses for each
...@@ -1185,10 +1185,10 @@ fi ...@@ -1185,10 +1185,10 @@ fi
config="${path}/config" config="${path}/config"
if [ -z "${rootfs}" ] if [ -z "${rootfs}" ]
then then
# check for 'lxc.rootfs' passed in through default config by lxc-create # check for 'lxc.rootfs.path' passed in through default config by lxc-create
if grep -q '^lxc.rootfs' "${config}" 2>/dev/null if grep -q '^lxc.rootfs.path' "${config}" 2>/dev/null
then then
rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' "${config}") rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' "${config}")
else else
rootfs="${path}/rootfs" rootfs="${path}/rootfs"
fi fi
......
...@@ -282,9 +282,9 @@ container_setup() { ...@@ -282,9 +282,9 @@ container_setup() {
echo '### lxc-gentoo template stuff starts here' >> "$path/config" echo '### lxc-gentoo template stuff starts here' >> "$path/config"
#Determine rootfs #Determine rootfs
#If backingstore was specified, lxc.rootfs should be present or --rootfs did the rootfs var creation #If backingstore was specified, lxc.rootfs.path should be present or --rootfs did the rootfs var creation
if [ -z "${rootfs}" ]; then if [ -z "${rootfs}" ]; then
rootfs=`awk -F= '$1 ~ /^lxc.rootfs/ { print $2 }' "$path/config" 2>/dev/null` rootfs=`awk -F= '$1 ~ /^lxc.rootfs.path/ { print $2 }' "$path/config" 2>/dev/null`
if [ -z "${rootfs}" ]; then if [ -z "${rootfs}" ]; then
#OK it's default #OK it's default
rootfs="${path}/rootfs" rootfs="${path}/rootfs"
...@@ -686,11 +686,11 @@ container_conf() ...@@ -686,11 +686,11 @@ container_conf()
grep -q "^lxc.net.0.hwaddr" ${conf_file} || sed -i -e "/^lxc\.net\.0\.type[ \t]*=[ \t]*veth/a lxc.net.0.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" ${conf_file} grep -q "^lxc.net.0.hwaddr" ${conf_file} || sed -i -e "/^lxc\.net\.0\.type[ \t]*=[ \t]*veth/a lxc.net.0.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" ${conf_file}
fi fi
if grep -q "^lxc.rootfs" "${conf_file}" ; then if grep -q "^lxc.rootfs.path" "${conf_file}" ; then
#lxc-create already provided one #lxc-create already provided one
conf_rootfs_line="" conf_rootfs_line=""
else else
conf_rootfs_line="lxc.rootfs = $(readlink -f "${rootfs}")" conf_rootfs_line="lxc.rootfs.path = $(readlink -f "${rootfs}")"
fi fi
if [[ "${arch}" == "x86" || "${arch}" == "amd64" ]]; then if [[ "${arch}" == "x86" || "${arch}" == "amd64" ]]; then
local conf_arch_line="lxc.arch = ${arch}" local conf_arch_line="lxc.arch = ${arch}"
......
...@@ -226,7 +226,7 @@ copy_configuration() ...@@ -226,7 +226,7 @@ copy_configuration()
{ {
mkdir -p $config_path mkdir -p $config_path
grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo "lxc.rootfs = $rootfs_path" >> $config_path/config grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs_path" >> $config_path/config
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.uts.name = $name lxc.uts.name = $name
lxc.tty = 4 lxc.tty = 4
...@@ -424,10 +424,10 @@ if [ "$(id -u)" != "0" ]; then ...@@ -424,10 +424,10 @@ if [ "$(id -u)" != "0" ]; then
exit 1 exit 1
fi fi
# check for 'lxc.rootfs' passed in through default config by lxc-create # check for 'lxc.rootfs.path' passed in through default config by lxc-create
if [ -z "$rootfs_path" ]; then if [ -z "$rootfs_path" ]; then
if grep -q '^lxc.rootfs' $path/config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $path/config 2>/dev/null ; then
rootfs_path=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $path/config) rootfs_path=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $path/config)
else else
rootfs_path=$path/$name/rootfs rootfs_path=$path/$name/rootfs
fi fi
......
...@@ -303,8 +303,8 @@ copy_configuration() ...@@ -303,8 +303,8 @@ copy_configuration()
rootfs=$2 rootfs=$2
name=$3 name=$3
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo " grep -q "^lxc.rootfs.path" $path/config 2>/dev/null || echo "
lxc.rootfs = $rootfs_path lxc.rootfs.path = $rootfs_path
" >> $path/config " >> $path/config
# The following code is to create static MAC addresses for each # The following code is to create static MAC addresses for each
...@@ -504,8 +504,8 @@ fi ...@@ -504,8 +504,8 @@ fi
# detect rootfs # detect rootfs
config="$path/config" config="$path/config"
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
if grep -q '^lxc.rootfs' $config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then
rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config) rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config)
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -484,7 +484,7 @@ container_config_create() ...@@ -484,7 +484,7 @@ container_config_create()
lxc.arch = $arch lxc.arch = $arch
lxc.uts.name = $name lxc.uts.name = $name
EOF EOF
grep -q "^lxc.rootfs" $cfg_dir/config 2>/dev/null || echo "lxc.rootfs = $container_rootfs" >> $cfg_dir/config grep -q "^lxc.rootfs.path" $cfg_dir/config 2>/dev/null || echo "lxc.rootfs.path = $container_rootfs" >> $cfg_dir/config
if [ $container_release_major != "4" ]; then if [ $container_release_major != "4" ]; then
echo "lxc.cap.drop = sys_resource" >>$cfg_dir/config echo "lxc.cap.drop = sys_resource" >>$cfg_dir/config
......
...@@ -346,8 +346,8 @@ ptcache=$cache/partial-${prog##*-}-$release-$arch ...@@ -346,8 +346,8 @@ ptcache=$cache/partial-${prog##*-}-$release-$arch
dlcache=$cache/cache-${prog##*-}-$release-$arch dlcache=$cache/cache-${prog##*-}-$release-$arch
rtcache=$cache/rootfs-${prog##*-}-$release-$arch rtcache=$cache/rootfs-${prog##*-}-$release-$arch
if [ -z "$rootfs" ] ; then if [ -z "$rootfs" ] ; then
if grep -q "^lxc.rootfs" $path/config ; then if grep -q "^lxc.rootfs.path" $path/config ; then
rootfs=`awk -F= '/^lxc.rootfs =/{ print $2 }' $path/config` rootfs=`awk -F= '/^lxc.rootfs.path =/{ print $2 }' $path/config`
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -234,7 +234,7 @@ copy_configuration() ...@@ -234,7 +234,7 @@ copy_configuration()
{ {
mkdir -p $config_path mkdir -p $config_path
grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo "lxc.rootfs = $rootfs_path" >> $config_path/config grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs_path" >> $config_path/config
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
# Most of below settings should be taken as defaults from # Most of below settings should be taken as defaults from
# lxc.include = /usr/share/lxc/config/common.conf # lxc.include = /usr/share/lxc/config/common.conf
...@@ -423,10 +423,10 @@ fi ...@@ -423,10 +423,10 @@ fi
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
rootfs_path=$path/rootfs rootfs_path=$path/rootfs
# check for 'lxc.rootfs' passed in through default config by lxc-create # check for 'lxc.rootfs.path' passed in through default config by lxc-create
# TODO: should be lxc.rootfs.mount used instead? # TODO: should be lxc.rootfs.mount used instead?
if grep -q '^lxc.rootfs' $path/config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $path/config 2>/dev/null ; then
rootfs_path=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $path/config) rootfs_path=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $path/config)
fi fi
else else
rootfs_path=$rootfs rootfs_path=$rootfs
......
...@@ -743,8 +743,8 @@ fi ...@@ -743,8 +743,8 @@ fi
# detect rootfs # detect rootfs
config="$path/config" config="$path/config"
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
if grep -q '^lxc.rootfs' $config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then
rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config) rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config)
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -318,7 +318,7 @@ container_config_create() ...@@ -318,7 +318,7 @@ container_config_create()
lxc.arch = $arch lxc.arch = $arch
lxc.uts.name = $name lxc.uts.name = $name
EOF EOF
grep -q "^lxc.rootfs" $cfg_dir/config 2>/dev/null || echo "lxc.rootfs = $container_rootfs" >> $cfg_dir/config grep -q "^lxc.rootfs.path" $cfg_dir/config 2>/dev/null || echo "lxc.rootfs.path = $container_rootfs" >> $cfg_dir/config
echo "lxc.cap.drop = sys_resource" >>$cfg_dir/config echo "lxc.cap.drop = sys_resource" >>$cfg_dir/config
......
...@@ -127,7 +127,7 @@ copy_configuration() ...@@ -127,7 +127,7 @@ copy_configuration()
init_path=$(realpath --relative-to=/ $(readlink -f /sbin/init)) init_path=$(realpath --relative-to=/ $(readlink -f /sbin/init))
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config grep -q "^lxc.rootfs.path" $path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs" >> $path/config
cat <<EOF >> $path/config cat <<EOF >> $path/config
lxc.uts.name = $name lxc.uts.name = $name
lxc.pts = 1024 lxc.pts = 1024
...@@ -250,8 +250,8 @@ fi ...@@ -250,8 +250,8 @@ fi
# detect rootfs # detect rootfs
config="$path/config" config="$path/config"
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
if grep -q '^lxc.rootfs' $config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then
rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config) rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config)
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -89,7 +89,7 @@ copy_configuration() ...@@ -89,7 +89,7 @@ copy_configuration()
echo "" >> $path/config echo "" >> $path/config
echo "# Container specific configuration" >> $path/config echo "# Container specific configuration" >> $path/config
[ -e "$path/config-auto" ] && cat $path/config-auto >> $path/config && rm $path/config-auto [ -e "$path/config-auto" ] && cat $path/config-auto >> $path/config && rm $path/config-auto
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config grep -q "^lxc.rootfs.path" $path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs" >> $path/config
cat <<EOF >> $path/config cat <<EOF >> $path/config
lxc.uts.name = $name lxc.uts.name = $name
lxc.arch = $arch lxc.arch = $arch
...@@ -263,8 +263,8 @@ fi ...@@ -263,8 +263,8 @@ fi
# detect rootfs # detect rootfs
config="$path/config" config="$path/config"
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
if grep -q '^lxc.rootfs' $config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then
rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config) rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config)
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -529,7 +529,7 @@ copy_configuration() ...@@ -529,7 +529,7 @@ copy_configuration()
echo "" >> $path/config echo "" >> $path/config
echo "# Container specific configuration" >> $path/config echo "# Container specific configuration" >> $path/config
[ -e "$path/config-auto" ] && cat $path/config-auto >> $path/config && rm $path/config-auto [ -e "$path/config-auto" ] && cat $path/config-auto >> $path/config && rm $path/config-auto
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config grep -q "^lxc.rootfs.path" $path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs" >> $path/config
cat <<EOF >> $path/config cat <<EOF >> $path/config
lxc.uts.name = $name lxc.uts.name = $name
lxc.arch = $arch lxc.arch = $arch
...@@ -809,8 +809,8 @@ fi ...@@ -809,8 +809,8 @@ fi
config="$path/config" config="$path/config"
# if $rootfs exists here, it was passed in with --rootfs # if $rootfs exists here, it was passed in with --rootfs
if [ -z "$rootfs" ]; then if [ -z "$rootfs" ]; then
if grep -q '^lxc.rootfs' $config 2>/dev/null ; then if grep -q '^lxc.rootfs.path' $config 2>/dev/null ; then
rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config) rootfs=$(awk -F= '/^lxc.rootfs.path =/{ print $2 }' $config)
else else
rootfs=$path/rootfs rootfs=$path/rootfs
fi fi
......
...@@ -69,8 +69,8 @@ copy_configuration() { ...@@ -69,8 +69,8 @@ copy_configuration() {
mkdir -p "${config_path}" mkdir -p "${config_path}"
local config="${config_path}/config" local config="${config_path}/config"
echo "lxc.uts.name = ${name}" >> "${config}" echo "lxc.uts.name = ${name}" >> "${config}"
grep -q "^lxc.rootfs" "${config}" 2>/dev/null \ grep -q "^lxc.rootfs.path" "${config}" 2>/dev/null \
|| echo "lxc.rootfs = ${rootfs_path}" >> "${config}" || echo "lxc.rootfs.path = ${rootfs_path}" >> "${config}"
# Detect if were in a UserNS and include the right config # Detect if were in a UserNS and include the right config
if [ -z "${LXC_MAPPED_GID+x}" ] || [ -z "${LXC_MAPPED_UID+x}" ]; then if [ -z "${LXC_MAPPED_GID+x}" ] || [ -z "${LXC_MAPPED_UID+x}" ]; then
......
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