incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1082370 - in /incubator/tashi/trunk/src/tashi: clustermanager/data/fromconfig.py nodemanager/nodemanager.py nodemanager/nodemanagerservice.py nodemanager/vmcontrol/qemu.py
Date Thu, 17 Mar 2011 01:30:06 GMT
Author: stroucki
Date: Thu Mar 17 01:30:06 2011
New Revision: 1082370

URL: http://svn.apache.org/viewvc?rev=1082370&view=rev
Log:
Bring in changes from deployment at CMU (trunk branch)
   * Contains support for allocating scratch space hard disks to VMs
   * Support booting from virtio disks
   * Turn off caching for disks based on empirical performance measurements
   * Don't raise exception when starting nodemanager up for first time and its database file
doesn't exist
   * Using "with" in python 2.5 environment requires import from future


Modified:
    incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py
    incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py
    incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
    incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py

Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py?rev=1082370&r1=1082369&r2=1082370&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py Thu Mar 17 01:30:06
2011
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.    
 
+from __future__ import with_statement
 import threading
 import os
 import ConfigParser

Modified: incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py?rev=1082370&r1=1082369&r2=1082370&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py Thu Mar 17 01:30:06 2011
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file

Modified: incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py?rev=1082370&r1=1082369&r2=1082370&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py Thu Mar 17 01:30:06
2011
@@ -76,8 +76,7 @@ class NodeManagerService(object):
 			f.close()
 			self.instances = cPickle.loads(data)
 		except Exception, e:
-# this fails reasonably often. should probably not be a verbose exception
-			self.log.exception('Failed to load VM info from %s' % (self.infoFile))
+			self.log.warning('Failed to load VM info from %s' % (self.infoFile))
 			self.instances = {}
 	
 	def saveVmInfo(self):

Modified: incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py?rev=1082370&r1=1082369&r2=1082370&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py Thu Mar 17 01:30:06 2011
@@ -27,6 +27,9 @@ import subprocess
 import sys
 import time
 
+# for scratch space support
+from os import system
+
 from tashi.rpycservices.rpyctypes import *
 from tashi.util import broken, logged, scrubString, boolean
 from tashi import version, stringPartition
@@ -102,6 +105,8 @@ class Qemu(VmControlInterface):
 		self.consolePortLock = threading.Lock()
 		self.migrationSemaphore = threading.Semaphore(int(self.config.get("Qemu", "maxParallelMigrations")))
 		self.stats = {}
+		self.scratchDir = self.config.get("Qemu", "scratchDir")
+
 		try:
 			os.mkdir(self.INFO_DIR)
 		except:
@@ -338,7 +343,7 @@ class Qemu(VmControlInterface):
 			thisDiskList.append("if=%s" % diskInterface)
 			thisDiskList.append("index=%d" % index)
 
-			if (diskInterface == "virtio"):
+			if (index == 0 and diskInterface == "virtio"):
 				thisDiskList.append("boot=on")
 
 			if (disk.persistent):
@@ -348,6 +353,8 @@ class Qemu(VmControlInterface):
 				snapshot = "on"
 				migrate = "on"
 
+			thisDiskList.append("cache=off")
+
 			thisDiskList.append("snapshot=%s" % snapshot)
 
 			if (self.useMigrateArgument):
@@ -355,7 +362,50 @@ class Qemu(VmControlInterface):
 
 			diskString = diskString + "-drive " + ",".join(thisDiskList) + " "
 
+		# scratch disk (should be probable handled elsewhere)
+		scratchSize = instance.hints.get("scratchSpace", "0")
+		scratchSize = int(scratchSize)
+
+		try:
+			if scratchSize > 0:
+				print 'creating scratch file'
+				# create scratch disk
+				# XXXstroucki: needs to be cleaned somewhere
+				scratch_file = os.path.join(self.scratchDir, instance.name + ".scratch")
+				print 'scratch file name is ', scratch_file
+				tempfd = open(scratch_file, "w")
+				print 'opened'
+				tempfd.seek( (scratchSize * 2 ** 30) - 1 )
+				print 'seeked'
+				tempfd.write('x')
+				print 'written'
+				tempfd.close()
+				print 'closed'
+				index += 1
+
+				thisDiskList = [ "file=%s" % scratch_file ]
+				thisDiskList.append("if=%s" % diskInterface)
+				thisDiskList.append("index=%d" % index)
+				thisDiskList.append("cache=off")
+				
+				if (True or disk.persistent):
+					snapshot = "off"
+					migrate = "off"
+				else:
+					snapshot = "on"
+					migrate = "on"
+
+				thisDiskList.append("snapshot=%s" % snapshot)
 
+				if (self.useMigrateArgument):
+					thisDiskList.append("migrate=%s" % migrate)
+
+				diskString = diskString + "-drive " + ",".join(thisDiskList) + " "
+
+		except:
+			print 'caught exception'
+			raise 'exception'
+	
 		#  Nic hints
 		nicModel = instance.hints.get("nicModel", "e1000")
 		nicString = ""
@@ -402,6 +452,13 @@ class Qemu(VmControlInterface):
 		self.saveChildInfo(child)
 		self.controlledVMs[child.pid] = child
 		log.info("Adding vmId %d" % (child.pid))
+
+		# clean up scratch file
+		if scratchSize > 0:
+			scratch_file = os.path.join(self.scratchDir, instance.name + ".scratch")
+			time.sleep(5)
+			os.unlink(scratch_file)
+
 		return (child.pid, cmd)
 
 	def getPtyInfo(self, child, issueContinue):



Mime
View raw message