Skip to content

Commit

Permalink
Merge pull request #13482 from anoopcs9/libvirt-use-src-arp
Browse files Browse the repository at this point in the history
drivers/kvm: Use ARP for retrieving interface ip addresses
  • Loading branch information
sharifelgamal authored Feb 1, 2022
2 parents 74452b5 + 061fd88 commit 2cbe070
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/drivers/kvm/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,19 @@ func ifListFromAPI(conn *libvirt.Connect, domain string) ([]libvirt.DomainInterf
}
defer func() { _ = dom.Free() }()

ifs, err := dom.ListAllInterfaceAddresses(libvirt.DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE)
if err != nil {
return nil, fmt.Errorf("failed listing network interface addresses of domain %s: %w", domain, err)
ifs, err := dom.ListAllInterfaceAddresses(libvirt.DOMAIN_INTERFACE_ADDRESSES_SRC_ARP)
if ifs == nil {
if err != nil {
log.Debugf("failed listing network interface addresses of domain %s(source=arp): %w", domain, err)
} else {
log.Debugf("No network interface addresses found for domain %s(source=arp)", domain)
}
log.Debugf("trying to list again with source=lease")

ifs, err = dom.ListAllInterfaceAddresses(libvirt.DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE)
if err != nil {
return nil, fmt.Errorf("failed listing network interface addresses of domain %s(source=lease): %w", domain, err)
}
}

return ifs, nil
Expand Down

0 comments on commit 2cbe070

Please sign in to comment.