incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r750129 - in /incubator/tashi/trunk/src/tashi: nodemanager/vmcontrol/qemu.py util.py
Date Wed, 04 Mar 2009 19:58:30 GMT
Author: mryan3
Date: Wed Mar  4 19:58:30 2009
New Revision: 750129

URL: http://svn.apache.org/viewvc?rev=750129&view=rev
Log:
Update of qemu backend to support booting VMs with multiple NICs and multiple disks.


Modified:
    incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py
    incubator/tashi/trunk/src/tashi/util.py

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=750129&r1=750128&r2=750129&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py Wed Mar  4 19:58:30 2009
@@ -28,7 +28,7 @@
 import time
 
 from tashi.services.ttypes import *
-from tashi.util import broken, logged
+from tashi.util import broken, logged, scrubString
 from vmcontrolinterface import VmControlInterface
 
 log = logging.getLogger(__file__)
@@ -285,22 +285,28 @@
 
 	def startVm(self, instance, source):
 		"""Universal function to start a VM -- used by instantiateVM, resumeVM, and prepReceiveVM"""
-		global lastCmd
-		(image, macAddr, memory, cores, diskModel, instanceId, opts) = self.instanceToOld(instance)
+		clockString = instance.hints.get("clock", "dynticks")
+		diskInterface = instance.hints.get("diskInterface", "ide")
+		diskString = ""
+		for index in range(0, len(instance.disks)):
+			disk = instance.disks[index]
+			uri = scrubString(disk.uri)
+			imageLocal = self.dfs.getLocalHandle("images/" + uri)
+			if (disk.persistent):
+				snapshot = "off"
+			else:
+				snapshot = "on"
+			diskString = diskString + "-drive file=%s,if=%s,index=%d,snapshot=%s,media=disk " % (imageLocal,
diskInterface, index, snapshot)
+		nicModel = instance.hints.get("nicModel", "e1000")
+		nicString = ""
+		for nic in instance.nics:
+			nicString = nicString + "-net nic,macaddr=%s,model=%s,vlan=%d -net tap,vlan=%d,script=/etc/qemu-ifup.%d
" % (nic.mac, nicModel, nic.network, nic.network, nic.network)
 		if (not source):
 			sourceString = ""
 		else:
 			sourceString = "-incoming %s" % (source)
-		if (diskModel == "persistent"):
-			snapshotString = ""
-		else:
-			snapshotString = "-snapshot"
-		modelString = opts.get("nicModel", "e1000")
-		clockString = opts.get("clock", "dynticks")
-		imageLocal = self.dfs.getLocalHandle("images/" + image)
-		cmd = "%s -clock %s %s -hda %s -net nic,macaddr=%s,model=%s -net tap -m %d -smp %d -serial
none -vnc none -monitor pty %s" % (self.QEMU_BIN, clockString, snapshotString, imageLocal,
macAddr, modelString, memory, cores, sourceString)
+		cmd = "%s -clock %s %s %s -m %d -smp %d -serial none -vnc none -monitor pty %s" % (self.QEMU_BIN,
clockString, diskString, nicString, instance.memory, instance.cores, sourceString)
 		log.info("QEMU command: %s" % (cmd))
-		lastCmd = cmd
 		cmd = cmd.split()
 		(pipe_r, pipe_w) = os.pipe()
 		pid = os.fork()

Modified: incubator/tashi/trunk/src/tashi/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/util.py?rev=750129&r1=750128&r2=750129&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/util.py (original)
+++ incubator/tashi/trunk/src/tashi/util.py Wed Mar  4 19:58:30 2009
@@ -255,6 +255,13 @@
 	r = s[index+len(field):]
 	return (l, sep, r)
 
+def scrubString(s, allowed="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_."):
+	ns = ""
+	for c in s:
+		if (c in allowed):
+			ns = ns + c
+	return ns
+
 def createClient(config):
 	cfgHost = config.get('Client', 'clusterManagerHost')
 	cfgPort = config.get('Client', 'clusterManagerPort')



Mime
View raw message