mirror of
https://git.yoctoproject.org/poky
synced 2026-03-06 23:39:40 +01:00
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>
This commit is contained in:
committed by
Steve Sakoman
parent
983548705a
commit
e69c311ed6
@@ -1062,6 +1062,17 @@ class BaseConfig(object):
|
||||
self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % (
|
||||
self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper')))
|
||||
|
||||
def make_lock_dir(self, lockdir):
|
||||
if not os.path.exists(lockdir):
|
||||
# There might be a race issue when multi runqemu processess are
|
||||
# running at the same time.
|
||||
try:
|
||||
os.mkdir(lockdir)
|
||||
os.chmod(lockdir, 0o777)
|
||||
except FileExistsError:
|
||||
pass
|
||||
return
|
||||
|
||||
def setup_slirp(self):
|
||||
"""Setup user networking"""
|
||||
|
||||
@@ -1080,14 +1091,7 @@ class BaseConfig(object):
|
||||
mac = 2
|
||||
|
||||
lockdir = "/tmp/qemu-port-locks"
|
||||
if not os.path.exists(lockdir):
|
||||
# There might be a race issue when multi runqemu processess are
|
||||
# running at the same time.
|
||||
try:
|
||||
os.mkdir(lockdir)
|
||||
os.chmod(lockdir, 0o777)
|
||||
except FileExistsError:
|
||||
pass
|
||||
self.make_lock_dir(lockdir)
|
||||
|
||||
# Find a free port to avoid conflicts
|
||||
for p in ports[:]:
|
||||
@@ -1127,14 +1131,7 @@ class BaseConfig(object):
|
||||
logger.error("ip: %s" % ip)
|
||||
raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found")
|
||||
|
||||
if not os.path.exists(lockdir):
|
||||
# There might be a race issue when multi runqemu processess are
|
||||
# running at the same time.
|
||||
try:
|
||||
os.mkdir(lockdir)
|
||||
os.chmod(lockdir, 0o777)
|
||||
except FileExistsError:
|
||||
pass
|
||||
self.make_lock_dir(lockdir)
|
||||
|
||||
cmd = (ip, 'link')
|
||||
logger.debug('Running %s...' % str(cmd))
|
||||
|
||||
Reference in New Issue
Block a user