confile: lxc.tty --> lxc.tty.max

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2017-07-02 12:37:33 +02:00
parent 2e44ae28dc
commit fe1c588797
No known key found for this signature in database
GPG Key ID: 7B3C391EFEA93624
21 changed files with 55 additions and 35 deletions

View File

@ -2,7 +2,7 @@
lxc.include = @LXCTEMPLATECONFIG@/common.conf lxc.include = @LXCTEMPLATECONFIG@/common.conf
# Allow for 6 tty devices by default # Allow for 6 tty devices by default
lxc.tty = 6 lxc.tty.max = 6
# Set the halt/stop signals # Set the halt/stop signals
lxc.signal.halt=SIGRTMIN+4 lxc.signal.halt=SIGRTMIN+4

View File

@ -7,7 +7,7 @@ lxc.tty.dir = lxc
lxc.pts = 1024 lxc.pts = 1024
# Setup 4 tty devices # Setup 4 tty devices
lxc.tty = 4 lxc.tty.max = 4
# Drop some harmful capabilities # Drop some harmful capabilities
lxc.cap.drop = mac_admin mac_override sys_time sys_module sys_rawio lxc.cap.drop = mac_admin mac_override sys_time sys_module sys_rawio

View File

@ -1,6 +1,6 @@
# Default console settings # Default console settings
lxc.tty.dir = lxc lxc.tty.dir = lxc
lxc.tty = 4 lxc.tty.max = 4
lxc.pts = 1024 lxc.pts = 1024
# Default capabilities # Default capabilities

View File

@ -7,7 +7,7 @@ lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed
lxc.pts = 1024 lxc.pts = 1024
# Setup 1 tty devices for lxc-console command # Setup 1 tty devices for lxc-console command
lxc.tty = 1 lxc.tty.max = 1
# Needed for systemd distro # Needed for systemd distro
lxc.autodev = 1 lxc.autodev = 1

View File

@ -2,7 +2,7 @@
lxc.include = @LXCTEMPLATECONFIG@/common.conf lxc.include = @LXCTEMPLATECONFIG@/common.conf
# Allow for 6 tty devices by default # Allow for 6 tty devices by default
lxc.tty = 6 lxc.tty.max = 6
# Set $VIRTUALIZATION so runit doesn't try to mount filesystems or start udevd # Set $VIRTUALIZATION so runit doesn't try to mount filesystems or start udevd
lxc.environment=VIRTUALIZATION=lxc lxc.environment=VIRTUALIZATION=lxc

View File

@ -718,7 +718,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>
<option>lxc.tty</option> <option>lxc.tty.max</option>
</term> </term>
<listitem> <listitem>
<para> <para>
@ -747,7 +747,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>
<option>lxc.devttydir</option> <option>lxc.tty.dir</option>
</term> </term>
<listitem> <listitem>
<para> <para>

View File

@ -330,7 +330,8 @@ struct lxc_conf {
struct lxc_list caps; struct lxc_list caps;
struct lxc_list keepcaps; struct lxc_list keepcaps;
struct lxc_tty_info tty_info; struct lxc_tty_info tty_info;
char *pty_names; // comma-separated list of lxc.tty pty names /* Comma-separated list of lxc.tty.max pty names. */
char *pty_names;
struct lxc_console console; struct lxc_console console;
struct lxc_rootfs rootfs; struct lxc_rootfs rootfs;
char *ttydir; char *ttydir;

View File

@ -76,7 +76,7 @@ lxc_log_define(lxc_confile, lxc);
lxc_config_define(personality); lxc_config_define(personality);
lxc_config_define(pts); lxc_config_define(pts);
lxc_config_define(tty); lxc_config_define(tty_max);
lxc_config_define(tty_dir); lxc_config_define(tty_dir);
lxc_config_define(apparmor_profile); lxc_config_define(apparmor_profile);
lxc_config_define(apparmor_allow_incomplete); lxc_config_define(apparmor_allow_incomplete);
@ -137,13 +137,18 @@ static struct lxc_config_t config[] = {
{ "lxc.arch", set_config_personality, get_config_personality, clr_config_personality, }, { "lxc.arch", set_config_personality, get_config_personality, clr_config_personality, },
{ "lxc.pts", set_config_pts, get_config_pts, clr_config_pts, }, { "lxc.pts", set_config_pts, get_config_pts, clr_config_pts, },
{ "lxc.tty.dir", set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, }, { "lxc.tty.dir", set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, },
{ "lxc.tty.max", set_config_tty_max, get_config_tty_max, clr_config_tty_max, },
/* REMOVE IN LXC 3.0 /* REMOVE IN LXC 3.0
legacy devttydir key legacy devttydir key
*/ */
{ "lxc.devttydir", set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, }, { "lxc.devttydir", set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, },
{ "lxc.tty", set_config_tty, get_config_tty, clr_config_tty, }, /* REMOVE IN LXC 3.0
legacy tty key
*/
{ "lxc.tty", set_config_tty_max, get_config_tty_max, clr_config_tty_max, },
{ "lxc.apparmor.profile", set_config_apparmor_profile, get_config_apparmor_profile, clr_config_apparmor_profile, }, { "lxc.apparmor.profile", set_config_apparmor_profile, get_config_apparmor_profile, clr_config_apparmor_profile, },
{ "lxc.apparmor.allow_incomplete", set_config_apparmor_allow_incomplete, get_config_apparmor_allow_incomplete, clr_config_apparmor_allow_incomplete, }, { "lxc.apparmor.allow_incomplete", set_config_apparmor_allow_incomplete, get_config_apparmor_allow_incomplete, clr_config_apparmor_allow_incomplete, },
{ "lxc.selinux.context", set_config_selinux_context, get_config_selinux_context, clr_config_selinux_context, }, { "lxc.selinux.context", set_config_selinux_context, get_config_selinux_context, clr_config_selinux_context, },
@ -1313,7 +1318,7 @@ on_error:
return -1; return -1;
} }
static int set_config_tty(const char *key, const char *value, static int set_config_tty_max(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data) struct lxc_conf *lxc_conf, void *data)
{ {
/* Set config value to default. */ /* Set config value to default. */
@ -2795,7 +2800,7 @@ static int get_config_pts(const char *key, char *retv, int inlen,
return lxc_get_conf_int(c, retv, inlen, c->pts); return lxc_get_conf_int(c, retv, inlen, c->pts);
} }
static int get_config_tty(const char *key, char *retv, int inlen, static int get_config_tty_max(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data) struct lxc_conf *c, void *data)
{ {
return lxc_get_conf_int(c, retv, inlen, c->tty); return lxc_get_conf_int(c, retv, inlen, c->tty);
@ -3368,7 +3373,7 @@ static inline int clr_config_pts(const char *key, struct lxc_conf *c,
return 0; return 0;
} }
static inline int clr_config_tty(const char *key, struct lxc_conf *c, static inline int clr_config_tty_max(const char *key, struct lxc_conf *c,
void *data) void *data)
{ {
c->tty = 0; c->tty = 0;

View File

@ -110,7 +110,7 @@ extern int lxc_console_mainloop_add(struct lxc_epoll_descr *, struct lxc_conf *
extern void lxc_console_sigwinch(int sig); extern void lxc_console_sigwinch(int sig);
/* /*
* Connect to one of the ptys given to the container via lxc.tty. * Connect to one of the ptys given to the container via lxc.tty.max.
* - allocates either the current controlling pty (default) or a user specified * - allocates either the current controlling pty (default) or a user specified
* pty as peer pty for the containers tty * pty as peer pty for the containers tty
* - sets up SIGWINCH handler, winsz, and new terminal settings * - sets up SIGWINCH handler, winsz, and new terminal settings
@ -123,10 +123,10 @@ extern int lxc_console(struct lxc_container *c, int ttynum,
int escape); int escape);
/* /*
* Allocate one of the ptys given to the container via lxc.tty. Returns an open * Allocate one of the ptys given to the container via lxc.tty.max. Returns an
* fd to the allocated pty. * open fd to the allocated pty.
* Set ttynum to -1 to allocate the first available pty, or to a value within * Set ttynum to -1 to allocate the first available pty, or to a value within
* the range specified by lxc.tty to allocate a specific pty. * the range specified by lxc.tty.max to allocate a specific pty.
*/ */
extern int lxc_console_getfd(struct lxc_container *c, int *ttynum, extern int lxc_console_getfd(struct lxc_container *c, int *ttynum,
int *masterfd); int *masterfd);

View File

@ -145,7 +145,7 @@ static int test_console(const char *lxcpath,
goto out2; goto out2;
} }
c->load_config(c, NULL); c->load_config(c, NULL);
c->set_config_item(c, "lxc.tty", TTYCNT_STR); c->set_config_item(c, "lxc.tty.max", TTYCNT_STR);
c->save_config(c, NULL); c->save_config(c, NULL);
c->want_daemonize(c, true); c->want_daemonize(c, true);
if (!c->startl(c, 0, NULL)) { if (!c->startl(c, 0, NULL)) {

View File

@ -83,6 +83,11 @@ int main(int argc, char *argv[])
goto out; goto out;
} }
fprintf(stderr, "%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2); fprintf(stderr, "%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2);
/* REMOVE IN LXC 3.0
legacy lxc.tty key
*/
if (!c->set_config_item(c, "lxc.tty", "4")) { if (!c->set_config_item(c, "lxc.tty", "4")) {
fprintf(stderr, "%d: failed to set tty\n", __LINE__); fprintf(stderr, "%d: failed to set tty\n", __LINE__);
goto out; goto out;

View File

@ -32,7 +32,7 @@ lxc-create -t ubuntu -n $name || FAIL "creating container"
cat >> "$(lxc-config lxc.lxcpath)/$name/config" <<EOF cat >> "$(lxc-config lxc.lxcpath)/$name/config" <<EOF
# hax for criu # hax for criu
lxc.console.path = none lxc.console.path = none
lxc.tty = 0 lxc.tty.max = 0
lxc.cgroup.devices.deny = c 5:1 rwm lxc.cgroup.devices.deny = c 5:1 rwm
EOF EOF

View File

@ -307,13 +307,22 @@ int main(int argc, char *argv[])
goto non_test_error; goto non_test_error;
} }
/* lxc.tty */ /* REMOVE IN LXC 3.0
legacy tty.max keys
*/
if (set_get_compare_clear_save_load(c, "lxc.tty", "4", tmpf, true) < if (set_get_compare_clear_save_load(c, "lxc.tty", "4", tmpf, true) <
0) { 0) {
lxc_error("%s\n", "lxc.tty"); lxc_error("%s\n", "lxc.tty");
goto non_test_error; goto non_test_error;
} }
/* lxc.tty.max */
if (set_get_compare_clear_save_load(c, "lxc.tty.max", "4", tmpf, true) <
0) {
lxc_error("%s\n", "lxc.tty.max");
goto non_test_error;
}
/* REMOVE IN LXC 3.0 /* REMOVE IN LXC 3.0
legacy devttydir keys legacy devttydir keys
*/ */

View File

@ -277,7 +277,7 @@ copy_configuration()
grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $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.max = 4
lxc.pts = 1024 lxc.pts = 1024
lxc.cap.drop = sys_module mac_admin mac_override sys_time lxc.cap.drop = sys_module mac_admin mac_override sys_time

View File

@ -121,7 +121,7 @@ systemctl enable systemd-resolved
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
EOF EOF
# enable getty on active ttys # enable getty on active ttys
local nttys=$(cat "${config_path}/config" ${shared_config} ${common_config} | grep "^lxc.tty" | head -n1 | cut -d= -f2 | tr -d "[:blank:]") local nttys=$(cat "${config_path}/config" ${shared_config} ${common_config} | grep "^lxc.tty.max" | head -n1 | cut -d= -f2 | tr -d "[:blank:]")
local devttydir=$(cat "${config_path}/config" ${shared_config} ${common_config} | grep "^lxc.tty.dir" | head -n1 | cut -d= -f2 | tr -d "[:blank:]") local devttydir=$(cat "${config_path}/config" ${shared_config} ${common_config} | grep "^lxc.tty.dir" | head -n1 | cut -d= -f2 | tr -d "[:blank:]")
local devtty="" local devtty=""
# bind getty instances to /dev/<devttydir>/tty* if lxc.tty.dir is set # bind getty instances to /dev/<devttydir>/tty* if lxc.tty.dir is set

View File

@ -344,7 +344,7 @@ cat <<EOF >> $path/config
lxc.signal.halt = SIGUSR1 lxc.signal.halt = SIGUSR1
lxc.rebootsignal = SIGTERM lxc.rebootsignal = SIGTERM
lxc.uts.name = $name lxc.uts.name = $name
lxc.tty = 1 lxc.tty.max = 1
lxc.pts = 1 lxc.pts = 1
lxc.cap.drop = sys_module mac_admin mac_override sys_time lxc.cap.drop = sys_module mac_admin mac_override sys_time

View File

@ -120,7 +120,7 @@ cat >> "$path/config" <<EOF
lxc.rootfs.path = $rootfs lxc.rootfs.path = $rootfs
lxc.tty = 4 lxc.tty.max = 4
lxc.pts = 1024 lxc.pts = 1024
lxc.uts.name = $name lxc.uts.name = $name

View File

@ -265,7 +265,7 @@ configure_debian_systemd()
chroot "${rootfs}" ln -s /dev/null /etc/systemd/system/systemd-udevd.service chroot "${rootfs}" ln -s /dev/null /etc/systemd/system/systemd-udevd.service
chroot "${rootfs}" ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target chroot "${rootfs}" ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
# Setup getty service on the ttys we are going to allow in the # Setup getty service on the ttys we are going to allow in the
# default config. Number should match lxc.tty # default config. Number should match lxc.tty.max
( cd "${rootfs}/etc/systemd/system/getty.target.wants" ( cd "${rootfs}/etc/systemd/system/getty.target.wants"
for i in $(seq 1 "$num_tty") ; do ln -sf ../getty\@.service getty@tty"${i}".service; done ) for i in $(seq 1 "$num_tty") ; do ln -sf ../getty\@.service getty@tty"${i}".service; done )
@ -514,7 +514,7 @@ copy_configuration()
grep -q "^lxc.rootfs.path" "$path/config" 2> /dev/null || echo "lxc.rootfs.path = $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.max = $num_tty
lxc.uts.name = $hostname lxc.uts.name = $hostname
lxc.arch = $arch lxc.arch = $arch
lxc.pts=1023 lxc.pts=1023
@ -795,8 +795,8 @@ if [ -z "$rootfs" ]; then
fi fi
# determine the number of ttys - default is 4 # determine the number of ttys - default is 4
if grep -q '^lxc.tty' "$config" 2> /dev/null ; then if grep -q '^lxc.tty.max' "$config" 2> /dev/null ; then
num_tty=$(awk -F= '/^lxc.tty[ \t]+=/{ print $2 }' "$config") num_tty=$(awk -F= '/^lxc.tty.max[ \t]+=/{ print $2 }' "$config")
else else
num_tty=4 num_tty=4
fi fi

View File

@ -706,7 +706,7 @@ ${conf_arch_line}
# set the hostname # set the hostname
lxc.uts.name = ${name} lxc.uts.name = ${name}
lxc.tty = ${tty} lxc.tty.max = ${tty}
${conf_rootfs_line} ${conf_rootfs_line}
${portage_mount} ${portage_mount}

View File

@ -229,7 +229,7 @@ copy_configuration()
grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $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.max = 4
lxc.pts = 1024 lxc.pts = 1024
lxc.cap.drop = sys_module mac_admin mac_override sys_time lxc.cap.drop = sys_module mac_admin mac_override sys_time
lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed

View File

@ -138,7 +138,7 @@ configure_pld_systemd()
> ${rootfs_path}/etc/systemd/system/getty@.service > ${rootfs_path}/etc/systemd/system/getty@.service
# Setup getty service on the 4 ttys we are going to allow in the # Setup getty service on the 4 ttys we are going to allow in the
# default config. Number should match lxc.tty # default config. Number should match lxc.tty.max
for i in 1 2 3 4; do for i in 1 2 3 4; do
ln -sf ../getty@.service ${rootfs_path}/etc/systemd/system/getty.target.wants/getty@tty${i}.service ln -sf ../getty@.service ${rootfs_path}/etc/systemd/system/getty.target.wants/getty@tty${i}.service
done done
@ -239,7 +239,7 @@ copy_configuration()
# 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
lxc.uts.name = $utsname lxc.uts.name = $utsname
lxc.tty = 4 lxc.tty.max = 4
lxc.pts = 1024 lxc.pts = 1024
# Consider if below line is right for systemd container # Consider if below line is right for systemd container
lxc.mount.fstab = $config_path/fstab lxc.mount.fstab = $config_path/fstab