diff options
| author | Konrad Weihmann <kweihmann@outlook.com> | 2024-09-21 10:04:42 +0000 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-09-27 05:57:35 -0700 |
| commit | 6ee7342411035befa676122a0e874acbd85f1d38 (patch) | |
| tree | 220744c05e58683e1beb36dd3e899af517e0f51c /scripts | |
| parent | 065bd86349ffbe6c66487a3dd9dc4c9a1e7e3306 (diff) | |
| download | poky-6ee7342411035befa676122a0e874acbd85f1d38.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: 23876576d054ebbab9b02c0012782aa56feda123)
(From OE-Core rev: 5215635442949a62f502e839ddf1f12e790e5e37)
Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/runqemu | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index ba7c1b2461..8a417a7c24 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
| @@ -1150,16 +1150,20 @@ to your build configuration. | |||
| 1150 | uid = os.getuid() | 1150 | uid = os.getuid() |
| 1151 | logger.info("Setting up tap interface under sudo") | 1151 | logger.info("Setting up tap interface under sudo") |
| 1152 | cmd = ('sudo', self.qemuifup, str(uid), str(gid), self.bindir_native) | 1152 | cmd = ('sudo', self.qemuifup, str(uid), str(gid), self.bindir_native) |
| 1153 | try: | 1153 | for _ in range(5): |
| 1154 | tap = subprocess.check_output(cmd).decode('utf-8').strip() | 1154 | try: |
| 1155 | except subprocess.CalledProcessError as e: | 1155 | tap = subprocess.check_output(cmd).decode('utf-8').strip() |
| 1156 | logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e)) | 1156 | except subprocess.CalledProcessError as e: |
| 1157 | sys.exit(1) | 1157 | logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e)) |
| 1158 | lockfile = os.path.join(lockdir, tap) | 1158 | sys.exit(1) |
| 1159 | self.taplock = lockfile + '.lock' | 1159 | lockfile = os.path.join(lockdir, tap) |
| 1160 | self.acquire_taplock() | 1160 | self.taplock = lockfile + '.lock' |
| 1161 | self.cleantap = True | 1161 | if self.acquire_taplock(): |
| 1162 | logger.debug('Created tap: %s' % tap) | 1162 | self.cleantap = True |
| 1163 | logger.debug('Created tap: %s' % tap) | ||
| 1164 | break | ||
| 1165 | else: | ||
| 1166 | tap = None | ||
| 1163 | 1167 | ||
| 1164 | if not tap: | 1168 | if not tap: |
| 1165 | logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.") | 1169 | logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.") |
