Skip to contentSkip to conversation

xend fixes for SMF

PATCH In review John Levon 2 participants 3 messages Oct 17, 2006

lore
Share & tools
lore

John Levon

author
#0 lore raw

PATCH 1/1 xend fixes for SMF

# HG changeset patch
# User [email protected]
# Date 1161091415 25200
# Node ID 1911935b49d16e774f51d4104edb0164b770e0d7
# Parent 02317b0c61896c147299f0560ccafa35adabf0eb
On Solaris, the Xen daemons are managed separately, so we need a way to start just xend, and we need to disable xend's self-restarter.

tools/misc/xend +5 -0
@@ -19,6 +19,9 @@
 
    The daemon should reconnect to device control interfaces
    and recover its state when restarted.
+
+   On Solaris, the daemons are SMF managed, and you should not attempt
+   to start xend by hand.
 """
 import os
 import os.path
@@ -117,6 +120,8 @@ def main():
         start_consoled()
         start_blktapctrl()
         return daemon.start(trace=1)
+    elif sys.argv[1] == 'xend_start':
+        return daemon.start();
     elif sys.argv[1] == 'stop':
         return daemon.stop()
     elif sys.argv[1] == 'restart':
tools/python/xen/xend/osdep.py +10 -1
@@ -24,4 +24,13 @@ _scripts_dir = {
     "SunOS": "/usr/lib/xen/scripts",
 }
 
-scripts_dir = _scripts_dir.get(os.uname()[0], "/etc/xen/scripts")
+_xend_autorestart = {
+    "Linux": True,
+    "SunOS": False,
+}
+
+def _get(var, default=None):
+    return var.get(os.uname()[0], default)
+
+scripts_dir = _get(_scripts_dir, "/etc/xen/scripts")
+xend_autorestart = _get(_xend_autorestart)
tools/python/xen/xend/server/SrvDaemon.py +8 -1
@@ -17,6 +17,7 @@ import xen.lowlevel.xc
 import xen.lowlevel.xc
 
 from xen.xend.XendLogging import log
+from xen.xend import osdep
 
 import relocate
 import SrvServer
@@ -168,8 +169,14 @@ class Daemon:
             # ready to receive requests.  All subsequent restarts we don't
             # want this behaviour, or the pipe will eventually fill up, so
             # we just pass None into run in subsequent cases (by clearing w
-            # in the parent of the first fork).
+            # in the parent of the first fork).  On some operating systems,
+            # restart is managed externally, so we won't fork, and just exit.
             while True:
+
+                if not osdep.xend_autorestart:
+                    self.run(os.fdopen(w, 'w'))
+                    break
+
                 pid = self.fork_pid()
                 if pid:
                     if w is not None:
#1 lore raw
Quoted 4 lines · John Levon

On Solaris, the Xen daemons are managed separately, so we need a way to start just xend, and we need to disable xend's self-restarter.

Rather than a new command to the script (xend_start) can't you just fix 'start' not to start the other daemons, based on os.uname[0]?

-- Keir

author
#2 lore raw
Quoted 5 lines · Keir Fraser
Quoted 2 lines

On Solaris, the Xen daemons are managed separately, so we need a way to start just xend, and we need to disable xend's self-restarter.

Rather than a new command to the script (xend_start) can't you just fix 'start' not to start the other daemons, based on os.uname[0]?

Sure, if you'd prefer.

regards
john

# HG changeset patch
# User [email protected]
# Date 1161106742 25200
# Node ID 3b26bf28b858fd28ce6e2979ed8a86c2c134e740
# Parent 5f430ce6323f951844fcf81e65af7ce0bcb724dc
On Solaris, the Xen daemons are managed separately, so we need a way to start just xend, and we need to disable xend's self-restarter.

tools/misc/xend +7 -3
@@ -19,6 +19,9 @@
 
    The daemon should reconnect to device control interfaces
    and recover its state when restarted.
+
+   On Solaris, the daemons are SMF managed, and you should not attempt
+   to start xend by hand.
 """
 import os
 import os.path
@@ -108,9 +111,10 @@ def main():
     if not sys.argv[1:]:
         print 'usage: %s {start|stop|restart}' % sys.argv[0]
     elif sys.argv[1] == 'start':
-        start_xenstored()
-        start_consoled()
-	start_blktapctrl()
+        if os.uname()[0] != "SunOS":
+            start_xenstored()
+            start_consoled()
+            start_blktapctrl()
         return daemon.start()
     elif sys.argv[1] == 'trace_start':
         start_xenstored()
tools/python/xen/xend/osdep.py +10 -1
@@ -24,4 +24,13 @@ _scripts_dir = {
     "SunOS": "/usr/lib/xen/scripts",
 }
 
-scripts_dir = _scripts_dir.get(os.uname()[0], "/etc/xen/scripts")
+_xend_autorestart = {
+    "Linux": True,
+    "SunOS": False,
+}
+
+def _get(var, default=None):
+    return var.get(os.uname()[0], default)
+
+scripts_dir = _get(_scripts_dir, "/etc/xen/scripts")
+xend_autorestart = _get(_xend_autorestart)
tools/python/xen/xend/server/SrvDaemon.py +8 -1
@@ -17,6 +17,7 @@ import xen.lowlevel.xc
 import xen.lowlevel.xc
 
 from xen.xend.XendLogging import log
+from xen.xend import osdep
 
 import relocate
 import SrvServer
@@ -168,8 +169,14 @@ class Daemon:
             # ready to receive requests.  All subsequent restarts we don't
             # want this behaviour, or the pipe will eventually fill up, so
             # we just pass None into run in subsequent cases (by clearing w
-            # in the parent of the first fork).
+            # in the parent of the first fork).  On some operating systems,
+            # restart is managed externally, so we won't fork, and just exit.
             while True:
+
+                if not osdep.xend_autorestart:
+                    self.run(os.fdopen(w, 'w'))
+                    break
+
                 pid = self.fork_pid()
                 if pid:
                     if w is not None: