kvm: Fix router migration issue when router has control/public nics on other physical network than guest (#3855)

In VM migration on KVM, libvirt qemu hook script will change the bridge name to bridges for guest networks. It works for user vm. However for virtual router, it has nics on control network and public network. If control/public use different physical networks than guest network, virtual router cannot be migrated.

Fixes: #2783
This commit is contained in:
Wei Zhou 2020-01-31 10:44:35 +01:00 committed by GitHub
parent 9d105b6546
commit 76fb811e08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,11 +65,15 @@ def handleMigrateBegin():
bridge = source.getAttribute("bridge")
if isOldStyleBridge(bridge):
vlanId = bridge.replace("cloudVirBr", "")
phyDev = getGuestNetworkDevice()
elif isNewStyleBridge(bridge):
vlanId = re.sub(r"br(\w+)-", "", bridge)
phyDev = re.sub(r"-(\d+)$", "" , re.sub(r"^br", "" ,bridge))
netlib = networkConfig()
if not netlib.isNetworkDev(phyDev):
phyDev = getGuestNetworkDevice()
else:
continue
phyDev = getGuestNetworkDevice()
newBrName = "br" + phyDev + "-" + vlanId
source.setAttribute("bridge", newBrName)
print(domain.toxml())