Lines Matching +full:re +full:- +full:config

5 # Copyright (C) 2006-2011 Linux Foundation
8 # SPDX-License-Identifier: GPL-2.0-only
15 import re
32 or to source oe-init-build-env before running this script.\n\n \
34 runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`\n\n %s" % message)
46 formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
62 KERNEL - the kernel image file to use
63 BIOS - the bios image file to use
64 ROOTFS - the rootfs image file or nfsroot directory to use
65 DEVICE_TREE - the device tree blob to use
66 MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)
67 Simplified QEMU command-line options can be passed with:
68 nographic - disable video console
69 novga - Disable VGA emulation completely
70 sdl - choose the SDL UI frontend
71 gtk - choose the Gtk UI frontend
72 gl - enable virgl-based GL acceleration (also needs gtk or sdl options)
73 gl-es - enable virgl-based GL acceleration, using OpenGL ES (also needs gtk or sdl options)
74 egl-headless - enable headless EGL output; use vnc (via publicvnc option) or spice to see it
77 serial - enable a serial console on /dev/ttyS0
78 serialstdio - enable a serial console on the console (regardless of graphics mode)
79 slirp - enable user networking, no root privilege is required
80 snapshot - don't write changes back to images
81 kvm - enable KVM when running x86/x86_64 (VT-capable CPU required)
82 kvm-vhost - enable KVM with vhost when running x86/x86_64 (VT-capable CPU required)
83 publicvnc - enable a VNC server open to all hosts
84 audio - enable audio
85 [*/]ovmf* - OVMF firmware file or base name for booting with UEFI
86 tcpserial=<port> - specify tcp serial port number
87 qemuparams=<xyz> - specify custom parameters to QEMU
88 bootparams=<xyz> - specify custom kernel parameters during boot
89 help, -h, --help: print this text
90 -d, --debug: Enable debug output
91 -q, --quiet: Hide most output except error messages
98 runqemu qemux86-64 core-image-sato ext4
99 runqemu qemux86-64 wic-image-minimal wic
100 runqemu path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial
102 runqemu qemux86 qemuparams="-m 256"
104 runqemu path/to/<image>-<machine>.wic
105 runqemu path/to/<image>-<machine>.wic.vmdk
106 runqemu path/to/<image>-<machine>.wic.vhdx
107 runqemu path/to/<image>-<machine>.wic.vhd
154 # to be added with -drive if=pflash.
201 self.network_device = "-device e1000,netdev=net0,mac=@MAC@"
315 if not re.search('.qemuboot.conf$', '\n'.join(os.listdir(p)), re.M):
318 if not any(map(lambda name: '-image-' in name, os.listdir(p))):
319 logger.debug("Can't find *-image-* in %s" % p)
349 m = re.match('(.*):(.*)', p)
356 - Check whether it is <image>.qemuboot.conf or contains <image>.qemuboot.conf
357 - Check whether it is a kernel file
358 - Check whether it is an image file
359 - Check whether it is an NFS dir
360 - Check whether it is an OVMF flash file
365 elif re.search('\.bin$', p) or re.search('bzImage', p) or \
366 re.search('zImage', p) or re.search('vmlinux', p) or \
367 re.search('fitImage', p) or re.search('uImage', p):
369 elif os.path.exists(p) and (not os.path.isdir(p)) and '-image-' in os.path.basename(p):
379 m = re.search('.*\.(.*)$', self.rootfs)
384 qb = re.sub('\.' + fst + "$", '', self.rootfs)
385 qb = '%s%s' % (re.sub('\.rootfs$', '', qb), '.qemuboot.conf')
394 elif os.path.isdir(p) or re.search(':', p) and re.search('/', p):
412 elif re.search('/', arg):
417 # if we're running under testimage, or similarly as a child
428 # also check whether we're running under a sourced toolchain
435 # bitbake -e doesn't report invalid MACHINE as an error, so
438 s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M)
442 raise RunQemuError("bitbake -e %s" % self.bitbake_e)
451 # we need to ensure that we run host pkg-config, and that it does not
452 # get mis-directed to native build paths set by bitbake.
462 …dripath = subprocess.check_output("PATH=/bin:/usr/bin:$PATH pkg-config --variable=dridriverdir dri…
464 …emuError("Could not determine the path to dri drivers on the host via pkg-config.\nPlease install …
465 self.qemu_environ['LIBGL_DRIVERS_PATH'] = dripath.decode('utf-8').strip()
476 for debug in ("-d", "--debug"):
481 for quiet in ("-q", "--quiet"):
486 if 'gl' not in sys.argv[1:] and 'gl-es' not in sys.argv[1:]:
502 elif arg == 'gl-es':
504 elif arg == 'egl-headless':
518 elif arg == 'kvm-vhost':
528 self.qemu_opt_script += ' -vnc :0'
535 elif os.path.exists(arg) or (re.search(':', arg) and re.search('/', arg)):
537 elif re.search(r'-image-|-image$', arg):
561 s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M)
566 """Check kvm and kvm-host"""
578 dev_vhost = '/dev/vhost-net'
581 kvm_cap = re.search('vmx|svm', "".join(f.readlines()))
584 logger.error("Remove kvm from the command-line, or refer:")
593 self.qemu_opt_script += ' -enable-kvm'
598 self.kernel_cmdline_script += " clocksource=kvm-clock hpet=disable noapic nolapic"
606 logger.error("Missing virtio net device. Have you inserted vhost-net module?")
611 logger.error("You have no read or write permission on /dev/vhost-net.")
624 …# parse QB_FSINFO into dict, e.g. { 'wic': ['no-kernel-in-fs', 'a-flag'], 'ext4': ['another-flag']}
634 if fsflag == 'no-kernel-in-fs':
636 elif fsflag == 'kernel-in-fs':
675 self.rootfs = "%s/%s-%s.%s" % (self.get('DEPLOY_DIR_IMAGE'),
699 replace('-----BEGIN CERTIFICATE-----', ''). \
700 replace('-----END CERTIFICATE-----', '')
802 s = re.search('-m +([0-9]+)', self.qemuparams)
804 self.set('QB_MEM', '-m %s' % s.group(1))
807 self.set('QB_MEM', '-m 256')
812 qb_mem = qb_mem[:-1]
814 # Add -m prefix it not present
815 if not qb_mem.startswith('-m'):
816 qb_mem = '-m %s' % qb_mem
822 … self.kernel_cmdline_script += ' mem=%s' % self.get('QB_MEM').replace('-m','').strip() + 'M'
833 self.qemu_opt_script += ' -serial tcp:127.0.0.1:%s' % port
837 self.qemu_opt_script += ' -serial tcp:127.0.0.1:%s' % port
880 self.qemuboot = "%s/%s-%s.qemuboot.conf" % (deploy_dir_image,
883 cmd = 'ls -t %s/*.qemuboot.conf' % deploy_dir_image
886 qbs = subprocess.check_output(cmd, shell=True).decode('utf-8')
892 if '-initramfs-' in os.path.basename(qb) and self.fstype != 'cpio.gz':
923 # When we're started with a *.qemuboot.conf arg assume that image
932 # If the STAGING_*_NATIVE directories from the config file don't exist
933 # and we're in a sourced OE build directory try to extract the paths
934 # from `bitbake -e`
945 s = re.search('^%s="(.*)"' % nv, self.bitbake_e, re.M)
950 # when we're invoked from a running bitbake instance we won't
951 # be able to call `bitbake -e`, then try:
952 # - get OE_TMPDIR from environment and guess paths based on it
953 # - get OECORE_NATIVE_SYSROOT from environment (for sdk)
959 buildsys = '%s-%s' % (machine, hostos.lower())
1005 ps = subprocess.check_output(("ps", "auxww")).decode('utf-8')
1006 pattern = '/bin/unfsd .* -i .*\.pid -e .*/exports([0-9]+) '
1007 all_instances = re.findall(pattern, ps, re.M)
1015 # Export vars for runqemu-export-rootfs
1030 dest = "%s-nfsroot" % src_prefix
1045 cmd = ('runqemu-extract-sdk', src, dest)
1054 cmd = ('runqemu-export-rootfs', 'start', self.rootfs)
1062 …self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0…
1063 self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper')))
1074 hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23"
1075 … qb_slirp_opt_default = "-netdev user,id=net0%s,tftp=%s" % (hostfwd, self.get('DEPLOY_DIR_IMAGE'))
1078 ports = re.findall('hostfwd=[^-]*:([0-9]+)-[^,-]*', qb_slirp_opt)
1082 lockdir = "/tmp/qemu-port-locks"
1103 qb_slirp_opt = re.sub(':%s-' % p, ':%s-' % p_new, qb_slirp_opt)
1104 logger.info("Port forward changed: %s -> %s" % (p, p_new))
1108 hostfwd = re.findall('(hostfwd=[^,]*)', qb_slirp_opt)
1115 # This file is created when runqemu-gen-tapdevs creates a bank of tap
1118 nosudo_flag = '/etc/runqemu-nosudo'
1119 self.qemuifup = shutil.which('runqemu-ifup')
1120 self.qemuifdown = shutil.which('runqemu-ifdown')
1122 lockdir = "/tmp/qemu-tap-locks"
1125 logger.error("runqemu-ifup: %s" % self.qemuifup)
1126 logger.error("runqemu-ifdown: %s" % self.qemuifdown)
1128 raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found")
1141 ip_link = subprocess.check_output(cmd).decode('utf-8')
1143 possibles = re.findall('^[0-9]+: +(tap[0-9]+): <.*', ip_link, re.M)
1168 tap = subprocess.check_output(cmd).decode('utf-8').strip()
1170 …logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' …
1179 logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.")
1197 qemu_tap_opt = "-netdev tap,id=net0,ifname=%s,script=no,downscript=no" % (self.tap)
1208 self.saved_stty = subprocess.check_output(("stty", "-g")).decode('utf-8').strip()
1232 logger.info("Copy done in %s seconds" % (time.time() - copy_start))
1242 … self.rootfs_options = '-drive file=%s,if=virtio,format=%s' % (self.rootfs, rootfs_format)
1250 self.rootfs_options = '-initrd %s' % self.rootfs
1255 vm_drive = '-drive file=%s,if=virtio,media=cdrom' % self.rootfs
1260 …vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd…
1264 vm_drive = "-drive file=%s,format=%s" % (self.rootfs, rootfs_format)
1267 … vm_drive = '-drive id=disk0,file=%s,if=none,format=%s -device virtio-blk-device,drive=disk0%s' \
1276 … vm_drive = '-drive if=virtio,file=%s,format=%s' % (self.rootfs, rootfs_format)
1281 self.rootfs_options += ' -no-reboot'
1301 """attempt to determine the appropriate qemu-system binary"""
1304 …search = '.*(qemux86-64|qemux86|qemuarm64|qemuarm|qemumips64|qemumips64el|qemumipsel|qemumips|qemu…
1306 match = re.match(search, self.rootfs)
1310 match = re.match(search, self.kernel)
1323 elif mach == 'qemux86-64':
1342 …logger.error("qemux86-64, qemux86, qemuarm64, qemuarm, qemumips64, qemumips64el, qemumipsel, qemum…
1345 return 'qemu-system-%s' % qbsys
1361 self.qemu_opt += ' -nographic'
1364 self.qemu_opt += ' -vga none'
1368 raise RunQemuError('Option gl/gl-es needs gtk or sdl option.')
1371 # need our font setup and show-cusor below so we need to see what qemu --help says
1372 # is supported so we can pass our correct config in.
1374 …output = subprocess.check_output([self.qemu_bin, "--help"], universal_newlines=True, env=self.qemu…
1375 if "-display gtk" in output:
1377 elif "-display sdl" in output:
1380 self.qemu_opt += ' -display none'
1386 self.qemu_opt += ' -device virtio-vga-gl '
1388 self.qemu_opt += ' -device virtio-vga '
1390 self.qemu_opt += ' -display '
1393 self.qemu_opt += 'egl-headless,'
1407 self.qemu_opt += 'show-cursor=on'
1418 self.qemu_opt += " -serial mon:stdio"
1420 self.qemu_opt += " -serial mon:vc"
1432 serial_num = len(re.findall("-serial", self.qemu_opt))
1434 self.qemu_opt += " -serial null"
1439 # It is possible to have qemu-native in ASSUME_PROVIDED, and it won't
1464 format = ovmf.rsplit('.', 1)[-1]
1467 self.qemu_opt += ' -drive if=pflash,format=%s,file=%s' % (format, ovmf)
1475 self.qemu_opt += ' -smbios type=11,value=4e32566d-8e9e-4f52-81d3-5bb9715f9727:' \
1483 self.qemu_opt += " -snapshot"
1491 kernel_opts = "-kernel %s -append '%s %s %s %s'" % (self.kernel, self.kernel_cmdline,
1495 kernel_opts += " -dtb %s" % self.dtb
1500 self.qemu_opt += " -bios %s" % self.bios
1518 if retcode == -signal.SIGTERM:
1552 cmd = ("runqemu-export-rootfs", "stop", self.rootfs)
1585 cmd = 'MACHINE=%s bitbake -e %s' % (mach, multiconfig)
1587 cmd = 'bitbake -e %s' % multiconfig
1590 return subprocess.check_output(cmd, shell=True).decode('utf-8')
1600 …logger.warning("Couldn't run 'bitbake -e' to gather environment information:\n%s" % err.output.dec…
1612 cmd = ['bitbake', '-e']
1615 cmd.append('mc:%s:qemu-helper-native' % multiconfig)
1617 cmd.append('qemu-helper-native')
1620 out = subprocess.check_output(cmd).decode('utf-8')
1622 match = re.search('^STAGING_BINDIR_NATIVE="(.*)"', out, re.M)
1634 if "help" in sys.argv or '-h' in sys.argv or '--help' in sys.argv:
1638 config = BaseConfig()
1640 renice = os.path.expanduser("~/bin/runqemu-renice")
1647 config.cleanup()
1650 config.check_args()
1651 config.read_qemuboot()
1652 config.check_and_set()
1654 config.validate_combos()
1655 config.print_config()
1656 config.setup_network()
1657 config.setup_rootfs()
1658 config.setup_final()
1659 config.start_qemu()
1668 config.cleanup()