mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
runqemu: keep generating tap devices
in case there is no tap device the script tries to generate a new one. The new device is then unguarded for a moment, so the newly generated device could be acquired by a different instance or user, before it is locked to the instance with acquire_taplock. To fix that keep generating new tap devices in case the lock can't be acquired up to 5 times. If no tap device can be locked it fails in the existing error handling (From OE-Core rev: 23876576d054ebbab9b02c0012782aa56feda123) Signed-off-by: Konrad Weihmann <kweihmann@outlook.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
4854fc5dbb
commit
c9a9999400
|
@ -1195,16 +1195,20 @@ to your build configuration.
|
||||||
uid = os.getuid()
|
uid = os.getuid()
|
||||||
logger.info("Setting up tap interface under sudo")
|
logger.info("Setting up tap interface under sudo")
|
||||||
cmd = ('sudo', self.qemuifup, str(gid))
|
cmd = ('sudo', self.qemuifup, str(gid))
|
||||||
try:
|
for _ in range(5):
|
||||||
tap = subprocess.check_output(cmd).decode('utf-8').strip()
|
try:
|
||||||
except subprocess.CalledProcessError as e:
|
tap = subprocess.check_output(cmd).decode('utf-8').strip()
|
||||||
logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e))
|
except subprocess.CalledProcessError as e:
|
||||||
sys.exit(1)
|
logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e))
|
||||||
lockfile = os.path.join(lockdir, tap)
|
sys.exit(1)
|
||||||
self.taplock = lockfile + '.lock'
|
lockfile = os.path.join(lockdir, tap)
|
||||||
self.acquire_taplock()
|
self.taplock = lockfile + '.lock'
|
||||||
self.cleantap = True
|
if self.acquire_taplock():
|
||||||
logger.debug('Created tap: %s' % tap)
|
self.cleantap = True
|
||||||
|
logger.debug('Created tap: %s' % tap)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
tap = None
|
||||||
|
|
||||||
if not tap:
|
if not tap:
|
||||||
logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.")
|
logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user