summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2023-06-14 15:00:46 +0200
committerSteve Sakoman <steve@sakoman.com>2023-07-04 05:32:29 -1000
commit5336ba0908d97da2410ff3eaee66c4c792038580 (patch)
treee68ecaba868ad4ebdc63d881d59bdfa87a81d848 /scripts
parent168fb2e293a1a074345ff88d3cb4fb54252aaeea (diff)
downloadpoky-5336ba0908d97da2410ff3eaee66c4c792038580.tar.gz
scripts/runqemu: split lock dir creation into a reusable function
(From OE-Core rev: 811e24cf68c542d38386f83eda05d7efe3e5e4dc) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 004d6bcb067ecf1d796801fa43a98820c4efd3c7) Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu29
1 files changed, 13 insertions, 16 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 4c06cefbff..50224f2784 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1083,6 +1083,17 @@ to your build configuration.
1083 self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % ( 1083 self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % (
1084 self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper'))) 1084 self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper')))
1085 1085
1086 def make_lock_dir(self, lockdir):
1087 if not os.path.exists(lockdir):
1088 # There might be a race issue when multi runqemu processess are
1089 # running at the same time.
1090 try:
1091 os.mkdir(lockdir)
1092 os.chmod(lockdir, 0o777)
1093 except FileExistsError:
1094 pass
1095 return
1096
1086 def setup_slirp(self): 1097 def setup_slirp(self):
1087 """Setup user networking""" 1098 """Setup user networking"""
1088 1099
@@ -1101,14 +1112,7 @@ to your build configuration.
1101 mac = 2 1112 mac = 2
1102 1113
1103 lockdir = "/tmp/qemu-port-locks" 1114 lockdir = "/tmp/qemu-port-locks"
1104 if not os.path.exists(lockdir): 1115 self.make_lock_dir(lockdir)
1105 # There might be a race issue when multi runqemu processess are
1106 # running at the same time.
1107 try:
1108 os.mkdir(lockdir)
1109 os.chmod(lockdir, 0o777)
1110 except FileExistsError:
1111 pass
1112 1116
1113 # Find a free port to avoid conflicts 1117 # Find a free port to avoid conflicts
1114 for p in ports[:]: 1118 for p in ports[:]:
@@ -1148,14 +1152,7 @@ to your build configuration.
1148 logger.error("ip: %s" % ip) 1152 logger.error("ip: %s" % ip)
1149 raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found") 1153 raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found")
1150 1154
1151 if not os.path.exists(lockdir): 1155 self.make_lock_dir(lockdir)
1152 # There might be a race issue when multi runqemu processess are
1153 # running at the same time.
1154 try:
1155 os.mkdir(lockdir)
1156 os.chmod(lockdir, 0o777)
1157 except FileExistsError:
1158 pass
1159 1156
1160 cmd = (ip, 'link') 1157 cmd = (ip, 'link')
1161 logger.debug('Running %s...' % str(cmd)) 1158 logger.debug('Running %s...' % str(cmd))