2 # supernested Makefile.am
4 # (C) Copyright 2014 Red Hat Inc.
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.
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.
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.
20 # Written by Richard W.M. Jones <rjones@redhat.com>
24 image="supernested-@VERSION@-@DISTRO@.qcow2"
28 append="panic=1 udevtimeout=6000 udev.event-timeout=6000 no_timer_check printk.time=1 root=/dev/sda selinux=0"
34 append="$append earlyprintk=pl011,0x9000000 ignore_loglevel efi-rtc=noprobe"
37 append="$append console=ttyS0"
43 --longoptions 'help,nested,smp:,tcg' \
44 -n run-supernested.sh -- "$@"`
46 echo "$0: problem parsing the command line arguments"
53 echo "$0: Run the supernested appliance."
54 echo " $0 [--smp=N] [--tcg]"
56 echo " --smp=N Use N virtual CPUs (at all levels)."
57 echo " --tcg Use TCG (at all levels) instead of KVM."
63 # When the nested guest calls this script, it uses the
64 # --nested flag. DO NOT ADD THIS FLAG YOURSELF!
70 grep -Eo 'supernested.smp=[[:digit:]]+' /proc/cmdline |
71 grep -Eo '[[:digit:]]+'
74 if grep -q supernested.tcg=1 /proc/cmdline; then
96 echo "internal error ($1)"
102 # How much memory to give to the guest?
104 grep -Eo '^MemTotal:.*[[:digit:]]+ kB' /proc/meminfo |
105 grep -Eo '[[:digit:]]+'
107 if [ -z "memory" ]; then
108 echo "$0: could not get total memory from /proc/meminfo"
111 memory=$((memory / 1024))
112 if [ $memory -lt 2048 ]; then
113 echo "$0: not enough memory left: memory=$memory MB"
116 memory=$((memory - 1500))
118 # Get current nesting level from /proc/cmdline, increment it, add it
119 # to the command line.
121 grep -Eo 'supernested.level=[[:digit:]]+' /proc/cmdline |
122 grep -Eo '[[:digit:]]+'
124 if [ -z "$level" ]; then level=0; fi
125 append="$append supernested.level=$((level+1))"
127 # Append other parameters to nested command line.
128 append="$append supernested.smp=$smp supernested.tcg=$tcg"
131 if [ -n "$smp" ]; then extra_args="$extra_args -smp $smp"; fi
132 if [ -n "$tcg" ]; then
133 extra_args="$extra_args -machine accel=tcg"
135 extra_args="$extra_args -cpu host -machine accel=kvm"
140 echo " extra_args = $extra_args"
141 echo " memory = $memory"
142 echo " kernel = $kernel"
143 echo " initrd = $initrd"
144 echo " disk = $image"
145 echo " append = $append"
147 # Since this could crash the machine, better to sync ...
158 -global kvm-pit.lost_tick_policy=discard \
161 -device virtio-scsi-pci,id=scsi \
162 -drive file="$image",snapshot=on,cache=unsafe,format="$format",id=hd0,if=none \
163 -device scsi-hd,drive=hd0 \
164 -device virtio-serial-pci \