You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by mr...@apache.org on 2009/07/10 15:31:01 UTC

svn commit: r792984 - /incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py

Author: mryan3
Date: Fri Jul 10 15:31:01 2009
New Revision: 792984

URL: http://svn.apache.org/viewvc?rev=792984&view=rev
Log:
Jim Cipar's patch on tashi-dev@i.a.o:

The HVM booting was broken in Xen.  This patch should fix it.  It also  
adds VNC support.  The VNC display number is the VMs global ID, so  
this will remain unique even if the VM is moved to a different host.


Modified:
    incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py

Modified: incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py?rev=792984&r1=792983&r2=792984&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py Fri Jul 10 15:31:01 2009
@@ -152,7 +152,7 @@
 # a lot easier
 ########################################
 	def createXenConfig(self, vmName, 
-			    image, macAddr, memory, cores, hints):
+	                    image, macAddr, memory, cores, hints, id):
 		fn = os.path.join("/tmp", vmName)
 		vmType = hints.get('vmtype', self.defaultVmType)
 		print 'starting vm with type: ', vmType
@@ -162,11 +162,31 @@
 			bootstr = '''
 kernel = '/usr/lib/xen/boot/pv-grub-x86_64.gz'
 extra = '(hd0,0)/grub/menu.lst'
-'''
+disk=['tap:qcow:%s,xvda1,w']
+vif = [ 'mac=%s' ]
+memory=%i
+vcpus=%i
+root="/dev/xvda1"
+extra='xencons=tty'
+'''%(image,
+     macAddr,
+     memory,
+     cores)
+	
 		elif vmType == 'pygrub':
 			bootstr = '''
 bootloader="/usr/bin/pygrub"
-'''
+disk=['tap:qcow:%s,xvda1,w']
+vif = [ 'mac=%s' ]
+memory=%i
+vcpus=%i
+root="/dev/xvda1"
+extra='xencons=tty'
+'''%(image,
+     macAddr,
+     memory,
+     cores)
+	
 		elif vmType == 'kernel':
 			kernel = hints.get('kernel', None)
 			ramdisk = hints.get('ramdisk', None)
@@ -175,16 +195,29 @@
 					kernel = self.config.get('XenPV', 'defaultKernel')
 				except:
 					raise Exception, "vmtype=kernel requires kernel= argument"
-			bootstr = "kernel=\"%s\"\n"%kernel
 			if ramdisk == None:
 				try:
 					ramdisk = self.config.get('XenPV', 'defaultRamdisk')
+					ramdisk = "ramdisk = \"%s\""%ramdisk
 				except:
-					ramdisk = None
-			if ramdisk != None:
-				bootstr = bootstr + "ramdisk = \"%s\"\n"%ramdisk
+					ramdisk = ''
+			bootstr = '''
+kernel = "%s"
+%s     # ramdisk string is full command
+
+disk=['tap:qcow:%s,xvda1,w']
+vif = [ 'mac=%s' ]
+memory=%i
+vcpus=%i
+root="/dev/xvda1"
+extra='xencons=tty'
+'''%(kernel, ramdisk,
+     image,
+     macAddr,
+     memory,
+     cores)
+
 		elif vmType == 'hvm':
-			# FIXME: untested, I don't have any hvm domains set up
 			bootstr = '''
 import os, re
 arch = os.uname()[4]
@@ -192,21 +225,36 @@
 	arch_libdir = 'lib64'
 else:
 	arch_libdir = 'lib'
-kernel = '/usr/lib/xen/boot/hvmlocader'
+kernel = '/usr/lib/xen/boot/hvmloader'
 builder = 'hvm'
-'''
-		else:
-			raise Exception, "Unknown vmType in hints: %s"%vmType
-		cfgstr = """
-disk=['tap:qcow:%s,xvda1,w']
-vif = [ 'mac=%s' ]
+
+device_model='/usr/lib/xen/bin/qemu-dm'
+
+sdl=0
+vnc=1
+vnclisten='0.0.0.0'
+vncdisplay=%i
+vncpasswd=''
+stdvga=0
+serial='pty'
+usbdevice='tablet'
+
+shadow_memory=8
+disk=['tap:qcow:%s,hda,w']
+vif = [ 'type=ioemu,bridge=xenbr0,mac=%s' ]
 memory=%i
 vcpus=%i
 root="/dev/xvda1"
 extra='xencons=tty'
-"""%(image, macAddr, memory, cores)
+'''%(id,
+     image,
+     macAddr,
+     memory,
+     cores)
+		else:
+			raise Exception, "Unknown vmType in hints: %s"%vmType
 		f = open(fn, "w")
-		f.write(bootstr+cfgstr)
+		f.write(bootstr)
 		f.close()
 		return fn
 	def deleteXenConfig(self, vmName):
@@ -250,7 +298,8 @@
 					  instance.nics[0].mac, 
 					  instance.memory,
 					  instance.cores,
-					  instance.hints)
+					  instance.hints,
+					  instance.id)
 		cmd = "xm create %s"%fn
 		r = os.system(cmd)
 #		self.deleteXenConfig(name)