diff options
| author | Phil Wise <phil@advancedtelematic.com> | 2017-07-20 10:20:31 +0200 |
|---|---|---|
| committer | Phil Wise <phil@advancedtelematic.com> | 2017-07-20 10:20:31 +0200 |
| commit | 5ec153ae190020bfc5a75b5064348d45a565d21b (patch) | |
| tree | 6377bd535ba93e3e7a77819021f3cd1e98eea762 /scripts | |
| parent | 6f7f86bf7d71d31bfc5407d2a97eeab3ec18dc36 (diff) | |
| download | meta-updater-5ec153ae190020bfc5a75b5064348d45a565d21b.tar.gz | |
Copy run-qemu script over from meta-updater-qemux86-64
Also remove old bash scripts for running inside qemu
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/run-qemu-ota | 150 | ||||
| -rwxr-xr-x | scripts/runqemu | 575 | ||||
| -rwxr-xr-x | scripts/runqemu-addptable2image | 51 | ||||
| -rwxr-xr-x | scripts/runqemu-export-rootfs | 163 | ||||
| -rwxr-xr-x | scripts/runqemu-extract-sdk | 104 | ||||
| -rwxr-xr-x | scripts/runqemu-gen-tapdevs | 100 | ||||
| -rwxr-xr-x | scripts/runqemu-ifdown | 66 | ||||
| -rwxr-xr-x | scripts/runqemu-ifup | 121 | ||||
| -rwxr-xr-x | scripts/runqemu-internal | 760 | ||||
| -rw-r--r-- | scripts/runqemu.README | 42 |
10 files changed, 150 insertions, 1982 deletions
diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota new file mode 100755 index 0000000..181558c --- /dev/null +++ b/scripts/run-qemu-ota | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | #! /usr/bin/env python | ||
| 2 | |||
| 3 | from argparse import ArgumentParser | ||
| 4 | from subprocess import Popen | ||
| 5 | from os.path import exists, join, realpath | ||
| 6 | from os import listdir | ||
| 7 | import random | ||
| 8 | import sys | ||
| 9 | import socket | ||
| 10 | |||
| 11 | DEFAULT_DIR = 'tmp/deploy/images' | ||
| 12 | |||
| 13 | EXTENSIONS = { | ||
| 14 | 'intel-corei7-64': 'wic', | ||
| 15 | 'qemux86-64': 'otaimg' | ||
| 16 | } | ||
| 17 | |||
| 18 | |||
| 19 | def find_local_port(start_port): | ||
| 20 | """" | ||
| 21 | Find the next free TCP port after 'start_port'. | ||
| 22 | """ | ||
| 23 | |||
| 24 | for port in range(start_port, start_port + 10): | ||
| 25 | try: | ||
| 26 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
| 27 | s.bind(('', port)) | ||
| 28 | return port | ||
| 29 | except socket.error: | ||
| 30 | print("Skipping port %d" % port) | ||
| 31 | finally: | ||
| 32 | s.close() | ||
| 33 | raise Exception("Could not find a free TCP port") | ||
| 34 | |||
| 35 | |||
| 36 | def random_mac(): | ||
| 37 | """Return a random Ethernet MAC address | ||
| 38 | @link https://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml#ethernet-numbers-2 | ||
| 39 | """ | ||
| 40 | head = "ca:fe:" | ||
| 41 | hex_digits = '0123456789abcdef' | ||
| 42 | tail = ':'.join([random.choice(hex_digits) + random.choice(hex_digits) for _ in range(4)]) | ||
| 43 | return head + tail | ||
| 44 | |||
| 45 | |||
| 46 | class QemuCommand(object): | ||
| 47 | def __init__(self, args): | ||
| 48 | if args.machine: | ||
| 49 | self.machine = args.machine | ||
| 50 | else: | ||
| 51 | machines = listdir(args.dir) | ||
| 52 | if len(machines) == 1: | ||
| 53 | self.machine = machines[0] | ||
| 54 | else: | ||
| 55 | raise ValueError("Could not autodetect machine type from %s" % args.dir) | ||
| 56 | if args.efi: | ||
| 57 | self.bios = 'OVMF.fd' | ||
| 58 | else: | ||
| 59 | uboot = join(args.dir, self.machine, 'u-boot-qemux86-64.rom') | ||
| 60 | if not exists(uboot): | ||
| 61 | raise ValueError("U-Boot image %s does not exist" % uboot) | ||
| 62 | self.bios = uboot | ||
| 63 | ext = EXTENSIONS.get(self.machine, 'wic') | ||
| 64 | image = join(args.dir, self.machine, '%s-%s.%s' % (args.imagename, self.machine, ext)) | ||
| 65 | self.image = realpath(image) | ||
| 66 | if not exists(self.image): | ||
| 67 | raise ValueError("OS image %s does not exist" % self.image) | ||
| 68 | if args.mac: | ||
| 69 | self.mac_address = args.mac | ||
| 70 | else: | ||
| 71 | self.mac_address = random_mac() | ||
| 72 | self.serial_port = find_local_port(8990) | ||
| 73 | self.ssh_port = find_local_port(2222) | ||
| 74 | self.kvm = not args.no_kvm | ||
| 75 | self.gui = not args.no_gui | ||
| 76 | self.gdb = args.gdb | ||
| 77 | self.pcap = args.pcap | ||
| 78 | |||
| 79 | def command_line(self): | ||
| 80 | netuser = 'user,hostfwd=tcp:0.0.0.0:%d-:22,restrict=off' % self.ssh_port | ||
| 81 | if self.gdb: | ||
| 82 | netuser += ',hostfwd=tcp:0.0.0.0:2159-:2159' | ||
| 83 | cmdline = [ | ||
| 84 | "qemu-system-x86_64", | ||
| 85 | "-bios", self.bios, | ||
| 86 | "-drive", "file=%s,if=ide,format=raw,snapshot=on" % self.image, | ||
| 87 | "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port, | ||
| 88 | "-m", "1G", | ||
| 89 | "-usb", | ||
| 90 | "-usbdevice", "tablet", | ||
| 91 | "-show-cursor", | ||
| 92 | "-vga", "std", | ||
| 93 | "-net", netuser, | ||
| 94 | "-net", "nic,macaddr=%s" % self.mac_address | ||
| 95 | ] | ||
| 96 | if self.pcap: | ||
| 97 | cmdline += ['-net', 'dump,file=' + self.pcap] | ||
| 98 | if self.gui: | ||
| 99 | cmdline += ["-serial", "stdio"] | ||
| 100 | else: | ||
| 101 | cmdline.append('-nographic') | ||
| 102 | if self.kvm: | ||
| 103 | cmdline.append('-enable-kvm') | ||
| 104 | else: | ||
| 105 | cmdline += ['-cpu', 'Haswell'] | ||
| 106 | return cmdline | ||
| 107 | |||
| 108 | |||
| 109 | def main(): | ||
| 110 | parser = ArgumentParser(description='Run meta-updater image in qemu') | ||
| 111 | parser.add_argument('imagename', default='core-image-minimal', nargs='?') | ||
| 112 | parser.add_argument('mac', default=None, nargs='?') | ||
| 113 | parser.add_argument('--dir', default=DEFAULT_DIR, | ||
| 114 | help='Path to build directory containing the image and u-boot-qemux86-64.rom') | ||
| 115 | parser.add_argument('--efi', | ||
| 116 | help='Boot using UEFI rather than U-Boot. This requires the image to be built with ' + | ||
| 117 | 'OSTREE_BOOTLOADER = "grub" and OVMF.fd firmware to be installed (try "apt install ovmf")', | ||
| 118 | action='store_true') | ||
| 119 | parser.add_argument('--machine', default=None, help="Target MACHINE") | ||
| 120 | parser.add_argument('--no-kvm', help='Disable KVM in QEMU', action='store_true') | ||
| 121 | parser.add_argument('--no-gui', help='Disable GUI', action='store_true') | ||
| 122 | parser.add_argument('--gdb', help='Export gdbserver port 2159 from the image', action='store_true') | ||
| 123 | parser.add_argument('--pcap', default=None, help='Dump all network traffic') | ||
| 124 | parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true') | ||
| 125 | args = parser.parse_args() | ||
| 126 | try: | ||
| 127 | qemu_command = QemuCommand(args) | ||
| 128 | except ValueError as e: | ||
| 129 | print(e.message) | ||
| 130 | sys.exit(1) | ||
| 131 | |||
| 132 | print("Launching %s with mac address %s" % (args.imagename, qemu_command.mac_address)) | ||
| 133 | print("To connect via SSH:") | ||
| 134 | print(" ssh -o StrictHostKeyChecking=no root@localhost -p %d" % qemu_command.ssh_port) | ||
| 135 | print("To connect to the serial console:") | ||
| 136 | print(" nc localhost %d" % qemu_command.serial_port) | ||
| 137 | |||
| 138 | cmdline = qemu_command.command_line() | ||
| 139 | if args.dry_run: | ||
| 140 | print(" ".join(cmdline)) | ||
| 141 | else: | ||
| 142 | s = Popen(cmdline) | ||
| 143 | try: | ||
| 144 | s.wait() | ||
| 145 | except KeyboardInterrupt: | ||
| 146 | pass | ||
| 147 | |||
| 148 | |||
| 149 | if __name__ == '__main__': | ||
| 150 | main() | ||
diff --git a/scripts/runqemu b/scripts/runqemu deleted file mode 100755 index b6c9b54..0000000 --- a/scripts/runqemu +++ /dev/null | |||
| @@ -1,575 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Handle running OE images standalone with QEMU | ||
| 4 | # | ||
| 5 | # Copyright (C) 2006-2011 Linux Foundation | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License version 2 as | ||
| 9 | # published by the Free Software Foundation. | ||
| 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 along | ||
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | |||
| 20 | usage() { | ||
| 21 | MYNAME=`basename $0` | ||
| 22 | cat <<_EOF | ||
| 23 | |||
| 24 | Usage: you can run this script with any valid combination | ||
| 25 | of the following environment variables (in any order): | ||
| 26 | KERNEL - the kernel image file to use | ||
| 27 | ROOTFS - the rootfs image file or nfsroot directory to use | ||
| 28 | MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified) | ||
| 29 | Simplified QEMU command-line options can be passed with: | ||
| 30 | nographic - disables video console | ||
| 31 | serial - enables a serial console on /dev/ttyS0 | ||
| 32 | kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required) | ||
| 33 | kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required) | ||
| 34 | publicvnc - enable a VNC server open to all hosts | ||
| 35 | qemuparams="xyz" - specify custom parameters to QEMU | ||
| 36 | bootparams="xyz" - specify custom kernel parameters during boot | ||
| 37 | |||
| 38 | Examples: | ||
| 39 | $MYNAME qemuarm | ||
| 40 | $MYNAME qemux86-64 core-image-sato ext4 | ||
| 41 | $MYNAME qemux86-64 wic-image-minimal wic | ||
| 42 | $MYNAME path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial | ||
| 43 | $MYNAME qemux86 iso/hddimg/vmdk/qcow2/vdi/ramfs/cpio.gz... | ||
| 44 | $MYNAME qemux86 qemuparams="-m 256" | ||
| 45 | $MYNAME qemux86 bootparams="psplash=false" | ||
| 46 | $MYNAME path/to/<image>-<machine>.vmdk | ||
| 47 | $MYNAME path/to/<image>-<machine>.wic | ||
| 48 | _EOF | ||
| 49 | exit 1 | ||
| 50 | } | ||
| 51 | |||
| 52 | if [ "x$1" = "x" ]; then | ||
| 53 | usage | ||
| 54 | fi | ||
| 55 | |||
| 56 | error() { | ||
| 57 | echo "Error: "$* | ||
| 58 | usage | ||
| 59 | } | ||
| 60 | |||
| 61 | MACHINE=${MACHINE:=""} | ||
| 62 | KERNEL=${KERNEL:=""} | ||
| 63 | ROOTFS=${ROOTFS:=""} | ||
| 64 | FSTYPE=${FSTYPE:=""} | ||
| 65 | LAZY_ROOTFS="" | ||
| 66 | SCRIPT_QEMU_OPT="" | ||
| 67 | SCRIPT_QEMU_EXTRA_OPT="" | ||
| 68 | SCRIPT_KERNEL_OPT="" | ||
| 69 | SERIALSTDIO="" | ||
| 70 | TCPSERIAL_PORTNUM="" | ||
| 71 | KVM_ENABLED="no" | ||
| 72 | KVM_ACTIVE="no" | ||
| 73 | VHOST_ENABLED="no" | ||
| 74 | VHOST_ACTIVE="no" | ||
| 75 | IS_VM="false" | ||
| 76 | |||
| 77 | # Determine whether the file is a kernel or QEMU image, and set the | ||
| 78 | # appropriate variables | ||
| 79 | process_filename() { | ||
| 80 | filename=$1 | ||
| 81 | |||
| 82 | # Extract the filename extension | ||
| 83 | EXT=`echo $filename | awk -F . '{ print \$NF }'` | ||
| 84 | case /$EXT/ in | ||
| 85 | /bin/) | ||
| 86 | # A file ending in .bin is a kernel | ||
| 87 | [ -z "$KERNEL" ] && KERNEL=$filename || \ | ||
| 88 | error "conflicting KERNEL args [$KERNEL] and [$filename]" | ||
| 89 | ;; | ||
| 90 | /ext[234]/|/jffs2/|/btrfs/) | ||
| 91 | # A file ending in a supportted fs type is a rootfs image | ||
| 92 | if [ -z "$FSTYPE" -o "$FSTYPE" = "$EXT" ]; then | ||
| 93 | FSTYPE=$EXT | ||
| 94 | ROOTFS=$filename | ||
| 95 | else | ||
| 96 | error "conflicting FSTYPE types [$FSTYPE] and [$EXT]" | ||
| 97 | fi | ||
| 98 | ;; | ||
| 99 | /hddimg/|/hdddirect/|/vmdk/|/wic/|/qcow2/|/vdi/|/otaimg/) | ||
| 100 | FSTYPE=$EXT | ||
| 101 | VM=$filename | ||
| 102 | ROOTFS=$filename | ||
| 103 | IS_VM="true" | ||
| 104 | ;; | ||
| 105 | *) | ||
| 106 | error "unknown file arg [$filename]" | ||
| 107 | ;; | ||
| 108 | esac | ||
| 109 | } | ||
| 110 | |||
| 111 | check_fstype_conflicts() { | ||
| 112 | if [ -z "$FSTYPE" -o "$FSTYPE" = "$1" ]; then | ||
| 113 | FSTYPE=$1 | ||
| 114 | else | ||
| 115 | error "conflicting FSTYPE types [$FSTYPE] and [$1]" | ||
| 116 | fi | ||
| 117 | } | ||
| 118 | # Parse command line args without requiring specific ordering. It's a | ||
| 119 | # bit more complex, but offers a great user experience. | ||
| 120 | while true; do | ||
| 121 | arg=${1} | ||
| 122 | case "$arg" in | ||
| 123 | "qemux86" | "qemux86-64" | "qemuarm" | "qemuarm64" | "qemumips" | "qemumipsel" | \ | ||
| 124 | "qemumips64" | "qemush4" | "qemuppc" | "qemumicroblaze" | "qemuzynq" | "qemuzynqmp") | ||
| 125 | [ -z "$MACHINE" -o "$MACHINE" = "$arg" ] && MACHINE=$arg || \ | ||
| 126 | error "conflicting MACHINE types [$MACHINE] and [$arg]" | ||
| 127 | ;; | ||
| 128 | "ext"[234] | "jffs2" | "nfs" | "btrfs") | ||
| 129 | check_fstype_conflicts $arg | ||
| 130 | ;; | ||
| 131 | "hddimg" | "hdddirect" | "wic" | "vmdk" | "qcow2" | "vdi" | "iso" | "otaimg") | ||
| 132 | check_fstype_conflicts $arg | ||
| 133 | IS_VM="true" | ||
| 134 | ;; | ||
| 135 | "ramfs" | "cpio.gz") | ||
| 136 | FSTYPE=cpio.gz | ||
| 137 | ;; | ||
| 138 | "nographic") | ||
| 139 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -nographic" | ||
| 140 | SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0" | ||
| 141 | ;; | ||
| 142 | "serial") | ||
| 143 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -serial stdio" | ||
| 144 | SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT console=ttyS0" | ||
| 145 | SERIALSTDIO="1" | ||
| 146 | ;; | ||
| 147 | "tcpserial="*) | ||
| 148 | TCPSERIAL_PORTNUM=${arg##tcpserial=} | ||
| 149 | ;; | ||
| 150 | "biosdir="*) | ||
| 151 | CUSTOMBIOSDIR="${arg##biosdir=}" | ||
| 152 | ;; | ||
| 153 | "biosfilename="*) | ||
| 154 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -bios ${arg##biosfilename=}" | ||
| 155 | ;; | ||
| 156 | "qemuparams="*) | ||
| 157 | SCRIPT_QEMU_EXTRA_OPT="${arg##qemuparams=}" | ||
| 158 | |||
| 159 | # Warn user if they try to specify serial or kvm options | ||
| 160 | # to use simplified options instead | ||
| 161 | serial_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-serial\)'` | ||
| 162 | kvm_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-enable-kvm\)'` | ||
| 163 | vga_option=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-vga\)'` | ||
| 164 | [ ! -z "$serial_option" -o ! -z "$kvm_option" ] && \ | ||
| 165 | echo "Please use simplified serial or kvm options instead" | ||
| 166 | ;; | ||
| 167 | "bootparams="*) | ||
| 168 | SCRIPT_KERNEL_OPT="$SCRIPT_KERNEL_OPT ${arg##bootparams=}" | ||
| 169 | ;; | ||
| 170 | "audio") | ||
| 171 | if [ "x$MACHINE" = "xqemux86" -o "x$MACHINE" = "xqemux86-64" ]; then | ||
| 172 | echo "Enabling audio in qemu." | ||
| 173 | echo "Please install snd_intel8x0 or snd_ens1370 driver in linux guest." | ||
| 174 | QEMU_AUDIO_DRV="alsa" | ||
| 175 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -soundhw ac97,es1370" | ||
| 176 | fi | ||
| 177 | ;; | ||
| 178 | "kvm") | ||
| 179 | KVM_ENABLED="yes" | ||
| 180 | KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1` | ||
| 181 | ;; | ||
| 182 | "kvm-vhost") | ||
| 183 | KVM_ENABLED="yes" | ||
| 184 | KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1` | ||
| 185 | VHOST_ENABLED="yes" | ||
| 186 | ;; | ||
| 187 | "slirp") | ||
| 188 | SLIRP_ENABLED="yes" | ||
| 189 | ;; | ||
| 190 | "publicvnc") | ||
| 191 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -vnc :0" | ||
| 192 | ;; | ||
| 193 | *-image*) | ||
| 194 | [ -z "$ROOTFS" ] || \ | ||
| 195 | error "conflicting ROOTFS args [$ROOTFS] and [$arg]" | ||
| 196 | if [ -f "$arg" ]; then | ||
| 197 | process_filename $arg | ||
| 198 | elif [ -d "$arg" ]; then | ||
| 199 | # Handle the case where the nfsroot dir has -image- | ||
| 200 | # in the pathname | ||
| 201 | echo "Assuming $arg is an nfs rootfs" | ||
| 202 | FSTYPE=nfs | ||
| 203 | ROOTFS=$arg | ||
| 204 | else | ||
| 205 | ROOTFS=$arg | ||
| 206 | LAZY_ROOTFS="true" | ||
| 207 | fi | ||
| 208 | ;; | ||
| 209 | "") break ;; | ||
| 210 | *) | ||
| 211 | # A directory name is an nfs rootfs | ||
| 212 | if [ -d "$arg" ]; then | ||
| 213 | echo "Assuming $arg is an nfs rootfs" | ||
| 214 | if [ -z "$FSTYPE" -o "$FSTYPE" = "nfs" ]; then | ||
| 215 | FSTYPE=nfs | ||
| 216 | else | ||
| 217 | error "conflicting FSTYPE types [$arg] and nfs" | ||
| 218 | fi | ||
| 219 | |||
| 220 | if [ -z "$ROOTFS" ]; then | ||
| 221 | ROOTFS=$arg | ||
| 222 | else | ||
| 223 | error "conflicting ROOTFS args [$ROOTFS] and [$arg]" | ||
| 224 | fi | ||
| 225 | elif [ -f "$arg" ]; then | ||
| 226 | process_filename $arg | ||
| 227 | else | ||
| 228 | error "unable to classify arg [$arg]" | ||
| 229 | fi | ||
| 230 | ;; | ||
| 231 | esac | ||
| 232 | shift | ||
| 233 | done | ||
| 234 | |||
| 235 | if [ ! -c /dev/net/tun ] ; then | ||
| 236 | echo "TUN control device /dev/net/tun is unavailable; you may need to enable TUN (e.g. sudo modprobe tun)" | ||
| 237 | exit 1 | ||
| 238 | elif [ ! -w /dev/net/tun ] ; then | ||
| 239 | echo "TUN control device /dev/net/tun is not writable, please fix (e.g. sudo chmod 666 /dev/net/tun)" | ||
| 240 | exit 1 | ||
| 241 | fi | ||
| 242 | |||
| 243 | # Report errors for missing combinations of options | ||
| 244 | if [ -z "$MACHINE" -a -z "$KERNEL" -a -z "$VM" -a "$FSTYPE" != "wic" ]; then | ||
| 245 | error "you must specify at least a MACHINE or KERNEL argument" | ||
| 246 | fi | ||
| 247 | if [ "$FSTYPE" = "nfs" -a -z "$ROOTFS" ]; then | ||
| 248 | error "NFS booting without an explicit ROOTFS path is not yet supported" | ||
| 249 | fi | ||
| 250 | |||
| 251 | if [ -z "$MACHINE" ]; then | ||
| 252 | if [ "$IS_VM" = "true" ]; then | ||
| 253 | [ "x$FSTYPE" = "xwic" ] && filename=$ROOTFS || filename=$VM | ||
| 254 | MACHINE=`basename $filename | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'` | ||
| 255 | if [ -z "$MACHINE" ]; then | ||
| 256 | error "Unable to set MACHINE from image filename [$VM]" | ||
| 257 | fi | ||
| 258 | echo "Set MACHINE to [$MACHINE] based on image [$VM]" | ||
| 259 | else | ||
| 260 | MACHINE=`basename $KERNEL | sed -n 's/.*\(qemux86-64\|qemux86\|qemuarm64\|qemuarm\|qemumips64\|qemumips\|qemuppc\|qemush4\).*/\1/p'` | ||
| 261 | if [ -z "$MACHINE" ]; then | ||
| 262 | error "Unable to set MACHINE from kernel filename [$KERNEL]" | ||
| 263 | fi | ||
| 264 | echo "Set MACHINE to [$MACHINE] based on kernel [$KERNEL]" | ||
| 265 | fi | ||
| 266 | fi | ||
| 267 | |||
| 268 | YOCTO_KVM_WIKI="https://wiki.yoctoproject.org/wiki/How_to_enable_KVM_for_Poky_qemu" | ||
| 269 | YOCTO_PARAVIRT_KVM_WIKI="https://wiki.yoctoproject.org/wiki/Running_an_x86_Yocto_Linux_image_under_QEMU_KVM" | ||
| 270 | # Detect KVM configuration | ||
| 271 | if [ "x$KVM_ENABLED" = "xyes" ]; then | ||
| 272 | if [ -z "$KVM_CAPABLE" ]; then | ||
| 273 | echo "You are trying to enable KVM on a cpu without VT support." | ||
| 274 | echo "Remove kvm from the command-line, or refer" | ||
| 275 | echo "$YOCTO_KVM_WIKI"; | ||
| 276 | exit 1; | ||
| 277 | fi | ||
| 278 | if [ "x$MACHINE" != "xqemux86" -a "x$MACHINE" != "xqemux86-64" ]; then | ||
| 279 | echo "KVM only support x86 & x86-64. Remove kvm from the command-line"; | ||
| 280 | exit 1; | ||
| 281 | fi | ||
| 282 | if [ ! -e /dev/kvm ]; then | ||
| 283 | echo "Missing KVM device. Have you inserted kvm modules?" | ||
| 284 | echo "For further help see:" | ||
| 285 | echo "$YOCTO_KVM_WIKI"; | ||
| 286 | exit 1; | ||
| 287 | fi | ||
| 288 | if [ -w /dev/kvm -a -r /dev/kvm ]; then | ||
| 289 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm" | ||
| 290 | KVM_ACTIVE="yes" | ||
| 291 | else | ||
| 292 | echo "You have no rights on /dev/kvm." | ||
| 293 | echo "Please change the ownership of this file as described at:" | ||
| 294 | echo "$YOCTO_KVM_WIKI"; | ||
| 295 | exit 1; | ||
| 296 | fi | ||
| 297 | if [ "x$VHOST_ENABLED" = "xyes" ]; then | ||
| 298 | if [ ! -e /dev/vhost-net ]; then | ||
| 299 | echo "Missing virtio net device. Have you inserted vhost-net module?" | ||
| 300 | echo "For further help see:" | ||
| 301 | echo "$YOCTO_PARAVIRT_KVM_WIKI"; | ||
| 302 | exit 1; | ||
| 303 | fi | ||
| 304 | |||
| 305 | if [ -w /dev/vhost-net -a -r /dev/vhost-net ]; then | ||
| 306 | VHOST_ACTIVE="yes" | ||
| 307 | else | ||
| 308 | echo "You have no rights on /dev/vhost-net." | ||
| 309 | echo "Please change the ownership of this file as described at:" | ||
| 310 | echo "$YOCTO_KVM_WIKI"; | ||
| 311 | exit 1; | ||
| 312 | fi | ||
| 313 | fi | ||
| 314 | fi | ||
| 315 | |||
| 316 | machine2=`echo $MACHINE | tr 'a-z' 'A-Z' | sed 's/-/_/'` | ||
| 317 | # MACHINE is now set for all cases | ||
| 318 | |||
| 319 | # Defaults used when these vars need to be inferred | ||
| 320 | QEMUX86_DEFAULT_KERNEL=bzImage-qemux86.bin | ||
| 321 | QEMUX86_DEFAULT_FSTYPE=ext4 | ||
| 322 | |||
| 323 | QEMUX86_64_DEFAULT_KERNEL=bzImage-qemux86-64.bin | ||
| 324 | QEMUX86_64_DEFAULT_FSTYPE=ext4 | ||
| 325 | |||
| 326 | QEMUARM_DEFAULT_KERNEL=zImage-qemuarm.bin | ||
| 327 | QEMUARM_DEFAULT_FSTYPE=ext4 | ||
| 328 | |||
| 329 | QEMUARM64_DEFAULT_KERNEL=Image-qemuarm64.bin | ||
| 330 | QEMUARM64_DEFAULT_FSTYPE=ext4 | ||
| 331 | |||
| 332 | QEMUMIPS_DEFAULT_KERNEL=vmlinux-qemumips.bin | ||
| 333 | QEMUMIPS_DEFAULT_FSTYPE=ext4 | ||
| 334 | |||
| 335 | QEMUMIPSEL_DEFAULT_KERNEL=vmlinux-qemumipsel.bin | ||
| 336 | QEMUMIPSEL_DEFAULT_FSTYPE=ext4 | ||
| 337 | |||
| 338 | QEMUMIPS64_DEFAULT_KERNEL=vmlinux-qemumips64.bin | ||
| 339 | QEMUMIPS64_DEFAULT_FSTYPE=ext4 | ||
| 340 | |||
| 341 | QEMUSH4_DEFAULT_KERNEL=vmlinux-qemumips.bin | ||
| 342 | QEMUSH4_DEFAULT_FSTYPE=ext4 | ||
| 343 | |||
| 344 | QEMUPPC_DEFAULT_KERNEL=vmlinux-qemuppc.bin | ||
| 345 | QEMUPPC_DEFAULT_FSTYPE=ext4 | ||
| 346 | |||
| 347 | QEMUMICROBLAZE_DEFAULT_KERNEL=linux.bin.ub | ||
| 348 | QEMUMICROBLAZE_DEFAULT_FSTYPE=cpio | ||
| 349 | |||
| 350 | QEMUZYNQ_DEFAULT_KERNEL=uImage | ||
| 351 | QEMUZYNQ_DEFAULT_FSTYPE=cpio | ||
| 352 | |||
| 353 | QEMUZYNQMP_DEFAULT_KERNEL=Image | ||
| 354 | QEMUZYNQMP_DEFAULT_FSTYPE=cpio | ||
| 355 | |||
| 356 | setup_path_vars() { | ||
| 357 | if [ -z "$OE_TMPDIR" ] ; then | ||
| 358 | PATHS_REQUIRED=true | ||
| 359 | elif [ "$1" = "1" -a -z "$DEPLOY_DIR_IMAGE" ] ; then | ||
| 360 | PATHS_REQUIRED=true | ||
| 361 | else | ||
| 362 | PATHS_REQUIRED=false | ||
| 363 | fi | ||
| 364 | |||
| 365 | if [ "$PATHS_REQUIRED" = "true" ]; then | ||
| 366 | # Try to get the variable values from bitbake | ||
| 367 | type -P bitbake &>/dev/null || { | ||
| 368 | echo "In order for this script to dynamically infer paths"; | ||
| 369 | echo "to kernels or filesystem images, you either need"; | ||
| 370 | echo "bitbake in your PATH or to source oe-init-build-env"; | ||
| 371 | echo "before running this script" >&2; | ||
| 372 | exit 1; } | ||
| 373 | |||
| 374 | # We have bitbake in PATH, get the variable values from bitbake | ||
| 375 | BITBAKE_ENV_TMPFILE=`mktemp --tmpdir runqemu.XXXXXXXXXX` | ||
| 376 | if [ "$?" != "0" ] ; then | ||
| 377 | echo "Error: mktemp failed for bitbake environment output" | ||
| 378 | exit 1 | ||
| 379 | fi | ||
| 380 | |||
| 381 | MACHINE=$MACHINE bitbake -e > $BITBAKE_ENV_TMPFILE | ||
| 382 | if [ -z "$OE_TMPDIR" ] ; then | ||
| 383 | OE_TMPDIR=`sed -n 's/^TMPDIR=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE` | ||
| 384 | fi | ||
| 385 | if [ -z "$DEPLOY_DIR_IMAGE" ] ; then | ||
| 386 | DEPLOY_DIR_IMAGE=`sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE` | ||
| 387 | fi | ||
| 388 | if [ -z "$QEMU_DTB" ] ; then | ||
| 389 | QEMU_DTB=`sed -n 's/^QEMU_DTB=\"\(.*\)\"/\1/p' $BITBAKE_ENV_TMPFILE` | ||
| 390 | fi | ||
| 391 | if [ -z "$OE_TMPDIR" ]; then | ||
| 392 | # Check for errors from bitbake that the user needs to know about | ||
| 393 | BITBAKE_OUTPUT=`cat $BITBAKE_ENV_TMPFILE | wc -l` | ||
| 394 | if [ "$BITBAKE_OUTPUT" -eq "0" ]; then | ||
| 395 | echo "Error: this script needs to be run from your build directory, or you need" | ||
| 396 | echo "to explicitly set OE_TMPDIR and DEPLOY_DIR_IMAGE in your environment" | ||
| 397 | else | ||
| 398 | echo "There was an error running bitbake to determine TMPDIR" | ||
| 399 | echo "Here is the output from 'bitbake -e':" | ||
| 400 | cat $BITBAKE_ENV_TMPFILE | ||
| 401 | fi | ||
| 402 | rm $BITBAKE_ENV_TMPFILE | ||
| 403 | exit 1 | ||
| 404 | fi | ||
| 405 | rm $BITBAKE_ENV_TMPFILE | ||
| 406 | fi | ||
| 407 | } | ||
| 408 | |||
| 409 | setup_sysroot() { | ||
| 410 | # Toolchain installs set up $OECORE_NATIVE_SYSROOT in their | ||
| 411 | # environment script. If that variable isn't set, we're | ||
| 412 | # either in an in-tree build scenario or the environment | ||
| 413 | # script wasn't source'd. | ||
| 414 | if [ -z "$OECORE_NATIVE_SYSROOT" ]; then | ||
| 415 | setup_path_vars | ||
| 416 | BUILD_ARCH=`uname -m` | ||
| 417 | BUILD_OS=`uname | tr '[A-Z]' '[a-z]'` | ||
| 418 | BUILD_SYS="$BUILD_ARCH-$BUILD_OS" | ||
| 419 | |||
| 420 | OECORE_NATIVE_SYSROOT=$OE_TMPDIR/sysroots/$BUILD_SYS | ||
| 421 | fi | ||
| 422 | |||
| 423 | # Some recipes store the BIOS under $OE_TMPDIR/sysroots/$MACHINE, | ||
| 424 | # now defined as OECORE_MACHINE_SYSROOT. The latter is used when searching | ||
| 425 | # BIOS, VGA BIOS and keymaps. | ||
| 426 | if [ -z "$OECORE_MACHINE_SYSROOT" ]; then | ||
| 427 | OECORE_MACHINE_SYSROOT=$OE_TMPDIR/sysroots/$MACHINE | ||
| 428 | fi | ||
| 429 | } | ||
| 430 | |||
| 431 | # Locate a rootfs image to boot which matches our expected | ||
| 432 | # machine and fstype. | ||
| 433 | findimage() { | ||
| 434 | where=$1 | ||
| 435 | machine=$2 | ||
| 436 | extension=$3 | ||
| 437 | |||
| 438 | # Sort rootfs candidates by modification time - the most | ||
| 439 | # recently created one is the one we most likely want to boot. | ||
| 440 | filename=`ls -t1 $where/*-image*$machine.$extension 2>/dev/null | head -n1` | ||
| 441 | if [ "x$filename" != "x" ]; then | ||
| 442 | ROOTFS=$filename | ||
| 443 | return | ||
| 444 | fi | ||
| 445 | |||
| 446 | echo "Couldn't find a $machine rootfs image in $where." | ||
| 447 | exit 1 | ||
| 448 | } | ||
| 449 | |||
| 450 | # Bios is necessary when using otaimg, look for it | ||
| 451 | if [ "$FSTYPE" = "otaimg" ]; then | ||
| 452 | setup_path_vars 1 | ||
| 453 | bios_option=`expr "$SCRIPT_QEMU_OPT" : '.*\(-bios\)'` | ||
| 454 | echo "bios_option: $bios_option" | ||
| 455 | if [ -z $bios_option ]; then | ||
| 456 | echo "LOOK FOR BIOS at ${DEPLOY_DIR_IMAGE}" | ||
| 457 | # if -bios wasn't specified explicitly, try to look at the default location | ||
| 458 | if [ -e "${DEPLOY_DIR_IMAGE}/u-boot.rom" ]; then | ||
| 459 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -bios ${DEPLOY_DIR_IMAGE}/u-boot.rom" | ||
| 460 | else | ||
| 461 | error "OTA image requires specifying u-boot as BIOS" | ||
| 462 | fi | ||
| 463 | fi | ||
| 464 | fi | ||
| 465 | |||
| 466 | |||
| 467 | # Kernel command line is stored in compressed format as u-boot environment | ||
| 468 | # which breaks determining drive interface with grep in runqemu-internal | ||
| 469 | if [ "$FSTYPE" = "otaimg" ]; then | ||
| 470 | FORCE_DRIVE_IF="ide" | ||
| 471 | fi | ||
| 472 | |||
| 473 | if [ -e "$ROOTFS" -a -z "$FSTYPE" ]; then | ||
| 474 | # Extract the filename extension | ||
| 475 | EXT=`echo $ROOTFS | awk -F . '{ print \$NF }'` | ||
| 476 | if [ "x$EXT" = "xext2" -o "x$EXT" = "xext3" -o \ | ||
| 477 | "x$EXT" = "xjffs2" -o "x$EXT" = "xbtrfs" -o \ | ||
| 478 | "x$EXT" = "xext4" ]; then | ||
| 479 | FSTYPE=$EXT | ||
| 480 | else | ||
| 481 | echo "Note: Unable to determine filesystem extension for $ROOTFS" | ||
| 482 | echo "We will use the default FSTYPE for $MACHINE" | ||
| 483 | # ...which is done further below... | ||
| 484 | fi | ||
| 485 | fi | ||
| 486 | |||
| 487 | if [ -z "$KERNEL" -a "$IS_VM" = "false" ]; then \ | ||
| 488 | setup_path_vars 1 | ||
| 489 | eval kernel_file=\$${machine2}_DEFAULT_KERNEL | ||
| 490 | KERNEL=$DEPLOY_DIR_IMAGE/$kernel_file | ||
| 491 | |||
| 492 | if [ -z "$KERNEL" ]; then | ||
| 493 | error "Unable to determine default kernel for MACHINE [$MACHINE]" | ||
| 494 | fi | ||
| 495 | fi | ||
| 496 | # KERNEL is now set for all cases | ||
| 497 | |||
| 498 | if [ -z "$FSTYPE" ]; then | ||
| 499 | eval FSTYPE=\$${machine2}_DEFAULT_FSTYPE | ||
| 500 | |||
| 501 | if [ -z "$FSTYPE" ]; then | ||
| 502 | error "Unable to determine default fstype for MACHINE [$MACHINE]" | ||
| 503 | fi | ||
| 504 | fi | ||
| 505 | |||
| 506 | # FSTYPE is now set for all cases | ||
| 507 | |||
| 508 | # Handle cases where a ROOTFS type is given instead of a filename, e.g. | ||
| 509 | # core-image-sato | ||
| 510 | if [ "$LAZY_ROOTFS" = "true" ]; then | ||
| 511 | setup_path_vars 1 | ||
| 512 | echo "Assuming $ROOTFS really means $DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE" | ||
| 513 | if [ "$IS_VM" = "true" ]; then | ||
| 514 | VM=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE | ||
| 515 | else | ||
| 516 | ROOTFS=$DEPLOY_DIR_IMAGE/$ROOTFS-$MACHINE.$FSTYPE | ||
| 517 | fi | ||
| 518 | fi | ||
| 519 | |||
| 520 | if [ -z "$ROOTFS" ]; then | ||
| 521 | setup_path_vars 1 | ||
| 522 | T=$DEPLOY_DIR_IMAGE | ||
| 523 | eval rootfs_list=\$${machine2}_DEFAULT_ROOTFS | ||
| 524 | findimage $T $MACHINE $FSTYPE | ||
| 525 | |||
| 526 | if [ -z "$ROOTFS" ]; then | ||
| 527 | error "Unable to determine default rootfs for MACHINE [$MACHINE]" | ||
| 528 | elif [ "$IS_VM" = "true" ]; then | ||
| 529 | VM=$ROOTFS | ||
| 530 | fi | ||
| 531 | fi | ||
| 532 | # ROOTFS is now set for all cases, now expand it to be an absolute path, it should exist at this point | ||
| 533 | |||
| 534 | ROOTFS=`readlink -f $ROOTFS` | ||
| 535 | |||
| 536 | echo "" | ||
| 537 | echo "Continuing with the following parameters:" | ||
| 538 | if [ "$IS_VM" = "false" ]; then | ||
| 539 | echo "KERNEL: [$KERNEL]" | ||
| 540 | echo "ROOTFS: [$ROOTFS]" | ||
| 541 | else | ||
| 542 | echo "VM: [$VM]" | ||
| 543 | fi | ||
| 544 | echo "FSTYPE: [$FSTYPE]" | ||
| 545 | |||
| 546 | setup_sysroot | ||
| 547 | # OECORE_NATIVE_SYSROOT and OECORE_MACHINE_SYSROOT are now set for all cases | ||
| 548 | |||
| 549 | INTERNAL_SCRIPT="$0-internal" | ||
| 550 | if [ ! -f "$INTERNAL_SCRIPT" -o ! -r "$INTERNAL_SCRIPT" ]; then | ||
| 551 | INTERNAL_SCRIPT=`which runqemu-internal` | ||
| 552 | fi | ||
| 553 | |||
| 554 | # Specify directory for BIOS, VGA BIOS and keymaps | ||
| 555 | if [ ! -z "$CUSTOMBIOSDIR" ]; then | ||
| 556 | if [ -d "$OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR" ]; then | ||
| 557 | echo "Assuming biosdir is $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR" | ||
| 558 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR" | ||
| 559 | elif [ -d "$OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR" ]; then | ||
| 560 | echo "Assuming biosdir is $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR" | ||
| 561 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR" | ||
| 562 | else | ||
| 563 | if [ ! -d "$CUSTOMBIOSDIR" ]; then | ||
| 564 | echo "Custom BIOS directory not found. Tried: $CUSTOMBIOSDIR" | ||
| 565 | echo "and $OECORE_NATIVE_SYSROOT/$CUSTOMBIOSDIR" | ||
| 566 | echo "and $OECORE_MACHINE_SYSROOT/$CUSTOMBIOSDIR" | ||
| 567 | exit 1; | ||
| 568 | fi | ||
| 569 | echo "Assuming biosdir is $CUSTOMBIOSDIR" | ||
| 570 | SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -L $CUSTOMBIOSDIR" | ||
| 571 | fi | ||
| 572 | fi | ||
| 573 | |||
| 574 | . $INTERNAL_SCRIPT | ||
| 575 | exit $? | ||
diff --git a/scripts/runqemu-addptable2image b/scripts/runqemu-addptable2image deleted file mode 100755 index f0195ad..0000000 --- a/scripts/runqemu-addptable2image +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Add a partion table to an ext2 image file | ||
| 4 | # | ||
| 5 | # Copyright (C) 2006-2007 OpenedHand Ltd. | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License as published by | ||
| 9 | # the Free Software Foundation; either version 2 of the License, or | ||
| 10 | # (at your option) any later version. | ||
| 11 | # | ||
| 12 | # This program is distributed in the hope that it will be useful, | ||
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | # GNU General Public License for more details. | ||
| 16 | # | ||
| 17 | # You should have received a copy of the GNU General Public License | ||
| 18 | # along with this program; if not, write to the Free Software | ||
| 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | |||
| 21 | |||
| 22 | IMAGE=$1 | ||
| 23 | IMAGEOUT=$2 | ||
| 24 | |||
| 25 | echo $IMAGE | ||
| 26 | echo $IMAGEOUT | ||
| 27 | |||
| 28 | size=`ls -l $IMAGE | awk '{ print $5}'` | ||
| 29 | size2=`expr $size / 512 / 16 / 63` | ||
| 30 | |||
| 31 | echo $size | ||
| 32 | echo $size2 | ||
| 33 | |||
| 34 | # MBR Size = 512 * 63 bytes | ||
| 35 | dd if=/dev/zero of=$IMAGEOUT count=63 | ||
| 36 | |||
| 37 | echo "x" > /tmp/fdisk.cmds | ||
| 38 | echo "c" >> /tmp/fdisk.cmds | ||
| 39 | echo "1024" >> /tmp/fdisk.cmds | ||
| 40 | echo "h" >> /tmp/fdisk.cmds | ||
| 41 | echo "16" >> /tmp/fdisk.cmds | ||
| 42 | echo "r" >> /tmp/fdisk.cmds | ||
| 43 | echo "n" >> /tmp/fdisk.cmds | ||
| 44 | echo "p" >> /tmp/fdisk.cmds | ||
| 45 | echo "1" >> /tmp/fdisk.cmds | ||
| 46 | echo "1" >> /tmp/fdisk.cmds | ||
| 47 | echo "$size2" >> /tmp/fdisk.cmds | ||
| 48 | echo "w" >> /tmp/fdisk.cmds | ||
| 49 | |||
| 50 | /sbin/fdisk $IMAGEOUT < /tmp/fdisk.cmds | ||
| 51 | cat $IMAGE >> $IMAGEOUT | ||
diff --git a/scripts/runqemu-export-rootfs b/scripts/runqemu-export-rootfs deleted file mode 100755 index 3dee131..0000000 --- a/scripts/runqemu-export-rootfs +++ /dev/null | |||
| @@ -1,163 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Copyright (c) 2005-2009 Wind River Systems, Inc. | ||
| 4 | # | ||
| 5 | # This program is free software; you can redistribute it and/or modify | ||
| 6 | # it under the terms of the GNU General Public License version 2 as | ||
| 7 | # published by the Free Software Foundation. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 12 | # See the GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program; if not, write to the Free Software | ||
| 16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 17 | |||
| 18 | usage() { | ||
| 19 | echo "Usage: $0 {start|stop|restart} <nfs-export-dir>" | ||
| 20 | } | ||
| 21 | |||
| 22 | if [ $# != 2 ]; then | ||
| 23 | usage | ||
| 24 | exit 1 | ||
| 25 | fi | ||
| 26 | |||
| 27 | if [[ "$1" != "start" && "$1" != "stop" && "$1" != "restart" ]]; then | ||
| 28 | echo "Unknown command '$1'" | ||
| 29 | usage | ||
| 30 | exit 1 | ||
| 31 | fi | ||
| 32 | |||
| 33 | if [ ! -d "$2" ]; then | ||
| 34 | echo "Error: '$2' does not exist" | ||
| 35 | usage | ||
| 36 | exit 1 | ||
| 37 | fi | ||
| 38 | # Ensure the nfs-export-dir is an absolute path | ||
| 39 | NFS_EXPORT_DIR=$(cd "$2" && pwd) | ||
| 40 | |||
| 41 | SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot 2> /dev/null` | ||
| 42 | if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then | ||
| 43 | echo "Error: Unable to find the oe-find-native-sysroot script" | ||
| 44 | echo "Did you forget to source your build environment setup script?" | ||
| 45 | exit 1 | ||
| 46 | fi | ||
| 47 | . $SYSROOT_SETUP_SCRIPT | ||
| 48 | |||
| 49 | if [ ! -e "$OECORE_NATIVE_SYSROOT/usr/bin/unfsd" ]; then | ||
| 50 | echo "Error: Unable to find unfsd binary in $OECORE_NATIVE_SYSROOT/usr/bin/" | ||
| 51 | |||
| 52 | if [ "x$OECORE_DISTRO_VERSION" = "x" ]; then | ||
| 53 | echo "Have you run 'bitbake meta-ide-support'?" | ||
| 54 | else | ||
| 55 | echo "This shouldn't happen - something is missing from your toolchain installation" | ||
| 56 | fi | ||
| 57 | exit 1 | ||
| 58 | fi | ||
| 59 | |||
| 60 | if [ ! -d ~/.runqemu-sdk ]; then | ||
| 61 | mkdir -p ~/.runqemu-sdk | ||
| 62 | fi | ||
| 63 | |||
| 64 | NFS_INSTANCE=${NFS_INSTANCE:=0} | ||
| 65 | EXPORTS=~/.runqemu-sdk/exports$NFS_INSTANCE | ||
| 66 | RMTAB=~/.runqemu-sdk/rmtab$NFS_INSTANCE | ||
| 67 | NFSPID=~/.runqemu-sdk/nfs$NFS_INSTANCE.pid | ||
| 68 | MOUNTPID=~/.runqemu-sdk/mount$NFS_INSTANCE.pid | ||
| 69 | |||
| 70 | PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr" | ||
| 71 | PSEUDO_LOCALSTATEDIR="$NFS_EXPORT_DIR/../$(basename $NFS_EXPORT_DIR).pseudo_state" | ||
| 72 | export PSEUDO_LOCALSTATEDIR | ||
| 73 | |||
| 74 | if [ ! -d "$PSEUDO_LOCALSTATEDIR" ]; then | ||
| 75 | echo "Error: $PSEUDO_LOCALSTATEDIR does not exist." | ||
| 76 | echo "Did you create the export directory using runqemu-extract-sdk?" | ||
| 77 | exit 1 | ||
| 78 | fi | ||
| 79 | |||
| 80 | # rpc.mountd RPC port | ||
| 81 | NFS_MOUNTPROG=$[ 21111 + $NFS_INSTANCE ] | ||
| 82 | # rpc.nfsd RPC port | ||
| 83 | NFS_NFSPROG=$[ 11111 + $NFS_INSTANCE ] | ||
| 84 | # NFS port number | ||
| 85 | NFS_PORT=$[ 3049 + 2 * $NFS_INSTANCE ] | ||
| 86 | # mountd port number | ||
| 87 | MOUNT_PORT=$[ 3048 + 2 * $NFS_INSTANCE ] | ||
| 88 | |||
| 89 | ## For debugging you would additionally add | ||
| 90 | ## --debug all | ||
| 91 | UNFSD_OPTS="-p -N -i $NFSPID -e $EXPORTS -x $NFS_NFSPROG -n $NFS_PORT -y $NFS_MOUNTPROG -m $MOUNT_PORT" | ||
| 92 | |||
| 93 | # Setup the exports file | ||
| 94 | if [ "$1" = "start" ]; then | ||
| 95 | echo "Creating exports file..." | ||
| 96 | echo "$NFS_EXPORT_DIR (rw,async,no_root_squash,no_all_squash,insecure)" > $EXPORTS | ||
| 97 | fi | ||
| 98 | |||
| 99 | # See how we were called. | ||
| 100 | case "$1" in | ||
| 101 | start) | ||
| 102 | PORTMAP_RUNNING=`ps -ef | grep portmap | grep -v grep` | ||
| 103 | RPCBIND_RUNNING=`ps -ef | grep rpcbind | grep -v grep` | ||
| 104 | if [[ "x$PORTMAP_RUNNING" = "x" && "x$RPCBIND_RUNNING" = "x" ]]; then | ||
| 105 | echo "=======================================================" | ||
| 106 | echo "Error: neither rpcbind nor portmap appear to be running" | ||
| 107 | echo "Please install and start one of these services first" | ||
| 108 | echo "=======================================================" | ||
| 109 | echo "Tip: for recent Ubuntu hosts, run:" | ||
| 110 | echo " sudo apt-get install rpcbind" | ||
| 111 | echo "Then add OPTIONS=\"-i -w\" to /etc/default/rpcbind and run" | ||
| 112 | echo " sudo service portmap restart" | ||
| 113 | |||
| 114 | exit 1 | ||
| 115 | fi | ||
| 116 | |||
| 117 | echo "Starting User Mode nfsd" | ||
| 118 | echo " $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/bin/unfsd $UNFSD_OPTS" | ||
| 119 | $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/bin/unfsd $UNFSD_OPTS | ||
| 120 | if [ ! $? = 0 ]; then | ||
| 121 | echo "Error starting nfsd" | ||
| 122 | exit 1 | ||
| 123 | fi | ||
| 124 | # Check to make sure everything started ok. | ||
| 125 | if [ ! -f $NFSPID ]; then | ||
| 126 | echo "rpc.nfsd did not start correctly" | ||
| 127 | exit 1 | ||
| 128 | fi | ||
| 129 | ps -fp `cat $NFSPID` > /dev/null 2> /dev/null | ||
| 130 | if [ ! $? = 0 ]; then | ||
| 131 | echo "rpc.nfsd did not start correctly" | ||
| 132 | exit 1 | ||
| 133 | fi | ||
| 134 | echo " " | ||
| 135 | echo "On your target please remember to add the following options for NFS" | ||
| 136 | echo "nfsroot=IP_ADDRESS:$NFS_EXPORT_DIR,nfsvers=3,port=$NFSD_PORT,mountprog=$MOUNTD_RPCPORT,nfsprog=$NFSD_RPCPORT,udp,mountport=$MOUNTD_PORT" | ||
| 137 | ;; | ||
| 138 | stop) | ||
| 139 | if [ -f "$NFSPID" ]; then | ||
| 140 | echo "Stopping rpc.nfsd" | ||
| 141 | kill `cat $NFSPID` | ||
| 142 | rm -f $NFSPID | ||
| 143 | else | ||
| 144 | echo "No PID file, not stopping rpc.nfsd" | ||
| 145 | fi | ||
| 146 | if [ -f "$EXPORTS" ]; then | ||
| 147 | echo "Removing exports file" | ||
| 148 | rm -f $EXPORTS | ||
| 149 | fi | ||
| 150 | ;; | ||
| 151 | restart) | ||
| 152 | $0 stop $NFS_EXPORT_DIR | ||
| 153 | $0 start $NFS_EXPORT_DIR | ||
| 154 | if [ ! $? = 0 ]; then | ||
| 155 | exit 1 | ||
| 156 | fi | ||
| 157 | ;; | ||
| 158 | *) | ||
| 159 | echo "$0 {start|stop|restart} <nfs-export-dir>" | ||
| 160 | ;; | ||
| 161 | esac | ||
| 162 | |||
| 163 | exit 0 | ||
diff --git a/scripts/runqemu-extract-sdk b/scripts/runqemu-extract-sdk deleted file mode 100755 index 32ddd48..0000000 --- a/scripts/runqemu-extract-sdk +++ /dev/null | |||
| @@ -1,104 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # This utility extracts an SDK image tarball using pseudo, and stores | ||
| 4 | # the pseudo database in var/pseudo within the rootfs. If you want to | ||
| 5 | # boot QEMU using an nfsroot, you *must* use this script to create the | ||
| 6 | # rootfs to ensure it is done correctly with pseudo. | ||
| 7 | # | ||
| 8 | # Copyright (c) 2010 Intel Corp. | ||
| 9 | # | ||
| 10 | # This program is free software; you can redistribute it and/or modify | ||
| 11 | # it under the terms of the GNU General Public License version 2 as | ||
| 12 | # published by the Free Software Foundation. | ||
| 13 | # | ||
| 14 | # This program is distributed in the hope that it will be useful, | ||
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 17 | # See the GNU General Public License for more details. | ||
| 18 | # | ||
| 19 | # You should have received a copy of the GNU General Public License | ||
| 20 | # along with this program; if not, write to the Free Software | ||
| 21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 22 | |||
| 23 | function usage() { | ||
| 24 | echo "Usage: $0 <image-tarball> <extract-dir>" | ||
| 25 | } | ||
| 26 | |||
| 27 | if [ $# -ne 2 ]; then | ||
| 28 | usage | ||
| 29 | exit 1 | ||
| 30 | fi | ||
| 31 | |||
| 32 | SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot 2> /dev/null` | ||
| 33 | if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then | ||
| 34 | echo "Error: Unable to find the oe-find-native-sysroot script" | ||
| 35 | echo "Did you forget to source your build system environment setup script?" | ||
| 36 | exit 1 | ||
| 37 | fi | ||
| 38 | . $SYSROOT_SETUP_SCRIPT | ||
| 39 | PSEUDO_OPTS="-P $OECORE_NATIVE_SYSROOT/usr" | ||
| 40 | |||
| 41 | ROOTFS_TARBALL=$1 | ||
| 42 | SDK_ROOTFS_DIR=$2 | ||
| 43 | |||
| 44 | if [ ! -e "$ROOTFS_TARBALL" ]; then | ||
| 45 | echo "Error: sdk tarball '$ROOTFS_TARBALL' does not exist" | ||
| 46 | usage | ||
| 47 | exit 1 | ||
| 48 | fi | ||
| 49 | |||
| 50 | # Convert SDK_ROOTFS_DIR to a full pathname | ||
| 51 | if [[ ${SDK_ROOTFS_DIR:0:1} != "/" ]]; then | ||
| 52 | SDK_ROOTFS_DIR=$(readlink -f $(pwd)/$SDK_ROOTFS_DIR) | ||
| 53 | fi | ||
| 54 | |||
| 55 | TAR_OPTS="" | ||
| 56 | if [[ "$ROOTFS_TARBALL" =~ tar\.bz2$ ]]; then | ||
| 57 | TAR_OPTS="--numeric-owner -xjf" | ||
| 58 | fi | ||
| 59 | if [[ "$ROOTFS_TARBALL" =~ tar\.gz$ ]]; then | ||
| 60 | TAR_OPTS="--numeric-owner -xzf" | ||
| 61 | fi | ||
| 62 | if [[ "$ROOTFS_TARBALL" =~ \.tar$ ]]; then | ||
| 63 | TAR_OPTS="--numeric-owner -xf" | ||
| 64 | fi | ||
| 65 | if [ -z "$TAR_OPTS" ]; then | ||
| 66 | echo "Error: Unable to determine sdk tarball format" | ||
| 67 | echo "Accepted types: .tar / .tar.gz / .tar.bz2" | ||
| 68 | exit 1 | ||
| 69 | fi | ||
| 70 | |||
| 71 | if [ ! -d "$SDK_ROOTFS_DIR" ]; then | ||
| 72 | echo "Creating directory $SDK_ROOTFS_DIR" | ||
| 73 | mkdir -p "$SDK_ROOTFS_DIR" | ||
| 74 | fi | ||
| 75 | |||
| 76 | pseudo_state_dir="$SDK_ROOTFS_DIR/../$(basename "$SDK_ROOTFS_DIR").pseudo_state" | ||
| 77 | pseudo_state_dir="$(readlink -f $pseudo_state_dir)" | ||
| 78 | |||
| 79 | if [ -e "$pseudo_state_dir" ]; then | ||
| 80 | echo "Error: $pseudo_state_dir already exists!" | ||
| 81 | echo "Please delete the rootfs tree and pseudo directory manually" | ||
| 82 | echo "if this is really what you want." | ||
| 83 | exit 1 | ||
| 84 | fi | ||
| 85 | |||
| 86 | mkdir -p "$pseudo_state_dir" | ||
| 87 | touch "$pseudo_state_dir/pseudo.pid" | ||
| 88 | PSEUDO_LOCALSTATEDIR="$pseudo_state_dir" | ||
| 89 | export PSEUDO_LOCALSTATEDIR | ||
| 90 | |||
| 91 | echo "Extracting rootfs tarball using pseudo..." | ||
| 92 | echo "$PSEUDO $PSEUDO_OPTS tar -C \"$SDK_ROOTFS_DIR\" $TAR_OPTS \"$ROOTFS_TARBALL\"" | ||
| 93 | $PSEUDO $PSEUDO_OPTS tar -C "$SDK_ROOTFS_DIR" $TAR_OPTS "$ROOTFS_TARBALL" | ||
| 94 | |||
| 95 | DIRCHECK=`ls -l "$SDK_ROOTFS_DIR" | wc -l` | ||
| 96 | if [ "$DIRCHECK" -lt 5 ]; then | ||
| 97 | echo "Warning: I don't see many files in $SDK_ROOTFS_DIR" | ||
| 98 | echo "Please double-check the extraction worked as intended" | ||
| 99 | exit 0 | ||
| 100 | fi | ||
| 101 | |||
| 102 | echo "SDK image successfully extracted to $SDK_ROOTFS_DIR" | ||
| 103 | |||
| 104 | exit 0 | ||
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs deleted file mode 100755 index 624deac..0000000 --- a/scripts/runqemu-gen-tapdevs +++ /dev/null | |||
| @@ -1,100 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Create a "bank" of tap network devices that can be used by the | ||
| 4 | # runqemu script. This script needs to be run as root, and will | ||
| 5 | # use the tunctl binary from the build system sysroot. Note: many Linux | ||
| 6 | # distros these days still use an older version of tunctl which does not | ||
| 7 | # support the group permissions option, hence the need to use the build | ||
| 8 | # system provided version. | ||
| 9 | # | ||
| 10 | # Copyright (C) 2010 Intel Corp. | ||
| 11 | # | ||
| 12 | # This program is free software; you can redistribute it and/or modify | ||
| 13 | # it under the terms of the GNU General Public License version 2 as | ||
| 14 | # published by the Free Software Foundation. | ||
| 15 | # | ||
| 16 | # This program is distributed in the hope that it will be useful, | ||
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | # GNU General Public License for more details. | ||
| 20 | # | ||
| 21 | # You should have received a copy of the GNU General Public License along | ||
| 22 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 23 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 24 | |||
| 25 | usage() { | ||
| 26 | echo "Usage: sudo $0 <uid> <gid> <num> <native-sysroot-basedir>" | ||
| 27 | echo "Where <uid> is the numeric user id the tap devices will be owned by" | ||
| 28 | echo "Where <gid> is the numeric group id the tap devices will be owned by" | ||
| 29 | echo "<num> is the number of tap devices to create (0 to remove all)" | ||
| 30 | echo "<native-sysroot-basedir> is the path to the build system's native sysroot" | ||
| 31 | exit 1 | ||
| 32 | } | ||
| 33 | |||
| 34 | if [ $EUID -ne 0 ]; then | ||
| 35 | echo "Error: This script must be run with root privileges" | ||
| 36 | exit | ||
| 37 | fi | ||
| 38 | |||
| 39 | if [ $# -ne 4 ]; then | ||
| 40 | echo "Error: Incorrect number of arguments" | ||
| 41 | usage | ||
| 42 | fi | ||
| 43 | |||
| 44 | TUID=$1 | ||
| 45 | GID=$2 | ||
| 46 | COUNT=$3 | ||
| 47 | SYSROOT=$4 | ||
| 48 | |||
| 49 | TUNCTL=$SYSROOT/usr/bin/tunctl | ||
| 50 | if [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then | ||
| 51 | echo "Error: $TUNCTL is not an executable" | ||
| 52 | usage | ||
| 53 | fi | ||
| 54 | |||
| 55 | SCRIPT_DIR=`dirname $0` | ||
| 56 | RUNQEMU_IFUP="$SCRIPT_DIR/runqemu-ifup" | ||
| 57 | if [ ! -x "$RUNQEMU_IFUP" ]; then | ||
| 58 | echo "Error: Unable to find the runqemu-ifup script in $SCRIPT_DIR" | ||
| 59 | exit 1 | ||
| 60 | fi | ||
| 61 | |||
| 62 | IFCONFIG=`which ip 2> /dev/null` | ||
| 63 | if [ -z "$IFCONFIG" ]; then | ||
| 64 | # Is it ever anywhere else? | ||
| 65 | IFCONFIG=/sbin/ip | ||
| 66 | fi | ||
| 67 | if [ ! -x "$IFCONFIG" ]; then | ||
| 68 | echo "$IFCONFIG cannot be executed" | ||
| 69 | exit 1 | ||
| 70 | fi | ||
| 71 | |||
| 72 | # Ensure we start with a clean slate | ||
| 73 | for tap in `$IFCONFIG link | grep tap | awk '{ print \$2 }' | sed s/://`; do | ||
| 74 | echo "Note: Destroying pre-existing tap interface $tap..." | ||
| 75 | $TUNCTL -d $tap | ||
| 76 | done | ||
| 77 | |||
| 78 | echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..." | ||
| 79 | for ((index=0; index < $COUNT; index++)); do | ||
| 80 | echo "Creating tap$index" | ||
| 81 | ifup=`$RUNQEMU_IFUP $TUID $GID $SYSROOT 2>&1` | ||
| 82 | if [ $? -ne 0 ]; then | ||
| 83 | echo "Error running tunctl: $ifup" | ||
| 84 | exit 1 | ||
| 85 | fi | ||
| 86 | done | ||
| 87 | |||
| 88 | if [ $COUNT -gt 0 ]; then | ||
| 89 | echo "Note: For systems running NetworkManager, it's recommended" | ||
| 90 | echo "Note: that the tap devices be set as unmanaged in the" | ||
| 91 | echo "Note: NetworkManager.conf file. Add the following lines to" | ||
| 92 | echo "Note: /etc/NetworkManager/NetworkManager.conf" | ||
| 93 | echo "[keyfile]" | ||
| 94 | echo "unmanaged-devices=interface-name:tap*" | ||
| 95 | fi | ||
| 96 | |||
| 97 | # The runqemu script will check for this file, and if it exists, | ||
| 98 | # will use the existing bank of tap devices without creating | ||
| 99 | # additional ones via sudo. | ||
| 100 | touch /etc/runqemu-nosudo | ||
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown deleted file mode 100755 index 8f66cfa..0000000 --- a/scripts/runqemu-ifdown +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # QEMU network configuration script to bring down tap devices. This | ||
| 4 | # utility needs to be run as root, and will use the tunctl binary | ||
| 5 | # from the native sysroot. | ||
| 6 | # | ||
| 7 | # If you find yourself calling this script a lot, you can add the | ||
| 8 | # the following to your /etc/sudoers file to be able to run this | ||
| 9 | # command without entering your password each time: | ||
| 10 | # | ||
| 11 | # <my-username> ALL=NOPASSWD: /path/to/runqemu-ifup | ||
| 12 | # <my-username> ALL=NOPASSWD: /path/to/runqemu-ifdown | ||
| 13 | # | ||
| 14 | # Copyright (c) 2006-2011 Linux Foundation | ||
| 15 | # | ||
| 16 | # This program is free software; you can redistribute it and/or modify | ||
| 17 | # it under the terms of the GNU General Public License version 2 as | ||
| 18 | # published by the Free Software Foundation. | ||
| 19 | # | ||
| 20 | # This program is distributed in the hope that it will be useful, | ||
| 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 23 | # GNU General Public License for more details. | ||
| 24 | # | ||
| 25 | # You should have received a copy of the GNU General Public License along | ||
| 26 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 27 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 28 | |||
| 29 | usage() { | ||
| 30 | echo "sudo $(basename $0) <tap-dev> <native-sysroot-basedir>" | ||
| 31 | } | ||
| 32 | |||
| 33 | if [ $EUID -ne 0 ]; then | ||
| 34 | echo "Error: This script (runqemu-ifdown) must be run with root privileges" | ||
| 35 | exit 1 | ||
| 36 | fi | ||
| 37 | |||
| 38 | if [ $# -ne 2 ]; then | ||
| 39 | usage | ||
| 40 | exit 1 | ||
| 41 | fi | ||
| 42 | |||
| 43 | TAP=$1 | ||
| 44 | NATIVE_SYSROOT_DIR=$2 | ||
| 45 | |||
| 46 | TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl | ||
| 47 | if [ ! -e "$TUNCTL" ]; then | ||
| 48 | echo "Error: Unable to find tunctl binary in '$NATIVE_SYSROOT_DIR/usr/bin', please bitbake qemu-helper-native" | ||
| 49 | exit 1 | ||
| 50 | fi | ||
| 51 | |||
| 52 | $TUNCTL -d $TAP | ||
| 53 | |||
| 54 | # cleanup the remaining iptables rules | ||
| 55 | IPTABLES=`which iptables 2> /dev/null` | ||
| 56 | if [ "x$IPTABLES" = "x" ]; then | ||
| 57 | IPTABLES=/sbin/iptables | ||
| 58 | fi | ||
| 59 | if [ ! -x "$IPTABLES" ]; then | ||
| 60 | echo "$IPTABLES cannot be executed" | ||
| 61 | exit 1 | ||
| 62 | fi | ||
| 63 | n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] | ||
| 64 | dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] | ||
| 65 | $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 | ||
| 66 | $IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32 | ||
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup deleted file mode 100755 index d9bd894..0000000 --- a/scripts/runqemu-ifup +++ /dev/null | |||
| @@ -1,121 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # QEMU network interface configuration script. This utility needs to | ||
| 4 | # be run as root, and will use the tunctl binary from a native sysroot. | ||
| 5 | # Note: many Linux distros these days still use an older version of | ||
| 6 | # tunctl which does not support the group permissions option, hence | ||
| 7 | # the need to use build system's version. | ||
| 8 | # | ||
| 9 | # If you find yourself calling this script a lot, you can add the | ||
| 10 | # the following to your /etc/sudoers file to be able to run this | ||
| 11 | # command without entering your password each time: | ||
| 12 | # | ||
| 13 | # <my-username> ALL=NOPASSWD: /path/to/runqemu-ifup | ||
| 14 | # <my-username> ALL=NOPASSWD: /path/to/runqemu-ifdown | ||
| 15 | # | ||
| 16 | # If you'd like to create a bank of tap devices at once, you should use | ||
| 17 | # the runqemu-gen-tapdevs script instead. If tap devices are set up using | ||
| 18 | # that script, the runqemu script will never end up calling this | ||
| 19 | # script. | ||
| 20 | # | ||
| 21 | # Copyright (c) 2006-2011 Linux Foundation | ||
| 22 | # | ||
| 23 | # This program is free software; you can redistribute it and/or modify | ||
| 24 | # it under the terms of the GNU General Public License version 2 as | ||
| 25 | # published by the Free Software Foundation. | ||
| 26 | # | ||
| 27 | # This program is distributed in the hope that it will be useful, | ||
| 28 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 29 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 30 | # GNU General Public License for more details. | ||
| 31 | # | ||
| 32 | # You should have received a copy of the GNU General Public License along | ||
| 33 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 34 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 35 | |||
| 36 | usage() { | ||
| 37 | echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir>" | ||
| 38 | } | ||
| 39 | |||
| 40 | if [ $EUID -ne 0 ]; then | ||
| 41 | echo "Error: This script (runqemu-ifup) must be run with root privileges" | ||
| 42 | exit 1 | ||
| 43 | fi | ||
| 44 | |||
| 45 | if [ $# -ne 3 ]; then | ||
| 46 | usage | ||
| 47 | exit 1 | ||
| 48 | fi | ||
| 49 | |||
| 50 | USERID="-u $1" | ||
| 51 | GROUP="-g $2" | ||
| 52 | NATIVE_SYSROOT_DIR=$3 | ||
| 53 | |||
| 54 | TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl | ||
| 55 | if [ ! -x "$TUNCTL" ]; then | ||
| 56 | echo "Error: Unable to find tunctl binary in '$NATIVE_SYSROOT_DIR/usr/bin', please bitbake qemu-helper-native" | ||
| 57 | exit 1 | ||
| 58 | fi | ||
| 59 | |||
| 60 | TAP=`$TUNCTL -b $GROUP 2>&1` | ||
| 61 | STATUS=$? | ||
| 62 | if [ $STATUS -ne 0 ]; then | ||
| 63 | # If tunctl -g fails, try using tunctl -u, for older host kernels | ||
| 64 | # which do not support the TUNSETGROUP ioctl | ||
| 65 | TAP=`$TUNCTL -b $USERID 2>&1` | ||
| 66 | STATUS=$? | ||
| 67 | if [ $STATUS -ne 0 ]; then | ||
| 68 | echo "tunctl failed:" | ||
| 69 | exit 1 | ||
| 70 | fi | ||
| 71 | fi | ||
| 72 | |||
| 73 | IFCONFIG=`which ip 2> /dev/null` | ||
| 74 | if [ "x$IFCONFIG" = "x" ]; then | ||
| 75 | # better than nothing... | ||
| 76 | IFCONFIG=/sbin/ip | ||
| 77 | fi | ||
| 78 | if [ ! -x "$IFCONFIG" ]; then | ||
| 79 | echo "$IFCONFIG cannot be executed" | ||
| 80 | exit 1 | ||
| 81 | fi | ||
| 82 | |||
| 83 | IPTABLES=`which iptables 2> /dev/null` | ||
| 84 | if [ "x$IPTABLES" = "x" ]; then | ||
| 85 | IPTABLES=/sbin/iptables | ||
| 86 | fi | ||
| 87 | if [ ! -x "$IPTABLES" ]; then | ||
| 88 | echo "$IPTABLES cannot be executed" | ||
| 89 | exit 1 | ||
| 90 | fi | ||
| 91 | |||
| 92 | n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] | ||
| 93 | $IFCONFIG addr add 192.168.7.$n/32 broadcast 192.168.7.255 dev $TAP | ||
| 94 | STATUS=$? | ||
| 95 | if [ $STATUS -ne 0 ]; then | ||
| 96 | echo "Failed to set up IP addressing on $TAP" | ||
| 97 | exit 1 | ||
| 98 | fi | ||
| 99 | $IFCONFIG link set dev $TAP up | ||
| 100 | STATUS=$? | ||
| 101 | if [ $STATUS -ne 0 ]; then | ||
| 102 | echo "Failed to bring up $TAP" | ||
| 103 | exit 1 | ||
| 104 | fi | ||
| 105 | |||
| 106 | dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] | ||
| 107 | $IFCONFIG route add to 192.168.7.$dest dev $TAP | ||
| 108 | STATUS=$? | ||
| 109 | if [ $STATUS -ne 0 ]; then | ||
| 110 | echo "Failed to add route to 192.168.7.$dest using $TAP" | ||
| 111 | exit 1 | ||
| 112 | fi | ||
| 113 | |||
| 114 | # setup NAT for tap0 interface to have internet access in QEMU | ||
| 115 | $IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 | ||
| 116 | $IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32 | ||
| 117 | echo 1 > /proc/sys/net/ipv4/ip_forward | ||
| 118 | echo 1 > /proc/sys/net/ipv4/conf/$TAP/proxy_arp | ||
| 119 | $IPTABLES -P FORWARD ACCEPT | ||
| 120 | |||
| 121 | echo $TAP | ||
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal deleted file mode 100755 index 9811cf9..0000000 --- a/scripts/runqemu-internal +++ /dev/null | |||
| @@ -1,760 +0,0 @@ | |||
| 1 | #!/bin/bash -x | ||
| 2 | |||
| 3 | # Handle running OE images under qemu | ||
| 4 | # | ||
| 5 | # Copyright (C) 2006-2011 Linux Foundation | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License version 2 as | ||
| 9 | # published by the Free Software Foundation. | ||
| 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 along | ||
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | |||
| 20 | # Call setting: | ||
| 21 | # QEMU_MEMORY (optional) - set the amount of memory in the emualted system. | ||
| 22 | # SERIAL_LOGFILE (optional) - log the serial port output to a file | ||
| 23 | # | ||
| 24 | # Image options: | ||
| 25 | # MACHINE - the machine to run | ||
| 26 | # FSTYPE - the image type to run | ||
| 27 | # KERNEL - the kernel image file to use | ||
| 28 | # ROOTFS - the disk image file to use | ||
| 29 | # | ||
| 30 | |||
| 31 | mem_size=-1 | ||
| 32 | |||
| 33 | #Get rid of <> and get the contents of extra qemu running params | ||
| 34 | SCRIPT_QEMU_EXTRA_OPT=`echo $SCRIPT_QEMU_EXTRA_OPT | sed -e 's/<//' -e 's/>//'` | ||
| 35 | #if user set qemu memory, eg: -m 256 in qemu extra params, we need to do some | ||
| 36 | # validation check | ||
| 37 | mem_set=`expr "$SCRIPT_QEMU_EXTRA_OPT" : '.*\(-m[[:space:]] *[0-9]*\)'` | ||
| 38 | if [ ! -z "$mem_set" ] ; then | ||
| 39 | #Get memory setting size from user input | ||
| 40 | mem_size=`echo $mem_set | sed 's/-m[[:space:]] *//'` | ||
| 41 | fi | ||
| 42 | |||
| 43 | # This file is created when runqemu-gen-tapdevs creates a bank of tap | ||
| 44 | # devices, indicating that the user should not bring up new ones using | ||
| 45 | # sudo. | ||
| 46 | NOSUDO_FLAG="/etc/runqemu-nosudo" | ||
| 47 | |||
| 48 | QEMUIFUP=`which runqemu-ifup 2> /dev/null` | ||
| 49 | QEMUIFDOWN=`which runqemu-ifdown 2> /dev/null` | ||
| 50 | if [ -z "$QEMUIFUP" -o ! -x "$QEMUIFUP" ]; then | ||
| 51 | echo "runqemu-ifup cannot be found or executed" | ||
| 52 | exit 1 | ||
| 53 | fi | ||
| 54 | if [ -z "$QEMUIFDOWN" -o ! -x "$QEMUIFDOWN" ]; then | ||
| 55 | echo "runqemu-ifdown cannot be found or executed" | ||
| 56 | exit 1 | ||
| 57 | fi | ||
| 58 | |||
| 59 | NFSRUNNING="false" | ||
| 60 | |||
| 61 | #capture original stty values | ||
| 62 | ORIG_STTY=$(stty -g) | ||
| 63 | |||
| 64 | if [ "$SLIRP_ENABLED" = "yes" ]; then | ||
| 65 | KERNEL_NETWORK_CMD="ip=dhcp" | ||
| 66 | QEMU_TAP_CMD="" | ||
| 67 | QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice tablet" | ||
| 68 | QEMU_NETWORK_CMD="" | ||
| 69 | DROOT="/dev/vda" | ||
| 70 | ROOTFS_OPTIONS="-drive file=$ROOTFS,if=virtio,format=raw" | ||
| 71 | else | ||
| 72 | acquire_lock() { | ||
| 73 | lockfile=$1 | ||
| 74 | if [ -z "$lockfile" ]; then | ||
| 75 | echo "Error: missing lockfile arg passed to acquire_lock()" | ||
| 76 | return 1 | ||
| 77 | fi | ||
| 78 | |||
| 79 | touch $lockfile.lock 2>/dev/null | ||
| 80 | if [ $? -ne 0 ]; then | ||
| 81 | echo "Acquiring lockfile for $lockfile.lock failed" | ||
| 82 | return 1 | ||
| 83 | fi | ||
| 84 | exec 8>$lockfile.lock | ||
| 85 | flock -n -x 8 | ||
| 86 | if [ $? -ne 0 ]; then | ||
| 87 | exec 8>&- | ||
| 88 | return 1 | ||
| 89 | fi | ||
| 90 | |||
| 91 | return 0 | ||
| 92 | } | ||
| 93 | |||
| 94 | release_lock() { | ||
| 95 | lockfile=$1 | ||
| 96 | if [ -z "$lockfile" ]; then | ||
| 97 | echo "Error: missing lockfile arg passed to release_lock()" | ||
| 98 | return 1 | ||
| 99 | fi | ||
| 100 | |||
| 101 | rm -f $lockfile.lock | ||
| 102 | exec 8>&- | ||
| 103 | } | ||
| 104 | |||
| 105 | LOCKDIR="/tmp/qemu-tap-locks" | ||
| 106 | if [ ! -d "$LOCKDIR" ]; then | ||
| 107 | mkdir $LOCKDIR | ||
| 108 | chmod 777 $LOCKDIR | ||
| 109 | fi | ||
| 110 | |||
| 111 | IFCONFIG=`which ip 2> /dev/null` | ||
| 112 | if [ -z "$IFCONFIG" ]; then | ||
| 113 | IFCONFIG=/sbin/ip | ||
| 114 | fi | ||
| 115 | if [ ! -x "$IFCONFIG" ]; then | ||
| 116 | echo "$IFCONFIG cannot be executed" | ||
| 117 | exit 1 | ||
| 118 | fi | ||
| 119 | |||
| 120 | POSSIBLE=`$IFCONFIG link | grep 'tap' | awk '{print $2}' | sed -e 's/://' -e 's/@.*//'` | ||
| 121 | TAP="" | ||
| 122 | LOCKFILE="" | ||
| 123 | USE_PRECONF_TAP="no" | ||
| 124 | for tap in $POSSIBLE; do | ||
| 125 | LOCKFILE="$LOCKDIR/$tap" | ||
| 126 | if [ -e "$LOCKFILE.skip" ]; then | ||
| 127 | echo "Found $LOCKFILE.skip, skipping $tap" | ||
| 128 | continue | ||
| 129 | fi | ||
| 130 | echo "Acquiring lockfile for $tap..." | ||
| 131 | acquire_lock $LOCKFILE | ||
| 132 | if [ $? -eq 0 ]; then | ||
| 133 | TAP=$tap | ||
| 134 | USE_PRECONF_TAP="yes" | ||
| 135 | break | ||
| 136 | fi | ||
| 137 | done | ||
| 138 | |||
| 139 | if [ "$TAP" = "" ]; then | ||
| 140 | if [ -e "$NOSUDO_FLAG" ]; then | ||
| 141 | echo "Error: There are no available tap devices to use for networking," | ||
| 142 | echo "and I see $NOSUDO_FLAG exists, so I am not going to try creating" | ||
| 143 | echo "a new one with sudo." | ||
| 144 | exit 1 | ||
| 145 | fi | ||
| 146 | |||
| 147 | GROUPID=`id -g` | ||
| 148 | USERID=`id -u` | ||
| 149 | echo "Setting up tap interface under sudo" | ||
| 150 | # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded | ||
| 151 | # but inactive. This looks scary but is harmless | ||
| 152 | tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null` | ||
| 153 | if [ $? -ne 0 ]; then | ||
| 154 | # Re-run standalone to see verbose errors | ||
| 155 | sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT | ||
| 156 | return 1 | ||
| 157 | fi | ||
| 158 | LOCKFILE="$LOCKDIR/$tap" | ||
| 159 | echo "Acquiring lockfile for $tap..." | ||
| 160 | acquire_lock $LOCKFILE | ||
| 161 | if [ $? -eq 0 ]; then | ||
| 162 | TAP=$tap | ||
| 163 | fi | ||
| 164 | else | ||
| 165 | echo "Using preconfigured tap device '$TAP'" | ||
| 166 | echo "If this is not intended, touch $LOCKFILE.skip to make runqemu skip $TAP." | ||
| 167 | fi | ||
| 168 | |||
| 169 | cleanup() { | ||
| 170 | if [ ! -e "$NOSUDO_FLAG" -a "$USE_PRECONF_TAP" = "no" ]; then | ||
| 171 | # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded | ||
| 172 | # but inactive. This looks scary but is harmless | ||
| 173 | sudo $QEMUIFDOWN $TAP $OECORE_NATIVE_SYSROOT 2> /dev/null | ||
| 174 | fi | ||
| 175 | echo "Releasing lockfile of preconfigured tap device '$TAP'" | ||
| 176 | release_lock $LOCKFILE | ||
| 177 | |||
| 178 | if [ "$NFSRUNNING" = "true" ]; then | ||
| 179 | echo "Shutting down the userspace NFS server..." | ||
| 180 | echo "runqemu-export-rootfs stop $ROOTFS" | ||
| 181 | runqemu-export-rootfs stop $ROOTFS | ||
| 182 | fi | ||
| 183 | # If QEMU crashes or somehow tty properties are not restored | ||
| 184 | # after qemu exits, we need to run stty sane | ||
| 185 | #stty sane | ||
| 186 | |||
| 187 | #instead of using stty sane we set the original stty values | ||
| 188 | stty ${ORIG_STTY} | ||
| 189 | |||
| 190 | } | ||
| 191 | |||
| 192 | |||
| 193 | n0=$(echo $TAP | sed 's/tap//') | ||
| 194 | |||
| 195 | case $n0 in | ||
| 196 | ''|*[!0-9]*) | ||
| 197 | echo "Error Couldn't turn $TAP into an interface number?" | ||
| 198 | exit 1 | ||
| 199 | ;; | ||
| 200 | esac | ||
| 201 | |||
| 202 | n1=$(($n0 * 2 + 1)) | ||
| 203 | n2=$(($n1 + 1)) | ||
| 204 | |||
| 205 | KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0" | ||
| 206 | QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no" | ||
| 207 | if [ "$VHOST_ACTIVE" = "yes" ]; then | ||
| 208 | QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD,vhost=on" | ||
| 209 | else | ||
| 210 | QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD" | ||
| 211 | fi | ||
| 212 | DROOT="/dev/vda" | ||
| 213 | ROOTFS_OPTIONS="-drive file=$ROOTFS,if=virtio,format=raw" | ||
| 214 | |||
| 215 | KERNCMDLINE="mem=$QEMU_MEMORY" | ||
| 216 | QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice tablet" | ||
| 217 | |||
| 218 | NFS_INSTANCE=`echo $TAP | sed 's/tap//'` | ||
| 219 | export NFS_INSTANCE | ||
| 220 | |||
| 221 | SERIALOPTS="" | ||
| 222 | if [ "x$SERIAL_LOGFILE" != "x" ]; then | ||
| 223 | SERIALOPTS="-serial file:$SERIAL_LOGFILE" | ||
| 224 | fi | ||
| 225 | fi | ||
| 226 | |||
| 227 | if [ ! -f "$KERNEL" -a "$IS_VM" = "false" ]; then | ||
| 228 | echo "Error: Kernel image file $KERNEL doesn't exist" | ||
| 229 | cleanup | ||
| 230 | return 1 | ||
| 231 | fi | ||
| 232 | |||
| 233 | if [ "$FSTYPE" != "nfs" -a "$IS_VM" = "false" -a ! -f "$ROOTFS" ]; then | ||
| 234 | echo "Error: Image file $ROOTFS doesn't exist" | ||
| 235 | cleanup | ||
| 236 | return 1 | ||
| 237 | fi | ||
| 238 | |||
| 239 | if [ "$NFS_SERVER" = "" ]; then | ||
| 240 | NFS_SERVER="192.168.7.1" | ||
| 241 | if [ "$SLIRP_ENABLED" = "yes" ]; then | ||
| 242 | NFS_SERVER="10.0.2.2" | ||
| 243 | fi | ||
| 244 | fi | ||
| 245 | |||
| 246 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 247 | NFS_DIR=`echo $ROOTFS | sed 's/^[^:]*:\(.*\)/\1/'` | ||
| 248 | if [ "$NFS_INSTANCE" = "" ] ; then | ||
| 249 | NFS_INSTANCE=0 | ||
| 250 | fi | ||
| 251 | MOUNTD_RPCPORT=$[ 21111 + $NFS_INSTANCE ] | ||
| 252 | NFSD_RPCPORT=$[ 11111 + $NFS_INSTANCE ] | ||
| 253 | NFSD_PORT=$[ 3049 + 2 * $NFS_INSTANCE ] | ||
| 254 | MOUNTD_PORT=$[ 3048 + 2 * $NFS_INSTANCE ] | ||
| 255 | UNFS_OPTS="nfsvers=3,port=$NFSD_PORT,mountprog=$MOUNTD_RPCPORT,nfsprog=$NFSD_RPCPORT,udp,mountport=$MOUNTD_PORT" | ||
| 256 | |||
| 257 | PSEUDO_LOCALSTATEDIR=~/.runqemu-sdk/pseudo | ||
| 258 | export PSEUDO_LOCALSTATEDIR | ||
| 259 | |||
| 260 | # Start the userspace NFS server | ||
| 261 | echo "runqemu-export-rootfs restart $ROOTFS" | ||
| 262 | runqemu-export-rootfs restart $ROOTFS | ||
| 263 | if [ $? != 0 ]; then | ||
| 264 | return 1 | ||
| 265 | fi | ||
| 266 | NFSRUNNING="true" | ||
| 267 | fi | ||
| 268 | |||
| 269 | |||
| 270 | set_mem_size() { | ||
| 271 | if [ ! -z "$mem_set" ] ; then | ||
| 272 | #Get memory setting size from user input | ||
| 273 | mem_size=`echo $mem_set | sed 's/-m[[:space:]] *//'` | ||
| 274 | else | ||
| 275 | mem_size=$1 | ||
| 276 | fi | ||
| 277 | # QEMU_MEMORY has 'M' appended to mem_size | ||
| 278 | QEMU_MEMORY="$mem_size"M | ||
| 279 | |||
| 280 | } | ||
| 281 | |||
| 282 | config_qemuarm() { | ||
| 283 | set_mem_size 128 | ||
| 284 | QEMU=qemu-system-arm | ||
| 285 | MACHINE_SUBTYPE=versatilepb | ||
| 286 | export QEMU_AUDIO_DRV="none" | ||
| 287 | QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS" | ||
| 288 | if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then | ||
| 289 | KERNCMDLINE="root=$DROOT rw console=ttyAMA0,115200 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY highres=off" | ||
| 290 | QEMUOPTIONS="$QEMU_NETWORK_CMD -M ${MACHINE_SUBTYPE} $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS" | ||
| 291 | fi | ||
| 292 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 293 | if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then | ||
| 294 | echo "Error: NFS mount point $ROOTFS doesn't exist" | ||
| 295 | cleanup | ||
| 296 | return 1 | ||
| 297 | fi | ||
| 298 | KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw console=ttyAMA0,115200 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 299 | QEMUOPTIONS="$QEMU_NETWORK_CMD -M ${MACHINE_SUBTYPE} --no-reboot $QEMU_UI_OPTIONS" | ||
| 300 | fi | ||
| 301 | if [ "$MACHINE" = "qemuarmv6" ]; then | ||
| 302 | QEMUOPTIONS="$QEMUOPTIONS -cpu arm1136" | ||
| 303 | fi | ||
| 304 | if [ "$MACHINE" = "qemuarmv7" ]; then | ||
| 305 | QEMUOPTIONS="$QEMUOPTIONS -cpu cortex-a8" | ||
| 306 | fi | ||
| 307 | } | ||
| 308 | |||
| 309 | config_qemuarm64() { | ||
| 310 | set_mem_size 512 | ||
| 311 | QEMU=qemu-system-aarch64 | ||
| 312 | |||
| 313 | QEMU_NETWORK_CMD="-netdev tap,id=net0,ifname=$TAP,script=no,downscript=no -device virtio-net-device,netdev=net0 " | ||
| 314 | DROOT="/dev/vda" | ||
| 315 | ROOTFS_OPTIONS="-drive id=disk0,file=$ROOTFS,if=none,format=raw -device virtio-blk-device,drive=disk0" | ||
| 316 | |||
| 317 | export QEMU_AUDIO_DRV="none" | ||
| 318 | if [ "x$SERIALSTDIO" = "x" ] ; then | ||
| 319 | QEMU_UI_OPTIONS="-nographic" | ||
| 320 | else | ||
| 321 | QEMU_UI_OPTIONS="" | ||
| 322 | fi | ||
| 323 | if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then | ||
| 324 | KERNCMDLINE="root=$DROOT rw console=ttyAMA0,38400 mem=$QEMU_MEMORY highres=off $KERNEL_NETWORK_CMD" | ||
| 325 | # qemu-system-aarch64 only support '-machine virt -cpu cortex-a57' for now | ||
| 326 | QEMUOPTIONS="$QEMU_NETWORK_CMD -machine virt -cpu cortex-a57 $ROOTFS_OPTIONS $QEMU_UI_OPTIONS" | ||
| 327 | fi | ||
| 328 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 329 | if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then | ||
| 330 | echo "Error: NFS mount point $ROOTFS doesn't exist" | ||
| 331 | cleanup | ||
| 332 | return 1 | ||
| 333 | fi | ||
| 334 | KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw console=ttyAMA0,38400 mem=$QEMU_MEMORY highres=off $KERNEL_NETWORK_CMD" | ||
| 335 | QEMUOPTIONS="$QEMU_NETWORK_CMD -machine virt -cpu cortex-a57 $QEMU_UI_OPTIONS" | ||
| 336 | fi | ||
| 337 | } | ||
| 338 | |||
| 339 | config_qemux86() { | ||
| 340 | set_mem_size 256 | ||
| 341 | QEMU=qemu-system-i386 | ||
| 342 | if [ "$KVM_ACTIVE" = "yes" ]; then | ||
| 343 | CPU_SUBTYPE=kvm32 | ||
| 344 | else | ||
| 345 | CPU_SUBTYPE=qemu32 | ||
| 346 | fi | ||
| 347 | if [ ! -z "$vga_option" ]; then | ||
| 348 | QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS" | ||
| 349 | else | ||
| 350 | QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware" | ||
| 351 | fi | ||
| 352 | if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then | ||
| 353 | KERNCMDLINE="vga=0 uvesafb.mode_option=640x480-32 root=$DROOT rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD" | ||
| 354 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $ROOTFS_OPTIONS $QEMU_UI_OPTIONS" | ||
| 355 | fi | ||
| 356 | if [ "${FSTYPE:0:4}" = "cpio" ]; then | ||
| 357 | KERNCMDLINE="vga=0 uvesafb.mode_option=640x480-32 root=/dev/ram0 rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD" | ||
| 358 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -initrd $ROOTFS $QEMU_UI_OPTIONS" | ||
| 359 | fi | ||
| 360 | |||
| 361 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 362 | if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then | ||
| 363 | echo "Error: NFS mount point $ROOTFS doesn't exist." | ||
| 364 | cleanup | ||
| 365 | return 1 | ||
| 366 | fi | ||
| 367 | KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 368 | QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS" | ||
| 369 | fi | ||
| 370 | if [ "$IS_VM" = "true" ]; then | ||
| 371 | QEMUOPTIONS="$QEMU_NETWORK_CMD $QEMU_UI_OPTIONS" | ||
| 372 | fi | ||
| 373 | # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in | ||
| 374 | # qemux86 and qemux86-64. We can use timer interrupt mode for now. | ||
| 375 | KERNCMDLINE="$KERNCMDLINE oprofile.timer=1" | ||
| 376 | } | ||
| 377 | |||
| 378 | config_qemux86_64() { | ||
| 379 | set_mem_size 256 | ||
| 380 | QEMU=qemu-system-x86_64 | ||
| 381 | if [ "$KVM_ACTIVE" = "yes" ]; then | ||
| 382 | CPU_SUBTYPE=kvm64 | ||
| 383 | else | ||
| 384 | CPU_SUBTYPE=core2duo | ||
| 385 | fi | ||
| 386 | if [ ! -z "$vga_option" ]; then | ||
| 387 | QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS" | ||
| 388 | else | ||
| 389 | QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware" | ||
| 390 | fi | ||
| 391 | if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then | ||
| 392 | KERNCMDLINE="vga=0 uvesafb.mode_option=640x480-32 root=$DROOT rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD" | ||
| 393 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $ROOTFS_OPTIONS $QEMU_UI_OPTIONS" | ||
| 394 | fi | ||
| 395 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 396 | if [ "x$ROOTFS" = "x" ]; then | ||
| 397 | ROOTFS=/srv/nfs/qemux86-64 | ||
| 398 | fi | ||
| 399 | if [ ! -d "$ROOTFS" ]; then | ||
| 400 | echo "Error: NFS mount point $ROOTFS doesn't exist." | ||
| 401 | cleanup | ||
| 402 | return 1 | ||
| 403 | fi | ||
| 404 | KERNCMDLINE="root=/dev/nfs nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 405 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS" | ||
| 406 | fi | ||
| 407 | if [ "$IS_VM" = "true" ]; then | ||
| 408 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE $QEMU_UI_OPTIONS" | ||
| 409 | fi | ||
| 410 | # Currently oprofile's event based interrupt mode doesn't work(Bug #828) in | ||
| 411 | # qemux86 and qemux86-64. We can use timer interrupt mode for now. | ||
| 412 | KERNCMDLINE="$KERNCMDLINE oprofile.timer=1" | ||
| 413 | } | ||
| 414 | |||
| 415 | config_qemumips() { | ||
| 416 | set_mem_size 256 | ||
| 417 | case "$MACHINE" in | ||
| 418 | qemumips) QEMU=qemu-system-mips ;; | ||
| 419 | qemumipsel) QEMU=qemu-system-mipsel ;; | ||
| 420 | qemumips64) QEMU=qemu-system-mips64 ;; | ||
| 421 | esac | ||
| 422 | MACHINE_SUBTYPE=malta | ||
| 423 | QEMU_UI_OPTIONS="-vga cirrus $QEMU_UI_OPTIONS" | ||
| 424 | if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then | ||
| 425 | #KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty0 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 426 | KERNCMDLINE="root=$DROOT rw console=ttyS0 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 427 | QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS" | ||
| 428 | fi | ||
| 429 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 430 | if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then | ||
| 431 | echo "Error: NFS mount point $ROOTFS doesn't exist" | ||
| 432 | cleanup | ||
| 433 | return 1 | ||
| 434 | fi | ||
| 435 | KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 436 | QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS" | ||
| 437 | fi | ||
| 438 | } | ||
| 439 | |||
| 440 | config_qemuppc() { | ||
| 441 | set_mem_size 256 | ||
| 442 | QEMU=qemu-system-ppc | ||
| 443 | MACHINE_SUBTYPE=mac99 | ||
| 444 | CPU_SUBTYPE=G4 | ||
| 445 | QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS" | ||
| 446 | if [ "$SLIRP_ENABLED" = "yes" ]; then | ||
| 447 | QEMU_NETWORK_CMD="" | ||
| 448 | else | ||
| 449 | QEMU_NETWORK_CMD="-net nic,model=pcnet $QEMU_TAP_CMD" | ||
| 450 | fi | ||
| 451 | if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then | ||
| 452 | KERNCMDLINE="root=$DROOT rw console=ttyS0 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 453 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE $ROOTFS_OPTIONS -no-reboot $QEMU_UI_OPTIONS" | ||
| 454 | fi | ||
| 455 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 456 | if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then | ||
| 457 | echo "Error: NFS mount point $ROOTFS doesn't exist" | ||
| 458 | cleanup | ||
| 459 | return 1 | ||
| 460 | fi | ||
| 461 | KERNCMDLINE="root=/dev/nfs console=ttyS0 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 462 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cpu $CPU_SUBTYPE -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS" | ||
| 463 | fi | ||
| 464 | } | ||
| 465 | |||
| 466 | config_qemush4() { | ||
| 467 | set_mem_size 1024 | ||
| 468 | QEMU=qemu-system-sh4 | ||
| 469 | MACHINE_SUBTYPE=r2d | ||
| 470 | QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS" | ||
| 471 | if [ "${FSTYPE:0:3}" = "ext" -o "$FSTYPE" = "btrfs" -o "$FSTYPE" = "wic" ]; then | ||
| 472 | #KERNCMDLINE="root=/dev/hda console=ttyS0 console=tty0 $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 473 | KERNCMDLINE="root=/dev/hda rw console=ttySC1 noiotrap earlyprintk=sh-sci.1 console=tty $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 474 | QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -hda $ROOTFS -no-reboot $QEMU_UI_OPTIONS -monitor null -serial vc -serial stdio" | ||
| 475 | SERIALSTDIO="1" | ||
| 476 | fi | ||
| 477 | if [ "$FSTYPE" = "nfs" ]; then | ||
| 478 | if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then | ||
| 479 | echo "Error: NFS mount point $ROOTFS doesn't exist" | ||
| 480 | cleanup | ||
| 481 | return 1 | ||
| 482 | fi | ||
| 483 | KERNCMDLINE="root=/dev/nfs console=ttySC1 noiotrap earlyprintk=sh-sci.1 console=tty nfsroot=$NFS_SERVER:$NFS_DIR,$UNFS_OPTS rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 484 | QEMUOPTIONS="$QEMU_NETWORK_CMD -M $MACHINE_SUBTYPE -no-reboot $QEMU_UI_OPTIONS -monitor null -serial vc -serial stdio" | ||
| 485 | SERIALSTDIO="1" | ||
| 486 | fi | ||
| 487 | } | ||
| 488 | |||
| 489 | config_qemuzynq() { | ||
| 490 | set_mem_size 1024 | ||
| 491 | QEMU=qemu-system-arm | ||
| 492 | QEMU_NETWORK_CMD="-net nic -net nic $QEMU_TAP_CMD" | ||
| 493 | QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M xilinx-zynq-a9 -serial null -serial mon:stdio -nographic -dtb $KERNEL-$MACHINE.dtb" | ||
| 494 | # zynq serial ports are named 'ttyPS0' and 'ttyPS1', fixup the default values | ||
| 495 | SCRIPT_KERNEL_OPT=$(echo "$SCRIPT_KERNEL_OPT" | sed 's/console=ttyS/console=ttyPS/g') | ||
| 496 | if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then | ||
| 497 | KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 498 | QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS" | ||
| 499 | fi | ||
| 500 | } | ||
| 501 | |||
| 502 | config_qemuzynqmp() { | ||
| 503 | set_mem_size 2048 | ||
| 504 | QEMU=qemu-system-aarch64 | ||
| 505 | |||
| 506 | export QEMU_AUDIO_DRV="none" | ||
| 507 | if [ "x$SERIALSTDIO" = "x" ] ; then | ||
| 508 | QEMU_UI_OPTIONS="-nographic" | ||
| 509 | else | ||
| 510 | QEMU_UI_OPTIONS="" | ||
| 511 | fi | ||
| 512 | |||
| 513 | # Networking and system options required for QEMU ZynqMP machine | ||
| 514 | QEMU_NETWORK_CMD="-net nic -net nic -net nic -net nic -net user,net=10.10.70.0,dhcpstart=10.10.70.1,host=10.10.70.101" | ||
| 515 | QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M xlnx-ep108 -serial mon:stdio -dtb $DEPLOY_DIR_IMAGE/${QEMU_DTB}.dtb" | ||
| 516 | |||
| 517 | QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS $QEMU_UI_OPTIONS -initrd $ROOTFS" | ||
| 518 | } | ||
| 519 | |||
| 520 | config_qemumicroblaze() { | ||
| 521 | set_mem_size 256 | ||
| 522 | QEMU=qemu-system-microblazeel | ||
| 523 | QEMU_SYSTEM_OPTIONS="$QEMU_NETWORK_CMD -M petalogix-ml605 -serial mon:stdio" | ||
| 524 | if [ "${FSTYPE:0:3}" = "ext" -o "${FSTYPE:0:4}" = "cpio" ]; then | ||
| 525 | KERNCMDLINE="earlyprintk root=/dev/ram rw $KERNEL_NETWORK_CMD mem=$QEMU_MEMORY" | ||
| 526 | QEMUOPTIONS="$QEMU_SYSTEM_OPTIONS -initrd $ROOTFS" | ||
| 527 | fi | ||
| 528 | } | ||
| 529 | |||
| 530 | case "$MACHINE" in | ||
| 531 | "qemuarm" | "qemuarmv6" | "qemuarmv7") | ||
| 532 | config_qemuarm | ||
| 533 | ;; | ||
| 534 | "qemuarm64") | ||
| 535 | config_qemuarm64 | ||
| 536 | ;; | ||
| 537 | "qemux86") | ||
| 538 | config_qemux86 | ||
| 539 | ;; | ||
| 540 | "qemux86-64") | ||
| 541 | config_qemux86_64 | ||
| 542 | ;; | ||
| 543 | "qemumips" | "qemumipsel" | "qemumips64") | ||
| 544 | config_qemumips | ||
| 545 | ;; | ||
| 546 | "qemuppc") | ||
| 547 | config_qemuppc | ||
| 548 | ;; | ||
| 549 | "qemush4") | ||
| 550 | config_qemush4 | ||
| 551 | ;; | ||
| 552 | "qemuzynq") | ||
| 553 | config_qemuzynq | ||
| 554 | ;; | ||
| 555 | "qemuzynqmp") | ||
| 556 | config_qemuzynqmp | ||
| 557 | ;; | ||
| 558 | "qemumicroblaze") | ||
| 559 | config_qemumicroblaze | ||
| 560 | ;; | ||
| 561 | *) | ||
| 562 | echo "Error: Unsupported machine type $MACHINE" | ||
| 563 | return 1 | ||
| 564 | ;; | ||
| 565 | esac | ||
| 566 | |||
| 567 | # We need to specify -m <mem_size> to overcome a bug in qemu 0.14.0 | ||
| 568 | # https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/584480 | ||
| 569 | if [ -z "$mem_set" ] ; then | ||
| 570 | SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -m $mem_size" | ||
| 571 | fi | ||
| 572 | |||
| 573 | if [ "${FSTYPE:0:3}" = "ext" ]; then | ||
| 574 | KERNCMDLINE="$KERNCMDLINE rootfstype=$FSTYPE" | ||
| 575 | fi | ||
| 576 | |||
| 577 | if [ "$FSTYPE" = "cpio.gz" ]; then | ||
| 578 | QEMUOPTIONS="-initrd $ROOTFS -nographic" | ||
| 579 | KERNCMDLINE="root=/dev/ram0 console=ttyS0 debugshell" | ||
| 580 | fi | ||
| 581 | |||
| 582 | if [ "$FSTYPE" = "iso" ]; then | ||
| 583 | QEMUOPTIONS="$QEMU_NETWORK_CMD -cdrom $ROOTFS $QEMU_UI_OPTIONS" | ||
| 584 | fi | ||
| 585 | |||
| 586 | if [ "x$QEMUOPTIONS" = "x" ]; then | ||
| 587 | echo "Error: Unable to support this combination of options" | ||
| 588 | cleanup | ||
| 589 | return 1 | ||
| 590 | fi | ||
| 591 | |||
| 592 | if [ "$TCPSERIAL_PORTNUM" != "" ]; then | ||
| 593 | if [ "$MACHINE" = "qemuarm64" ]; then | ||
| 594 | SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -device virtio-serial-device -chardev socket,id=virtcon,port=$TCPSERIAL_PORTNUM,host=127.0.0.1 -device virtconsole,chardev=virtcon" | ||
| 595 | else | ||
| 596 | SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT -serial tcp:127.0.0.1:$TCPSERIAL_PORTNUM" | ||
| 597 | fi | ||
| 598 | fi | ||
| 599 | |||
| 600 | PATH=$OECORE_NATIVE_SYSROOT/usr/bin:$PATH | ||
| 601 | |||
| 602 | QEMUBIN=`which $QEMU 2> /dev/null` | ||
| 603 | if [ ! -x "$QEMUBIN" ]; then | ||
| 604 | echo "Error: No QEMU binary '$QEMU' could be found." | ||
| 605 | cleanup | ||
| 606 | return 1 | ||
| 607 | fi | ||
| 608 | |||
| 609 | NEED_GL=`ldd $QEMUBIN/$QEMU 2>&1 | grep libGLU` | ||
| 610 | # We can't run without a libGL.so | ||
| 611 | if [ "$NEED_GL" != "" ]; then | ||
| 612 | libgl='no' | ||
| 613 | |||
| 614 | [ -e /usr/lib/libGL.so -a -e /usr/lib/libGLU.so ] && libgl='yes' | ||
| 615 | [ -e /usr/lib64/libGL.so -a -e /usr/lib64/libGLU.so ] && libgl='yes' | ||
| 616 | [ -e /usr/lib/*-linux-gnu/libGL.so -a -e /usr/lib/*-linux-gnu/libGLU.so ] && libgl='yes' | ||
| 617 | |||
| 618 | if [ "$libgl" != 'yes' ]; then | ||
| 619 | echo "You need libGL.so and libGLU.so to exist in your library path to run the QEMU emulator. | ||
| 620 | Ubuntu package names are: libgl1-mesa-dev and libglu1-mesa-dev. | ||
| 621 | Fedora package names are: mesa-libGL-devel mesa-libGLU-devel." | ||
| 622 | return 1; | ||
| 623 | fi | ||
| 624 | fi | ||
| 625 | |||
| 626 | do_quit() { | ||
| 627 | cleanup | ||
| 628 | return 1 | ||
| 629 | } | ||
| 630 | |||
| 631 | trap do_quit INT TERM QUIT | ||
| 632 | |||
| 633 | # qemu got segfault if linked with nVidia's libgl | ||
| 634 | GL_LD_PRELOAD=$LD_PRELOAD | ||
| 635 | |||
| 636 | if ldd $QEMUBIN | grep -i nvidia &> /dev/null | ||
| 637 | then | ||
| 638 | cat << EOM | ||
| 639 | WARNING: nVidia proprietary OpenGL libraries detected. | ||
| 640 | nVidia's OpenGL libraries are known to have compatibility issues with qemu, | ||
| 641 | resulting in a segfault. Please uninstall these drivers or ensure the mesa libGL | ||
| 642 | libraries precede nvidia's via LD_PRELOAD(Already do it on Ubuntu 10). | ||
| 643 | EOM | ||
| 644 | |||
| 645 | # Automatically use Ubuntu system's mesa libGL, other distro can add its own path | ||
| 646 | if grep -i ubuntu /etc/lsb-release &> /dev/null | ||
| 647 | then | ||
| 648 | # precede nvidia's driver on Ubuntu 10 | ||
| 649 | UBUNTU_MAIN_VERSION=`cat /etc/lsb-release |grep DISTRIB_RELEASE |cut -d= -f 2| cut -d. -f 1` | ||
| 650 | if [ "$UBUNTU_MAIN_VERSION" = "10" ]; | ||
| 651 | then | ||
| 652 | GL_PATH="" | ||
| 653 | if test -e /usr/lib/libGL.so | ||
| 654 | then | ||
| 655 | GL_PATH="/usr/lib/libGL.so" | ||
| 656 | elif test -e /usr/lib/x86_64-linux-gnu/libGL.so | ||
| 657 | then | ||
| 658 | GL_PATH="/usr/lib/x86_64-linux-gnu/libGL.so" | ||
| 659 | fi | ||
| 660 | |||
| 661 | echo "Skip nVidia's libGL on Ubuntu 10!" | ||
| 662 | GL_LD_PRELOAD="$GL_PATH $LD_PRELOAD" | ||
| 663 | fi | ||
| 664 | fi | ||
| 665 | fi | ||
| 666 | |||
| 667 | if [ "x$SERIALSTDIO" = "x1" ]; then | ||
| 668 | echo "Interrupt character is '^]'" | ||
| 669 | stty intr ^] | ||
| 670 | fi | ||
| 671 | |||
| 672 | |||
| 673 | # Preserve the multiplexing behavior for the monitor that would be there based | ||
| 674 | # on whether nographic is used. | ||
| 675 | if echo "$QEMUOPTIONS $SERIALOPTS $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" | grep -- "-nographic"; then | ||
| 676 | FIRST_SERIAL_OPT="-serial mon:stdio" | ||
| 677 | else | ||
| 678 | FIRST_SERIAL_OPT="-serial mon:vc" | ||
| 679 | fi | ||
| 680 | |||
| 681 | # qemuarm64 uses virtio for any additional serial ports so the normal mechanism | ||
| 682 | # of using -serial will not work | ||
| 683 | if [ "$MACHINE" = "qemuarm64" ]; then | ||
| 684 | SECOND_SERIAL_OPT="-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon" | ||
| 685 | else | ||
| 686 | SECOND_SERIAL_OPT="-serial null" | ||
| 687 | fi | ||
| 688 | |||
| 689 | # We always want a ttyS1. Since qemu by default adds a serial port when | ||
| 690 | # nodefaults is not specified, it seems that all that would be needed is to | ||
| 691 | # make sure a "-serial" is there. However, it appears that when "-serial" is | ||
| 692 | # specified, it ignores the default serial port that is normally added. | ||
| 693 | # So here we make sure to add two -serial if there are none. And only one | ||
| 694 | # if there is one -serial already. | ||
| 695 | NUM_SERIAL_OPTS=`echo $QEMUOPTIONS $SERIALOPTS $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT | sed -e 's/ /\n/g' | grep --count -- -serial` | ||
| 696 | |||
| 697 | if [ "$NUM_SERIAL_OPTS" = "0" ]; then | ||
| 698 | SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT $FIRST_SERIAL_OPT $SECOND_SERIAL_OPT" | ||
| 699 | elif [ "$NUM_SERIAL_OPTS" = "1" ]; then | ||
| 700 | SCRIPT_QEMU_EXTRA_OPT="$SCRIPT_QEMU_EXTRA_OPT $SECOND_SERIAL_OPT" | ||
| 701 | fi | ||
| 702 | |||
| 703 | echo "Running $QEMU..." | ||
| 704 | # -no-reboot is a mandatory option - see bug #100 | ||
| 705 | if [ "$IS_VM" = "true" ]; then | ||
| 706 | # Check root=/dev/sdX or root=/dev/vdX | ||
| 707 | [ ! -e "$VM" ] && error "VM image is not found!" | ||
| 708 | |||
| 709 | case "$FORCE_DRIVE_IF" in | ||
| 710 | "ide") | ||
| 711 | echo "Using ide drive" | ||
| 712 | VM_DRIVE="$VM" | ||
| 713 | ;; | ||
| 714 | "scsi") | ||
| 715 | echo "Using scsi drive" | ||
| 716 | VM_DRIVE="-drive if=none,id=hd,file=$VM -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd" | ||
| 717 | ;; | ||
| 718 | "virtio") | ||
| 719 | echo "Using virtio block drive" | ||
| 720 | VM_DRIVE="-drive if=virtio,file=$VM" | ||
| 721 | ;; | ||
| 722 | "") | ||
| 723 | if grep -q 'root=/dev/sd' $VM; then | ||
| 724 | echo "Using scsi drive" | ||
| 725 | VM_DRIVE="-drive if=none,id=hd,file=$VM -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd" | ||
| 726 | elif grep -q 'root=/dev/hd' $VM; then | ||
| 727 | echo "Using ide drive" | ||
| 728 | VM_DRIVE="$VM" | ||
| 729 | else | ||
| 730 | echo "Using virtio block drive" | ||
| 731 | VM_DRIVE="-drive if=virtio,file=$VM" | ||
| 732 | fi | ||
| 733 | ;; | ||
| 734 | *) | ||
| 735 | error "Invalid drive interface: $FORCE_DRIVE_IF" | ||
| 736 | ;; | ||
| 737 | esac | ||
| 738 | |||
| 739 | QEMU_FIRE="$QEMUBIN $VM_DRIVE $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" | ||
| 740 | echo $QEMU_FIRE | ||
| 741 | LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE | ||
| 742 | elif [ "$FSTYPE" = "iso" -o "$FSTYPE" = "wic" ]; then | ||
| 743 | QEMU_FIRE="$QEMUBIN $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" | ||
| 744 | echo $QEMU_FIRE | ||
| 745 | LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE | ||
| 746 | else | ||
| 747 | QEMU_FIRE="$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SLIRP_CMD $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT" | ||
| 748 | echo $QEMU_FIRE -append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"' | ||
| 749 | LD_PRELOAD="$GL_LD_PRELOAD" $QEMU_FIRE -append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" | ||
| 750 | fi | ||
| 751 | ret=$? | ||
| 752 | if [ "$SLIRP_ENABLED" != "yes" ]; then | ||
| 753 | cleanup | ||
| 754 | fi | ||
| 755 | |||
| 756 | #set the original stty values before exit | ||
| 757 | stty ${ORIG_STTY} | ||
| 758 | trap - INT TERM QUIT | ||
| 759 | |||
| 760 | return $ret | ||
diff --git a/scripts/runqemu.README b/scripts/runqemu.README deleted file mode 100644 index 5908d83..0000000 --- a/scripts/runqemu.README +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 1 | Using OE images with QEMU | ||
| 2 | ========================= | ||
| 3 | |||
| 4 | OE-Core can generate qemu bootable kernels and images with can be used | ||
| 5 | on a desktop system. The scripts currently support booting ARM, MIPS, PowerPC | ||
| 6 | and x86 (32 and 64 bit) images. The scripts can be used within the OE build | ||
| 7 | system or externaly. | ||
| 8 | |||
| 9 | The runqemu script is run as: | ||
| 10 | |||
| 11 | runqemu <machine> <zimage> <filesystem> | ||
| 12 | |||
| 13 | where: | ||
| 14 | |||
| 15 | <machine> is the machine/architecture to use (qemuarm/qemumips/qemuppc/qemux86/qemux86-64) | ||
| 16 | <zimage> is the path to a kernel (e.g. zimage-qemuarm.bin) | ||
| 17 | <filesystem> is the path to an ext2 image (e.g. filesystem-qemuarm.ext2) or an nfs directory | ||
| 18 | |||
| 19 | If <machine> isn't specified, the script will try to detect the machine name | ||
| 20 | from the name of the <zimage> file. | ||
| 21 | |||
| 22 | If <filesystem> isn't specified, nfs booting will be assumed. | ||
| 23 | |||
| 24 | When used within the build system, it will default to qemuarm, ext2 and the last kernel and | ||
| 25 | core-image-sato-sdk image built by the build system. If an sdk image isn't present it will look | ||
| 26 | for sato and minimal images. | ||
| 27 | |||
| 28 | Full usage instructions can be seen by running the command with no options specified. | ||
| 29 | |||
| 30 | |||
| 31 | Notes | ||
| 32 | ===== | ||
| 33 | |||
| 34 | - The scripts run qemu using sudo. Change perms on /dev/net/tun to | ||
| 35 | run as non root. The runqemu-gen-tapdevs script can also be used by | ||
| 36 | root to prepopulate the appropriate network devices. | ||
| 37 | - You can access the host computer at 192.168.7.1 within the image. | ||
| 38 | - Your qemu system will be accessible as 192.16.7.2. | ||
| 39 | - The script extracts the root filesystem specified under pseudo and sets up a userspace | ||
| 40 | NFS server to share the image over by default meaning the filesystem can be accessed by | ||
| 41 | both the host and guest systems. | ||
| 42 | |||
