mlsorensen commented on code in PR #7482:
URL: https://github.com/apache/cloudstack/pull/7482#discussion_r1183971710
##########
agent/bindir/libvirtqemuhook.in:
##########
@@ -61,21 +61,23 @@ def handleMigrateBegin():
try:
domain = parse(sys.stdin)
for interface in domain.getElementsByTagName("interface"):
- source = interface.getElementsByTagName("source")[0]
- 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):
+ sources = interface.getElementsByTagName("source")
+ if sources.length > 0:
+ source = interface.getElementsByTagName("source")[0]
+ bridge = source.getAttribute("bridge")
+ if isOldStyleBridge(bridge):
+ vlanId = bridge.replace("cloudVirBr", "")
phyDev = getGuestNetworkDevice()
- else:
- continue
- newBrName = "br" + phyDev + "-" + vlanId
- source.setAttribute("bridge", newBrName)
+ 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
+ newBrName = "br" + phyDev + "-" + vlanId
+ source.setAttribute("bridge", newBrName)
print(domain.toxml())
Review Comment:
Print is what returns the domain XML back to libvirt - unless you are asking
me to refactor this in some way?
The only addition I have made is to check the array length:
```
sources = interface.getElementsByTagName("source")
if sources.length > 0:
```
The rest is pre-existing code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]