Re: [libvirt-php] libvirt_domain_interface_addresses() only returns only on IP address for NICs with multiple IPs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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









[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux