@@ -477,20 +477,19 @@ func ifListFromAPI(conn *libvirt.Connect, domain string) ([]libvirt.DomainInterf
477
477
}
478
478
defer func () { _ = dom .Free () }()
479
479
480
- // check lease first, then arp
481
- // ref: https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInterfaceAddresses
482
- ifs , err := dom .ListAllInterfaceAddresses (libvirt .DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE )
483
- if err == nil && len (ifs ) > 0 {
484
- return ifs , nil
485
- }
486
- if err != nil {
487
- log .Debugf ("failed listing network interface addresses of domain %s using lease (will try arp): %v" , domain , err )
488
- } else if len (ifs ) == 0 {
489
- log .Debugf ("no network interface addresses found for domain %s using lease (will try arp)" , domain )
490
- }
491
- ifs , err = dom .ListAllInterfaceAddresses (libvirt .DOMAIN_INTERFACE_ADDRESSES_SRC_ARP )
492
- if err != nil {
493
- return nil , fmt .Errorf ("failed listing network interface addresses of domain %s using arp: %w" , domain , err )
480
+ ifs , err := dom .ListAllInterfaceAddresses (libvirt .DOMAIN_INTERFACE_ADDRESSES_SRC_ARP )
481
+ if ifs == nil {
482
+ if err != nil {
483
+ log .Debugf ("failed listing network interface addresses of domain %s(source=arp): %w" , domain , err )
484
+ } else {
485
+ log .Debugf ("No network interface addresses found for domain %s(source=arp)" , domain )
486
+ }
487
+ log .Debugf ("trying to list again with source=lease" )
488
+
489
+ ifs , err = dom .ListAllInterfaceAddresses (libvirt .DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE )
490
+ if err != nil {
491
+ return nil , fmt .Errorf ("failed listing network interface addresses of domain %s(source=lease): %w" , domain , err )
492
+ }
494
493
}
495
494
496
495
return ifs , nil
0 commit comments