Skip to content

Commit

Permalink
Make domainIfaceHasAddress return true only if there is at least on…
Browse files Browse the repository at this point in the history
…e IP address assigned to a network interface with matching physical address. (#1048)
  • Loading branch information
pstrzelczak authored Nov 19, 2023
1 parent 8d7c58f commit 8a732c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libvirt/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func domainIfaceHasAddress(virConn *libvirt.Libvirt, domain libvirt.Domain,
log.Printf("[DEBUG] ifaces with addresses: %+v\n", ifacesWithAddr)

for _, ifaceWithAddr := range ifacesWithAddr {
if len(ifaceWithAddr.Hwaddr) > 0 && (mac == strings.ToUpper(ifaceWithAddr.Hwaddr[0])) {
if len(ifaceWithAddr.Hwaddr) > 0 && (mac == strings.ToUpper(ifaceWithAddr.Hwaddr[0])) && len(ifaceWithAddr.Addrs) > 0 {
log.Printf("[DEBUG] found IPs for MAC=%+v: %+v\n", mac, ifaceWithAddr.Addrs)
return true, false, nil
}
Expand Down

0 comments on commit 8a732c3

Please sign in to comment.