diff options
author | Konrad Weihmann <kweihmann@outlook.com> | 2024-09-09 08:32:15 +0000 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2024-10-02 06:15:15 -0700 |
commit | a335a496d2fc1e7e454cbeb73aa8e75c4930046f (patch) | |
tree | a9d9ac41e28b90e212294c5935a0ac0928a3e516 | |
parent | ddbf9f68f992036f1636a9c516f3fc4da6d10dc4 (diff) | |
download | poky-a335a496d2fc1e7e454cbeb73aa8e75c4930046f.tar.gz |
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: ae4e4fb703f63402cacbef772e70082e5760f78a)
Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 23876576d054ebbab9b02c0012782aa56feda123)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rwxr-xr-x | scripts/runqemu | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index 69cd44864e..fe395d1bc6 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
@@ -1195,16 +1195,20 @@ to your build configuration. | |||
1195 | uid = os.getuid() | 1195 | uid = os.getuid() |
1196 | logger.info("Setting up tap interface under sudo") | 1196 | logger.info("Setting up tap interface under sudo") |
1197 | cmd = ('sudo', self.qemuifup, str(gid)) | 1197 | cmd = ('sudo', self.qemuifup, str(gid)) |
1198 | try: | 1198 | for _ in range(5): |
1199 | tap = subprocess.check_output(cmd).decode('utf-8').strip() | 1199 | try: |
1200 | except subprocess.CalledProcessError as e: | 1200 | tap = subprocess.check_output(cmd).decode('utf-8').strip() |
1201 | logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e)) | 1201 | except subprocess.CalledProcessError as e: |
1202 | sys.exit(1) | 1202 | logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e)) |
1203 | lockfile = os.path.join(lockdir, tap) | 1203 | sys.exit(1) |
1204 | self.taplock = lockfile + '.lock' | 1204 | lockfile = os.path.join(lockdir, tap) |
1205 | self.acquire_taplock() | 1205 | self.taplock = lockfile + '.lock' |
1206 | self.cleantap = True | 1206 | if self.acquire_taplock(): |
1207 | logger.debug('Created tap: %s' % tap) | 1207 | self.cleantap = True |
1208 | logger.debug('Created tap: %s' % tap) | ||
1209 | break | ||
1210 | else: | ||
1211 | tap = None | ||
1208 | 1212 | ||
1209 | if not tap: | 1213 | if not tap: |
1210 | logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.") | 1214 | logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.") |