On 07.09.2016 15:58, Matthias Bolte wrote:
2016-09-07 14:20 GMT+02:00 Fernando Casas Schössow
<casasfernando(a)hotmail.com>:
> Hi all,
>
> I'm using libvirt-php to manage a Hyper-V 2012 R2 host.
> When trying to retrieve the active VMs using the function
> libvirt_list_active_domains() I get an array with the correct amount of
> items but with garbage instead of the domain names:
>
> Array ( [0] => P’*µ [1] => +µ [2] => `„*µ [3] => °Ø*µ [4] => Є*µ [5]
=>
> `†*µ [6] => [7] => `†*µ [8] => [9] => p +µ [10] => p"+µ [11]
=> P#+µ [12] =>
> ß*µ )
>
> On the other hand libvirt_list_inactive_domains() and libvirt_list_domains()
> work as expected returning the right amount of items and the domain names
> correctly:
>
> libvirt_list_inactive_domains() output:
>
> Array ( [0] => DCHOMELAB01 [1] => VMFCSW7 [2] => REMOTEAPP01 [3] =>
MPSSD01
> [4] => CS16SVR )
Hey thank you for the bug report. It's important to me to fix whatever
bugs you find, because libvirt-php hasn't been given enough attention
lately.
The problem is here
http://libvirt.org/git/?p=libvirt-php.git;a=blob;f=src/libvirt-php.c;h=20...
libvirt_list_active_domains gets the domain name using
virDomainGetName, then frees the domain object using virDomainFree
(this also frees the domain name) and afterwards tries to use the
already freed domain name.
libvirt_list_active_domains needs to add the domian name to the result
list and then free the domain. For example, libvirt_list_domains does
it in the correct order.
And thanks to Matthias for the analysis. You're right. I've just pushed
the patch for it. @Fernando you can try it out.
http://libvirt.org/git/?p=libvirt-php.git;a=commitdiff;h=a0039f72a1c480e5...
Michal