diff options
-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)) |