Esempio n. 1
0
def addInterface(host, vmid, iface):
	assert getState(host, vmid) == generic.State.PREPARED, "VM must be stopped to add interfaces"
	iface_id = int(re.match("eth(\d+)", iface).group(1))
	# qm automatically connects ethN to vmbrN
	# if this bridge does not exist, kvm start fails
	if not ifaceutil.interfaceExists(host, "vmbr%d" % iface_id):
		ifaceutil.bridgeCreate(host, "vmbr%d" % iface_id)
	_qm(host, vmid, "set", "--vlan%d e1000" % iface_id)			
Esempio n. 2
0
def _startDummyCapture(host):
	# Due to some weird kernel optimization bridges get sometimes skipped
	# and the link emulation will not work.
	# Using the pcap interface seams to prevent this issue
	if not ifaceutil.bridgeExists(host, "dummy"):
		ifaceutil.bridgeCreate(host, "dummy")
	ifaceutil.ifup(host, "dummy")
	if not tcpdump.captureToFileRunning(host, "_dummy"):
		tcpdump.startCaptureToFile(host, "_dummy", "dummy")
Esempio n. 3
0
def _connectEndpoint(endpoint, mode):
	host = endpoint.getHost()
	assert host
	bridge = endpoint.getBridge()
	assert bridge
	if not ifaceutil.bridgeExists(host, bridge):
		ifaceutil.bridgeCreate(host, bridge)
	if mode == Mode.ROUTER:
		_setupRouting(endpoint)
	else:
		ifaceutil.ifup(host, bridge)
		ifaceutil.bridgeConnect(host, bridge, _tincName(endpoint))