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>
23 image="supernested-@VERSION@-@DISTRO@.qcow2"
27 append="panic=1 console=ttyS0 udevtimeout=6000 no_timer_check printk.time=1 root=/dev/sda selinux=0"
34 --longoptions 'help,nested,smp:,tcg' \
35 -n run-supernested.sh -- "$@"`
37 echo "$0: problem parsing the command line arguments"
44 echo "$0: Run the supernested appliance."
45 echo " $0 [--smp=N] [--tcg]"
47 echo " --smp=N Use N virtual CPUs (at all levels)."
48 echo " --tcg Use TCG (at all levels) instead of KVM."
54 # When the nested guest calls this script, it uses the
55 # --nested flag. DO NOT ADD THIS FLAG YOURSELF!
61 grep -Eo 'supernested.smp=[[:digit:]]+' /proc/cmdline |
62 grep -Eo '[[:digit:]]+'
64 if [ -n "$smp" ]; then smp="-smp $smp"; fi
66 grep -Eo 'supernested.accel=tcg' /proc/cmdline
68 if [ -n "$accel" ]; then
76 append="$append supernested.smp=$2"
82 append="$append supernested.accel=tcg"
94 echo "internal error ($1)"
100 # How much memory to give to the guest?
102 grep -Eo '^MemTotal:.*[[:digit:]]+ kB' /proc/meminfo |
103 grep -Eo '[[:digit:]]+'
105 if [ -z "memory" ]; then
106 echo "$0: could not get total memory from /proc/meminfo"
109 memory=$((memory / 1024))
110 if [ $memory -lt 2048 ]; then
111 echo "$0: not enough memory left: memory=$memory MB"
114 memory=$((memory - 1500))
116 # Get current nesting level from /proc/cmdline, increment it, add it
117 # to the command line.
119 grep -Eo 'supernested.level=[[:digit:]]+' /proc/cmdline |
120 grep -Eo '[[:digit:]]+'
122 if [ -z "$level" ]; then level=0; fi
123 append="$append supernested.level=$((level+1))"
129 echo " accel = $accel"
130 echo " memory = $memory"
131 echo " kernel = $kernel"
132 echo " initrd = $initrd"
133 echo " disk = $image"
134 echo " append = $append"
136 # Since this could crash the machine, better to sync ...
143 -machine accel=$accel \
149 -global kvm-pit.lost_tick_policy=discard \
152 -device virtio-scsi-pci,id=scsi \
153 -drive file="$image",snapshot=on,cache=unsafe,format="$format",id=hd0,if=none \
154 -device scsi-hd,drive=hd0 \
155 -device virtio-serial-pci \