You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2023/05/08 06:29:48 UTC
[cloudstack] branch 4.18 updated: Qemu migration hook: check for source length before using element 0 (#7482)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.18 by this push:
new bdd53633148 Qemu migration hook: check for source length before using element 0 (#7482)
bdd53633148 is described below
commit bdd5363314826df2bbce55a9d091da3625367133
Author: Marcus Sorensen <ma...@apple.com>
AuthorDate: Mon May 8 00:29:42 2023 -0600
Qemu migration hook: check for source length before using element 0 (#7482)
Co-authored-by: Marcus Sorensen <ml...@apple.com>
---
agent/bindir/libvirtqemuhook.in | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/agent/bindir/libvirtqemuhook.in b/agent/bindir/libvirtqemuhook.in
index cf3d36410b8..e17944d8353 100755
--- a/agent/bindir/libvirtqemuhook.in
+++ b/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())
except:
pass