* [PATCH] lxc: Tweak lxc template script for systemd/sysvinit
@ 2014-10-15 3:41 Yang Shi
2014-10-15 18:13 ` Bruce Ashfield
0 siblings, 1 reply; 2+ messages in thread
From: Yang Shi @ 2014-10-15 3:41 UTC (permalink / raw)
To: bruce.ashfield, meta-virtualization; +Cc: yang.shi
Tweak the script to make it work for both systemd and sysvinit.
Add "-i <init_method>" 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 <yang.shi@windriver.com>
---
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 <<EOF >> $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 <<EOF >> $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 <<EOF > $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 <<EOF
usage:
$1 -n|--name=<container_name>
- [-p|--path=<path>] [-h|--help]
+ [-p|--path=<path>] [-i|--init=<init_method>] [-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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lxc: Tweak lxc template script for systemd/sysvinit
2014-10-15 3:41 [PATCH] lxc: Tweak lxc template script for systemd/sysvinit Yang Shi
@ 2014-10-15 18:13 ` Bruce Ashfield
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2014-10-15 18:13 UTC (permalink / raw)
To: Yang Shi, meta-virtualization
On 14-10-14 11:41 PM, Yang Shi wrote:
> Tweak the script to make it work for both systemd and sysvinit.
>
> Add "-i <init_method>" 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.
This is definitely good information, and worth the broadcast. I was
asking for any systemd changes that may be floating around, but since
we are patching code that isn't already part of meta-virt, we'll let
this sit and see if any of the dependencies are also available to merge.
Cheers,
Bruce
>
> Signed-off-by: Yang Shi <yang.shi@windriver.com>
> ---
> 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 <<EOF >> $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 <<EOF >> $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 <<EOF > $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 <<EOF
> usage:
> $1 -n|--name=<container_name>
> - [-p|--path=<path>] [-h|--help]
> + [-p|--path=<path>] [-i|--init=<init_method>] [-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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-15 18:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15 3:41 [PATCH] lxc: Tweak lxc template script for systemd/sysvinit Yang Shi
2014-10-15 18:13 ` Bruce Ashfield
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.