From: Christian Brauner Date: Sat, 10 Feb 2018 23:12:36 +0000 (+0100) Subject: tree-wide: remove legacy codepaths X-Git-Tag: lxc-3.0.0.beta1~35^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fba98b52458cd94cd0590ec5d0d757ecfb39abe;p=thirdparty%2Flxc.git tree-wide: remove legacy codepaths Signed-off-by: Christian Brauner --- diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index bcd37290a..f56436bbc 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -25,7 +25,6 @@ noinst_HEADERS = \ caps.h \ conf.h \ confile.h \ - confile_legacy.h \ confile_utils.h \ console.h \ error.h \ @@ -113,7 +112,6 @@ liblxc_la_SOURCES = \ namespace.h namespace.c \ conf.c conf.h \ confile.c confile.h \ - confile_legacy.c confile_legacy.h \ confile_utils.c confile_utils.h \ list.h \ state.c state.h \ diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 2e90976a9..c5f27336a 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -391,12 +391,6 @@ struct lxc_conf { /* RLIMIT_* limits */ struct lxc_list limits; - /* REMOVE IN LXC 3.0 - * Indicator whether the current config file we're using contained any - * legacy configuration keys. - */ - bool contains_legacy_key; - /* Contains generic info about the cgroup configuration for this * container. Note that struct lxc_cgroup contains a union. It is only * valid to access the members of the anonymous "meta" struct within diff --git a/src/lxc/confile.c b/src/lxc/confile.c index e460ab395..66b7615fe 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -47,7 +47,6 @@ #include "conf.h" #include "config.h" #include "confile.h" -#include "confile_legacy.h" #include "confile_utils.h" #include "log.h" #include "lxcseccomp.h" @@ -128,11 +127,9 @@ lxc_config_define(net_type); lxc_config_define(net_veth_pair); lxc_config_define(net_vlan_id); lxc_config_define(no_new_privs); -lxc_config_define(noop); lxc_config_define(personality); lxc_config_define(prlimit); lxc_config_define(pty_max); -lxc_config_define(rootfs_backend); lxc_config_define(rootfs_mount); lxc_config_define(rootfs_options); lxc_config_define(rootfs_path); @@ -149,138 +146,88 @@ lxc_config_define(sysctl); lxc_config_define(proc); static struct lxc_config_t config[] = { - /* REMOVE in LXC 3.0 */ - { "lxc.arch", false, set_config_personality, get_config_personality, clr_config_personality, }, - { "lxc.apparmor.profile", false, set_config_apparmor_profile, get_config_apparmor_profile, clr_config_apparmor_profile, }, - { "lxc.apparmor.allow_incomplete", false, set_config_apparmor_allow_incomplete, get_config_apparmor_allow_incomplete, clr_config_apparmor_allow_incomplete, }, - { "lxc.autodev", false, set_config_autodev, get_config_autodev, clr_config_autodev, }, - { "lxc.cap.drop", false, set_config_cap_drop, get_config_cap_drop, clr_config_cap_drop, }, - { "lxc.cap.keep", false, set_config_cap_keep, get_config_cap_keep, clr_config_cap_keep, }, - { "lxc.cgroup2", false, set_config_cgroup2_controller, get_config_cgroup2_controller, clr_config_cgroup2_controller, }, - { "lxc.cgroup.dir", false, set_config_cgroup_dir, get_config_cgroup_dir, clr_config_cgroup_dir, }, - { "lxc.cgroup", false, set_config_cgroup_controller, get_config_cgroup_controller, clr_config_cgroup_controller, }, - { "lxc.console.buffer.logfile", false, set_config_console_buffer_logfile, get_config_console_buffer_logfile, clr_config_console_buffer_logfile, }, - { "lxc.console.buffer.size", false, set_config_console_buffer_size, get_config_console_buffer_size, clr_config_console_buffer_size, }, - { "lxc.console.logfile", false, set_config_console_logfile, get_config_console_logfile, clr_config_console_logfile, }, - { "lxc.console.path", false, set_config_console_path, get_config_console_path, clr_config_console_path, }, - { "lxc.console.rotate", false, set_config_console_rotate, get_config_console_rotate, clr_config_console_rotate, }, - { "lxc.environment", false, set_config_environment, get_config_environment, clr_config_environment, }, - { "lxc.ephemeral", false, set_config_ephemeral, get_config_ephemeral, clr_config_ephemeral, }, - { "lxc.execute.cmd", false, set_config_execute_cmd, get_config_execute_cmd, clr_config_execute_cmd, }, - { "lxc.group", false, set_config_group, get_config_group, clr_config_group, }, - { "lxc.hook.autodev", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.clone", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.destroy", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.mount", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.post-stop", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.pre-mount", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.pre-start", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.start", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.start-host", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.stop", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.hook.version", false, set_config_hooks_version, get_config_hooks_version, clr_config_hooks_version, }, - { "lxc.hook", false, set_config_hooks, get_config_hooks, clr_config_hooks, }, - { "lxc.idmap", false, set_config_idmaps, get_config_idmaps, clr_config_idmaps, }, - { "lxc.include", false, set_config_includefiles, get_config_includefiles, clr_config_includefiles, }, - { "lxc.init.cmd", false, set_config_init_cmd, get_config_init_cmd, clr_config_init_cmd, }, - { "lxc.init.gid", false, set_config_init_gid, get_config_init_gid, clr_config_init_gid, }, - { "lxc.init.uid", false, set_config_init_uid, get_config_init_uid, clr_config_init_uid, }, - { "lxc.init.cwd", false, set_config_init_cwd, get_config_init_cwd, clr_config_init_cwd, }, - { "lxc.log.file", false, set_config_log_file, get_config_log_file, clr_config_log_file, }, - { "lxc.log.level", false, set_config_log_level, get_config_log_level, clr_config_log_level, }, - { "lxc.log.syslog", false, set_config_log_syslog, get_config_log_syslog, clr_config_log_syslog, }, - { "lxc.monitor.unshare", false, set_config_monitor, get_config_monitor, clr_config_monitor, }, - { "lxc.mount.auto", false, set_config_mount_auto, get_config_mount_auto, clr_config_mount_auto, }, - { "lxc.mount.entry", false, set_config_mount, get_config_mount, clr_config_mount, }, - { "lxc.mount.fstab", false, set_config_mount_fstab, get_config_mount_fstab, clr_config_mount_fstab, }, - { "lxc.namespace.clone", false, set_config_namespace_clone, get_config_namespace_clone, clr_config_namespace_clone, }, - { "lxc.namespace.keep", false, set_config_namespace_keep, get_config_namespace_keep, clr_config_namespace_keep, }, - { "lxc.namespace.share", false, set_config_namespace_share, get_config_namespace_share, clr_config_namespace_share, }, - - /* [START]: REMOVE IN LXC 3.0 */ - { "lxc.network.type", true, set_config_network_legacy_type, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.flags", true, set_config_network_legacy_flags, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.link", true, set_config_network_legacy_link, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.name", true, set_config_network_legacy_name, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.macvlan.mode", true, set_config_network_legacy_macvlan_mode, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.veth.pair", true, set_config_network_legacy_veth_pair, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.script.up", true, set_config_network_legacy_script_up, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.script.down", true, set_config_network_legacy_script_down, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.hwaddr", true, set_config_network_legacy_hwaddr, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.mtu", true, set_config_network_legacy_mtu, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.vlan.id", true, set_config_network_legacy_vlan_id, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.ipv4.gateway", true, set_config_network_legacy_ipv4_gateway, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.ipv4", true, set_config_network_legacy_ipv4, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.ipv6.gateway", true, set_config_network_legacy_ipv6_gateway, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.ipv6", true, set_config_network_legacy_ipv6, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network.", true, set_config_network_legacy_nic, get_config_network_legacy_item, clr_config_network_legacy_item, }, - { "lxc.network", true, set_config_network_legacy, get_config_network_legacy, clr_config_network_legacy, }, - /* [END]: REMOVE IN LXC 3.0 */ - - { "lxc.net.flags", false, set_config_net_flags, get_config_net_flags, clr_config_net_flags, }, - { "lxc.net.hwaddr", false, set_config_net_hwaddr, get_config_net_hwaddr, clr_config_net_hwaddr, }, - { "lxc.net.ipv4.address", false, set_config_net_ipv4_address, get_config_net_ipv4_address, clr_config_net_ipv4_address, }, - { "lxc.net.ipv4.gateway", false, set_config_net_ipv4_gateway, get_config_net_ipv4_gateway, clr_config_net_ipv4_gateway, }, - { "lxc.net.ipv6.address", false, set_config_net_ipv6_address, get_config_net_ipv6_address, clr_config_net_ipv6_address, }, - { "lxc.net.ipv6.gateway", false, set_config_net_ipv6_gateway, get_config_net_ipv6_gateway, clr_config_net_ipv6_gateway, }, - { "lxc.net.link", false, set_config_net_link, get_config_net_link, clr_config_net_link, }, - { "lxc.net.macvlan.mode", false, set_config_net_macvlan_mode, get_config_net_macvlan_mode, clr_config_net_macvlan_mode, }, - { "lxc.net.mtu", false, set_config_net_mtu, get_config_net_mtu, clr_config_net_mtu, }, - { "lxc.net.name", false, set_config_net_name, get_config_net_name, clr_config_net_name, }, - { "lxc.net.script.down", false, set_config_net_script_down, get_config_net_script_down, clr_config_net_script_down, }, - { "lxc.net.script.up", false, set_config_net_script_up, get_config_net_script_up, clr_config_net_script_up, }, - { "lxc.net.type", false, set_config_net_type, get_config_net_type, clr_config_net_type, }, - { "lxc.net.vlan.id", false, set_config_net_vlan_id, get_config_net_vlan_id, clr_config_net_vlan_id, }, - { "lxc.net.veth.pair", false, set_config_net_veth_pair, get_config_net_veth_pair, clr_config_net_veth_pair, }, - { "lxc.net.", false, set_config_net_nic, get_config_net_nic, clr_config_net_nic, }, - { "lxc.net", false, set_config_net, get_config_net, clr_config_net, }, - { "lxc.no_new_privs", false, set_config_no_new_privs, get_config_no_new_privs, clr_config_no_new_privs, }, - { "lxc.prlimit", false, set_config_prlimit, get_config_prlimit, clr_config_prlimit, }, - { "lxc.pty.max", false, set_config_pty_max, get_config_pty_max, clr_config_pty_max, }, - { "lxc.rootfs.mount", false, set_config_rootfs_mount, get_config_rootfs_mount, clr_config_rootfs_mount, }, - { "lxc.rootfs.options", false, set_config_rootfs_options, get_config_rootfs_options, clr_config_rootfs_options, }, - { "lxc.rootfs.path", false, set_config_rootfs_path, get_config_rootfs_path, clr_config_rootfs_path, }, - { "lxc.seccomp.profile", false, set_config_seccomp_profile, get_config_seccomp_profile, clr_config_seccomp_profile, }, - { "lxc.selinux.context", false, set_config_selinux_context, get_config_selinux_context, clr_config_selinux_context, }, - { "lxc.signal.halt", false, set_config_signal_halt, get_config_signal_halt, clr_config_signal_halt, }, - { "lxc.signal.reboot", false, set_config_signal_reboot, get_config_signal_reboot, clr_config_signal_reboot, }, - { "lxc.signal.stop", false, set_config_signal_stop, get_config_signal_stop, clr_config_signal_stop, }, - { "lxc.start.auto", false, set_config_start, get_config_start, clr_config_start, }, - { "lxc.start.delay", false, set_config_start, get_config_start, clr_config_start, }, - { "lxc.start.order", false, set_config_start, get_config_start, clr_config_start, }, - { "lxc.tty.dir", false, set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, }, - { "lxc.tty.max", false, set_config_tty_max, get_config_tty_max, clr_config_tty_max, }, - { "lxc.uts.name", false, set_config_uts_name, get_config_uts_name, clr_config_uts_name, }, - { "lxc.sysctl", false, set_config_sysctl, get_config_sysctl, clr_config_sysctl, }, - { "lxc.proc", false, set_config_proc, get_config_proc, clr_config_proc, }, - - /* [START]: REMOVE IN LXC 3.0 */ - { "lxc.pts", true, set_config_pty_max, get_config_pty_max, clr_config_pty_max, }, - { "lxc.devttydir", true, set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, }, - { "lxc.tty", true, set_config_tty_max, get_config_tty_max, clr_config_tty_max, }, - { "lxc.aa_profile", true, set_config_lsm_aa_profile, get_config_lsm_aa_profile, clr_config_lsm_aa_profile, }, - { "lxc.aa_allow_incomplete", true, set_config_lsm_aa_incomplete, get_config_lsm_aa_incomplete, clr_config_lsm_aa_incomplete, }, - { "lxc.se_context", true, set_config_lsm_se_context, get_config_lsm_se_context, clr_config_lsm_se_context, }, - { "lxc.id_map", true, set_config_idmaps, get_config_idmaps, clr_config_idmaps, }, - { "lxc.mount", true, set_config_mount_fstab, get_config_mount_fstab, clr_config_mount_fstab, }, - { "lxc.rootfs.backend", true, set_config_rootfs_backend, get_config_rootfs_backend, clr_config_rootfs_backend, }, - { "lxc.rootfs", true, set_config_rootfs_path, get_config_rootfs_path, clr_config_rootfs_path, }, - { "lxc.utsname", true, set_config_uts_name, get_config_uts_name, clr_config_uts_name, }, - { "lxc.seccomp", true, set_config_seccomp_profile, get_config_seccomp_profile, clr_config_seccomp_profile, }, - { "lxc.console", true, set_config_console_path, get_config_console_path, clr_config_console_path, }, - { "lxc.haltsignal", true, set_config_signal_halt, get_config_signal_halt, clr_config_signal_halt, }, - { "lxc.rebootsignal", true, set_config_signal_reboot, get_config_signal_reboot, clr_config_signal_reboot, }, - { "lxc.stopsignal", true, set_config_signal_stop, get_config_signal_stop, clr_config_signal_stop, }, - { "lxc.syslog", true, set_config_log_syslog, get_config_log_syslog, clr_config_log_syslog, }, - { "lxc.kmsg", true, set_config_noop, get_config_noop, clr_config_noop, }, - { "lxc.loglevel", true, set_config_log_level, get_config_log_level, clr_config_log_level, }, - { "lxc.logfile", true, set_config_log_file, get_config_log_file, clr_config_log_file, }, - { "lxc.init_cmd", true, set_config_init_cmd, get_config_init_cmd, clr_config_init_cmd, }, - { "lxc.init_uid", true, set_config_init_uid, get_config_init_uid, clr_config_init_uid, }, - { "lxc.init_gid", true, set_config_init_gid, get_config_init_gid, clr_config_init_gid, }, - { "lxc.limit", true, set_config_limit, get_config_limit, clr_config_limit, }, - { "lxc.pivotdir", true, set_config_noop, get_config_noop, clr_config_noop, }, - /* [END]: REMOVE IN LXC 3.0 */ + { "lxc.arch", set_config_personality, get_config_personality, clr_config_personality, }, + { "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.autodev", set_config_autodev, get_config_autodev, clr_config_autodev, }, + { "lxc.cap.drop", set_config_cap_drop, get_config_cap_drop, clr_config_cap_drop, }, + { "lxc.cap.keep", set_config_cap_keep, get_config_cap_keep, clr_config_cap_keep, }, + { "lxc.cgroup2", set_config_cgroup2_controller, get_config_cgroup2_controller, clr_config_cgroup2_controller, }, + { "lxc.cgroup.dir", set_config_cgroup_dir, get_config_cgroup_dir, clr_config_cgroup_dir, }, + { "lxc.cgroup", set_config_cgroup_controller, get_config_cgroup_controller, clr_config_cgroup_controller, }, + { "lxc.console.buffer.logfile", set_config_console_buffer_logfile, get_config_console_buffer_logfile, clr_config_console_buffer_logfile, }, + { "lxc.console.buffer.size", set_config_console_buffer_size, get_config_console_buffer_size, clr_config_console_buffer_size, }, + { "lxc.console.logfile", set_config_console_logfile, get_config_console_logfile, clr_config_console_logfile, }, + { "lxc.console.path", set_config_console_path, get_config_console_path, clr_config_console_path, }, + { "lxc.console.rotate", set_config_console_rotate, get_config_console_rotate, clr_config_console_rotate, }, + { "lxc.environment", set_config_environment, get_config_environment, clr_config_environment, }, + { "lxc.ephemeral", set_config_ephemeral, get_config_ephemeral, clr_config_ephemeral, }, + { "lxc.execute.cmd", set_config_execute_cmd, get_config_execute_cmd, clr_config_execute_cmd, }, + { "lxc.group", set_config_group, get_config_group, clr_config_group, }, + { "lxc.hook.autodev", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.clone", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.destroy", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.mount", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.post-stop", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.pre-mount", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.pre-start", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.start", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.start-host", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.stop", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.hook.version", set_config_hooks_version, get_config_hooks_version, clr_config_hooks_version, }, + { "lxc.hook", set_config_hooks, get_config_hooks, clr_config_hooks, }, + { "lxc.idmap", set_config_idmaps, get_config_idmaps, clr_config_idmaps, }, + { "lxc.include", set_config_includefiles, get_config_includefiles, clr_config_includefiles, }, + { "lxc.init.cmd", set_config_init_cmd, get_config_init_cmd, clr_config_init_cmd, }, + { "lxc.init.gid", set_config_init_gid, get_config_init_gid, clr_config_init_gid, }, + { "lxc.init.uid", set_config_init_uid, get_config_init_uid, clr_config_init_uid, }, + { "lxc.init.cwd", set_config_init_cwd, get_config_init_cwd, clr_config_init_cwd, }, + { "lxc.log.file", set_config_log_file, get_config_log_file, clr_config_log_file, }, + { "lxc.log.level", set_config_log_level, get_config_log_level, clr_config_log_level, }, + { "lxc.log.syslog", set_config_log_syslog, get_config_log_syslog, clr_config_log_syslog, }, + { "lxc.monitor.unshare", set_config_monitor, get_config_monitor, clr_config_monitor, }, + { "lxc.mount.auto", set_config_mount_auto, get_config_mount_auto, clr_config_mount_auto, }, + { "lxc.mount.entry", set_config_mount, get_config_mount, clr_config_mount, }, + { "lxc.mount.fstab", set_config_mount_fstab, get_config_mount_fstab, clr_config_mount_fstab, }, + { "lxc.namespace.clone", set_config_namespace_clone, get_config_namespace_clone, clr_config_namespace_clone, }, + { "lxc.namespace.keep", set_config_namespace_keep, get_config_namespace_keep, clr_config_namespace_keep, }, + { "lxc.namespace.share", set_config_namespace_share, get_config_namespace_share, clr_config_namespace_share, }, + { "lxc.net.flags", set_config_net_flags, get_config_net_flags, clr_config_net_flags, }, + { "lxc.net.hwaddr", set_config_net_hwaddr, get_config_net_hwaddr, clr_config_net_hwaddr, }, + { "lxc.net.ipv4.address", set_config_net_ipv4_address, get_config_net_ipv4_address, clr_config_net_ipv4_address, }, + { "lxc.net.ipv4.gateway", set_config_net_ipv4_gateway, get_config_net_ipv4_gateway, clr_config_net_ipv4_gateway, }, + { "lxc.net.ipv6.address", set_config_net_ipv6_address, get_config_net_ipv6_address, clr_config_net_ipv6_address, }, + { "lxc.net.ipv6.gateway", set_config_net_ipv6_gateway, get_config_net_ipv6_gateway, clr_config_net_ipv6_gateway, }, + { "lxc.net.link", set_config_net_link, get_config_net_link, clr_config_net_link, }, + { "lxc.net.macvlan.mode", set_config_net_macvlan_mode, get_config_net_macvlan_mode, clr_config_net_macvlan_mode, }, + { "lxc.net.mtu", set_config_net_mtu, get_config_net_mtu, clr_config_net_mtu, }, + { "lxc.net.name", set_config_net_name, get_config_net_name, clr_config_net_name, }, + { "lxc.net.script.down", set_config_net_script_down, get_config_net_script_down, clr_config_net_script_down, }, + { "lxc.net.script.up", set_config_net_script_up, get_config_net_script_up, clr_config_net_script_up, }, + { "lxc.net.type", set_config_net_type, get_config_net_type, clr_config_net_type, }, + { "lxc.net.vlan.id", set_config_net_vlan_id, get_config_net_vlan_id, clr_config_net_vlan_id, }, + { "lxc.net.veth.pair", set_config_net_veth_pair, get_config_net_veth_pair, clr_config_net_veth_pair, }, + { "lxc.net.", set_config_net_nic, get_config_net_nic, clr_config_net_nic, }, + { "lxc.net", set_config_net, get_config_net, clr_config_net, }, + { "lxc.no_new_privs", set_config_no_new_privs, get_config_no_new_privs, clr_config_no_new_privs, }, + { "lxc.prlimit", set_config_prlimit, get_config_prlimit, clr_config_prlimit, }, + { "lxc.pty.max", set_config_pty_max, get_config_pty_max, clr_config_pty_max, }, + { "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.path", set_config_rootfs_path, get_config_rootfs_path, clr_config_rootfs_path, }, + { "lxc.seccomp.profile", set_config_seccomp_profile, get_config_seccomp_profile, clr_config_seccomp_profile, }, + { "lxc.selinux.context", set_config_selinux_context, get_config_selinux_context, clr_config_selinux_context, }, + { "lxc.signal.halt", set_config_signal_halt, get_config_signal_halt, clr_config_signal_halt, }, + { "lxc.signal.reboot", set_config_signal_reboot, get_config_signal_reboot, clr_config_signal_reboot, }, + { "lxc.signal.stop", set_config_signal_stop, get_config_signal_stop, clr_config_signal_stop, }, + { "lxc.start.auto", set_config_start, get_config_start, clr_config_start, }, + { "lxc.start.delay", set_config_start, get_config_start, clr_config_start, }, + { "lxc.start.order", set_config_start, get_config_start, clr_config_start, }, + { "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, }, + { "lxc.uts.name", set_config_uts_name, get_config_uts_name, clr_config_uts_name, }, + { "lxc.sysctl", set_config_sysctl, get_config_sysctl, clr_config_sysctl, }, + { "lxc.proc", set_config_proc, get_config_proc, clr_config_proc, }, }; struct signame { @@ -2152,12 +2099,6 @@ static int set_config_rootfs_options(const char *key, const char *value, return set_config_string_item(&lxc_conf->rootfs.options, value); } -static int set_config_rootfs_backend(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - return 0; -} - static int set_config_uts_name(const char *key, const char *value, struct lxc_conf *lxc_conf, void *data) { @@ -2352,24 +2293,6 @@ static int parse_line(char *buffer, void *data) goto on_error; } - /* [START]: REMOVE IN LXC 3.0 */ - if (config->is_legacy_key && !plc->conf->contains_legacy_key) { - plc->conf->contains_legacy_key = true; - if (getenv("LXC_UPDATE_CONFIG_FORMAT")) { - /* Warn the user once loud and clear that there is at - * least one legacy configuration item in the - * configuration file and then an update is required. - */ - fprintf(stderr, "The configuration file contains " - "legacy configuration keys.\nPlease " - "update your configuration file!\nThe " - "update script lxc-update-config -c " - " can be used for " - "this.\n"); - } - } - /* [END]: REMOVE IN LXC 3.0 */ - ret = config->set(key, value, plc->conf, NULL); on_error: @@ -2893,12 +2816,6 @@ static int set_config_no_new_privs(const char *key, const char *value, return 0; } -static int set_config_noop(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - return 0; -} - /* Callbacks to get configuration items. */ static int get_config_personality(const char *key, char *retv, int inlen, struct lxc_conf *c, void *data) @@ -3237,12 +3154,6 @@ static int get_config_rootfs_options(const char *key, char *retv, int inlen, return lxc_get_conf_str(retv, inlen, c->rootfs.options); } -static int get_config_rootfs_backend(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - return 0; -} - static int get_config_uts_name(const char *key, char *retv, int inlen, struct lxc_conf *c, void *data) { @@ -3643,12 +3554,6 @@ static int get_config_proc(const char *key, char *retv, int inlen, return fulllen; } -static int get_config_noop(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - return 0; -} - static int get_config_namespace_clone(const char *key, char *retv, int inlen, struct lxc_conf *c, void *data) { @@ -3851,12 +3756,6 @@ static inline int clr_config_rootfs_options(const char *key, struct lxc_conf *c, return 0; } -static inline int clr_config_rootfs_backend(const char *key, struct lxc_conf *c, - void *data) -{ - return 0; -} - static inline int clr_config_uts_name(const char *key, struct lxc_conf *c, void *data) { @@ -4091,12 +3990,6 @@ static inline int clr_config_includefiles(const char *key, struct lxc_conf *c, return 0; } -static inline int clr_config_noop(const char *key, struct lxc_conf *c, - void *data) -{ - return 0; -} - static int clr_config_namespace_clone(const char *key, struct lxc_conf *lxc_conf, void *data) { diff --git a/src/lxc/confile.h b/src/lxc/confile.h index 6c69bc7a5..c8929658e 100644 --- a/src/lxc/confile.h +++ b/src/lxc/confile.h @@ -53,7 +53,6 @@ typedef int (*config_clr_cb)(const char *key, struct lxc_conf *conf, struct lxc_config_t { char *name; - bool is_legacy_key; /* REMOVE in LXC 3.0 */ config_set_cb set; config_get_cb get; config_clr_cb clr; diff --git a/src/lxc/confile_legacy.c b/src/lxc/confile_legacy.c deleted file mode 100644 index df419e640..000000000 --- a/src/lxc/confile_legacy.c +++ /dev/null @@ -1,1244 +0,0 @@ -/* - * lxc: linux Container library - * (C) Copyright IBM Corp. 2007, 2008 - * - * Authors: - * Daniel Lezcano - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#define _GNU_SOURCE -#define __STDC_FORMAT_MACROS /* Required for PRIu64 to work. */ -#include -#include -#include -#include -#include -#include -#include -#include /* Required for PRIu64 to work. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "parse.h" -#include "config.h" -#include "confile.h" -#include "confile_utils.h" -#include "confile_legacy.h" -#include "utils.h" -#include "log.h" -#include "conf.h" -#include "network.h" -#include "lxcseccomp.h" -#include "storage.h" - -#if HAVE_IFADDRS_H -#include -#else -#include <../include/ifaddrs.h> -#endif - -lxc_log_define(lxc_confile_legacy, lxc); - -/* - * Config entry is something like "lxc.network.0.ipv4" the key 'lxc.network.' - * was found. So we make sure next comes an integer, find the right callback - * (by rewriting the key), and call it. - */ -int set_config_network_legacy_nic(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - char *copy = strdup(key), *p; - int ret = -1; - struct lxc_config_t *config; - - if (!copy) { - SYSERROR("failed to allocate memory"); - return -1; - } - /* - * Ok we know that to get here we've got "lxc.network." - * and it isn't any of the other network entries. So - * after the second . Should come an integer (# of defined - * nic) followed by a valid entry. - */ - if (*(key + 12) < '0' || *(key + 12) > '9') - goto out; - - p = strchr(key + 12, '.'); - if (!p) - goto out; - - if (strlen(p + 1) == 0) { - ERROR("No subkey in network configuration key \"%s\"", key); - goto out; - } - strcpy(copy + 12, p + 1); - config = lxc_get_config(copy); - if (!config) { - ERROR("unknown key %s", key); - goto out; - } - ret = config->set(key, value, lxc_conf, NULL); - -out: - free(copy); - return ret; -} - -static void lxc_remove_nic(struct lxc_list *it) -{ - struct lxc_netdev *netdev = it->elem; - struct lxc_list *it2,*next; - - lxc_list_del(it); - - free(netdev->upscript); - free(netdev->downscript); - free(netdev->hwaddr); - free(netdev->mtu); - free(netdev->ipv4_gateway); - free(netdev->ipv6_gateway); - lxc_list_for_each_safe(it2, &netdev->ipv4, next) { - lxc_list_del(it2); - free(it2->elem); - free(it2); - } - lxc_list_for_each_safe(it2, &netdev->ipv6, next) { - lxc_list_del(it2); - free(it2->elem); - free(it2); - } - free(netdev); - free(it); -} - -static int lxc_clear_config_network(struct lxc_conf *c) -{ - struct lxc_list *it,*next; - lxc_list_for_each_safe(it, &c->network, next) { - lxc_remove_nic(it); - } - return 0; -} - -int set_config_network_legacy(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - if (!lxc_config_value_empty(value)) { - ERROR("lxc.network must not have a value"); - return -1; - } - - return lxc_clear_config_network(lxc_conf); -} - -/* - * If you have p="lxc.network.0.link", pass it p+12 - * to get back '0' (the index of the nic). - */ -static int get_network_netdev_idx(const char *key) -{ - int ret, idx; - - if (*key < '0' || *key > '9') - return EINVAL; - - ret = sscanf(key, "%d", &idx); - if (ret != 1) - return EINVAL; - - /* Since we've implemented the new network parser legacy networks are - * recorded using a negative index starting from -1. To preserve the old - * behavior we need this function to return the appropriate negative - * index. - */ - return -(++idx); -} - -/* - * If you have p="lxc.network.0", pass this p+12 and it will return - * the netdev of the first configured nic. - */ -static struct lxc_netdev *get_netdev_from_key(const char *key, - struct lxc_list *network) -{ - int idx; - struct lxc_list *it; - struct lxc_netdev *netdev = NULL; - - idx = get_network_netdev_idx(key); - if (idx == EINVAL) - return NULL; - - lxc_list_for_each(it, network) { - netdev = it->elem; - if (idx == netdev->idx) - return netdev; - } - - return NULL; -} - -int set_config_network_legacy_type(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_list *network = &lxc_conf->network; - struct lxc_netdev *netdev, *prevnetdev; - struct lxc_list *list; - - if (lxc_config_value_empty(value)) - return lxc_clear_config_network(lxc_conf); - - netdev = get_netdev_from_key(key + 12, network); - if (netdev) { - ERROR("Network already exists"); - return -EEXIST; - } - - netdev = malloc(sizeof(*netdev)); - if (!netdev) { - SYSERROR("failed to allocate memory"); - return -1; - } - - memset(netdev, 0, sizeof(*netdev)); - lxc_list_init(&netdev->ipv4); - lxc_list_init(&netdev->ipv6); - - list = malloc(sizeof(*list)); - if (!list) { - SYSERROR("failed to allocate memory"); - free(netdev); - return -1; - } - - lxc_list_init(list); - lxc_list_add_elem(list, netdev); - - /* We maintain a negative count for legacy networks. */ - netdev->idx = -1; - if (!lxc_list_empty(network)) { - prevnetdev = lxc_list_first_elem(network); - netdev->idx = prevnetdev->idx; - if (netdev->idx == INT_MIN) { - ERROR("number of requested networks would underflow " - "counter"); - free(netdev); - free(list); - return -1; - } - netdev->idx--; - } - - lxc_list_add(network, list); - - if (!strcmp(value, "veth")) - netdev->type = LXC_NET_VETH; - else if (!strcmp(value, "macvlan")) { - netdev->type = LXC_NET_MACVLAN; - lxc_macvlan_mode_to_flag(&netdev->priv.macvlan_attr.mode, "private"); - } else if (!strcmp(value, "vlan")) - netdev->type = LXC_NET_VLAN; - else if (!strcmp(value, "phys")) - netdev->type = LXC_NET_PHYS; - else if (!strcmp(value, "empty")) - netdev->type = LXC_NET_EMPTY; - else if (!strcmp(value, "none")) - netdev->type = LXC_NET_NONE; - else { - ERROR("invalid network type %s", value); - return -1; - } - return 0; -} - -int lxc_list_nicconfigs_legacy(struct lxc_conf *c, const char *key, char *retv, - int inlen) -{ - struct lxc_netdev *netdev; - int len; - int fulllen = 0; - - netdev = get_netdev_from_key(key + 12, &c->network); - if (!netdev) - return -1; - - if (!retv) - inlen = 0; - else - memset(retv, 0, inlen); - - strprint(retv, inlen, "type\n"); - strprint(retv, inlen, "script.up\n"); - strprint(retv, inlen, "script.down\n"); - if (netdev->type != LXC_NET_EMPTY) { - strprint(retv, inlen, "flags\n"); - strprint(retv, inlen, "link\n"); - strprint(retv, inlen, "name\n"); - strprint(retv, inlen, "hwaddr\n"); - strprint(retv, inlen, "mtu\n"); - strprint(retv, inlen, "ipv6\n"); - strprint(retv, inlen, "ipv6.gateway\n"); - strprint(retv, inlen, "ipv4\n"); - strprint(retv, inlen, "ipv4.gateway\n"); - } - - switch (netdev->type) { - case LXC_NET_VETH: - strprint(retv, inlen, "veth.pair\n"); - break; - case LXC_NET_MACVLAN: - strprint(retv, inlen, "macvlan.mode\n"); - break; - case LXC_NET_VLAN: - strprint(retv, inlen, "vlan.id\n"); - break; - case LXC_NET_PHYS: - break; - } - - return fulllen; -} - -static struct lxc_netdev *network_netdev(const char *key, const char *value, - struct lxc_list *network) -{ - struct lxc_netdev *netdev = NULL; - - if (lxc_list_empty(network)) { - ERROR("network is not created for '%s' = '%s' option", key, - value); - return NULL; - } - - if (get_network_netdev_idx(key + 12) == EINVAL) - netdev = lxc_list_first_elem(network); - else - netdev = get_netdev_from_key(key + 12, network); - - if (!netdev) { - ERROR("no network device defined for '%s' = '%s' option", key, - value); - return NULL; - } - - return netdev; -} - -int set_config_network_legacy_flags(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - netdev->flags |= IFF_UP; - - return 0; -} - -static int create_matched_ifnames(const char *value, struct lxc_conf *lxc_conf, - struct lxc_netdev *netdev) -{ - struct ifaddrs *ifaddr, *ifa; - int n; - int ret = 0; - const char *type_key = "lxc.network.type"; - const char *link_key = "lxc.network.link"; - const char *tmpvalue = "phys"; - - if (getifaddrs(&ifaddr) == -1) { - SYSERROR("Get network interfaces failed"); - return -1; - } - - for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) { - if (!ifa->ifa_addr) - continue; - if (ifa->ifa_addr->sa_family != AF_PACKET) - continue; - - if (!strncmp(value, ifa->ifa_name, strlen(value) - 1)) { - ret = set_config_network_legacy_type(type_key, tmpvalue, - lxc_conf, netdev); - if (!ret) { - ret = set_config_network_legacy_link( - link_key, ifa->ifa_name, lxc_conf, netdev); - if (ret) { - ERROR("failed to create matched ifnames"); - break; - } - } else { - ERROR("failed to create matched ifnames"); - break; - } - } - } - - freeifaddrs(ifaddr); - ifaddr = NULL; - - return ret; -} - -int set_config_network_legacy_link(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - struct lxc_list *it; - int ret = 0; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - if (value[strlen(value) - 1] == '+' && netdev->type == LXC_NET_PHYS) { - /* Get the last network list and remove it. */ - it = lxc_conf->network.prev; - if (((struct lxc_netdev *)(it->elem))->type != LXC_NET_PHYS) { - ERROR("lxc config cannot support string pattern " - "matching for this link type"); - return -1; - } - - lxc_list_del(it); - free(it); - ret = create_matched_ifnames(value, lxc_conf, NULL); - } else { - ret = network_ifname(netdev->link, value); - } - - return ret; -} - -int set_config_network_legacy_name(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - return network_ifname(netdev->name, value); -} - -int set_config_network_legacy_veth_pair(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - if (netdev->type != LXC_NET_VETH) { - ERROR("Invalid veth pair for a non-veth netdev"); - return -1; - } - - return network_ifname(netdev->priv.veth_attr.pair, value); -} - -int set_config_network_legacy_macvlan_mode(const char *key, const char *value, - struct lxc_conf *lxc_conf, - void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - if (netdev->type != LXC_NET_MACVLAN) { - ERROR("Invalid macvlan.mode for a non-macvlan netdev"); - return -1; - } - - return lxc_macvlan_mode_to_flag(&netdev->priv.macvlan_attr.mode, value); -} - -int set_config_network_legacy_hwaddr(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - char *new_value; - - new_value = strdup(value); - if (!new_value) { - SYSERROR("failed to strdup \"%s\"", value); - return -1; - } - rand_complete_hwaddr(new_value); - - netdev = network_netdev(key, new_value, &lxc_conf->network); - if (!netdev) { - free(new_value); - return -1; - }; - - if (lxc_config_value_empty(new_value)) { - free(new_value); - netdev->hwaddr = NULL; - return 0; - } - - netdev->hwaddr = new_value; - return 0; -} - -int set_config_network_legacy_vlan_id(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - if (netdev->type != LXC_NET_VLAN) { - ERROR("Invalid vlan.id for a non-macvlan netdev"); - return -1; - } - - if (get_u16(&netdev->priv.vlan_attr.vid, value, 0)) - return -1; - - return 0; -} - -int set_config_network_legacy_mtu(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - return set_config_string_item(&netdev->mtu, value); -} - -int set_config_network_legacy_ipv4(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - struct lxc_inetdev *inetdev; - struct lxc_list *list; - char *cursor, *slash; - char *addr = NULL, *bcast = NULL, *prefix = NULL; - - if (lxc_config_value_empty(value)) - return clr_config_network_legacy_item(key, lxc_conf, NULL); - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - inetdev = malloc(sizeof(*inetdev)); - if (!inetdev) { - SYSERROR("failed to allocate ipv4 address"); - return -1; - } - memset(inetdev, 0, sizeof(*inetdev)); - - list = malloc(sizeof(*list)); - if (!list) { - SYSERROR("failed to allocate memory"); - free(inetdev); - return -1; - } - - lxc_list_init(list); - lxc_list_add_elem(list, inetdev); - - addr = strdup(value); - if (!addr) { - ERROR("no address specified"); - free(inetdev); - free(list); - return -1; - } - - cursor = strstr(addr, " "); - if (cursor) { - *cursor = '\0'; - bcast = cursor + 1; - } - - slash = strstr(addr, "/"); - if (slash) { - *slash = '\0'; - prefix = slash + 1; - } - - if (inet_pton(AF_INET, addr, &inetdev->addr) != 1) { - SYSERROR("invalid ipv4 address: %s", value); - free(inetdev); - free(addr); - free(list); - return -1; - } - - if (bcast && inet_pton(AF_INET, bcast, &inetdev->bcast) != 1) { - SYSERROR("invalid ipv4 broadcast address: %s", value); - free(inetdev); - free(list); - free(addr); - return -1; - } - - /* No prefix specified, determine it from the network class. */ - if (prefix) { - if (lxc_safe_uint(prefix, &inetdev->prefix) < 0) - return -1; - } else { - inetdev->prefix = config_ip_prefix(&inetdev->addr); - } - - /* If no broadcast address, let compute one from the - * prefix and address. - */ - if (!bcast) { - inetdev->bcast.s_addr = inetdev->addr.s_addr; - inetdev->bcast.s_addr |= - htonl(INADDR_BROADCAST >> inetdev->prefix); - } - - lxc_list_add_tail(&netdev->ipv4, list); - - free(addr); - return 0; -} - -int set_config_network_legacy_ipv4_gateway(const char *key, const char *value, - struct lxc_conf *lxc_conf, - void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - free(netdev->ipv4_gateway); - - if (lxc_config_value_empty(value)) { - netdev->ipv4_gateway = NULL; - } else if (!strcmp(value, "auto")) { - netdev->ipv4_gateway = NULL; - netdev->ipv4_gateway_auto = true; - } else { - struct in_addr *gw; - - gw = malloc(sizeof(*gw)); - if (!gw) { - SYSERROR("failed to allocate ipv4 gateway address"); - return -1; - } - - if (inet_pton(AF_INET, value, gw) != 1) { - SYSERROR("invalid ipv4 gateway address: %s", value); - free(gw); - return -1; - } - - netdev->ipv4_gateway = gw; - netdev->ipv4_gateway_auto = false; - } - - return 0; -} - -int set_config_network_legacy_ipv6(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - struct lxc_inet6dev *inet6dev; - struct lxc_list *list; - char *slash, *valdup, *netmask; - - if (lxc_config_value_empty(value)) - return clr_config_network_legacy_item(key, lxc_conf, NULL); - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - inet6dev = malloc(sizeof(*inet6dev)); - if (!inet6dev) { - SYSERROR("failed to allocate ipv6 address"); - return -1; - } - memset(inet6dev, 0, sizeof(*inet6dev)); - - list = malloc(sizeof(*list)); - if (!list) { - SYSERROR("failed to allocate memory"); - free(inet6dev); - return -1; - } - - lxc_list_init(list); - list->elem = inet6dev; - - valdup = strdup(value); - if (!valdup) { - ERROR("no address specified"); - free(list); - free(inet6dev); - return -1; - } - - inet6dev->prefix = 64; - slash = strstr(valdup, "/"); - if (slash) { - *slash = '\0'; - netmask = slash + 1; - if (lxc_safe_uint(netmask, &inet6dev->prefix) < 0) { - free(list); - free(inet6dev); - free(valdup); - return -1; - } - } - - if (inet_pton(AF_INET6, valdup, &inet6dev->addr) != 1) { - SYSERROR("invalid ipv6 address: %s", valdup); - free(list); - free(inet6dev); - free(valdup); - return -1; - } - - lxc_list_add_tail(&netdev->ipv6, list); - - free(valdup); - return 0; -} - -int set_config_network_legacy_ipv6_gateway(const char *key, const char *value, - struct lxc_conf *lxc_conf, - void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - free(netdev->ipv6_gateway); - - if (lxc_config_value_empty(value)) { - netdev->ipv6_gateway = NULL; - } else if (!strcmp(value, "auto")) { - netdev->ipv6_gateway = NULL; - netdev->ipv6_gateway_auto = true; - } else { - struct in6_addr *gw; - - gw = malloc(sizeof(*gw)); - if (!gw) { - SYSERROR("failed to allocate ipv6 gateway address"); - return -1; - } - - if (inet_pton(AF_INET6, value, gw) != 1) { - SYSERROR("invalid ipv6 gateway address: %s", value); - free(gw); - return -1; - } - - netdev->ipv6_gateway = gw; - netdev->ipv6_gateway_auto = false; - } - - return 0; -} - -int set_config_network_legacy_script_up(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - return set_config_string_item(&netdev->upscript, value); -} - -int set_config_network_legacy_script_down(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_netdev *netdev; - - netdev = network_netdev(key, value, &lxc_conf->network); - if (!netdev) - return -1; - - return set_config_string_item(&netdev->downscript, value); -} - -int get_config_network_legacy(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - int len, fulllen = 0; - struct lxc_list *it; - - if (!retv) - inlen = 0; - else - memset(retv, 0, inlen); - - lxc_list_for_each(it, &c->network) { - struct lxc_netdev *n = it->elem; - const char *t = lxc_net_type_to_str(n->type); - strprint(retv, inlen, "%s\n", t ? t : "(invalid)"); - } - - return fulllen; -} - -/* - * lxc.network.0.XXX, where XXX can be: name, type, link, flags, type, - * macvlan.mode, veth.pair, vlan, ipv4, ipv6, script.up, hwaddr, mtu, - * ipv4.gateway, ipv6.gateway. ipvX.gateway can return 'auto' instead - * of an address. ipv4 and ipv6 return lists (newline-separated). - * things like veth.pair return '' if invalid (i.e. if called for vlan - * type). - */ -int get_config_network_legacy_item(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - char *p1; - int len, fulllen = 0; - struct lxc_netdev *netdev; - - if (!retv) - inlen = 0; - else - memset(retv, 0, inlen); - - if (strncmp(key, "lxc.network.", 12) != 0) - return -1; - - p1 = strchr(key + 12, '.'); - if (!p1 || *(p1 + 1) == '\0') - return -1; - p1++; - - netdev = network_netdev(key, "", &c->network); - if (!netdev) - return -1; - - if (strcmp(p1, "name") == 0) { - if (netdev->name[0] != '\0') - strprint(retv, inlen, "%s", netdev->name); - } else if (strcmp(p1, "type") == 0) { - strprint(retv, inlen, "%s", lxc_net_type_to_str(netdev->type)); - } else if (strcmp(p1, "link") == 0) { - if (netdev->link[0] != '\0') - strprint(retv, inlen, "%s", netdev->link); - } else if (strcmp(p1, "flags") == 0) { - if (netdev->flags & IFF_UP) - strprint(retv, inlen, "up"); - } else if (strcmp(p1, "script.up") == 0) { - if (netdev->upscript) - strprint(retv, inlen, "%s", netdev->upscript); - } else if (strcmp(p1, "script.down") == 0) { - if (netdev->downscript) - strprint(retv, inlen, "%s", netdev->downscript); - } else if (strcmp(p1, "hwaddr") == 0) { - if (netdev->hwaddr) - strprint(retv, inlen, "%s", netdev->hwaddr); - } else if (strcmp(p1, "mtu") == 0) { - if (netdev->mtu) - strprint(retv, inlen, "%s", netdev->mtu); - } else if (strcmp(p1, "macvlan.mode") == 0) { - if (netdev->type == LXC_NET_MACVLAN) { - const char *mode; - switch (netdev->priv.macvlan_attr.mode) { - case MACVLAN_MODE_PRIVATE: - mode = "private"; - break; - case MACVLAN_MODE_VEPA: - mode = "vepa"; - break; - case MACVLAN_MODE_BRIDGE: - mode = "bridge"; - break; - case MACVLAN_MODE_PASSTHRU: - mode = "passthru"; - break; - default: - mode = "(invalid)"; - break; - } - strprint(retv, inlen, "%s", mode); - } - } else if (strcmp(p1, "veth.pair") == 0) { - if (netdev->type == LXC_NET_VETH) { - strprint(retv, inlen, "%s", - netdev->priv.veth_attr.pair[0] != '\0' - ? netdev->priv.veth_attr.pair - : netdev->priv.veth_attr.veth1); - } - } else if (strcmp(p1, "vlan") == 0) { - if (netdev->type == LXC_NET_VLAN) { - strprint(retv, inlen, "%d", netdev->priv.vlan_attr.vid); - } - } else if (strcmp(p1, "ipv4.gateway") == 0) { - if (netdev->ipv4_gateway_auto) { - strprint(retv, inlen, "auto"); - } else if (netdev->ipv4_gateway) { - char buf[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, netdev->ipv4_gateway, buf, - sizeof(buf)); - strprint(retv, inlen, "%s", buf); - } - } else if (strcmp(p1, "ipv4") == 0) { - struct lxc_list *it2; - lxc_list_for_each(it2, &netdev->ipv4) { - struct lxc_inetdev *i = it2->elem; - char buf[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, &i->addr, buf, sizeof(buf)); - strprint(retv, inlen, "%s/%u\n", buf, i->prefix); - } - } else if (strcmp(p1, "ipv6.gateway") == 0) { - if (netdev->ipv6_gateway_auto) { - strprint(retv, inlen, "auto"); - } else if (netdev->ipv6_gateway) { - char buf[INET6_ADDRSTRLEN]; - inet_ntop(AF_INET6, netdev->ipv6_gateway, buf, - sizeof(buf)); - strprint(retv, inlen, "%s", buf); - } - } else if (strcmp(p1, "ipv6") == 0) { - struct lxc_list *it2; - lxc_list_for_each(it2, &netdev->ipv6) { - struct lxc_inet6dev *i = it2->elem; - char buf[INET6_ADDRSTRLEN]; - inet_ntop(AF_INET6, &i->addr, buf, sizeof(buf)); - strprint(retv, inlen, "%s/%u\n", buf, i->prefix); - } - } - return fulllen; -} - -/* we get passed in something like '0', '0.ipv4' or '1.ipv6' */ -static int lxc_clear_nic(struct lxc_conf *c, const char *key) -{ - char *p1; - int idx; - struct lxc_list *it = NULL; - struct lxc_netdev *netdev = NULL; - - if (lxc_list_empty(&c->network)) { - ERROR("network is not created for %s", key); - return -1; - } - - if ((idx = get_network_netdev_idx(key)) == EINVAL) - netdev = lxc_list_first_elem(&c->network); - else { - lxc_list_for_each(it, &c->network) { - netdev = it->elem; - if (idx == netdev->idx) - break; - netdev = NULL; - } - } - if (!netdev) - return -1; - - p1 = strchr(key, '.'); - if (!p1 && it) { - lxc_remove_nic(it); - } else if (strcmp(p1, ".ipv4") == 0) { - struct lxc_list *it2,*next; - lxc_list_for_each_safe(it2, &netdev->ipv4, next) { - lxc_list_del(it2); - free(it2->elem); - free(it2); - } - } else if (strcmp(p1, ".ipv6") == 0) { - struct lxc_list *it2,*next; - lxc_list_for_each_safe(it2, &netdev->ipv6, next) { - lxc_list_del(it2); - free(it2->elem); - free(it2); - } - } else { - return -1; - } - - return 0; -} - -inline int clr_config_network_legacy_item(const char *key, struct lxc_conf *c, - void *data) -{ - return lxc_clear_nic(c, key + 12); -} - -inline int clr_config_network_legacy(const char *key, struct lxc_conf *c, void *data) -{ - return lxc_clear_config_network(c); -} - -inline int clr_config_lsm_aa_profile(const char *key, struct lxc_conf *c, - void *data) -{ - free(c->lsm_aa_profile); - c->lsm_aa_profile = NULL; - return 0; -} - -inline int clr_config_lsm_aa_incomplete(const char *key, struct lxc_conf *c, - void *data) -{ - c->lsm_aa_allow_incomplete = 0; - return 0; -} - -int get_config_lsm_aa_profile(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - return lxc_get_conf_str(retv, inlen, c->lsm_aa_profile); -} - -int get_config_lsm_aa_incomplete(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - return lxc_get_conf_int(c, retv, inlen, - c->lsm_aa_allow_incomplete); -} - -int set_config_lsm_aa_profile(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - return set_config_string_item(&lxc_conf->lsm_aa_profile, value); -} - -int set_config_lsm_aa_incomplete(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - /* Set config value to default. */ - if (lxc_config_value_empty(value)) { - lxc_conf->lsm_aa_allow_incomplete = 0; - return 0; - } - - /* Parse new config value. */ - if (lxc_safe_uint(value, &lxc_conf->lsm_aa_allow_incomplete) < 0) - return -1; - - if (lxc_conf->lsm_aa_allow_incomplete > 1) { - ERROR("Wrong value for lxc.lsm_aa_allow_incomplete. Can only " - "be set to 0 or 1"); - return -1; - } - - return 0; -} - -int set_config_lsm_se_context(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - return set_config_string_item(&lxc_conf->lsm_se_context, value); -} - -int get_config_lsm_se_context(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - return lxc_get_conf_str(retv, inlen, c->lsm_se_context); -} - -inline int clr_config_lsm_se_context(const char *key, struct lxc_conf *c, - void *data) -{ - free(c->lsm_se_context); - c->lsm_se_context = NULL; - return 0; -} - -extern int set_config_limit(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) -{ - struct lxc_list *iter; - struct rlimit limit; - rlim_t limit_value; - struct lxc_list *limlist = NULL; - struct lxc_limit *limelem = NULL; - - if (lxc_config_value_empty(value)) - return lxc_clear_limits(lxc_conf, key); - - if (strncmp(key, "lxc.limit.", sizeof("lxc.limit.") - 1) != 0) - return -1; - - key += sizeof("lxc.limit.") - 1; - - /* soft limit comes first in the value */ - if (!parse_limit_value(&value, &limit_value)) - return -1; - limit.rlim_cur = limit_value; - - /* skip spaces and a colon */ - while (isspace(*value)) - ++value; - - if (*value == ':') - ++value; - else if (*value) /* any other character is an error here */ - return -1; - - while (isspace(*value)) - ++value; - - /* optional hard limit */ - if (*value) { - if (!parse_limit_value(&value, &limit_value)) - return -1; - limit.rlim_max = limit_value; - - /* check for trailing garbage */ - while (isspace(*value)) - ++value; - - if (*value) - return -1; - } else { - /* a single value sets both hard and soft limit */ - limit.rlim_max = limit.rlim_cur; - } - - /* find existing list element */ - lxc_list_for_each(iter, &lxc_conf->limits) - { - limelem = iter->elem; - if (!strcmp(key, limelem->resource)) { - limelem->limit = limit; - return 0; - } - } - - /* allocate list element */ - limlist = malloc(sizeof(*limlist)); - if (!limlist) - goto out; - - limelem = malloc(sizeof(*limelem)); - if (!limelem) - goto out; - memset(limelem, 0, sizeof(*limelem)); - - limelem->resource = strdup(key); - if (!limelem->resource) - goto out; - limelem->limit = limit; - - limlist->elem = limelem; - - lxc_list_add_tail(&lxc_conf->limits, limlist); - - return 0; - -out: - free(limlist); - if (limelem) { - free(limelem->resource); - free(limelem); - } - return -1; -} - -/* - * If you ask for a specific value, i.e. lxc.limit.nofile, then just the value - * will be printed. If you ask for 'lxc.limit', then all limit entries will be - * printed, in 'lxc.limit.resource = value' format. - */ -extern int get_config_limit(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) -{ - int fulllen = 0, len; - bool get_all = false; - struct lxc_list *it; - - if (!retv) - inlen = 0; - else - memset(retv, 0, inlen); - - if (!strcmp(key, "lxc.limit")) - get_all = true; - else if (strncmp(key, "lxc.limit.", 10) == 0) - key += 10; - else - return -1; - - lxc_list_for_each(it, &c->limits) { - char buf[LXC_NUMSTRLEN64 * 2 + 2]; /* 2 colon separated 64 bit - integers or the word - 'unlimited' */ - int partlen; - struct lxc_limit *lim = it->elem; - - if (lim->limit.rlim_cur == RLIM_INFINITY) { - memcpy(buf, "unlimited", sizeof("unlimited")); - partlen = sizeof("unlimited") - 1; - } else { - partlen = sprintf(buf, "%" PRIu64, - (uint64_t)lim->limit.rlim_cur); - } - if (lim->limit.rlim_cur != lim->limit.rlim_max) { - if (lim->limit.rlim_max == RLIM_INFINITY) { - memcpy(buf + partlen, ":unlimited", - sizeof(":unlimited")); - } else { - sprintf(buf + partlen, ":%" PRIu64, - (uint64_t)lim->limit.rlim_max); - } - } - - if (get_all) { - strprint(retv, inlen, "lxc.limit.%s = %s\n", - lim->resource, buf); - } else if (strcmp(lim->resource, key) == 0) { - strprint(retv, inlen, "%s", buf); - } - } - - return fulllen; -} - -extern int clr_config_limit(const char *key, struct lxc_conf *c, - void *data) -{ - return lxc_clear_limits(c, key); -} diff --git a/src/lxc/confile_legacy.h b/src/lxc/confile_legacy.h deleted file mode 100644 index ab64a0e8a..000000000 --- a/src/lxc/confile_legacy.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * lxc: linux Container library - * - * (C) Copyright IBM Corp. 2007, 2008 - * - * Authors: - * Daniel Lezcano - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __LXC_CONFILE_LEGACY_H -#define __LXC_CONFILE_LEGACY_H - -#include -#include -#include - -struct lxc_conf; -struct lxc_list; - -extern int set_config_network_legacy_type(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_flags(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_link(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_name(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_veth_pair(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_macvlan_mode(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_hwaddr(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_vlan_id(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_mtu(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_ipv4(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_ipv4_gateway(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_script_up(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_script_down(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_ipv6(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_ipv6_gateway(const char *, const char *, - struct lxc_conf *, void *); -extern int set_config_network_legacy_nic(const char *, const char *, - struct lxc_conf *, void *); -extern int get_config_network_legacy_item(const char *, char *, int, - struct lxc_conf *, void *); -extern int clr_config_network_legacy_item(const char *, struct lxc_conf *, - void *); - -extern int lxc_list_nicconfigs_legacy(struct lxc_conf *c, const char *key, - char *retv, int inlen); -extern int lxc_listconfigs(char *retv, int inlen); - -extern bool network_new_hwaddrs(struct lxc_conf *conf); - -#define lxc_config_legacy_define(name) \ - extern int set_config_##name(const char *, const char *, \ - struct lxc_conf *, void *); \ - extern int get_config_##name(const char *, char *, int, \ - struct lxc_conf *, void *); \ - extern int clr_config_##name(const char *, struct lxc_conf *, \ - void *); - -lxc_config_legacy_define(network_legacy); -lxc_config_legacy_define(lsm_aa_profile); -lxc_config_legacy_define(lsm_aa_incomplete); -lxc_config_legacy_define(lsm_se_context); -lxc_config_legacy_define(limit); - -#endif /* __LXC_CONFILE_LEGACY_H */ diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index f0191c177..8eab554ed 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -46,7 +46,6 @@ #include "commands.h" #include "commands_utils.h" #include "confile.h" -#include "confile_legacy.h" #include "confile_utils.h" #include "console.h" #include "criu.h" @@ -2380,10 +2379,8 @@ static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *re * This is an intelligent result to show which keys are valid given the * type of nic it is. */ - if (!strncmp(key, "lxc.net.", 8)) + if (strncmp(key, "lxc.net.", 8) == 0) ret = lxc_list_net(c->lxc_conf, key, retv, inlen); - else if (strncmp(key, "lxc.network.", 12) == 0) - ret = lxc_list_nicconfigs_legacy(c->lxc_conf, key, retv, inlen); else ret = lxc_list_subkeys(c->lxc_conf, key, retv, inlen); @@ -3192,11 +3189,6 @@ static int copy_fstab(struct lxc_container *oldc, struct lxc_container *c) if (!oldpath) return 0; - /* REMOVE IN LXC 3.0 - legacy mount key - */ - clear_unexp_config_line(c->lxc_conf, "lxc.mount", false); - clear_unexp_config_line(c->lxc_conf, "lxc.mount.fstab", false); char *p = strrchr(oldpath, '/'); @@ -3330,11 +3322,6 @@ static int copy_storage(struct lxc_container *c0, struct lxc_container *c, return -1; } - /* REMOVE IN LXC 3.0 - * legacy rootfs key - */ - clear_unexp_config_line(c->lxc_conf, "lxc.rootfs", false); - /* 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", @@ -3343,11 +3330,6 @@ static int copy_storage(struct lxc_container *c0, struct lxc_container *c, return -1; } - /* REMOVE IN LXC 3.0 - * legacy rootfs.backend key - */ - clear_unexp_config_line(c->lxc_conf, "lxc.rootfs.backend", false); - if (flags & LXC_CLONE_SNAPSHOT) copy_rdepends(c, c0); if (need_rdep) { @@ -3569,11 +3551,6 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char 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.path", false); write_config(fout, c->lxc_conf); fclose(fout); diff --git a/src/lxc/network.c b/src/lxc/network.c index bf06e6f4a..5780e489a 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -3014,13 +3014,6 @@ int lxc_setup_network_in_child_namespaces(const struct lxc_conf *conf, lxc_list_for_each(iterator, network) { netdev = iterator->elem; - /* REMOVE in LXC 3.0 */ - if (netdev->idx < 0) { - ERROR("WARNING: using \"lxc.network.*\" keys to define " - "networks is DEPRECATED, please switch to using " - "\"lxc.net.[i].* keys\""); - } - if (lxc_setup_netdev_in_child_namespaces(netdev)) { ERROR("failed to setup netdev"); return -1; diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c index 253ea3092..087a46f68 100644 --- a/src/lxc/tools/lxc_attach.c +++ b/src/lxc/tools/lxc_attach.c @@ -291,9 +291,6 @@ int main(int argc, char *argv[]) } } - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - struct lxc_container *c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) exit(EXIT_FAILURE); diff --git a/src/lxc/tools/lxc_autostart.c b/src/lxc/tools/lxc_autostart.c index 41d2e4b57..21f9e0b39 100644 --- a/src/lxc/tools/lxc_autostart.c +++ b/src/lxc/tools/lxc_autostart.c @@ -357,9 +357,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - count = list_defined_containers(my_args.lxcpath[0], NULL, &containers); if (count < 0) diff --git a/src/lxc/tools/lxc_cgroup.c b/src/lxc/tools/lxc_cgroup.c index 231cc7b7c..14c6fa1e3 100644 --- a/src/lxc/tools/lxc_cgroup.c +++ b/src/lxc/tools/lxc_cgroup.c @@ -86,9 +86,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - state_object = my_args.argv[0]; c = lxc_container_new(my_args.name, my_args.lxcpath[0]); diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c index f3f9e7415..3eec94dce 100644 --- a/src/lxc/tools/lxc_checkpoint.c +++ b/src/lxc/tools/lxc_checkpoint.c @@ -251,9 +251,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { fprintf(stderr, "System error loading %s\n", my_args.name); diff --git a/src/lxc/tools/lxc_clone.c b/src/lxc/tools/lxc_clone.c index 4dca80b7b..b76d8669f 100644 --- a/src/lxc/tools/lxc_clone.c +++ b/src/lxc/tools/lxc_clone.c @@ -205,8 +205,6 @@ int main(int argc, char *argv[]) usage(argv[0]); } - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c1 = lxc_container_new(orig, lxcpath); if (!c1) exit(EXIT_FAILURE); diff --git a/src/lxc/tools/lxc_config.c b/src/lxc/tools/lxc_config.c index 682257f3d..775923e34 100644 --- a/src/lxc/tools/lxc_config.c +++ b/src/lxc/tools/lxc_config.c @@ -60,8 +60,6 @@ int main(int argc, char *argv[]) struct lxc_config_items *i; const char *value; - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - if (argc < 2 || strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) usage(argv[0]); diff --git a/src/lxc/tools/lxc_console.c b/src/lxc/tools/lxc_console.c index f847811cb..e55646225 100644 --- a/src/lxc/tools/lxc_console.c +++ b/src/lxc/tools/lxc_console.c @@ -111,9 +111,6 @@ int main(int argc, char *argv[]) if (ret) return EXIT_FAILURE; - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { fprintf(stderr, "System error loading container\n"); diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c index ae8b81021..d9db9a787 100644 --- a/src/lxc/tools/lxc_copy.c +++ b/src/lxc/tools/lxc_copy.c @@ -179,9 +179,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(ret); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - if (geteuid()) { if (access(my_args.lxcpath[0], O_RDONLY) < 0) { if (!my_args.quiet) diff --git a/src/lxc/tools/lxc_create.c b/src/lxc/tools/lxc_create.c index 9a4640316..f0c9caab1 100644 --- a/src/lxc/tools/lxc_create.c +++ b/src/lxc/tools/lxc_create.c @@ -241,9 +241,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - if (!my_args.template) { fprintf(stderr, "A template must be specified.\n"); fprintf(stderr, "Use \"none\" if you really want a container without a rootfs.\n"); diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c index 48484a6be..7de369ac8 100644 --- a/src/lxc/tools/lxc_destroy.c +++ b/src/lxc/tools/lxc_destroy.c @@ -86,9 +86,6 @@ int main(int argc, char *argv[]) if (my_args.quiet) quiet = true; - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { if (!quiet) diff --git a/src/lxc/tools/lxc_device.c b/src/lxc/tools/lxc_device.c index 501bc99a0..c139e96c8 100644 --- a/src/lxc/tools/lxc_device.c +++ b/src/lxc/tools/lxc_device.c @@ -123,9 +123,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) goto err; - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { fprintf(stderr, "%s doesn't exist\n", my_args.name); diff --git a/src/lxc/tools/lxc_execute.c b/src/lxc/tools/lxc_execute.c index dd58aed70..20c1b98a6 100644 --- a/src/lxc/tools/lxc_execute.c +++ b/src/lxc/tools/lxc_execute.c @@ -159,9 +159,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { fprintf(stderr, "Failed to create lxc_container\n"); diff --git a/src/lxc/tools/lxc_freeze.c b/src/lxc/tools/lxc_freeze.c index 09c21b30e..66180a07b 100644 --- a/src/lxc/tools/lxc_freeze.c +++ b/src/lxc/tools/lxc_freeze.c @@ -73,9 +73,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { fprintf(stderr, "No such container: %s:%s\n", my_args.lxcpath[0], my_args.name); diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c index de8f57463..6105b36eb 100644 --- a/src/lxc/tools/lxc_info.c +++ b/src/lxc/tools/lxc_info.c @@ -409,9 +409,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(ret); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - if (print_info(my_args.name, my_args.lxcpath[0]) == 0) ret = EXIT_SUCCESS; diff --git a/src/lxc/tools/lxc_ls.c b/src/lxc/tools/lxc_ls.c index 6a2453a7b..4b9623919 100644 --- a/src/lxc/tools/lxc_ls.c +++ b/src/lxc/tools/lxc_ls.c @@ -228,9 +228,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - struct lengths max_len = { /* default header length */ .name_length = 4, /* NAME */ @@ -559,11 +556,6 @@ static int ls_get(struct ls **m, size_t *size, const struct lxc_arguments *args, * problem with the ovl_mkdir() function in * lxcoverlay.{c,h}. */ 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) goto put_and_next; diff --git a/src/lxc/tools/lxc_monitor.c b/src/lxc/tools/lxc_monitor.c index 294e8c2f0..72dca8e21 100644 --- a/src/lxc/tools/lxc_monitor.c +++ b/src/lxc/tools/lxc_monitor.c @@ -521,9 +521,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(rc_main); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - if (quit_monitord) { int ret = EXIT_SUCCESS; for (i = 0; i < my_args.lxcpath_cnt; i++) { diff --git a/src/lxc/tools/lxc_snapshot.c b/src/lxc/tools/lxc_snapshot.c index 7c8255c2c..19542b374 100644 --- a/src/lxc/tools/lxc_snapshot.c +++ b/src/lxc/tools/lxc_snapshot.c @@ -97,9 +97,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - if (geteuid()) { if (access(my_args.lxcpath[0], O_RDONLY) < 0) { fprintf(stderr, "You lack access to %s\n", diff --git a/src/lxc/tools/lxc_start.c b/src/lxc/tools/lxc_start.c index 31a7cd690..d84fece11 100644 --- a/src/lxc/tools/lxc_start.c +++ b/src/lxc/tools/lxc_start.c @@ -206,9 +206,6 @@ int main(int argc, char *argv[]) exit(err); } - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - /* * rcfile possibilities: * 1. rcfile from random path specified in cli option diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c index f133c9977..787a6bdb6 100644 --- a/src/lxc/tools/lxc_stop.c +++ b/src/lxc/tools/lxc_stop.c @@ -114,9 +114,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(ret); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - /* Set default timeout */ if (my_args.timeout == -2) { if (my_args.hardstop) diff --git a/src/lxc/tools/lxc_unfreeze.c b/src/lxc/tools/lxc_unfreeze.c index f12b5d57a..482e0e7f4 100644 --- a/src/lxc/tools/lxc_unfreeze.c +++ b/src/lxc/tools/lxc_unfreeze.c @@ -74,9 +74,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { fprintf(stderr, "No such container: %s:%s\n", my_args.lxcpath[0], my_args.name); diff --git a/src/lxc/tools/lxc_wait.c b/src/lxc/tools/lxc_wait.c index 6186bce05..e4541e415 100644 --- a/src/lxc/tools/lxc_wait.c +++ b/src/lxc/tools/lxc_wait.c @@ -100,9 +100,6 @@ int main(int argc, char *argv[]) if (lxc_log_init(&log)) exit(EXIT_FAILURE); - /* REMOVE IN LXC 3.0 */ - setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0); - c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) exit(EXIT_FAILURE); diff --git a/src/tests/concurrent.c b/src/tests/concurrent.c index bcad8e52e..6804bec54 100644 --- a/src/tests/concurrent.c +++ b/src/tests/concurrent.c @@ -84,10 +84,8 @@ static void do_function(void *arguments) return; } - if (debug) { + if (debug) c->set_config_item(c, "lxc.log.level", "DEBUG"); - c->set_config_item(c, "lxc.log", name); - } if (strcmp(args->mode, "create") == 0) { if (!c->is_defined(c)) { diff --git a/src/tests/get_item.c b/src/tests/get_item.c index c2c561235..e7667c482 100644 --- a/src/tests/get_item.c +++ b/src/tests/get_item.c @@ -44,28 +44,28 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - /* EXPECT SUCCESS: lxc.syslog with valid value. */ - if (!c->set_config_item(c, "lxc.syslog", "local0")) { - lxc_error("%s\n", "Failed to set lxc.syslog.\n"); + /* EXPECT SUCCESS: lxc.log.syslog with valid value. */ + if (!c->set_config_item(c, "lxc.log.syslog", "local0")) { + lxc_error("%s\n", "Failed to set lxc.log.syslog.\n"); goto out; } - ret = c->get_config_item(c, "lxc.syslog", v2, 255); + ret = c->get_config_item(c, "lxc.log.syslog", v2, 255); if (ret < 0) { - lxc_error("Failed to retrieve lxc.syslog: %d.\n", ret); + lxc_error("Failed to retrieve lxc.log.syslog: %d.\n", ret); goto out; } if (strcmp(v2, "local0") != 0) { lxc_error("Expected: local0 == %s.\n", v2); goto out; } - lxc_debug("Retrieving value for lxc.syslog correctly returned: %s.\n", v2); + lxc_debug("Retrieving value for lxc.log.syslog correctly returned: %s.\n", v2); - /* EXPECT FAILURE: lxc.syslog with invalid value. */ - if (c->set_config_item(c, "lxc.syslog", "NONSENSE")) { - lxc_error("%s\n", "Succeeded int setting lxc.syslog to invalid value \"NONSENSE\".\n"); + /* EXPECT FAILURE: lxc.log.syslog with invalid value. */ + if (c->set_config_item(c, "lxc.log.syslog", "NONSENSE")) { + lxc_error("%s\n", "Succeeded int setting lxc.log.syslog to invalid value \"NONSENSE\".\n"); goto out; } - lxc_debug("%s\n", "Successfully failed to set lxc.syslog to invalid value.\n"); + lxc_debug("%s\n", "Successfully failed to set lxc.log.syslog to invalid value.\n"); if (!c->set_config_item(c, "lxc.hook.pre-start", "hi there")) { fprintf(stderr, "%d: failed to set hook.pre-start\n", __LINE__); @@ -78,22 +78,18 @@ int main(int argc, char *argv[]) } fprintf(stderr, "lxc.hook.pre-start returned %d %s\n", ret, v2); - ret = c->get_config_item(c, "lxc.network", v2, 255); + ret = c->get_config_item(c, "lxc.net", v2, 255); if (ret < 0) { fprintf(stderr, "%d: get_config_item returned %d\n", __LINE__, ret); goto out; } - fprintf(stderr, "%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2); + fprintf(stderr, "%d: get_config_item(lxc.net) 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.max", "4")) { fprintf(stderr, "%d: failed to set tty\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.tty", v2, 255); + ret = c->get_config_item(c, "lxc.tty.max", v2, 255); if (ret < 0) { fprintf(stderr, "%d: get_config_item(lxc.tty) returned %d\n", __LINE__, ret); goto out; @@ -111,22 +107,22 @@ int main(int argc, char *argv[]) } printf("lxc.arch returned %d %s\n", ret, v2); - if (!c->set_config_item(c, "lxc.init_uid", "100")) { + if (!c->set_config_item(c, "lxc.init.uid", "100")) { fprintf(stderr, "%d: failed to set init_uid\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.init_uid", v2, 255); + ret = c->get_config_item(c, "lxc.init.uid", v2, 255); if (ret < 0) { fprintf(stderr, "%d: get_config_item(lxc.init_uid) returned %d\n", __LINE__, ret); goto out; } printf("lxc.init_uid returned %d %s\n", ret, v2); - if (!c->set_config_item(c, "lxc.init_gid", "100")) { + if (!c->set_config_item(c, "lxc.init.gid", "100")) { fprintf(stderr, "%d: failed to set init_gid\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.init_gid", v2, 255); + ret = c->get_config_item(c, "lxc.init.gid", v2, 255); if (ret < 0) { fprintf(stderr, "%d: get_config_item(lxc.init_gid) returned %d\n", __LINE__, ret); goto out; @@ -136,13 +132,13 @@ int main(int argc, char *argv[]) #define HNAME "hostname1" // demonstrate proper usage: char *alloced; - if (!c->set_config_item(c, "lxc.utsname", HNAME)) { + if (!c->set_config_item(c, "lxc.uts.name", HNAME)) { fprintf(stderr, "%d: failed to set utsname\n", __LINE__); goto out; } int len; - len = c->get_config_item(c, "lxc.utsname", NULL, 0); // query the size of the string + len = c->get_config_item(c, "lxc.uts.name", NULL, 0); // query the size of the string if (len < 0) { fprintf(stderr, "%d: get_config_item(lxc.utsname) returned %d\n", __LINE__, len); goto out; @@ -157,7 +153,7 @@ int main(int argc, char *argv[]) } // now pass in the malloc'd array, and pass in length of string + 1: again // because we need room for the trailing \0 - ret = c->get_config_item(c, "lxc.utsname", alloced, len+1); + ret = c->get_config_item(c, "lxc.uts.name", alloced, len+1); if (ret < 0) { fprintf(stderr, "%d: get_config_item(lxc.utsname) returned %d\n", __LINE__, ret); goto out; @@ -180,69 +176,69 @@ int main(int argc, char *argv[]) } printf("lxc.mount.entry returned %d %s\n", ret, v2); - ret = c->get_config_item(c, "lxc.limit", v3, 2047); + ret = c->get_config_item(c, "lxc.prlimit", v3, 2047); if (ret != 0) { fprintf(stderr, "%d: get_config_item(limit) returned %d\n", __LINE__, ret); goto out; } - if (!c->set_config_item(c, "lxc.limit.nofile", "1234:unlimited")) { + if (!c->set_config_item(c, "lxc.prlimit.nofile", "1234:unlimited")) { fprintf(stderr, "%d: failed to set limit.nofile\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.limit.nofile", v2, 255); + ret = c->get_config_item(c, "lxc.prlimit.nofile", v2, 255); if (ret < 0) { - fprintf(stderr, "%d: get_config_item(lxc.limit.nofile) returned %d\n", __LINE__, ret); + fprintf(stderr, "%d: get_config_item(lxc.prlimit.nofile) returned %d\n", __LINE__, ret); goto out; } if (strcmp(v2, "1234:unlimited")) { - fprintf(stderr, "%d: lxc.limit.nofile returned wrong value: %d %s not 14 1234:unlimited\n", __LINE__, ret, v2); + fprintf(stderr, "%d: lxc.prlimit.nofile returned wrong value: %d %s not 14 1234:unlimited\n", __LINE__, ret, v2); goto out; } - printf("lxc.limit.nofile returned %d %s\n", ret, v2); + printf("lxc.prlimit.nofile returned %d %s\n", ret, v2); - if (!c->set_config_item(c, "lxc.limit.stack", "unlimited")) { + if (!c->set_config_item(c, "lxc.prlimit.stack", "unlimited")) { fprintf(stderr, "%d: failed to set limit.stack\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.limit.stack", v2, 255); + ret = c->get_config_item(c, "lxc.prlimit.stack", v2, 255); if (ret < 0) { - fprintf(stderr, "%d: get_config_item(lxc.limit.stack) returned %d\n", __LINE__, ret); + fprintf(stderr, "%d: get_config_item(lxc.prlimit.stack) returned %d\n", __LINE__, ret); goto out; } if (strcmp(v2, "unlimited")) { - fprintf(stderr, "%d: lxc.limit.stack returned wrong value: %d %s not 9 unlimited\n", __LINE__, ret, v2); + fprintf(stderr, "%d: lxc.prlimit.stack returned wrong value: %d %s not 9 unlimited\n", __LINE__, ret, v2); goto out; } - printf("lxc.limit.stack returned %d %s\n", ret, v2); + printf("lxc.prlimit.stack returned %d %s\n", ret, v2); -#define LIMIT_STACK "lxc.limit.stack = unlimited\n" -#define ALL_LIMITS "lxc.limit.nofile = 1234:unlimited\n" LIMIT_STACK - ret = c->get_config_item(c, "lxc.limit", v3, 2047); +#define LIMIT_STACK "lxc.prlimit.stack = unlimited\n" +#define ALL_LIMITS "lxc.prlimit.nofile = 1234:unlimited\n" LIMIT_STACK + ret = c->get_config_item(c, "lxc.prlimit", v3, 2047); if (ret != sizeof(ALL_LIMITS)-1) { fprintf(stderr, "%d: get_config_item(limit) returned %d\n", __LINE__, ret); goto out; } if (strcmp(v3, ALL_LIMITS)) { - fprintf(stderr, "%d: lxc.limit returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(ALL_LIMITS)-1, ALL_LIMITS); + fprintf(stderr, "%d: lxc.prlimit returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(ALL_LIMITS)-1, ALL_LIMITS); goto out; } - printf("lxc.limit returned %d %s\n", ret, v3); + printf("lxc.prlimit returned %d %s\n", ret, v3); - if (!c->clear_config_item(c, "lxc.limit.nofile")) { + if (!c->clear_config_item(c, "lxc.prlimit.nofile")) { fprintf(stderr, "%d: failed clearing limit.nofile\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.limit", v3, 2047); + ret = c->get_config_item(c, "lxc.prlimit", v3, 2047); if (ret != sizeof(LIMIT_STACK)-1) { fprintf(stderr, "%d: get_config_item(limit) returned %d\n", __LINE__, ret); goto out; } if (strcmp(v3, LIMIT_STACK)) { - fprintf(stderr, "%d: lxc.limit returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(LIMIT_STACK)-1, LIMIT_STACK); + fprintf(stderr, "%d: lxc.prlimit returned wrong value: %d %s not %d %s\n", __LINE__, ret, v3, (int)sizeof(LIMIT_STACK)-1, LIMIT_STACK); goto out; } - printf("lxc.limit returned %d %s\n", ret, v3); + printf("lxc.prlimit returned %d %s\n", ret, v3); #define SYSCTL_SOMAXCONN "lxc.sysctl.net.core.somaxconn = 256\n" #define ALL_SYSCTLS "lxc.sysctl.net.ipv4.ip_forward = 1\n" SYSCTL_SOMAXCONN @@ -376,11 +372,11 @@ int main(int argc, char *argv[]) } printf("lxc.proc returned %d %s\n", ret, v3); - if (!c->set_config_item(c, "lxc.aa_profile", "unconfined")) { + if (!c->set_config_item(c, "lxc.apparmor.profile", "unconfined")) { fprintf(stderr, "%d: failed to set aa_profile\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.aa_profile", v2, 255); + ret = c->get_config_item(c, "lxc.apparmor.profile", v2, 255); if (ret < 0) { fprintf(stderr, "%d: get_config_item(lxc.aa_profile) returned %d\n", __LINE__, ret); goto out; @@ -429,87 +425,87 @@ int main(int argc, char *argv[]) goto out; } printf("%d: get_config_item(lxc.cap.drop) returned %d %s\n", __LINE__, ret, v2); - ret = c->get_config_item(c, "lxc.network", v2, 255); + ret = c->get_config_item(c, "lxc.net", v2, 255); if (ret < 0) { - fprintf(stderr, "%d: get_config_item(lxc.network) returned %d\n", __LINE__, ret); + fprintf(stderr, "%d: get_config_item(lxc.net) returned %d\n", __LINE__, ret); goto out; } - printf("%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2); + printf("%d: get_config_item(lxc.net) returned %d %s\n", __LINE__, ret, v2); - if (!c->set_config_item(c, "lxc.network.type", "veth")) { - fprintf(stderr, "%d: failed to set network.type\n", __LINE__); + if (!c->set_config_item(c, "lxc.net.0.type", "veth")) { + fprintf(stderr, "%d: failed to set lxc.net.0.type\n", __LINE__); goto out; } - if (!c->set_config_item(c, "lxc.network.link", "lxcbr0")) { + if (!c->set_config_item(c, "lxc.net.0.link", "lxcbr0")) { fprintf(stderr, "%d: failed to set network.link\n", __LINE__); goto out; } - if (!c->set_config_item(c, "lxc.network.flags", "up")) { + if (!c->set_config_item(c, "lxc.net.0.flags", "up")) { fprintf(stderr, "%d: failed to set network.flags\n", __LINE__); goto out; } - if (!c->set_config_item(c, "lxc.network.hwaddr", "00:16:3e:xx:xx:xx")) { + if (!c->set_config_item(c, "lxc.net.0.hwaddr", "00:16:3e:xx:xx:xx")) { fprintf(stderr, "%d: failed to set network.hwaddr\n", __LINE__); goto out; } - if (!c->set_config_item(c, "lxc.network.ipv4", "10.2.3.4")) { + if (!c->set_config_item(c, "lxc.net.0.ipv4.address", "10.2.3.4")) { fprintf(stderr, "%d: failed to set ipv4\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.network.0.ipv4", v2, 255); + ret = c->get_config_item(c, "lxc.net.0.ipv4.address", v2, 255); if (ret <= 0) { - fprintf(stderr, "%d: lxc.network.0.ipv4 returned %d\n", __LINE__, ret); + fprintf(stderr, "%d: lxc.net.0.ipv4 returned %d\n", __LINE__, ret); goto out; } - if (!c->clear_config_item(c, "lxc.network.0.ipv4")) { + if (!c->clear_config_item(c, "lxc.net.0.ipv4.address")) { fprintf(stderr, "%d: failed clearing all ipv4 entries\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.network.0.ipv4", v2, 255); + ret = c->get_config_item(c, "lxc.net.0.ipv4.address", v2, 255); if (ret != 0) { fprintf(stderr, "%d: after clearing ipv4 entries get_item(lxc.network.0.ipv4 returned %d\n", __LINE__, ret); goto out; } - if (!c->set_config_item(c, "lxc.network.ipv4.gateway", "10.2.3.254")) { + if (!c->set_config_item(c, "lxc.net.0.ipv4.gateway", "10.2.3.254")) { fprintf(stderr, "%d: failed to set ipv4.gateway\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.network.0.ipv4.gateway", v2, 255); + ret = c->get_config_item(c, "lxc.net.0.ipv4.gateway", v2, 255); if (ret <= 0) { - fprintf(stderr, "%d: lxc.network.0.ipv4.gateway returned %d\n", __LINE__, ret); + fprintf(stderr, "%d: lxc.net.0.ipv4.gateway returned %d\n", __LINE__, ret); goto out; } - if (!c->set_config_item(c, "lxc.network.0.ipv4.gateway", "")) { + if (!c->set_config_item(c, "lxc.net.0.ipv4.gateway", "")) { fprintf(stderr, "%d: failed clearing ipv4.gateway\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.network.0.ipv4.gateway", v2, 255); + ret = c->get_config_item(c, "lxc.net.0.ipv4.gateway", v2, 255); if (ret != 0) { fprintf(stderr, "%d: after clearing ipv4.gateway get_item(lxc.network.0.ipv4.gateway returned %d\n", __LINE__, ret); goto out; } - ret = c->get_config_item(c, "lxc.network.0.link", v2, 255); + ret = c->get_config_item(c, "lxc.net.0.link", v2, 255); if (ret < 0) { fprintf(stderr, "%d: get_config_item returned %d\n", __LINE__, ret); goto out; } printf("%d: get_config_item (link) returned %d %s\n", __LINE__, ret, v2); - ret = c->get_config_item(c, "lxc.network.0.name", v2, 255); + ret = c->get_config_item(c, "lxc.net.0.name", v2, 255); if (ret < 0) { fprintf(stderr, "%d: get_config_item returned %d\n", __LINE__, ret); goto out; } printf("%d: get_config_item (name) returned %d %s\n", __LINE__, ret, v2); - if (!c->clear_config_item(c, "lxc.network")) { + if (!c->clear_config_item(c, "lxc.net")) { fprintf(stderr, "%d: clear_config_item failed\n", __LINE__); goto out; } - ret = c->get_config_item(c, "lxc.network", v2, 255); + ret = c->get_config_item(c, "lxc.net", v2, 255); if (ret != 0) { fprintf(stderr, "%d: network was not actually cleared (get_network returned %d)\n", __LINE__, ret); goto out; diff --git a/src/tests/getkeys.c b/src/tests/getkeys.c index f5923921c..a9299de31 100644 --- a/src/tests/getkeys.c +++ b/src/tests/getkeys.c @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) goto out; } - c->set_config_item(c, "lxc.network.type", "veth"); + c->set_config_item(c, "lxc.net.0.type", "veth"); len = c->get_keys(c, NULL, NULL, 0); if (len < 0) { @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) } printf("get_keys returned %d\n%s", ret, v3); - ret = c->get_keys(c, "lxc.network.0", v3, 2000); + ret = c->get_keys(c, "lxc.net.0", v3, 2000); if (ret < 0) { fprintf(stderr, "%d: failed to get nic 0 keys(%d)\n", __LINE__, ret); ret = 1; diff --git a/src/tests/lxc-test-utils.c b/src/tests/lxc-test-utils.c index a84ef00c0..1fa702ca6 100644 --- a/src/tests/lxc-test-utils.c +++ b/src/tests/lxc-test-utils.c @@ -498,10 +498,6 @@ void test_lxc_config_net_hwaddr(void) if (!lxc_config_net_hwaddr("lxc.net.0.hwaddr = 00:16:3e:04:65:b8\n")) exit(EXIT_FAILURE); - if (!lxc_config_net_hwaddr("lxc.network.hwaddr = 00:16:3e:04:65:b8\n")) - exit(EXIT_FAILURE); - if (!lxc_config_net_hwaddr("lxc.net.hwaddr = 00:16:3e:04:65:b8\n")) - exit(EXIT_FAILURE); if (lxc_config_net_hwaddr("lxc.net")) exit(EXIT_FAILURE); @@ -509,10 +505,6 @@ void test_lxc_config_net_hwaddr(void) exit(EXIT_FAILURE); if (lxc_config_net_hwaddr("lxc.net.0.")) exit(EXIT_FAILURE); - if (lxc_config_net_hwaddr("lxc.network")) - exit(EXIT_FAILURE); - if (lxc_config_net_hwaddr("lxc.network.0.")) - exit(EXIT_FAILURE); } int main(int argc, char *argv[]) diff --git a/src/tests/parse_config_file.c b/src/tests/parse_config_file.c index 76c631ccd..aad4d32b6 100644 --- a/src/tests/parse_config_file.c +++ b/src/tests/parse_config_file.c @@ -171,11 +171,6 @@ static int set_invalid_netdev(struct lxc_container *c) { return -1; } - if (c->set_config_item(c, "lxc.network.0.", "veth")) { - lxc_error("%s\n", "lxc.network.0. should be invalid"); - return -1; - } - c->clear_config(c); c->lxc_conf = NULL; @@ -330,9 +325,9 @@ int main(int argc, char *argv[]) /* REMOVE IN LXC 3.0 legacy ps keys */ - if (set_get_compare_clear_save_load(c, "lxc.pts", "1000", tmpf, true) < + if (set_get_compare_clear_save_load(c, "lxc.pty.max", "1000", tmpf, true) < 0) { - lxc_error("%s\n", "lxc.pts"); + lxc_error("%s\n", "lxc.pty.max"); goto non_test_error; } @@ -343,15 +338,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy tty.max keys - */ - if (set_get_compare_clear_save_load(c, "lxc.tty", "4", tmpf, true) < - 0) { - lxc_error("%s\n", "lxc.tty"); - goto non_test_error; - } - /* lxc.tty.max */ if (set_get_compare_clear_save_load(c, "lxc.tty.max", "4", tmpf, true) < 0) { @@ -359,15 +345,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy devttydir keys - */ - if (set_get_compare_clear_save_load(c, "lxc.devttydir", "not-dev", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.devttydir"); - goto non_test_error; - } - /* lxc.tty.dir */ if (set_get_compare_clear_save_load(c, "lxc.tty.dir", "not-dev", tmpf, true) < 0) { @@ -375,33 +352,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy security keys - */ - if (set_get_compare_clear_save_load(c, "lxc.aa_profile", "unconfined", - tmpf, true) < 0) { - lxc_error("%s\n", "lxc.aa_profile"); - goto non_test_error; - } - - /* REMOVE IN LXC 3.0 - legacy security keys - */ - if (set_get_compare_clear_save_load(c, "lxc.aa_allow_incomplete", "1", - tmpf, true) < 0) { - lxc_error("%s\n", "lxc.aa_allow_incomplete"); - goto non_test_error; - } - - /* REMOVE IN LXC 3.0 - legacy security keys - */ - if (set_get_compare_clear_save_load(c, "lxc.se_context", "system_u:system_r:lxc_t:s0:c22", - tmpf, true) < 0) { - lxc_error("%s\n", "lxc.se_context"); - goto non_test_error; - } - /* lxc.apparmor.profile */ if (set_get_compare_clear_save_load(c, "lxc.apparmor.profile", "unconfined", tmpf, true) < 0) { @@ -454,34 +404,6 @@ int main(int argc, char *argv[]) c->clear_config(c); c->lxc_conf = NULL; - /* lxc.id_map - * We can't really save the config here since save_config() wants to - * chown the container's directory but we haven't created an on-disk - * container. So let's test set-get-clear. - */ - if (set_get_compare_clear_save_load( - c, "lxc.id_map", "u 0 100000 1000000000", NULL, false) < 0) { - lxc_error("%s\n", "lxc.id_map"); - goto non_test_error; - } - - if (!c->set_config_item(c, "lxc.id_map", "u 1 100000 10000000")) { - lxc_error("%s\n", "failed to set config item " - "\"lxc.id_map\" to \"u 1 100000 10000000\""); - return -1; - } - - if (!c->set_config_item(c, "lxc.id_map", "g 1 100000 10000000")) { - lxc_error("%s\n", "failed to set config item " - "\"lxc.id_map\" to \"g 1 100000 10000000\""); - return -1; - } - - if (!c->get_config_item(c, "lxc.id_map", retval, sizeof(retval))) { - lxc_error("%s\n", "failed to get config item \"lxc.id_map\""); - return -1; - } - /* lxc.idmap * We can't really save the config here since save_config() wants to * chown the container's directory but we haven't created an on-disk @@ -513,25 +435,6 @@ int main(int argc, char *argv[]) c->clear_config(c); c->lxc_conf = NULL; - /* REMOVE IN LXC 3.0 - legacy lxc.loglevel key - */ - if (set_get_compare_clear_save_load(c, "lxc.loglevel", "DEBUG", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.loglevel"); - goto non_test_error; - } - - /* REMOVE IN LXC 3.0 - legacy lxc.logfile key - */ - if (set_get_compare_clear_save_load(c, "lxc.logfile", "/some/path", - tmpf, true) < 0) { - lxc_error("%s\n", "lxc.logfile"); - goto non_test_error; - } - - /* lxc.log.level */ if (set_get_compare_clear_save_load(c, "lxc.log.level", "DEBUG", tmpf, true) < 0) { @@ -546,15 +449,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.mount key - */ - if (set_get_compare_clear_save_load(c, "lxc.mount", "/some/path", NULL, - true) < 0) { - lxc_error("%s\n", "lxc.mount"); - goto non_test_error; - } - /* lxc.mount.fstab */ if (set_get_compare_clear_save_load(c, "lxc.mount.fstab", "/some/path", NULL, true) < 0) { @@ -585,15 +479,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.rootfs key - */ - if (set_get_compare_clear_save_load(c, "lxc.rootfs", "/some/path", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.rootfs"); - goto non_test_error; - } - /* lxc.rootfs.path */ if (set_get_compare_clear_save_load(c, "lxc.rootfs.path", "/some/path", tmpf, true) < 0) { @@ -615,15 +500,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.utsname key - */ - if (set_get_compare_clear_save_load(c, "lxc.utsname", "the-shire", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.utsname"); - goto non_test_error; - } - /* lxc.uts.name */ if (set_get_compare_clear_save_load(c, "lxc.uts.name", "the-shire", tmpf, true) < 0) { @@ -710,15 +586,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.console key - */ - if (set_get_compare_clear_save_load(c, "lxc.console", "none", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.console"); - goto non_test_error; - } - /* lxc.console.path */ if (set_get_compare_clear_save_load(c, "lxc.console.path", "none", tmpf, true) < 0) { @@ -733,15 +600,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy seccomp key - */ - if (set_get_compare_clear_save_load( - c, "lxc.seccomp", "/some/seccomp/file", tmpf, true) < 0) { - lxc_error("%s\n", "lxc.seccomp"); - goto non_test_error; - } - /* lxc.seccomp.profile */ if (set_get_compare_clear_save_load( c, "lxc.seccomp.profile", "/some/seccomp/file", tmpf, true) < 0) { @@ -756,15 +614,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.haltsignal key - */ - if (set_get_compare_clear_save_load(c, "lxc.haltsignal", "1", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.haltsignal"); - goto non_test_error; - } - /* lxc.signal.halt */ if (set_get_compare_clear_save_load(c, "lxc.signal.halt", "1", tmpf, true) < 0) { @@ -772,15 +621,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.rebootsignal key - */ - if (set_get_compare_clear_save_load(c, "lxc.rebootsignal", "1", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.rebootsignal"); - goto non_test_error; - } - /* lxc.signal.reboot */ if (set_get_compare_clear_save_load(c, "lxc.signal.reboot", "1", tmpf, true) < 0) { @@ -788,15 +628,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.stopsignal key - */ - if (set_get_compare_clear_save_load(c, "lxc.stopsignal", "1", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.stopsignal"); - goto non_test_error; - } - /* lxc.signal.stop */ if (set_get_compare_clear_save_load(c, "lxc.signal.stop", "1", tmpf, true) < 0) { @@ -832,13 +663,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* lxc.utsname */ - if (set_get_compare_clear_save_load(c, "lxc.utsname", "get-schwifty", - tmpf, true) < 0) { - lxc_error("%s\n", "lxc.utsname"); - goto non_test_error; - } - /* lxc.monitor.unshare */ if (set_get_compare_clear_save_load(c, "lxc.monitor.unshare", "1", tmpf, true) < 0) { @@ -860,15 +684,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.init_cmd key - */ - if (set_get_compare_clear_save_load(c, "lxc.init_cmd", "/bin/bash", - tmpf, true) < 0) { - lxc_error("%s\n", "lxc.init_cmd"); - goto non_test_error; - } - /* lxc.init.cmd */ if (set_get_compare_clear_save_load(c, "lxc.init.cmd", "/bin/bash", tmpf, true) < 0) { @@ -876,15 +691,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.init_uid key - */ - if (set_get_compare_clear_save_load(c, "lxc.init_uid", "1000", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.init_uid"); - goto non_test_error; - } - /* lxc.init.uid */ if (set_get_compare_clear_save_load(c, "lxc.init.uid", "1000", tmpf, true) < 0) { @@ -892,15 +698,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.init_gid key - */ - if (set_get_compare_clear_save_load(c, "lxc.init_gid", "1000", tmpf, - true) < 0) { - lxc_error("%s\n", "lxc.init_gid"); - goto non_test_error; - } - /* lxc.init.gid */ if (set_get_compare_clear_save_load(c, "lxc.init.gid", "1000", tmpf, true) < 0) { @@ -936,15 +733,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* REMOVE IN LXC 3.0 - legacy lxc.limit.* key - */ - if (set_get_compare_clear_save_load(c, "lxc.limit.nofile", "65536", - tmpf, true) < 0) { - lxc_error("%s\n", "lxc.limit.nofile"); - goto non_test_error; - } - /* lxc.prlimit.nofile */ if (set_get_compare_clear_save_load(c, "lxc.prlimit.nofile", "65536", tmpf, true) < 0) {