[OE-core] [PATCH 3/4] runqemu-internal: change the lock acquire/release logic

Qi.Chen at windriver.com Qi.Chen at windriver.com
Tue Aug 27 07:08:02 UTC 2013


From: Chen Qi <Qi.Chen at windriver.com>

Checking whether the lock file exists is sufficient for runqemu.
The contents of the lock file is not important.

This patch simplifies the lock acquire/release logic by removing the
flock mechanism. Also, we give more information to user indicating
why a tap interface is skipped.

As a side effect, the user now can easily create a lock file to
make runqemu skip a specific tap interface.

[YOCTO #5048]

Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
---
 scripts/runqemu-internal |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 8165e13..3f8674c 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -135,15 +135,12 @@ else
                 return 1
             fi
 
-            touch $lockfile.lock
-            exec 8>$lockfile.lock
-            flock -n -x 8
-            if [ $? -ne 0 ]; then
-                exec 8>&-
+            if [ -e $lockfile.lock ]; then
                 return 1
+            else
+                touch $lockfile.lock
+                return 0
             fi
-
-            return 0
         }
 
         release_lock() {
@@ -154,7 +151,6 @@ else
             fi
 
             rm -f $lockfile.lock
-            exec  8>&-
         }
 
         LOCKDIR="/tmp/qemu-tap-locks"
@@ -184,6 +180,8 @@ else
                 TAP=$tap
                 USE_PRECONF_TAP="yes"
                 break
+            else
+                echo "Skipping $tap as it's locked by $LOCKFILE.lock"
             fi
         done
 
-- 
1.7.9.5




More information about the Openembedded-core mailing list