incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r746326 - /incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py
Date Fri, 20 Feb 2009 18:33:19 GMT
Author: mryan3
Date: Fri Feb 20 18:33:19 2009
New Revision: 746326

URL: http://svn.apache.org/viewvc?rev=746326&view=rev
Log:
Added "startConsole" command to qemu backend for debugging.
Also made the qemu backend reuse VNC port numbers.


Modified:
    incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.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=746326&r1=746325&r2=746326&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py Fri Feb 20 18:33:19 2009
@@ -93,8 +93,10 @@
 		self.controlledVMs = {}
 		self.usedPorts = []
 		self.usedPortsLock = threading.Lock()
-		self.vncPort = 1
+		self.vncPorts = []
 		self.vncPortLock = threading.Lock()
+		self.consolePort = 10000
+		self.consolePortLock = threading.Lock()
 		self.migrationSemaphore = threading.Semaphore(int(self.config.get("Qemu", "maxParallelMigrations")))
 		try:
 			os.mkdir(self.INFO_DIR)
@@ -128,6 +130,10 @@
 				os.unlink(self.INFO_DIR + "/%d"%(vmId))
 				child = controlledVMs[vmId]
 				del controlledVMs[vmId]
+				if (child.vncPort >= 0):
+					self.vncPortLock.acquire()
+					self.vncPorts.remove(child.vncPort)
+					self.vncPortLock.release()
 				log.info("Removing vmId %d" % (vmId))
 				if (child.OSchild):
 					os.waitpid(vmId, 0)
@@ -157,8 +163,8 @@
 			try:
 				child = self.loadChildInfo(vmId)
 				self.vncPortLock.acquire()
-				if (child.vncPort >= self.vncPort):
-					self.vncPort = child.vncPort + 1
+				if (child.vncPort >= 0):
+					self.vncPorts.append(child.vncPort)
 				self.vncPortLock.release()
 				child.monitorFd = os.open(child.ptyFile, os.O_RDWR | os.O_NOCTTY)
 				child.monitor = os.fdopen(child.monitorFd)
@@ -519,20 +525,35 @@
 			hostname = socket.gethostname()
 			if (child.vncPort == -1):
 				self.vncPortLock.acquire()
-				port = self.vncPort
-				self.vncPort = self.vncPort + 1
+				port = 0
+				while (port in self.vncPorts):
+					port = port + 1
+				self.vncPorts.append(port)
 				self.vncPortLock.release()
 				self.enterCommand(child, "change vnc :%d" % (port))
 				child.vncPort = port
 				self.saveChildInfo(child)
 			port = child.vncPort
-			return "%s:%d" % (hostname, port)
+			return "VNC started on %s:%d" % (hostname, port+5900)
 		elif (arg == "stopvnc"):
 			child = self.getChildFromPid(vmId)
 			self.enterCommand(child, "change vnc none")
-			child.vncPort = -1
-			self.saveChildInfo(child)
-			return "None"
+			if (child.vncPort != -1):
+				self.vncPortLock.acquire()
+				self.vncPorts.remove(child.vncPort)
+				self.vncPortLock.release()
+				child.vncPort = -1
+				self.saveChildInfo(child)
+			return "VNC halted"
+		elif (arg == "startconsole"):
+			child = self.getChildFromPid(vmId)
+			hostname = socket.gethostname()
+			self.consolePortLock.acquire()
+			consolePort = self.consolePort
+			self.consolePort = self.consolePort+1
+			self.consolePortLock.release()
+			threading.Thread(target=lambda: controlConsole(child,consolePort)).start()
+			return "Control console listenting on %s:%d" % (hostname, consolePort)
 		else:
 			return "Unknown arg %s" % (arg)
 	



Mime
View raw message