Example #1
0
	def _startDev(self):
		host = self.host
		vmid = self.vmid
		state = qm.getState(host, vmid)
		if not self.getVncPort():
			self.host.takeId("port", self.setVncPort)
		if state == State.CREATED:
			self._prepareDev()
			state = qm.getState(host, vmid)
		for iface in self.interfaceSetAll():
			iface_id = int(re.match("eth(\d+)", iface.name).group(1))
			# qm automatically connects ethN to vmbrN
			# if this bridge does not exist, kvm start fails
			ifaceutil.bridgeCreate(host, "vmbr%d" % iface_id)
		try: 
			if state == State.PREPARED:
				qm.start(host, vmid)
			for iface in self.interfaceSetAll():
				qm.waitForInterface(host, vmid, iface.name)
				self.connectToBridge(iface, self.getBridge(iface))
			self._startVnc()
			self.state = State.STARTED
			self.save()
		except:
			try:
				qm.stop(host, vmid)
			except:
				pass
			raise
Example #2
0
	def _startVm(self):
		for iface in self.interfaceSetAll():
			iface_id = int(re.match("eth(\d+)", iface.name).group(1))
			# qm automatically connects ethN to vmbrN
			# if this bridge does not exist, kvm start fails
			if not ifaceutil.interfaceExists(self.host, "vmbr%d" % iface_id):
				ifaceutil.bridgeCreate(self.host, "vmbr%d" % iface_id)
		qm.start(self.host, self.getVmid())
		for iface in self.interfaceSetAll():
			qm.waitForInterface(self.host, self.getVmid(), iface.name)