WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] acm, xend: Serialize the execution of ext

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] acm, xend: Serialize the execution of external scripts.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 Dec 2007 07:20:13 -0800
Delivery-date: Fri, 14 Dec 2007 07:20:24 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1197627971 0
# Node ID 61ff9b393c83d4750acdf2b26dd70fd7981e5145
# Parent  8aa377fb1b1fe4e5f46a983b925073f3e9e6f619
acm, xend: Serialize the execution of external scripts.

Instead of starting a thread per script, run a single thread and send
orders to it. This serializes the execution of the scripts.

Signed-off-by: Stefan Berger <stefanB@xxxxxxxxxx>
---
 tools/python/xen/util/xsm/acm/acm.py |   49 +++++++++++++++++++++++++----------
 1 files changed, 36 insertions(+), 13 deletions(-)

diff -r 8aa377fb1b1f -r 61ff9b393c83 tools/python/xen/util/xsm/acm/acm.py
--- a/tools/python/xen/util/xsm/acm/acm.py      Fri Dec 14 10:25:00 2007 +0000
+++ b/tools/python/xen/util/xsm/acm/acm.py      Fri Dec 14 10:26:11 2007 +0000
@@ -1545,21 +1545,44 @@ def get_security_label(self, xspol=None)
         label = self.info.get('security_label', label)
     return label
 
+
+__cond = threading.Condition()
+__script_runner = None
+__orders = []
+
 def run_resource_label_change_script(resource, label, command):
-    def __run_resource_label_change_script(label, command):
+    global __cond, __orders, __script_runner
+
+    def __run_resource_label_change_script():
+        global __cond, __orders
         script = XendOptions.instance().get_resource_label_change_script()
         if script:
-            parms = {
-                'resource' : resource,
-                'label'    : label,
-                'command'  : command,
-            }
-            log.info("Running resource label change script %s: %s" %
-                     (script, parms))
-            parms.update(os.environ)
-            os.spawnve(os.P_WAIT, script[0], script, parms)
+            parms = {}
+            while True:
+                __cond.acquire()
+                if len(__orders) == 0:
+                    __cond.wait()
+
+                parms['label'], \
+                   parms['command'], \
+                   parms['resource'] = __orders[0]
+
+                __orders = __orders[1:]
+                __cond.release()
+
+                log.info("Running resource label change script %s: %s" %
+                         (script, parms))
+                parms.update(os.environ)
+                os.spawnve(os.P_WAIT, script[0], script, parms)
         else:
             log.info("No script given for relabeling of resources.")
-    thread = threading.Thread(target=__run_resource_label_change_script,
-                              args=(label,command))
-    thread.start()
+    if not __script_runner:
+        __script_runner = \
+                 threading.Thread(target=__run_resource_label_change_script,
+                                  args=())
+        __script_runner.start()
+
+    __cond.acquire()
+    __orders.append((label,command,resource))
+    __cond.notify()
+    __cond.release()

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] acm, xend: Serialize the execution of external scripts., Xen patchbot-unstable <=