Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id ED474E008A6; Tue, 14 Oct 2014 20:42:15 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.1.11 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail.windriver.com (mail.windriver.com [147.11.1.11]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id BCB9DE0084F for ; Tue, 14 Oct 2014 20:42:03 -0700 (PDT) Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail.windriver.com (8.14.9/8.14.5) with ESMTP id s9F3g2ge017805 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Tue, 14 Oct 2014 20:42:02 -0700 (PDT) Received: from yshi-Precision-T5600.corp.ad.wrs.com (147.11.216.82) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.174.1; Tue, 14 Oct 2014 20:42:01 -0700 From: Yang Shi To: , Date: Tue, 14 Oct 2014 20:41:03 -0700 Message-ID: <1413344463-30106-1-git-send-email-yang.shi@windriver.com> X-Mailer: git-send-email 2.0.2 MIME-Version: 1.0 Cc: yang.shi@windriver.com Subject: [PATCH] lxc: Tweak lxc template script for systemd/sysvinit X-BeenThere: meta-virtualization@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Discussion of layer enabling hypervisor, virtualization tool stack, and cloud support" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Oct 2014 03:42:16 -0000 Content-Type: text/plain Tweak the script to make it work for both systemd and sysvinit. Add "-i " parameter. If sysvinit guest is used, "-i sysvinit" need to be passed. The default init is systemd. The below systemd specific changes are added: Add "lxc.autodev=1" since LXC will create its own device tree. Add "lxc.kmsg=0" to prevent lxc symlinks /dev/kmsg to /dev/console, this leads to journald running 100% cpu usage all the time. Remove unnecessary mount entry in fstab. Signed-off-by: Yang Shi --- templates/lxc-wrlinux.in | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/templates/lxc-wrlinux.in b/templates/lxc-wrlinux.in index 1ef512b..7775cf2 100644 --- a/templates/lxc-wrlinux.in +++ b/templates/lxc-wrlinux.in @@ -30,8 +30,10 @@ default_profile=default configure_wrlinux() { - # Tweak initscripts - sed -i 's/^\(si::sysinit:\/etc\/init.d\/rcS\)/# \1/' ${rootfs_path}/etc/inittab + if [ "${init_method}" == "sysvinit" ]; then + # Tweak initscripts + sed -i 's/^\(si::sysinit:\/etc\/init.d\/rcS\)/# \1/' ${rootfs_path}/etc/inittab + fi # Touch file for fastboot dev_path="${rootfs_path}/dev" @@ -78,9 +80,11 @@ copy_configuration() mkdir -p $config_path grep -q "^lxc.rootfs" $config_path/config 2>/dev/null || echo "lxc.rootfs = $rootfs_path" >> $config_path/config + + if [ "${init_method}" == "sysvinit" ]; then cat <> $config_path/config lxc.utsname = $name -lxc.tty = 6 +lxc.tty = 6 lxc.pts = 1024 lxc.mount = $config_path/fstab EOF @@ -91,6 +95,21 @@ none $rootfs_path/sys sysfs defaults 0 0 none $rootfs_path/dev/pts devpts defaults 0 0 none $rootfs_path/dev/shm tmpfs defaults 0 0 EOF + # systemd + else + cat <> $config_path/config +lxc.utsname = $name +lxc.autodev=1 +lxc.kmsg=0 +lxc.tty = 6 +lxc.pts = 1024 +lxc.mount = $config_path/fstab +EOF + + cat < $config_path/fstab +none $rootfs_path/sys sysfs defaults 0 0 +EOF + fi if [ $? -ne 0 ]; then echo "Failed to add configuration" @@ -110,17 +129,18 @@ usage() cat < - [-p|--path=] [-h|--help] + [-p|--path=] [-i|--init=] [-h|--help] Mandatory args: -n,--name container name, used to as an identifier for that container from now on Optional args: -p,--path path to where the container rootfs will be created, defaults to @LXCPATH@. The container config will go under @LXCPATH@ in that case + -i,--init init method used by system, systemd or sysvinit -h,--help print this help EOF return 0 } -options=$(getopt -o hp:n: -l help,path:,name: -- "$@") +options=$(getopt -o hp:n:i: -l help,path:,name:,init: -- "$@") if [ $? -ne 0 ]; then usage $(basename $0) exit 1 @@ -133,6 +153,7 @@ do -h|--help) usage $0 && exit 0;; -p|--path) path=$2; shift 2;; -n|--name) name=$2; shift 2;; + -i|--init) init_method=$2; shift 2;; --) shift 1; break ;; *) break ;; esac -- 2.0.2