summaryrefslogtreecommitdiffstats
path: root/scripts/runqemu
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2023-06-14 15:00:46 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-15 08:00:41 +0100
commit5776d07bddc051ce3e9e73ace26af924f426b51f (patch)
treecc47c1f44102d08ce76cf688f0849acd7990ed59 /scripts/runqemu
parentd9cf8973d01b74aa2680dba5ac46c5cea3d1a6d0 (diff)
downloadpoky-5776d07bddc051ce3e9e73ace26af924f426b51f.tar.gz
scripts/runqemu: split lock dir creation into a reusable function
(From OE-Core rev: 004d6bcb067ecf1d796801fa43a98820c4efd3c7) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-xscripts/runqemu29
1 files changed, 13 insertions, 16 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 56715c3e1e..cef5b8d4a4 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1087,6 +1087,17 @@ to your build configuration.
1087 self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % ( 1087 self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % (
1088 self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper'))) 1088 self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper')))
1089 1089
1090 def make_lock_dir(self, lockdir):
1091 if not os.path.exists(lockdir):
1092 # There might be a race issue when multi runqemu processess are
1093 # running at the same time.
1094 try:
1095 os.mkdir(lockdir)
1096 os.chmod(lockdir, 0o777)
1097 except FileExistsError:
1098 pass
1099 return
1100
1090 def setup_slirp(self): 1101 def setup_slirp(self):
1091 """Setup user networking""" 1102 """Setup user networking"""
1092 1103
@@ -1105,14 +1116,7 @@ to your build configuration.
1105 mac = 2 1116 mac = 2
1106 1117
1107 lockdir = "/tmp/qemu-port-locks" 1118 lockdir = "/tmp/qemu-port-locks"
1108 if not os.path.exists(lockdir): 1119 self.make_lock_dir(lockdir)
1109 # There might be a race issue when multi runqemu processess are
1110 # running at the same time.
1111 try:
1112 os.mkdir(lockdir)
1113 os.chmod(lockdir, 0o777)
1114 except FileExistsError:
1115 pass
1116 1120
1117 # Find a free port to avoid conflicts 1121 # Find a free port to avoid conflicts
1118 for p in ports[:]: 1122 for p in ports[:]:
@@ -1152,14 +1156,7 @@ to your build configuration.
1152 logger.error("ip: %s" % ip) 1156 logger.error("ip: %s" % ip)
1153 raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found") 1157 raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found")
1154 1158
1155 if not os.path.exists(lockdir): 1159 self.make_lock_dir(lockdir)
1156 # There might be a race issue when multi runqemu processess are
1157 # running at the same time.
1158 try:
1159 os.mkdir(lockdir)
1160 os.chmod(lockdir, 0o777)
1161 except FileExistsError:
1162 pass
1163 1160
1164 cmd = (ip, 'link') 1161 cmd = (ip, 'link')
1165 logger.debug('Running %s...' % str(cmd)) 1162 logger.debug('Running %s...' % str(cmd))