Skip to content

Commit

Permalink
remove unrelated kvm stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
prezha committed Dec 7, 2022
1 parent 410da51 commit ecd0bed
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions pkg/drivers/kvm/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,20 +477,19 @@ func ifListFromAPI(conn *libvirt.Connect, domain string) ([]libvirt.DomainInterf
}
defer func() { _ = dom.Free() }()

// check lease first, then arp
// ref: https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInterfaceAddresses
ifs, err := dom.ListAllInterfaceAddresses(libvirt.DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE)
if err == nil && len(ifs) > 0 {
return ifs, nil
}
if err != nil {
log.Debugf("failed listing network interface addresses of domain %s using lease (will try arp): %v", domain, err)
} else if len(ifs) == 0 {
log.Debugf("no network interface addresses found for domain %s using lease (will try arp)", domain)
}
ifs, err = dom.ListAllInterfaceAddresses(libvirt.DOMAIN_INTERFACE_ADDRESSES_SRC_ARP)
if err != nil {
return nil, fmt.Errorf("failed listing network interface addresses of domain %s using arp: %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 ecd0bed

Please sign in to comment.