| 1 | #!/usr/bin/env python
|
|---|
| 2 | #
|
|---|
| 3 | # Copyright (c) 2013 Jakub Jermar
|
|---|
| 4 | # All rights reserved.
|
|---|
| 5 | #
|
|---|
| 6 | # Redistribution and use in source and binary forms, with or without
|
|---|
| 7 | # modification, are permitted provided that the following conditions
|
|---|
| 8 | # are met:
|
|---|
| 9 | #
|
|---|
| 10 | # - Redistributions of source code must retain the above copyright
|
|---|
| 11 | # notice, this list of conditions and the following disclaimer.
|
|---|
| 12 | # - Redistributions in binary form must reproduce the above copyright
|
|---|
| 13 | # notice, this list of conditions and the following disclaimer in the
|
|---|
| 14 | # documentation and/or other materials provided with the distribution.
|
|---|
| 15 | # - The name of the author may not be used to endorse or promote products
|
|---|
| 16 | # derived from this software without specific prior written permission.
|
|---|
| 17 | #
|
|---|
| 18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 28 | #
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | """
|
|---|
| 32 | Emulator wrapper for running HelenOS
|
|---|
| 33 | """
|
|---|
| 34 |
|
|---|
| 35 | import os
|
|---|
| 36 | import sys
|
|---|
| 37 | import subprocess
|
|---|
| 38 | import autotool
|
|---|
| 39 | import platform
|
|---|
| 40 | import thread
|
|---|
| 41 | import time
|
|---|
| 42 |
|
|---|
| 43 | overrides = {}
|
|---|
| 44 |
|
|---|
| 45 | def is_override(str):
|
|---|
| 46 | if str in overrides.keys():
|
|---|
| 47 | return overrides[str]
|
|---|
| 48 | return False
|
|---|
| 49 |
|
|---|
| 50 | def cfg_get(platform, machine, processor):
|
|---|
| 51 | if machine == "" or emulators[platform].has_key("run"):
|
|---|
| 52 | return emulators[platform]
|
|---|
| 53 | elif processor == "" or emulators[platform][machine].has_key("run"):
|
|---|
| 54 | return emulators[platform][machine]
|
|---|
| 55 | else:
|
|---|
| 56 | return emulators[platform][machine][processor]
|
|---|
| 57 |
|
|---|
| 58 | def termemu_detect():
|
|---|
| 59 | for termemu in ['xfce4-terminal', 'xterm']:
|
|---|
| 60 | try:
|
|---|
| 61 | subprocess.check_output('which ' + termemu, shell = True)
|
|---|
| 62 | return termemu
|
|---|
| 63 | except:
|
|---|
| 64 | pass
|
|---|
| 65 |
|
|---|
| 66 | def run_in_console(cmd, title):
|
|---|
| 67 | ecmd = cmd.replace('"', '\\"')
|
|---|
| 68 | cmdline = termemu_detect() + ' -T ' + '"' + title + '"' + ' -e "' + ecmd + '"'
|
|---|
| 69 | print(cmdline)
|
|---|
| 70 | if not is_override('dryrun'):
|
|---|
| 71 | subprocess.call(cmdline, shell = True)
|
|---|
| 72 |
|
|---|
| 73 | def get_host_native_width():
|
|---|
| 74 | return int(platform.architecture()[0].strip('bit'))
|
|---|
| 75 |
|
|---|
| 76 | def pc_options(guest_width):
|
|---|
| 77 | opts = ''
|
|---|
| 78 |
|
|---|
| 79 | # Do not enable KVM if running 64 bits HelenOS
|
|---|
| 80 | # on 32 bits host
|
|---|
| 81 | host_width = get_host_native_width()
|
|---|
| 82 | if guest_width <= host_width and not is_override('nokvm'):
|
|---|
| 83 | opts = opts + ' -enable-kvm'
|
|---|
| 84 |
|
|---|
| 85 | # Remove the leading space
|
|---|
| 86 | return opts[1:]
|
|---|
| 87 |
|
|---|
| 88 | def malta_options():
|
|---|
| 89 | return '-cpu 4Kc'
|
|---|
| 90 |
|
|---|
| 91 | def platform_to_qemu_options(platform, machine, processor):
|
|---|
| 92 | if platform == 'amd64':
|
|---|
| 93 | return 'system-x86_64', pc_options(64)
|
|---|
| 94 | elif platform == 'arm32':
|
|---|
| 95 | return 'system-arm', '-M integratorcp'
|
|---|
| 96 | elif platform == 'arm64':
|
|---|
| 97 | # Check that ROM image is present. Provide the user with
|
|---|
| 98 | # appropriate steps to fix this problem.
|
|---|
| 99 | if not os.path.exists('QEMU_EFI_ARM64.fd'):
|
|---|
| 100 | sys.stderr.write('Could not find ' +
|
|---|
| 101 | '\'QEMU_EFI_ARM64.fd\' which is expected to ' +
|
|---|
| 102 | 'contain EDK2 firmware image.\n')
|
|---|
| 103 | sys.stderr.write('Pre-built image can be obtained by ' +
|
|---|
| 104 | 'running the following command:\n')
|
|---|
| 105 | sys.stderr.write('$ wget http://snapshots.linaro.org/' +
|
|---|
| 106 | 'components/kernel/leg-virt-tianocore-edk2-' +
|
|---|
| 107 | 'upstream/latest/QEMU-AARCH64/RELEASE_GCC49/' +
|
|---|
| 108 | 'QEMU_EFI.fd -O QEMU_EFI_ARM64.fd\n')
|
|---|
| 109 | raise Exception
|
|---|
| 110 | return 'system-aarch64', \
|
|---|
| 111 | '-M virt -cpu cortex-a57 -m 1024 -bios QEMU_EFI_ARM64.fd'
|
|---|
| 112 | elif platform == 'ia32':
|
|---|
| 113 | return 'system-i386', pc_options(32)
|
|---|
| 114 | elif platform == 'mips32':
|
|---|
| 115 | if machine == 'lmalta':
|
|---|
| 116 | return 'system-mipsel', malta_options()
|
|---|
| 117 | elif machine == 'bmalta':
|
|---|
| 118 | return 'system-mips', malta_options()
|
|---|
| 119 | elif platform == 'ppc32':
|
|---|
| 120 | return 'system-ppc', '-m 256'
|
|---|
| 121 | elif platform == 'sparc64':
|
|---|
| 122 | if machine != 'generic':
|
|---|
| 123 | raise Exception
|
|---|
| 124 | if processor == 'us':
|
|---|
| 125 | return 'system-sparc64', '-M sun4u --prom-env boot-args="console=devices/\\hw\\pci0\\01:01.0\\com1\\a"'
|
|---|
| 126 | elif processor == 'sun4v':
|
|---|
| 127 | default_path = '/usr/local/opensparc/image/'
|
|---|
| 128 | try:
|
|---|
| 129 | if os.path.exists(default_path):
|
|---|
| 130 | opensparc_bins = default_path
|
|---|
| 131 | elif os.path.exists(os.environ['OPENSPARC_BINARIES']):
|
|---|
| 132 | opensparc_bins = os.environ['OPENSPARC_BINARIES']
|
|---|
| 133 | else:
|
|---|
| 134 | raise Exception
|
|---|
| 135 | except:
|
|---|
| 136 | print("Cannot find OpenSPARC binary images!")
|
|---|
| 137 | print("Either set OPENSPARC_BINARIES environment variable accordingly or place the images in %s." % (default_path))
|
|---|
| 138 | raise Exception
|
|---|
| 139 |
|
|---|
| 140 | return 'system-sparc64', '-M niagara -m 256 -L %s' % (opensparc_bins)
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | def hdisk_mk():
|
|---|
| 144 | if not os.path.exists('hdisk.img'):
|
|---|
| 145 | subprocess.call('tools/mkfat.py 1048576 uspace/dist/data hdisk.img', shell = True)
|
|---|
| 146 |
|
|---|
| 147 | def qemu_bd_options():
|
|---|
| 148 | if is_override('nohdd'):
|
|---|
| 149 | return ''
|
|---|
| 150 |
|
|---|
| 151 | hdisk_mk()
|
|---|
| 152 |
|
|---|
| 153 | hdd_options = ''
|
|---|
| 154 | if 'hdd' in overrides.keys():
|
|---|
| 155 | if 'ata' in overrides['hdd'].keys():
|
|---|
| 156 | hdd_options += ''
|
|---|
| 157 | elif 'virtio-blk' in overrides['hdd'].keys():
|
|---|
| 158 | hdd_options += ',if=virtio'
|
|---|
| 159 |
|
|---|
| 160 | return ' -drive file=hdisk.img,index=0,media=disk,format=raw' + hdd_options
|
|---|
| 161 |
|
|---|
| 162 | def qemu_nic_ne2k_options():
|
|---|
| 163 | return ' -device ne2k_isa,irq=5,netdev=n1'
|
|---|
| 164 |
|
|---|
| 165 | def qemu_nic_e1k_options():
|
|---|
| 166 | return ' -device e1000,netdev=n1'
|
|---|
| 167 |
|
|---|
| 168 | def qemu_nic_rtl8139_options():
|
|---|
| 169 | return ' -device rtl8139,netdev=n1'
|
|---|
| 170 |
|
|---|
| 171 | def qemu_nic_virtio_options():
|
|---|
| 172 | return ' -device virtio-net,netdev=n1'
|
|---|
| 173 |
|
|---|
| 174 | def qemu_net_options():
|
|---|
| 175 | if is_override('nonet'):
|
|---|
| 176 | return ''
|
|---|
| 177 |
|
|---|
| 178 | nic_options = ''
|
|---|
| 179 | if 'net' in overrides.keys():
|
|---|
| 180 | if 'e1k' in overrides['net'].keys():
|
|---|
| 181 | nic_options += qemu_nic_e1k_options()
|
|---|
| 182 | if 'rtl8139' in overrides['net'].keys():
|
|---|
| 183 | nic_options += qemu_nic_rtl8139_options()
|
|---|
| 184 | if 'ne2k' in overrides['net'].keys():
|
|---|
| 185 | nic_options += qemu_nic_ne2k_options()
|
|---|
| 186 | if 'virtio-net' in overrides['net'].keys():
|
|---|
| 187 | nic_options += qemu_nic_virtio_options()
|
|---|
| 188 | else:
|
|---|
| 189 | # Use the default NIC
|
|---|
| 190 | nic_options += qemu_nic_e1k_options()
|
|---|
| 191 |
|
|---|
| 192 | return nic_options + ' -netdev user,id=n1,hostfwd=udp::8080-:8080,hostfwd=udp::8081-:8081,hostfwd=tcp::8080-:8080,hostfwd=tcp::8081-:8081,hostfwd=tcp::2223-:2223'
|
|---|
| 193 |
|
|---|
| 194 | def qemu_usb_options():
|
|---|
| 195 | if is_override('nousb'):
|
|---|
| 196 | return ''
|
|---|
| 197 | return ' -usb'
|
|---|
| 198 |
|
|---|
| 199 | def qemu_xhci_options():
|
|---|
| 200 | if is_override('noxhci'):
|
|---|
| 201 | return ''
|
|---|
| 202 | return ' -device nec-usb-xhci,id=xhci'
|
|---|
| 203 |
|
|---|
| 204 | def qemu_tablet_options():
|
|---|
| 205 | if is_override('notablet') or (is_override('nousb') and is_override('noxhci')):
|
|---|
| 206 | return ''
|
|---|
| 207 | return ' -device usb-tablet'
|
|---|
| 208 |
|
|---|
| 209 | def qemu_audio_options():
|
|---|
| 210 | if is_override('nosnd'):
|
|---|
| 211 | return ''
|
|---|
| 212 | return ' -device intel-hda -device hda-duplex'
|
|---|
| 213 |
|
|---|
| 214 | def qemu_run(platform, machine, processor):
|
|---|
| 215 | cfg = cfg_get(platform, machine, processor)
|
|---|
| 216 | suffix, options = platform_to_qemu_options(platform, machine, processor)
|
|---|
| 217 | cmd = 'qemu-' + suffix
|
|---|
| 218 |
|
|---|
| 219 | cmdline = cmd
|
|---|
| 220 | if 'qemu_path' in overrides.keys():
|
|---|
| 221 | cmdline = overrides['qemu_path'] + cmd
|
|---|
| 222 |
|
|---|
| 223 | if options != '':
|
|---|
| 224 | cmdline += ' ' + options
|
|---|
| 225 |
|
|---|
| 226 | if (not 'hdd' in cfg.keys() or cfg['hdd']):
|
|---|
| 227 | cmdline += qemu_bd_options()
|
|---|
| 228 | if (not 'net' in cfg.keys()) or cfg['net']:
|
|---|
| 229 | cmdline += qemu_net_options()
|
|---|
| 230 | if (not 'usb' in cfg.keys()) or cfg['usb']:
|
|---|
| 231 | cmdline += qemu_usb_options()
|
|---|
| 232 | if (not 'xhci' in cfg.keys()) or cfg['xhci']:
|
|---|
| 233 | cmdline += qemu_xhci_options()
|
|---|
| 234 | if (not 'tablet' in cfg.keys()) or cfg['tablet']:
|
|---|
| 235 | cmdline += qemu_tablet_options()
|
|---|
| 236 | if (not 'audio' in cfg.keys()) or cfg['audio']:
|
|---|
| 237 | cmdline += qemu_audio_options()
|
|---|
| 238 |
|
|---|
| 239 | console = ('console' in cfg.keys() and cfg['console'])
|
|---|
| 240 |
|
|---|
| 241 | if (is_override('nographic')):
|
|---|
| 242 | cmdline += ' -nographic'
|
|---|
| 243 |
|
|---|
| 244 | if (not console and (not is_override('nographic')) and not is_override('noserial')):
|
|---|
| 245 | cmdline += ' -serial stdio'
|
|---|
| 246 |
|
|---|
| 247 | if (is_override('bigmem')):
|
|---|
| 248 | cmdline += ' -m 4G'
|
|---|
| 249 |
|
|---|
| 250 | if cfg['image'] == 'image.iso':
|
|---|
| 251 | cmdline += ' -boot d -cdrom image.iso'
|
|---|
| 252 | elif cfg['image'] == 'image.iso@arm64':
|
|---|
| 253 | # Define image.iso cdrom backend.
|
|---|
| 254 | cmdline += ' -drive if=none,file=image.iso,id=cdrom,media=cdrom'
|
|---|
| 255 | # Define scsi bus.
|
|---|
| 256 | cmdline += ' -device virtio-scsi-device'
|
|---|
| 257 | # Define cdrom frontend connected to this scsi bus.
|
|---|
| 258 | cmdline += ' -device scsi-cd,drive=cdrom'
|
|---|
| 259 | elif cfg['image'] == 'image.boot':
|
|---|
| 260 | cmdline += ' -kernel image.boot'
|
|---|
| 261 | else:
|
|---|
| 262 | cmdline += ' ' + cfg['image']
|
|---|
| 263 |
|
|---|
| 264 | if console:
|
|---|
| 265 | cmdline += ' -nographic'
|
|---|
| 266 |
|
|---|
| 267 | title = 'HelenOS/' + platform
|
|---|
| 268 | if machine != '':
|
|---|
| 269 | title += ' on ' + machine
|
|---|
| 270 | if 'expect' in cfg.keys():
|
|---|
| 271 | cmdline = 'expect -c \'spawn %s; expect "%s" { send "%s" } timeout exp_continue; interact\'' % (cmdline, cfg['expect']['src'], cfg['expect']['dst'])
|
|---|
| 272 | run_in_console(cmdline, title)
|
|---|
| 273 | else:
|
|---|
| 274 | print(cmdline)
|
|---|
| 275 | if not is_override('dryrun'):
|
|---|
| 276 | subprocess.call(cmdline, shell = True)
|
|---|
| 277 |
|
|---|
| 278 | def ski_run(platform, machine, processor):
|
|---|
| 279 | run_in_console('ski -i tools/conf/ski.conf', 'HelenOS/ia64 on ski')
|
|---|
| 280 |
|
|---|
| 281 | def msim_run(platform, machine, processor):
|
|---|
| 282 | hdisk_mk()
|
|---|
| 283 | run_in_console('msim -c tools/conf/msim.conf', 'HelenOS/mips32 on msim')
|
|---|
| 284 |
|
|---|
| 285 | def spike_run(platform, machine, processor):
|
|---|
| 286 | run_in_console('spike -m1073741824:1073741824 image.boot', 'HelenOS/risvc64 on Spike')
|
|---|
| 287 |
|
|---|
| 288 | emulators = {
|
|---|
| 289 | 'amd64' : {
|
|---|
| 290 | 'run' : qemu_run,
|
|---|
| 291 | 'image' : 'image.iso'
|
|---|
| 292 | },
|
|---|
| 293 | 'arm32' : {
|
|---|
| 294 | 'integratorcp' : {
|
|---|
| 295 | 'run' : qemu_run,
|
|---|
| 296 | 'image' : 'image.boot',
|
|---|
| 297 | 'net' : False,
|
|---|
| 298 | 'audio' : False,
|
|---|
| 299 | 'xhci' : False,
|
|---|
| 300 | 'tablet' : False
|
|---|
| 301 | }
|
|---|
| 302 | },
|
|---|
| 303 | 'arm64' : {
|
|---|
| 304 | 'virt' : {
|
|---|
| 305 | 'run' : qemu_run,
|
|---|
| 306 | 'image' : 'image.iso@arm64',
|
|---|
| 307 | 'audio' : False,
|
|---|
| 308 | 'console' : True,
|
|---|
| 309 | 'hdd' : False,
|
|---|
| 310 | 'net' : False,
|
|---|
| 311 | 'tablet' : False,
|
|---|
| 312 | 'usb' : False,
|
|---|
| 313 | 'xhci' : False
|
|---|
| 314 | }
|
|---|
| 315 | },
|
|---|
| 316 | 'ia32' : {
|
|---|
| 317 | 'run' : qemu_run,
|
|---|
| 318 | 'image' : 'image.iso'
|
|---|
| 319 | },
|
|---|
| 320 | 'ia64' : {
|
|---|
| 321 | 'ski' : {
|
|---|
| 322 | 'run' : ski_run
|
|---|
| 323 | }
|
|---|
| 324 | },
|
|---|
| 325 | 'mips32' : {
|
|---|
| 326 | 'msim' : {
|
|---|
| 327 | 'run' : msim_run
|
|---|
| 328 | },
|
|---|
| 329 | 'lmalta' : {
|
|---|
| 330 | 'run' : qemu_run,
|
|---|
| 331 | 'image' : 'image.boot',
|
|---|
| 332 | 'console' : True
|
|---|
| 333 | },
|
|---|
| 334 | 'bmalta' : {
|
|---|
| 335 | 'run' : qemu_run,
|
|---|
| 336 | 'image' : 'image.boot',
|
|---|
| 337 | 'console' : True
|
|---|
| 338 | },
|
|---|
| 339 | },
|
|---|
| 340 | 'ppc32' : {
|
|---|
| 341 | 'run' : qemu_run,
|
|---|
| 342 | 'image' : 'image.iso',
|
|---|
| 343 | 'audio' : False
|
|---|
| 344 | },
|
|---|
| 345 | 'riscv64' : {
|
|---|
| 346 | 'run' : spike_run,
|
|---|
| 347 | 'image' : 'image.boot'
|
|---|
| 348 | },
|
|---|
| 349 | 'sparc64' : {
|
|---|
| 350 | 'generic' : {
|
|---|
| 351 | 'us' : {
|
|---|
| 352 | 'run' : qemu_run,
|
|---|
| 353 | 'image' : 'image.iso',
|
|---|
| 354 | 'audio' : False,
|
|---|
| 355 | 'console' : True,
|
|---|
| 356 | 'net' : False,
|
|---|
| 357 | 'usb' : False,
|
|---|
| 358 | 'xhci' : False,
|
|---|
| 359 | 'tablet' : False
|
|---|
| 360 | },
|
|---|
| 361 | 'sun4v' : {
|
|---|
| 362 | 'run' : qemu_run,
|
|---|
| 363 | 'image' : '-drive if=pflash,readonly=on,file=image.iso',
|
|---|
| 364 | 'audio' : False,
|
|---|
| 365 | 'console' : True,
|
|---|
| 366 | 'net' : False,
|
|---|
| 367 | 'usb' : False,
|
|---|
| 368 | 'xhci' : False,
|
|---|
| 369 | 'tablet' : False,
|
|---|
| 370 | 'expect' : {
|
|---|
| 371 | 'src' : 'ok ',
|
|---|
| 372 | 'dst' : 'boot\n'
|
|---|
| 373 | },
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 | },
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | def usage():
|
|---|
| 380 | print("%s - emulator wrapper for running HelenOS\n" % os.path.basename(sys.argv[0]))
|
|---|
| 381 | print("%s [-d] [-h] [-net e1k|rtl8139|ne2k|virtio-net] [-hdd ata|virtio-blk] [-nohdd] [-nokvm] [-nonet] [-nosnd] [-nousb] [-noxhci] [-notablet]\n" %
|
|---|
| 382 | os.path.basename(sys.argv[0]))
|
|---|
| 383 | print("-d\tDry run: do not run the emulation, just print the command line.")
|
|---|
| 384 | print("-h\tPrint the usage information and exit.")
|
|---|
| 385 | print("-nohdd\tDisable hard disk, if applicable.")
|
|---|
| 386 | print("-nokvm\tDisable KVM, if applicable.")
|
|---|
| 387 | print("-nonet\tDisable networking support, if applicable.")
|
|---|
| 388 | print("-nosnd\tDisable sound, if applicable.")
|
|---|
| 389 | print("-nousb\tDisable USB support, if applicable.")
|
|---|
| 390 | print("-noxhci\tDisable XHCI support, if applicable.")
|
|---|
| 391 | print("-notablet\tDisable USB tablet (use only relative-position PS/2 mouse instead), if applicable.")
|
|---|
| 392 | print("-nographic\tDisable graphical output. Serial port output must be enabled for this to be useful.")
|
|---|
| 393 | print("-noserial\tDisable serial port output in the terminal.")
|
|---|
| 394 | print("-bigmem\tSets maximum RAM size to 4GB.")
|
|---|
| 395 |
|
|---|
| 396 | def fail(platform, machine):
|
|---|
| 397 | print("Cannot start emulation for the chosen configuration. (%s/%s)" % (platform, machine))
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 | def run():
|
|---|
| 401 | expect_nic = False
|
|---|
| 402 | expect_hdd = False
|
|---|
| 403 | expect_qemu = False
|
|---|
| 404 |
|
|---|
| 405 | for i in range(1, len(sys.argv)):
|
|---|
| 406 |
|
|---|
| 407 | if expect_nic:
|
|---|
| 408 | expect_nic = False
|
|---|
| 409 | if not 'net' in overrides.keys():
|
|---|
| 410 | overrides['net'] = {}
|
|---|
| 411 | if sys.argv[i] == 'e1k':
|
|---|
| 412 | overrides['net']['e1k'] = True
|
|---|
| 413 | elif sys.argv[i] == 'rtl8139':
|
|---|
| 414 | overrides['net']['rtl8139'] = True
|
|---|
| 415 | elif sys.argv[i] == 'ne2k':
|
|---|
| 416 | overrides['net']['ne2k'] = True
|
|---|
| 417 | elif sys.argv[i] == 'virtio-net':
|
|---|
| 418 | overrides['net']['virtio-net'] = True
|
|---|
| 419 | else:
|
|---|
| 420 | usage()
|
|---|
| 421 | exit()
|
|---|
| 422 | continue
|
|---|
| 423 |
|
|---|
| 424 | if expect_hdd:
|
|---|
| 425 | expect_hdd = False
|
|---|
| 426 | if not 'hdd' in overrides.keys():
|
|---|
| 427 | overrides['hdd'] = {}
|
|---|
| 428 | if sys.argv[i] == 'ata':
|
|---|
| 429 | overrides['hdd']['ata'] = True
|
|---|
| 430 | elif sys.argv[i] == 'virtio-blk':
|
|---|
| 431 | overrides['hdd']['virtio-blk'] = True
|
|---|
| 432 | else:
|
|---|
| 433 | usage()
|
|---|
| 434 | exit()
|
|---|
| 435 | continue
|
|---|
| 436 |
|
|---|
| 437 | if expect_qemu:
|
|---|
| 438 | expect_qemu = False
|
|---|
| 439 | overrides['qemu_path'] = sys.argv[i]
|
|---|
| 440 |
|
|---|
| 441 | elif sys.argv[i] == '-h':
|
|---|
| 442 | usage()
|
|---|
| 443 | exit()
|
|---|
| 444 | elif sys.argv[i] == '-d':
|
|---|
| 445 | overrides['dryrun'] = True
|
|---|
| 446 | elif sys.argv[i] == '-net' and i < len(sys.argv) - 1:
|
|---|
| 447 | expect_nic = True
|
|---|
| 448 | elif sys.argv[i] == '-hdd' and i < len(sys.argv) - 1:
|
|---|
| 449 | expect_hdd = True
|
|---|
| 450 | elif sys.argv[i] == '-nohdd':
|
|---|
| 451 | overrides['nohdd'] = True
|
|---|
| 452 | elif sys.argv[i] == '-nokvm':
|
|---|
| 453 | overrides['nokvm'] = True
|
|---|
| 454 | elif sys.argv[i] == '-nonet':
|
|---|
| 455 | overrides['nonet'] = True
|
|---|
| 456 | elif sys.argv[i] == '-nosnd':
|
|---|
| 457 | overrides['nosnd'] = True
|
|---|
| 458 | elif sys.argv[i] == '-nousb':
|
|---|
| 459 | overrides['nousb'] = True
|
|---|
| 460 | elif sys.argv[i] == '-noxhci':
|
|---|
| 461 | overrides['noxhci'] = True
|
|---|
| 462 | elif sys.argv[i] == '-notablet':
|
|---|
| 463 | overrides['notablet'] = True
|
|---|
| 464 | elif sys.argv[i] == '-nographic':
|
|---|
| 465 | overrides['nographic'] = True
|
|---|
| 466 | elif sys.argv[i] == '-bigmem':
|
|---|
| 467 | overrides['bigmem'] = True
|
|---|
| 468 | elif sys.argv[i] == '-noserial':
|
|---|
| 469 | overrides['noserial'] = True
|
|---|
| 470 | elif sys.argv[i] == '-qemu_path' and i < len(sys.argv) - 1:
|
|---|
| 471 | expect_qemu = True
|
|---|
| 472 | else:
|
|---|
| 473 | usage()
|
|---|
| 474 | exit()
|
|---|
| 475 |
|
|---|
| 476 | config = {}
|
|---|
| 477 | autotool.read_config(autotool.CONFIG, config)
|
|---|
| 478 |
|
|---|
| 479 | if 'PLATFORM' in config.keys():
|
|---|
| 480 | platform = config['PLATFORM']
|
|---|
| 481 | else:
|
|---|
| 482 | platform = ''
|
|---|
| 483 |
|
|---|
| 484 | if 'MACHINE' in config.keys():
|
|---|
| 485 | mach = config['MACHINE']
|
|---|
| 486 | else:
|
|---|
| 487 | mach = ''
|
|---|
| 488 |
|
|---|
| 489 | if 'PROCESSOR' in config.keys():
|
|---|
| 490 | processor = config['PROCESSOR']
|
|---|
| 491 | else:
|
|---|
| 492 | processor = ''
|
|---|
| 493 |
|
|---|
| 494 | try:
|
|---|
| 495 | emu_run = cfg_get(platform, mach, processor)['run']
|
|---|
| 496 | emu_run(platform, mach, processor)
|
|---|
| 497 | except:
|
|---|
| 498 | fail(platform, mach)
|
|---|
| 499 | return
|
|---|
| 500 |
|
|---|
| 501 | run()
|
|---|