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-12 05:11:38 -1000
commite69c311ed68e3f44f3e55f01f6f54b978d76e0d1 (patch)
tree4bfbf6e4fe21c6a4e1cac3fe660adc24897e2152 /scripts
parent983548705ab2e258c819b439edf291b9e946b0ec (diff)
downloadpoky-e69c311ed68e3f44f3e55f01f6f54b978d76e0d1.tar.gz
scripts/runqemu: split lock dir creation into a reusable function
(From OE-Core rev: 2ada5f426e71e3873ba8c47dd925d8cfc103524b) 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 5a98abfffe..f275cf7813 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1062,6 +1062,17 @@ class BaseConfig(object):
1062 self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % ( 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'))) 1063 self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper')))
1064 1064
1065 def make_lock_dir(self, lockdir):
1066 if not os.path.exists(lockdir):
1067 # There might be a race issue when multi runqemu processess are
1068 # running at the same time.
1069 try:
1070 os.mkdir(lockdir)
1071 os.chmod(lockdir, 0o777)
1072 except FileExistsError:
1073 pass
1074 return
1075
1065 def setup_slirp(self): 1076 def setup_slirp(self):
1066 """Setup user networking""" 1077 """Setup user networking"""
1067 1078
@@ -1080,14 +1091,7 @@ class BaseConfig(object):
1080 mac = 2 1091 mac = 2
1081 1092
1082 lockdir = "/tmp/qemu-port-locks" 1093 lockdir = "/tmp/qemu-port-locks"
1083 if not os.path.exists(lockdir): 1094 self.make_lock_dir(lockdir)
1084 # There might be a race issue when multi runqemu processess are
1085 # running at the same time.
1086 try:
1087 os.mkdir(lockdir)
1088 os.chmod(lockdir, 0o777)
1089 except FileExistsError:
1090 pass
1091 1095
1092 # Find a free port to avoid conflicts 1096 # Find a free port to avoid conflicts
1093 for p in ports[:]: 1097 for p in ports[:]:
@@ -1127,14 +1131,7 @@ class BaseConfig(object):
1127 logger.error("ip: %s" % ip) 1131 logger.error("ip: %s" % ip)
1128 raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found") 1132 raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found")
1129 1133
1130 if not os.path.exists(lockdir): 1134 self.make_lock_dir(lockdir)
1131 # There might be a race issue when multi runqemu processess are
1132 # running at the same time.
1133 try:
1134 os.mkdir(lockdir)
1135 os.chmod(lockdir, 0o777)
1136 except FileExistsError:
1137 pass
1138 1135
1139 cmd = (ip, 'link') 1136 cmd = (ip, 'link')
1140 logger.debug('Running %s...' % str(cmd)) 1137 logger.debug('Running %s...' % str(cmd))