Forgot to add the output of the equivalent virsh command for the same
VM:
Name MAC address Protocol Address
-------------------------------------------------------------------------------
lo 00:00:00:00:00:00 ipv4 127.0.0.1/8
lo 00:00:00:00:00:00 ipv6 ::1/128
eth0 52:54:00:12:b9:22 ipv4 192.168.7.31/26
eth0 52:54:00:12:b9:22 ipv6 fe80::5054:ff:fe12:b922/64
eth1 52:54:00:8e:b0:35 ipv4 192.168.1.34/24
eth1 52:54:00:8e:b0:35 ipv6 fe80::5054:ff:fe8e:b035/64
Thanks,
Fernando
On jue, abr 16, 2020 at 12:58 AM, Fernando Casas Schössow
<casasfernando@xxxxxxxxxxx> wrote:
Hi,
While using the function libvirt_domain_interface_addresses() with
qemu guest agent as the source, for interfaces with more than one IP
address, the function will only return one IP.
Example code:
$netdetails = libvirt_domain_interface_addresses($vmres, 2);
foreach ($netdetails as $nic) {
print_r($nic);
}
Example output:
Array
(
[name] => eth0
[hwaddr] => 52:54:00:12:b9:22
[naddrs] => 2
[addrs] => Array
(
[addr] => fe80::5054:ff:fe12:b922
[prefix] => 64
[type] => 1
)
)
Array
(
[name] => eth1
[hwaddr] => 52:54:00:8e:b0:35
[naddrs] => 2
[addrs] => Array
(
[addr] => fe80::5054:ff:fe8e:b035
[prefix] => 64
[type] => 1
)
)
As you can see for this guest the function returns two interfaces
(eth0 and eth1). For both interfaces naddrs => 2 which is correct
because both interfaces have an ipv4 and an ipv6 address but the
addrs array only contains the ipv6 address information while the ipv4
address information is missing.
System information:
OS: Debian Bullseye
PHP version (fast cgi): 7.3.15
Libvirt PHP version: 0.5.5
Libvirt version: 6.0.0
KVM host libvirt version: 5.9.0
If you need any other information please let me know.
Thanks.
Fernando