summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu63
1 files changed, 29 insertions, 34 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 08f4cfe4ca..55cdd414ec 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -115,9 +115,9 @@ def check_tun():
115 raise RunQemuError("TUN control device %s is not writable, please fix (e.g. sudo chmod 666 %s)" % (dev_tun, dev_tun)) 115 raise RunQemuError("TUN control device %s is not writable, please fix (e.g. sudo chmod 666 %s)" % (dev_tun, dev_tun))
116 116
117def check_libgl(qemu_bin): 117def check_libgl(qemu_bin):
118 cmd = 'ldd %s' % qemu_bin 118 cmd = ('ldd', qemu_bin)
119 logger.debug('Running %s...' % cmd) 119 logger.debug('Running %s...' % str(cmd))
120 need_gl = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8') 120 need_gl = subprocess.check_output(cmd).decode('utf-8')
121 if re.search('libGLU', need_gl): 121 if re.search('libGLU', need_gl):
122 # We can't run without a libGL.so 122 # We can't run without a libGL.so
123 libgl = False 123 libgl = False
@@ -398,7 +398,7 @@ class BaseConfig(object):
398 398
399 cmd = 'MACHINE=%s bitbake -e' % arg 399 cmd = 'MACHINE=%s bitbake -e' % arg
400 logger.info('Running %s...' % cmd) 400 logger.info('Running %s...' % cmd)
401 self.bitbake_e = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8') 401 self.bitbake_e = subprocess.check_output(cmd, shell=True).decode('utf-8')
402 # bitbake -e doesn't report invalid MACHINE as an error, so 402 # bitbake -e doesn't report invalid MACHINE as an error, so
403 # let's check DEPLOY_DIR_IMAGE to make sure that it is a valid 403 # let's check DEPLOY_DIR_IMAGE to make sure that it is a valid
404 # MACHINE. 404 # MACHINE.
@@ -838,10 +838,7 @@ class BaseConfig(object):
838 self.nfs_server = '192.168.7.1' 838 self.nfs_server = '192.168.7.1'
839 839
840 # Figure out a new nfs_instance to allow multiple qemus running. 840 # Figure out a new nfs_instance to allow multiple qemus running.
841 # CentOS 7.1's ps doesn't print full command line without "ww" 841 ps = subprocess.check_output(("ps", "auxww")).decode('utf-8')
842 # when invoke by subprocess.Popen().
843 cmd = "ps auxww"
844 ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
845 pattern = '/bin/unfsd .* -i .*\.pid -e .*/exports([0-9]+) ' 842 pattern = '/bin/unfsd .* -i .*\.pid -e .*/exports([0-9]+) '
846 all_instances = re.findall(pattern, ps, re.M) 843 all_instances = re.findall(pattern, ps, re.M)
847 if all_instances: 844 if all_instances:
@@ -881,17 +878,17 @@ class BaseConfig(object):
881 if not src: 878 if not src:
882 raise RunQemuError("No NFS_DIR is set, and can't find %s or %s to extract" % (src1, src2)) 879 raise RunQemuError("No NFS_DIR is set, and can't find %s or %s to extract" % (src1, src2))
883 logger.info('NFS_DIR not found, extracting %s to %s' % (src, dest)) 880 logger.info('NFS_DIR not found, extracting %s to %s' % (src, dest))
884 cmd = 'runqemu-extract-sdk %s %s' % (src, dest) 881 cmd = ('runqemu-extract-sdk', src, dest)
885 logger.info('Running %s...' % cmd) 882 logger.info('Running %s...' % str(cmd))
886 if subprocess.call(cmd, shell=True) != 0: 883 if subprocess.call(cmd) != 0:
887 raise RunQemuError('Failed to run %s' % cmd) 884 raise RunQemuError('Failed to run %s' % cmd)
888 self.clean_nfs_dir = True 885 self.clean_nfs_dir = True
889 self.rootfs = dest 886 self.rootfs = dest
890 887
891 # Start the userspace NFS server 888 # Start the userspace NFS server
892 cmd = 'runqemu-export-rootfs start %s' % self.rootfs 889 cmd = ('runqemu-export-rootfs', 'start', self.rootfs)
893 logger.info('Running %s...' % cmd) 890 logger.info('Running %s...' % str(cmd))
894 if subprocess.call(cmd, shell=True) != 0: 891 if subprocess.call(cmd) != 0:
895 raise RunQemuError('Failed to run %s' % cmd) 892 raise RunQemuError('Failed to run %s' % cmd)
896 893
897 self.nfs_running = True 894 self.nfs_running = True
@@ -957,9 +954,9 @@ class BaseConfig(object):
957 except FileExistsError: 954 except FileExistsError:
958 pass 955 pass
959 956
960 cmd = '%s link' % ip 957 cmd = (ip, 'link')
961 logger.debug('Running %s...' % cmd) 958 logger.debug('Running %s...' % str(cmd))
962 ip_link = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8') 959 ip_link = subprocess.check_output(cmd).decode('utf-8')
963 # Matches line like: 6: tap0: <foo> 960 # Matches line like: 6: tap0: <foo>
964 possibles = re.findall('^[0-9]+: +(tap[0-9]+): <.*', ip_link, re.M) 961 possibles = re.findall('^[0-9]+: +(tap[0-9]+): <.*', ip_link, re.M)
965 tap = "" 962 tap = ""
@@ -984,8 +981,8 @@ class BaseConfig(object):
984 gid = os.getgid() 981 gid = os.getgid()
985 uid = os.getuid() 982 uid = os.getuid()
986 logger.info("Setting up tap interface under sudo") 983 logger.info("Setting up tap interface under sudo")
987 cmd = 'sudo %s %s %s %s' % (self.qemuifup, uid, gid, self.bindir_native) 984 cmd = ('sudo', self.qemuifup, str(uid), str(gid), self.bindir_native)
988 tap = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8').rstrip('\n') 985 tap = subprocess.check_output(cmd).decode('utf-8').strip()
989 lockfile = os.path.join(lockdir, tap) 986 lockfile = os.path.join(lockdir, tap)
990 self.lock = lockfile + '.lock' 987 self.lock = lockfile + '.lock'
991 self.acquire_lock() 988 self.acquire_lock()
@@ -1020,7 +1017,7 @@ class BaseConfig(object):
1020 if self.get('QB_NET') == 'none': 1017 if self.get('QB_NET') == 'none':
1021 return 1018 return
1022 if sys.stdin.isatty(): 1019 if sys.stdin.isatty():
1023 self.saved_stty = subprocess.check_output("stty -g", shell=True).decode('utf-8') 1020 self.saved_stty = subprocess.check_output(("stty", "-g")).decode('utf-8').strip()
1024 self.network_device = self.get('QB_NETWORK_DEVICE') or self.network_device 1021 self.network_device = self.get('QB_NETWORK_DEVICE') or self.network_device
1025 if self.slirp_enabled: 1022 if self.slirp_enabled:
1026 self.setup_slirp() 1023 self.setup_slirp()
@@ -1134,7 +1131,7 @@ class BaseConfig(object):
1134 if not qemu_system: 1131 if not qemu_system:
1135 raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!") 1132 raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!")
1136 1133
1137 qemu_bin = '%s/%s' % (self.bindir_native, qemu_system) 1134 qemu_bin = os.path.join(self.bindir_native, qemu_system)
1138 1135
1139 # It is possible to have qemu-native in ASSUME_PROVIDED, and it won't 1136 # It is possible to have qemu-native in ASSUME_PROVIDED, and it won't
1140 # find QEMU in sysroot, it needs to use host's qemu. 1137 # find QEMU in sysroot, it needs to use host's qemu.
@@ -1172,7 +1169,7 @@ class BaseConfig(object):
1172 1169
1173 if self.serialstdio: 1170 if self.serialstdio:
1174 if sys.stdin.isatty(): 1171 if sys.stdin.isatty():
1175 subprocess.check_call("stty intr ^]", shell=True) 1172 subprocess.check_call(("stty", "intr", "^]"))
1176 logger.info("Interrupt character is '^]'") 1173 logger.info("Interrupt character is '^]'")
1177 1174
1178 first_serial = "" 1175 first_serial = ""
@@ -1236,20 +1233,19 @@ class BaseConfig(object):
1236 1233
1237 logger.info("Cleaning up") 1234 logger.info("Cleaning up")
1238 if self.cleantap: 1235 if self.cleantap:
1239 cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native) 1236 cmd = ('sudo', self.qemuifdown, self.tap, self.bindir_native)
1240 logger.debug('Running %s' % cmd) 1237 logger.debug('Running %s' % str(cmd))
1241 subprocess.check_call(cmd, shell=True) 1238 subprocess.check_call(cmd)
1242 self.release_lock() 1239 self.release_lock()
1243 1240
1244 if self.nfs_running: 1241 if self.nfs_running:
1245 logger.info("Shutting down the userspace NFS server...") 1242 logger.info("Shutting down the userspace NFS server...")
1246 cmd = "runqemu-export-rootfs stop %s" % self.rootfs 1243 cmd = ("runqemu-export-rootfs", "stop", self.rootfs)
1247 logger.debug('Running %s' % cmd) 1244 logger.debug('Running %s' % str(cmd))
1248 subprocess.check_call(cmd, shell=True) 1245 subprocess.check_call(cmd)
1249 1246
1250 if self.saved_stty: 1247 if self.saved_stty:
1251 cmd = "stty %s" % self.saved_stty 1248 subprocess.check_call(("stty", self.saved_stty))
1252 subprocess.check_call(cmd, shell=True)
1253 1249
1254 if self.clean_nfs_dir: 1250 if self.clean_nfs_dir:
1255 logger.info('Removing %s' % self.rootfs) 1251 logger.info('Removing %s' % self.rootfs)
@@ -1291,10 +1287,9 @@ class BaseConfig(object):
1291 if result and os.path.exists(result): 1287 if result and os.path.exists(result):
1292 return result 1288 return result
1293 1289
1294 cmd = 'bitbake qemu-helper-native -e' 1290 cmd = ('bitbake', 'qemu-helper-native', '-e')
1295 logger.info('Running %s...' % cmd) 1291 logger.info('Running %s...' % str(cmd))
1296 out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) 1292 out = subprocess.check_output(cmd).decode('utf-8')
1297 out = out.stdout.read().decode('utf-8')
1298 1293
1299 match = re.search('^STAGING_BINDIR_NATIVE="(.*)"', out, re.M) 1294 match = re.search('^STAGING_BINDIR_NATIVE="(.*)"', out, re.M)
1300 if match: 1295 if match: