diff --git a/scripts/runqemu b/scripts/runqemu
index 2817acb19f..e5db06be37 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1163,6 +1163,9 @@ to your build configuration.
 
         self.make_lock_dir(lockdir)
 
+        tap_setup_lock = open(os.path.join(lockdir, '_tap_creation_lock'), 'w')
+        fcntl.flock(tap_setup_lock, fcntl.LOCK_EX)
+
         cmd = (ip, 'link')
         logger.debug('Running %s...' % str(cmd))
         ip_link = subprocess.check_output(cmd).decode('utf-8')
@@ -1187,6 +1190,8 @@ to your build configuration.
 
         if not tap:
             if os.path.exists(nosudo_flag):
+                fcntl.flock(tap_setup_lock, fcntl.LOCK_UN)
+                tap_setup_lock.close()
                 logger.error("Error: There are no available tap devices to use for networking,")
                 logger.error("and I see %s exists, so I am not going to try creating" % nosudo_flag)
                 raise RunQemuError("a new one with sudo.")
@@ -1198,6 +1203,8 @@ to your build configuration.
             try:
                 tap = subprocess.check_output(cmd).decode('utf-8').strip()
             except subprocess.CalledProcessError as e:
+                fcntl.flock(tap_setup_lock, fcntl.LOCK_UN)
+                tap_setup_lock.close()
                 logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e))
                 sys.exit(1)
             lockfile = os.path.join(lockdir, tap)
@@ -1206,6 +1213,9 @@ to your build configuration.
             self.cleantap = True
             logger.debug('Created tap: %s' % tap)
 
+        fcntl.flock(tap_setup_lock, fcntl.LOCK_UN)
+        tap_setup_lock.close()
+
         if not tap:
             logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.")
             sys.exit(1)
