Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
get ip addresses with agent
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Mateus <[email protected]>
  • Loading branch information
rjmateus committed Nov 16, 2021
1 parent f08b94c commit 2d0670a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libvirt/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,19 @@ func domainGetIfacesInfo(virConn *libvirt.Libvirt, domain libvirt.Domain, rd *sc
}

qemuAgentEnabled := rd.Get("qemu_agent").(bool)
var interfaces []libvirt.DomainInterface

if qemuAgentEnabled {
log.Print("[DEBUG] Not implemented")
interfaces, err = virConn.DomainInterfaceAddresses(domain, uint32(libvirt.DomainInterfaceAddressesSrcAgent), 0)
log.Print("[DEBUG] qemu-agent is used")
} else {
log.Printf("[DEBUG] qemu-agent is not used")
}
var interfaces []libvirt.DomainInterface

// get all the interfaces attached to libvirt networks
log.Print("[DEBUG] no interfaces could be obtained with qemu-agent: falling back to the libvirt API")
if interfaces == nil{
log.Print("[DEBUG] no interfaces could be obtained with qemu-agent: falling back to the libvirt API")
interfaces, err = virConn.DomainInterfaceAddresses(domain, uint32(libvirt.DomainInterfaceAddressesSrcLease), 0)
}

interfaces, err = virConn.DomainInterfaceAddresses(domain, uint32(libvirt.DomainInterfaceAddressesSrcLease), 0)
if err != nil {
switch err.(type) {
default:
Expand Down

0 comments on commit 2d0670a

Please sign in to comment.