Limit memory to 30000MB for ARM mach_virt.
[supernested.git] / init.in
1 #!/bin/bash -
2 # supernested Makefile.am
3 # @configure_input@
4 # (C) Copyright 2014 Red Hat Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #
20 # Written by Richard W.M. Jones <rjones@redhat.com>
21
22 echo "*** /init script starting up ***"
23
24 export PATH=/sbin:/usr/sbin:/bin:/usr/bin
25
26 # Create /proc, /sys, /run, /dev, /tmp, /var/tmp
27 if [ ! -d /proc ]; then rm -f /proc; fi
28 mkdir -p /proc
29 mount -t proc /proc /proc
30 if [ ! -d /sys ]; then rm -f /sys; fi
31 mkdir -p /sys
32 mount -t sysfs /sys /sys
33 mkdir -p /run
34 mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
35 mkdir -p /run/lock
36 ln -s ../run/lock /var/lock
37 mount -t devtmpfs /dev /dev
38 mkdir -p /tmp
39 mount -t tmpfs tmpfs /tmp
40 mkdir -p /var/tmp
41 mount -t tmpfs tmpfs /var/tmp
42
43 # Find and start udev.
44 for f in /sbin/udevd /lib/udev/udevd \
45     /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd \
46     /usr/lib/udev/udevd; do
47   if [ -x "$f" ]; then UDEVD="$f"; fi
48 done
49 if [ -z "$UDEVD" ]; then
50   echo "udev not found!  Things will probably not work ..."
51 fi
52 $UDEVD --daemon
53 udevadm trigger
54 udevadm settle --timeout=600
55
56 # Set up kmod static-nodes (RHBZ#1011907).
57 mkdir -p /run/tmpfiles.d
58 kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
59
60 # Set up tmpfiles (must run after kmod.conf is created above).
61 systemd-tmpfiles --prefix=/dev --create
62
63 # libiscsi puts itself in a non-standard directory.
64 /sbin/ldconfig
65
66 # Print some information about the system.
67 echo "/proc/cpuinfo ------------------------------"
68 cat /proc/cpuinfo
69 echo "--------------------------------------------"
70 echo
71
72 echo -n "cmdline: "
73 cat /proc/cmdline
74
75 echo -n "clocksource: "
76 cat /sys/devices/system/clocksource/clocksource0/current_clocksource
77
78 echo -n "kernel: "
79 uname -r
80
81 # ls -lR /dev
82 # cat /proc/mounts
83 # lsmod
84
85 level="$(
86     grep -Eo 'supernested.level=[[:digit:]]+' /proc/cmdline |
87     grep -Eo '[[:digit:]]+'
88     )"
89 echo "*** This is the L$level hypervisor ***"
90
91 # Run the nested guest.
92 /run-supernested.sh --nested
93
94 echo "*** the L$level hypervisor is exiting ***"
95
96 # Exit and reboot.
97 # qemu has the -no-reboot flag, so issuing a reboot here actually
98 # causes qemu to exit gracefully.
99 reboot -f