2011-05-31 19:35:29 +02:00
|
|
|
xenpaging: start xenpaging via config option
|
2010-10-20 23:00:35 +02:00
|
|
|
|
|
|
|
Start xenpaging via config option.
|
|
|
|
|
|
|
|
TODO: add libxl support
|
|
|
|
TODO: parse config values like 42K, 42M, 42G, 42%
|
|
|
|
|
|
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
|
|
|
|
|
|
|
---
|
2011-05-31 19:35:29 +02:00
|
|
|
v4:
|
|
|
|
add config option for pagefile directory
|
|
|
|
add config option to enable debug
|
|
|
|
add config option to set polic mru_size
|
|
|
|
fail if chdir fails
|
|
|
|
force self.xenpaging* variables to be strings because a xm new may turn some
|
|
|
|
of them into type int and later os.execve fails with a TypeError
|
|
|
|
|
2011-02-14 22:35:06 +01:00
|
|
|
v3:
|
|
|
|
decouple create/destroycreateXenPaging from _create/_removeDevices
|
|
|
|
init xenpaging variable to 0 if xenpaging is not in config file to
|
|
|
|
avoid string None coming from sxp file
|
|
|
|
|
2010-11-19 21:15:50 +01:00
|
|
|
v2:
|
|
|
|
unlink logfile instead of truncating it.
|
|
|
|
allows hardlinking for further inspection
|
|
|
|
|
2011-05-31 19:35:29 +02:00
|
|
|
---
|
|
|
|
tools/examples/xmexample.hvm | 12 ++++
|
|
|
|
tools/python/README.XendConfig | 4 +
|
|
|
|
tools/python/README.sxpcfg | 4 +
|
|
|
|
tools/python/xen/xend/XendConfig.py | 12 ++++
|
2011-02-14 22:35:06 +01:00
|
|
|
tools/python/xen/xend/XendDomainInfo.py | 12 ++++
|
2011-05-31 19:35:29 +02:00
|
|
|
tools/python/xen/xend/image.py | 87 ++++++++++++++++++++++++++++++++
|
|
|
|
tools/python/xen/xm/create.py | 20 +++++++
|
|
|
|
tools/python/xen/xm/xenapi_create.py | 4 +
|
|
|
|
8 files changed, 155 insertions(+)
|
2010-10-20 23:00:35 +02:00
|
|
|
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/examples/xmexample.hvm
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/examples/xmexample.hvm
|
|
|
|
+++ xen-4.1.1-testing/tools/examples/xmexample.hvm
|
|
|
|
@@ -127,6 +127,18 @@ disk = [ 'file:/var/lib/xen/images/disk.
|
2010-10-20 23:00:35 +02:00
|
|
|
# Device Model to be used
|
|
|
|
device_model = 'qemu-dm'
|
|
|
|
|
2011-05-31 19:35:29 +02:00
|
|
|
+# number of guest pages to page-out, or -1 for entire guest memory range
|
|
|
|
+xenpaging=42
|
|
|
|
+
|
|
|
|
+# directory to store guest page file
|
|
|
|
+#xenpaging_workdir="/var/lib/xen/xenpaging"
|
|
|
|
+
|
|
|
|
+# enable debug output in pager
|
|
|
|
+#xenpaging_debug=0
|
|
|
|
+
|
|
|
|
+# number of paged-in pages to keep in memory
|
|
|
|
+#xenpaging_policy_mru_size=1024
|
2010-10-20 23:00:35 +02:00
|
|
|
+
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d)
|
|
|
|
# default: hard disk, cd-rom, floppy
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/python/README.XendConfig
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/python/README.XendConfig
|
|
|
|
+++ xen-4.1.1-testing/tools/python/README.XendConfig
|
|
|
|
@@ -120,6 +120,10 @@ otherConfig
|
2010-10-20 23:00:35 +02:00
|
|
|
image.vncdisplay
|
|
|
|
image.vncunused
|
|
|
|
image.hvm.device_model
|
|
|
|
+ image.hvm.xenpaging
|
2011-05-31 19:35:29 +02:00
|
|
|
+ image.hvm.xenpaging_workdir
|
|
|
|
+ image.hvm.xenpaging_debug
|
|
|
|
+ image.hvm.xenpaging_policy_mru_size
|
2010-10-20 23:00:35 +02:00
|
|
|
image.hvm.display
|
|
|
|
image.hvm.xauthority
|
|
|
|
image.hvm.vncconsole
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/python/README.sxpcfg
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/python/README.sxpcfg
|
|
|
|
+++ xen-4.1.1-testing/tools/python/README.sxpcfg
|
|
|
|
@@ -51,6 +51,10 @@ image
|
2010-10-20 23:00:35 +02:00
|
|
|
- vncunused
|
|
|
|
(HVM)
|
|
|
|
- device_model
|
|
|
|
+ - xenpaging
|
2011-05-31 19:35:29 +02:00
|
|
|
+ - xenpaging_workdir
|
|
|
|
+ - xenpaging_debug
|
|
|
|
+ - xenpaging_policy_mru_size
|
2010-10-20 23:00:35 +02:00
|
|
|
- display
|
|
|
|
- xauthority
|
|
|
|
- vncconsole
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/python/xen/xend/XendConfig.py
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/python/xen/xend/XendConfig.py
|
|
|
|
+++ xen-4.1.1-testing/tools/python/xen/xend/XendConfig.py
|
|
|
|
@@ -147,6 +147,10 @@ XENAPI_PLATFORM_CFG_TYPES = {
|
2010-10-20 23:00:35 +02:00
|
|
|
'apic': int,
|
|
|
|
'boot': str,
|
|
|
|
'device_model': str,
|
2011-02-14 22:35:06 +01:00
|
|
|
+ 'xenpaging': str,
|
2011-05-31 19:35:29 +02:00
|
|
|
+ 'xenpaging_workdir': str,
|
|
|
|
+ 'xenpaging_debug': str,
|
|
|
|
+ 'xenpaging_policy_mru_size': str,
|
2010-10-20 23:00:35 +02:00
|
|
|
'loader': str,
|
|
|
|
'display' : str,
|
|
|
|
'fda': str,
|
2011-07-01 21:31:25 +02:00
|
|
|
@@ -516,6 +520,14 @@ class XendConfig(dict):
|
2010-10-20 23:00:35 +02:00
|
|
|
self['platform']['nomigrate'] = 0
|
|
|
|
|
|
|
|
if self.is_hvm():
|
|
|
|
+ if 'xenpaging' not in self['platform']:
|
2011-02-14 22:35:06 +01:00
|
|
|
+ self['platform']['xenpaging'] = "0"
|
2011-05-31 19:35:29 +02:00
|
|
|
+ if 'xenpaging_workdir' not in self['platform']:
|
|
|
|
+ self['platform']['xenpaging_workdir'] = "/var/lib/xen/xenpaging"
|
|
|
|
+ if 'xenpaging_debug' not in self['platform']:
|
|
|
|
+ self['platform']['xenpaging_debug'] = "0"
|
|
|
|
+ if 'xenpaging_policy_mru_size' not in self['platform']:
|
|
|
|
+ self['platform']['xenpaging_policy_mru_size'] = "0"
|
2010-10-20 23:00:35 +02:00
|
|
|
if 'timer_mode' not in self['platform']:
|
|
|
|
self['platform']['timer_mode'] = 1
|
2011-01-14 19:24:51 +01:00
|
|
|
if 'extid' in self['platform'] and int(self['platform']['extid']) == 1:
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/python/xen/xend/XendDomainInfo.py
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/python/xen/xend/XendDomainInfo.py
|
|
|
|
+++ xen-4.1.1-testing/tools/python/xen/xend/XendDomainInfo.py
|
2011-08-15 15:32:00 +02:00
|
|
|
@@ -2290,6 +2290,8 @@ class XendDomainInfo:
|
2011-02-14 22:35:06 +01:00
|
|
|
self.info['name_label'], self.domid, self.info['uuid'],
|
|
|
|
new_name, new_uuid)
|
|
|
|
self._unwatchVm()
|
|
|
|
+ if self.image:
|
|
|
|
+ self.image.destroyXenPaging()
|
|
|
|
self._releaseDevices()
|
|
|
|
# Remove existing vm node in xenstore
|
|
|
|
self._removeVm()
|
2011-08-15 15:32:00 +02:00
|
|
|
@@ -2961,6 +2963,9 @@ class XendDomainInfo:
|
2011-02-14 22:35:06 +01:00
|
|
|
|
|
|
|
self._createDevices()
|
|
|
|
|
|
|
|
+ if self.image:
|
|
|
|
+ self.image.createXenPaging()
|
|
|
|
+
|
|
|
|
self.image.cleanupTmpImages()
|
2010-10-20 23:00:35 +02:00
|
|
|
|
2011-02-14 22:35:06 +01:00
|
|
|
self.info['start_time'] = time.time()
|
2011-08-15 15:32:00 +02:00
|
|
|
@@ -2985,6 +2990,8 @@ class XendDomainInfo:
|
2011-02-14 22:35:06 +01:00
|
|
|
self.refresh_shutdown_lock.acquire()
|
|
|
|
try:
|
|
|
|
self.unwatchShutdown()
|
|
|
|
+ if self.image:
|
|
|
|
+ self.image.destroyXenPaging()
|
|
|
|
self._releaseDevices()
|
|
|
|
bootloader_tidy(self)
|
|
|
|
|
2011-08-15 15:32:00 +02:00
|
|
|
@@ -3069,6 +3076,7 @@ class XendDomainInfo:
|
2011-02-14 22:35:06 +01:00
|
|
|
self.image = image.create(self, self.info)
|
2010-10-20 23:00:35 +02:00
|
|
|
if self.image:
|
2011-02-14 22:35:06 +01:00
|
|
|
self._createDevices(True)
|
2010-10-20 23:00:35 +02:00
|
|
|
+ self.image.createXenPaging()
|
2011-08-15 15:32:00 +02:00
|
|
|
self.console_port = console_port
|
2011-02-14 22:35:06 +01:00
|
|
|
self._storeDomDetails()
|
|
|
|
self._registerWatches()
|
2011-07-01 21:31:25 +02:00
|
|
|
@@ -3210,6 +3218,8 @@ class XendDomainInfo:
|
2011-02-14 22:35:06 +01:00
|
|
|
# could also fetch a parsed note from xenstore
|
|
|
|
fast = self.info.get_notes().get('SUSPEND_CANCEL') and 1 or 0
|
|
|
|
if not fast:
|
|
|
|
+ if self.image:
|
|
|
|
+ self.image.destroyXenPaging()
|
|
|
|
self._releaseDevices()
|
|
|
|
self.testDeviceComplete()
|
|
|
|
self.testvifsComplete()
|
2011-07-01 21:31:25 +02:00
|
|
|
@@ -3225,6 +3235,8 @@ class XendDomainInfo:
|
2011-02-14 22:35:06 +01:00
|
|
|
self._storeDomDetails()
|
2010-10-20 23:00:35 +02:00
|
|
|
|
2011-02-14 22:35:06 +01:00
|
|
|
self._createDevices()
|
|
|
|
+ if self.image:
|
|
|
|
+ self.image.createXenPaging()
|
|
|
|
log.debug("XendDomainInfo.resumeDomain: devices created")
|
2010-10-20 23:00:35 +02:00
|
|
|
|
2011-02-14 22:35:06 +01:00
|
|
|
xc.domain_resume(self.domid, fast)
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/python/xen/xend/image.py
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/python/xen/xend/image.py
|
|
|
|
+++ xen-4.1.1-testing/tools/python/xen/xend/image.py
|
|
|
|
@@ -122,6 +122,11 @@ class ImageHandler:
|
2010-10-20 23:00:35 +02:00
|
|
|
self.vm.permissionsVm("image/cmdline", { 'dom': self.vm.getDomid(), 'read': True } )
|
|
|
|
|
|
|
|
self.device_model = vmConfig['platform'].get('device_model')
|
2011-05-31 19:35:29 +02:00
|
|
|
+ self.xenpaging = str(vmConfig['platform'].get('xenpaging'))
|
|
|
|
+ self.xenpaging_workdir = str(vmConfig['platform'].get('xenpaging_workdir'))
|
|
|
|
+ self.xenpaging_debug = str(vmConfig['platform'].get('xenpaging_debug'))
|
|
|
|
+ self.xenpaging_policy_mru_size = str(vmConfig['platform'].get('xenpaging_policy_mru_size'))
|
|
|
|
+ self.xenpaging_pid = None
|
2010-10-20 23:00:35 +02:00
|
|
|
|
|
|
|
self.display = vmConfig['platform'].get('display')
|
|
|
|
self.xauthority = vmConfig['platform'].get('xauthority')
|
2011-05-31 19:35:29 +02:00
|
|
|
@@ -392,6 +397,88 @@ class ImageHandler:
|
2010-10-20 23:00:35 +02:00
|
|
|
sentinel_fifos_inuse[sentinel_path_fifo] = 1
|
|
|
|
self.sentinel_path_fifo = sentinel_path_fifo
|
|
|
|
|
|
|
|
+ def createXenPaging(self):
|
2011-05-31 19:35:29 +02:00
|
|
|
+ if not self.vm.info.is_hvm():
|
|
|
|
+ return
|
2011-02-14 22:35:06 +01:00
|
|
|
+ if self.xenpaging == "0":
|
2010-10-20 23:00:35 +02:00
|
|
|
+ return
|
|
|
|
+ if self.xenpaging_pid:
|
|
|
|
+ return
|
|
|
|
+ xenpaging_bin = auxbin.pathTo("xenpaging")
|
|
|
|
+ args = [xenpaging_bin]
|
|
|
|
+ args = args + ([ "%d" % self.vm.getDomid()])
|
|
|
|
+ args = args + ([ "%s" % self.xenpaging])
|
|
|
|
+ env = dict(os.environ)
|
2011-05-31 19:35:29 +02:00
|
|
|
+ if not self.xenpaging_debug == "0":
|
|
|
|
+ env['XENPAGING_DEBUG'] = self.xenpaging_debug
|
|
|
|
+ if not self.xenpaging_policy_mru_size == "0":
|
|
|
|
+ env['XENPAGING_POLICY_MRU_SIZE'] = self.xenpaging_policy_mru_size
|
2010-10-20 23:00:35 +02:00
|
|
|
+ self.xenpaging_logfile = "/var/log/xen/xenpaging-%s.log" % str(self.vm.info['name_label'])
|
|
|
|
+ logfile_mode = os.O_WRONLY|os.O_CREAT|os.O_APPEND|os.O_TRUNC
|
|
|
|
+ null = os.open("/dev/null", os.O_RDONLY)
|
2010-11-12 18:55:23 +01:00
|
|
|
+ try:
|
|
|
|
+ os.unlink(self.xenpaging_logfile)
|
|
|
|
+ except:
|
|
|
|
+ pass
|
2010-10-20 23:00:35 +02:00
|
|
|
+ logfd = os.open(self.xenpaging_logfile, logfile_mode, 0644)
|
|
|
|
+ sys.stderr.flush()
|
|
|
|
+ contract = osdep.prefork("%s:%d" % (self.vm.getName(), self.vm.getDomid()))
|
|
|
|
+ xenpaging_pid = os.fork()
|
|
|
|
+ if xenpaging_pid == 0: #child
|
|
|
|
+ try:
|
|
|
|
+ osdep.postfork(contract)
|
|
|
|
+ os.dup2(null, 0)
|
|
|
|
+ os.dup2(logfd, 1)
|
|
|
|
+ os.dup2(logfd, 2)
|
2011-05-31 19:35:29 +02:00
|
|
|
+ os.chdir(self.xenpaging_workdir)
|
2010-10-20 23:00:35 +02:00
|
|
|
+ try:
|
|
|
|
+ log.info("starting %s" % args)
|
|
|
|
+ os.execve(xenpaging_bin, args, env)
|
|
|
|
+ except Exception, e:
|
2011-05-31 19:35:29 +02:00
|
|
|
+ log.warn('failed to execute xenpaging: %s' % utils.exception_string(e))
|
2010-10-20 23:00:35 +02:00
|
|
|
+ os._exit(126)
|
2011-05-31 19:35:29 +02:00
|
|
|
+ except:
|
|
|
|
+ log.warn("starting xenpaging in %s failed" % self.xenpaging_workdir)
|
2010-10-20 23:00:35 +02:00
|
|
|
+ os._exit(127)
|
|
|
|
+ else:
|
|
|
|
+ osdep.postfork(contract, abandon=True)
|
|
|
|
+ self.xenpaging_pid = xenpaging_pid
|
|
|
|
+ os.close(null)
|
|
|
|
+ os.close(logfd)
|
|
|
|
+
|
|
|
|
+ def destroyXenPaging(self):
|
2011-02-14 22:35:06 +01:00
|
|
|
+ if self.xenpaging == "0":
|
2010-10-20 23:00:35 +02:00
|
|
|
+ return
|
|
|
|
+ if self.xenpaging_pid:
|
|
|
|
+ try:
|
|
|
|
+ os.kill(self.xenpaging_pid, signal.SIGHUP)
|
|
|
|
+ except OSError, exn:
|
|
|
|
+ log.exception(exn)
|
|
|
|
+ for i in xrange(100):
|
|
|
|
+ try:
|
|
|
|
+ (p, rv) = os.waitpid(self.xenpaging_pid, os.WNOHANG)
|
|
|
|
+ if p == self.xenpaging_pid:
|
|
|
|
+ break
|
|
|
|
+ except OSError:
|
|
|
|
+ # This is expected if Xend has been restarted within
|
|
|
|
+ # the life of this domain. In this case, we can kill
|
|
|
|
+ # the process, but we can't wait for it because it's
|
|
|
|
+ # not our child. We continue this loop, and after it is
|
|
|
|
+ # terminated make really sure the process is going away
|
|
|
|
+ # (SIGKILL).
|
|
|
|
+ pass
|
|
|
|
+ time.sleep(0.1)
|
|
|
|
+ else:
|
|
|
|
+ log.warning("xenpaging %d took more than 10s "
|
|
|
|
+ "to terminate: sending SIGKILL" % self.xenpaging_pid)
|
|
|
|
+ try:
|
|
|
|
+ os.kill(self.xenpaging_pid, signal.SIGKILL)
|
|
|
|
+ os.waitpid(self.xenpaging_pid, 0)
|
|
|
|
+ except OSError:
|
|
|
|
+ # This happens if the process doesn't exist.
|
|
|
|
+ pass
|
|
|
|
+ self.xenpaging_pid = None
|
|
|
|
+
|
|
|
|
def createDeviceModel(self, restore = False):
|
|
|
|
if self.device_model is None:
|
|
|
|
return
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/python/xen/xm/create.py
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/python/xen/xm/create.py
|
|
|
|
+++ xen-4.1.1-testing/tools/python/xen/xm/create.py
|
|
|
|
@@ -495,6 +495,22 @@ gopts.var('nfs_root', val="PATH",
|
2010-10-20 23:00:35 +02:00
|
|
|
fn=set_value, default=None,
|
|
|
|
use="Set the path of the root NFS directory.")
|
|
|
|
|
|
|
|
+gopts.var('xenpaging', val='NUM',
|
2011-02-14 22:35:06 +01:00
|
|
|
+ fn=set_value, default='0',
|
2010-10-20 23:00:35 +02:00
|
|
|
+ use="Number of pages to swap.")
|
2011-05-31 19:35:29 +02:00
|
|
|
+
|
|
|
|
+gopts.var('xenpaging_workdir', val='PATH',
|
|
|
|
+ fn=set_value, default='/var/lib/xen/xenpaging',
|
|
|
|
+ use="Number of pages to swap.")
|
|
|
|
+
|
|
|
|
+gopts.var('xenpaging_debug', val='NUM',
|
|
|
|
+ fn=set_value, default='0',
|
|
|
|
+ use="Number of pages to swap.")
|
|
|
|
+
|
|
|
|
+gopts.var('xenpaging_policy_mru_size', val='NUM',
|
|
|
|
+ fn=set_value, default='0',
|
|
|
|
+ use="Number of pages to swap.")
|
2010-10-20 23:00:35 +02:00
|
|
|
+
|
|
|
|
gopts.var('device_model', val='FILE',
|
|
|
|
fn=set_value, default=None,
|
|
|
|
use="Path to device model program.")
|
2011-07-01 21:31:25 +02:00
|
|
|
@@ -1095,6 +1111,10 @@ def configure_hvm(config_image, vals):
|
2010-10-20 23:00:35 +02:00
|
|
|
args = [ 'acpi', 'apic',
|
|
|
|
'boot',
|
|
|
|
'cpuid', 'cpuid_check',
|
|
|
|
+ 'xenpaging',
|
2011-05-31 19:35:29 +02:00
|
|
|
+ 'xenpaging_workdir',
|
|
|
|
+ 'xenpaging_debug',
|
|
|
|
+ 'xenpaging_policy_mru_size',
|
2010-10-20 23:00:35 +02:00
|
|
|
'device_model', 'display',
|
|
|
|
'fda', 'fdb',
|
|
|
|
'gfx_passthru', 'guest_os_type',
|
2011-05-31 19:35:29 +02:00
|
|
|
Index: xen-4.1.1-testing/tools/python/xen/xm/xenapi_create.py
|
2010-12-01 00:19:04 +01:00
|
|
|
===================================================================
|
2011-05-31 19:35:29 +02:00
|
|
|
--- xen-4.1.1-testing.orig/tools/python/xen/xm/xenapi_create.py
|
|
|
|
+++ xen-4.1.1-testing/tools/python/xen/xm/xenapi_create.py
|
|
|
|
@@ -1085,6 +1085,10 @@ class sxp2xml:
|
2010-10-20 23:00:35 +02:00
|
|
|
'acpi',
|
|
|
|
'apic',
|
|
|
|
'boot',
|
|
|
|
+ 'xenpaging',
|
2011-05-31 19:35:29 +02:00
|
|
|
+ 'xenpaging_workdir',
|
|
|
|
+ 'xenpaging_debug',
|
|
|
|
+ 'xenpaging_policy_mru_size',
|
2010-10-20 23:00:35 +02:00
|
|
|
'device_model',
|
|
|
|
'loader',
|
|
|
|
'fda',
|