From: Arun Sharma <arun.sharma@intel.com>
To: Ian Pratt <Ian.Pratt@cl.cam.ac.uk>,
Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: [PATCH][VT][6/15] Handle VMX domains correctly across xend restarts
Date: Thu, 11 Aug 2005 12:24:21 -0700 [thread overview]
Message-ID: <20050811192421.GA15280@intel.com> (raw)
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@intel.com>
Signed-off-by: Xiaohui Xin <xiaohui.xin@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
diff -r 5b239652c912 -r 4f2364097bd4 tools/python/xen/web/connection.py
--- a/tools/python/xen/web/connection.py Tue Aug 9 19:06:44 2005
+++ b/tools/python/xen/web/connection.py Tue Aug 9 19:06:44 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 5b239652c912 -r 4f2364097bd4 tools/python/xen/web/reactor.py
--- a/tools/python/xen/web/reactor.py Tue Aug 9 19:06:44 2005
+++ b/tools/python/xen/web/reactor.py Tue Aug 9 19:06:44 2005
@@ -16,4 +16,4 @@
#============================================================================
from unix import listenUNIX, connectUNIX
-from tcp import listenTCP, connectTCP
+from tcp import listenTCP, connectTCP, SetCloExec
diff -r 5b239652c912 -r 4f2364097bd4 tools/python/xen/web/tcp.py
--- a/tools/python/xen/web/tcp.py Tue Aug 9 19:06:44 2005
+++ b/tools/python/xen/web/tcp.py Tue Aug 9 19:06:44 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 5b239652c912 -r 4f2364097bd4 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Tue Aug 9 19:06:44 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py Tue Aug 9 19:06:44 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 5b239652c912 -r 4f2364097bd4 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py Tue Aug 9 19:06:44 2005
+++ b/tools/python/xen/xend/image.py Tue Aug 9 19:06:44 2005
@@ -262,7 +262,7 @@
memmap = None
memmap_value = []
device_channel = None
-
+ pid = 0
def createImage(self):
"""Create a VM for the VMX environment.
"""
@@ -369,6 +369,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
@@ -388,8 +389,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):
return (mem_mb * 1024) + self.getPageTableSize(mem_mb)
diff -r 5b239652c912 -r 4f2364097bd4 tools/python/xen/xend/server/relocate.py
--- a/tools/python/xen/xend/server/relocate.py Tue Aug 9 19:06:44 2005
+++ b/tools/python/xen/xend/server/relocate.py Tue Aug 9 19:06:44 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:
reply other threads:[~2005-08-11 19:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050811192421.GA15280@intel.com \
--to=arun.sharma@intel.com \
--cc=Ian.Pratt@cl.cam.ac.uk \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.