diff options
| author | Alexander Kanavin <alex.kanavin@gmail.com> | 2023-06-14 15:00:46 +0200 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-07-12 05:13:59 -1000 |
| commit | b30e81df2b71e7fdf23f7a4a19813fb6d512f2cd (patch) | |
| tree | 6fd5efe8dd73194c10631da73430c83d126d549a | |
| parent | 0a24a5bb3b98659fabfc1ba5a4b5cc830b3f04f8 (diff) | |
| download | poky-b30e81df2b71e7fdf23f7a4a19813fb6d512f2cd.tar.gz | |
scripts/runqemu: split lock dir creation into a reusable function
(From OE-Core rev: d296853f1c5bcc6ccd800a4fbcbba18021f98518)
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>
| -rwxr-xr-x | scripts/runqemu | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index 51607f10e5..42abda0962 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
| @@ -1034,6 +1034,17 @@ class BaseConfig(object): | |||
| 1034 | self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % ( | 1034 | self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % ( |
| 1035 | self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper'))) | 1035 | self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper'))) |
| 1036 | 1036 | ||
| 1037 | def make_lock_dir(self, lockdir): | ||
| 1038 | if not os.path.exists(lockdir): | ||
| 1039 | # There might be a race issue when multi runqemu processess are | ||
| 1040 | # running at the same time. | ||
| 1041 | try: | ||
| 1042 | os.mkdir(lockdir) | ||
| 1043 | os.chmod(lockdir, 0o777) | ||
| 1044 | except FileExistsError: | ||
| 1045 | pass | ||
| 1046 | return | ||
| 1047 | |||
| 1037 | def setup_slirp(self): | 1048 | def setup_slirp(self): |
| 1038 | """Setup user networking""" | 1049 | """Setup user networking""" |
| 1039 | 1050 | ||
| @@ -1052,14 +1063,7 @@ class BaseConfig(object): | |||
| 1052 | mac = 2 | 1063 | mac = 2 |
| 1053 | 1064 | ||
| 1054 | lockdir = "/tmp/qemu-port-locks" | 1065 | lockdir = "/tmp/qemu-port-locks" |
| 1055 | if not os.path.exists(lockdir): | 1066 | self.make_lock_dir(lockdir) |
| 1056 | # There might be a race issue when multi runqemu processess are | ||
| 1057 | # running at the same time. | ||
| 1058 | try: | ||
| 1059 | os.mkdir(lockdir) | ||
| 1060 | os.chmod(lockdir, 0o777) | ||
| 1061 | except FileExistsError: | ||
| 1062 | pass | ||
| 1063 | 1067 | ||
| 1064 | # Find a free port to avoid conflicts | 1068 | # Find a free port to avoid conflicts |
| 1065 | for p in ports[:]: | 1069 | for p in ports[:]: |
| @@ -1099,14 +1103,7 @@ class BaseConfig(object): | |||
| 1099 | logger.error("ip: %s" % ip) | 1103 | logger.error("ip: %s" % ip) |
| 1100 | raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found") | 1104 | raise OEPathError("runqemu-ifup, runqemu-ifdown or ip not found") |
| 1101 | 1105 | ||
| 1102 | if not os.path.exists(lockdir): | 1106 | self.make_lock_dir(lockdir) |
| 1103 | # There might be a race issue when multi runqemu processess are | ||
| 1104 | # running at the same time. | ||
| 1105 | try: | ||
| 1106 | os.mkdir(lockdir) | ||
| 1107 | os.chmod(lockdir, 0o777) | ||
| 1108 | except FileExistsError: | ||
| 1109 | pass | ||
| 1110 | 1107 | ||
| 1111 | cmd = (ip, 'link') | 1108 | cmd = (ip, 'link') |
| 1112 | logger.debug('Running %s...' % str(cmd)) | 1109 | logger.debug('Running %s...' % str(cmd)) |
