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] Handle VMX domains correctly across xend restarts

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Handle VMX domains correctly across xend restarts
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 11 Aug 2005 17:06:11 -0400
Delivery-date: Thu, 11 Aug 2005 21:06:54 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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 kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID fb619858dfa91cc306f4c0b5cf2c2e8a2fb71fca
# Parent  bf98996dded2b6c5f7f0e870ab48ac308a6eb24a
Handle VMX domains correctly across xend restarts

This patch remembers the device model pid across xend restarts and
avoids creating duplicate device model processes.

Also, device models don't inherit socket fds from xend (which are closed
on exec now), which used to prevent xend restarting.

Signed-off-by: Yunhong Jiang <yunhong.jiang@xxxxxxxxx>
Signed-off-by: Xiaohui Xin <xiaohui.xin@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>

diff -r bf98996dded2 -r fb619858dfa9 tools/python/xen/web/connection.py
--- a/tools/python/xen/web/connection.py        Thu Aug 11 21:01:36 2005
+++ b/tools/python/xen/web/connection.py        Thu Aug 11 21:02:51 2005
@@ -20,6 +20,7 @@
 import threading
 import select
 import socket
+import fcntl
 
 from errno import EAGAIN, EINTR, EWOULDBLOCK
 
@@ -151,6 +152,9 @@
 
     def createSocket(self):
         raise NotImplementedError()
+
+    def setCloExec(self):
+        fcntl.fcntl(self.sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
 
     def acceptConnection(self, sock, protocol, addr):
         return SocketServerConnection(sock, protocol, addr, self)
diff -r bf98996dded2 -r fb619858dfa9 tools/python/xen/web/reactor.py
--- a/tools/python/xen/web/reactor.py   Thu Aug 11 21:01:36 2005
+++ b/tools/python/xen/web/reactor.py   Thu Aug 11 21:02:51 2005
@@ -16,4 +16,4 @@
 #============================================================================
 
 from unix import listenUNIX, connectUNIX
-from tcp import listenTCP, connectTCP
+from tcp import listenTCP, connectTCP, SetCloExec
diff -r bf98996dded2 -r fb619858dfa9 tools/python/xen/web/tcp.py
--- a/tools/python/xen/web/tcp.py       Thu Aug 11 21:01:36 2005
+++ b/tools/python/xen/web/tcp.py       Thu Aug 11 21:02:51 2005
@@ -85,6 +85,9 @@
     l.startListening()
     return l
 
+def SetCloExec(SocketListener):
+    SocketListener.SetCloExec()
+
 def connectTCP(host, port, factory, timeout=None, bindAddress=None):
     c = TCPConnector(host, port, factory, timeout=timeout, 
bindAddress=bindAddress)
     c.connect()
diff -r bf98996dded2 -r fb619858dfa9 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Aug 11 21:01:36 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Aug 11 21:02:51 2005
@@ -231,6 +231,7 @@
         DBVar('restart_time',  ty='float'),
         DBVar('restart_count', ty='int'),
         DBVar('target',        ty='long', path="memory/target"),
+        DBVar('device_model_pid', ty='int'),
         ]
     
     def __init__(self, db):
@@ -275,6 +276,7 @@
         self.vcpus = 1
         self.vcpusdb = {}
         self.bootloader = None
+        self.device_model_pid = 0
 
     def setDB(self, db):
         self.db = db
@@ -457,6 +459,8 @@
             sxpr.append(devs)
         if self.config:
             sxpr.append(['config', self.config])
+        if self.device_model_pid:
+            sxpr.append(['device_model_pid',self.device_model_pid])
         return sxpr
 
     def sxpr_devices(self):
@@ -739,7 +743,8 @@
                 ctrl.initController(reboot=True)
         else:
             self.create_configured_devices()
-        self.image.createDeviceModel()
+        if not self.device_model_pid:
+            self.device_model_pid = self.image.createDeviceModel()
 
     def device_create(self, dev_config):
         """Create a new device.
diff -r bf98996dded2 -r fb619858dfa9 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Thu Aug 11 21:01:36 2005
+++ b/tools/python/xen/xend/image.py    Thu Aug 11 21:02:51 2005
@@ -262,7 +262,7 @@
     memmap = None
     memmap_value = []
     device_channel = None
-
+    pid = 0
     def createImage(self):
         """Create a VM for the VMX environment.
         """
@@ -379,6 +379,7 @@
         log.info("spawning device models: %s %s", device_model, args)
         self.pid = os.spawnve(os.P_NOWAIT, device_model, args, env)
         log.info("device model pid: %d", self.pid)
+        return self.pid
 
     def vncParams(self):
         # see if a vncviewer was specified
@@ -398,8 +399,11 @@
     def destroy(self):
         channel.eventChannelClose(self.device_channel)
         import signal
+        if not self.pid:
+            self.pid = self.vm.device_model_pid
         os.kill(self.pid, signal.SIGKILL)
         (pid, status) = os.waitpid(self.pid, 0)
+        self.pid = 0
 
     def getDomainMemory(self, mem_mb):
         # for ioreq_t and xenstore
diff -r bf98996dded2 -r fb619858dfa9 tools/python/xen/xend/server/relocate.py
--- a/tools/python/xen/xend/server/relocate.py  Thu Aug 11 21:01:36 2005
+++ b/tools/python/xen/xend/server/relocate.py  Thu Aug 11 21:02:51 2005
@@ -140,7 +140,8 @@
     if xroot.get_xend_relocation_server():
         port = xroot.get_xend_relocation_port()
         interface = xroot.get_xend_relocation_address()
-        reactor.listenTCP(port, factory, interface=interface)
+        l = reactor.listenTCP(port, factory, interface=interface)
+        l.setCloExec()
 
 def setupRelocation(dst, port):
     try:

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

<Prev in Thread] Current Thread [Next in Thread>