[libvirt] [libvirt-php] libvirt_connect not reading out credential info on 0.5.2

Fernando Casas Schössow casasfernando at hotmail.com
Fri Sep 2 09:11:31 UTC 2016


I'm running libvirt-php 0.5.2 on CentOS 7 with libvirt 2.1.0.
Using virsh I'm able to connect to hyper-v hosts correctly but using 
libvirt-php it fails during authentication since it seems that the 
credentials are not being passed along.

This is the php code I'm using:

<?php
$logfile = 'test.log';

unlink($logfile);
if (!libvirt_logfile_set($logfile))
die('Cannot set the log file');

$connstr = 'hyperv://user@hyperv-host/?transport=http';
$credentials = 
array(VIR_CRED_AUTHNAME=>'Administrator',VIR_CRED_PASSPHRASE=>'somepass');
$conn = libvirt_connect($connstr, false, $credentials);
echo libvirt_get_last_error();
unset($conn);

$fp = fopen($logfile, 'r');
    $str = fread($fp, filesize($logfile));
    fclose($fp);

echo '<pre>';
echo $str;
print_r($credentials);
echo '</pre>';
?>

And this is the output:


authentication failed: Password request failed

[2016-09-02 11:10:02 libvirt-php/core ]: libvirt_connect: Found 0 
elements for credentials
[2016-09-02 11:10:02 libvirt-php/core ]: 
libvirt_virConnectAuthCallback: cred 0, type 5, prompt Enter 
Administrator's password for hyperv-host challenge hyperv-host
 [2016-09-02 11:10:02 libvirt-php/core ]: 
libvirt_virConnectAuthCallback: result (null) (0)
[2016-09-02 11:10:02 libvirt-php/core ]: libvirt_connect: Cannot 
establish connection to 
hyperv://Administrator@hyperv-host/?transport=http
Array
(
    [2] => Administrator
    [5] => somepass
)


Note the "Found 0 elements for credentials".
After doing some googling I found an email thread "[libvirt] 
[libvirt-php PATCH 0/3] Fix PHP5 compatibilty issues." that I think is 
related to my problem, especially patch 2/3.
I also checked github project and saw that those patches are already 
merged in the code so I went ahead and apply them to 0.5.2 source code 
and rebuild:

use VIRT_FOREACH macros everywhere - Commit: f4b760d
libvirt_connect: use loop macros to read cred info - Commit: d704106
Define macros for looping php hash tables - Commit: 673a0bf

The build went fine but now when I'm trying to connect to the hyper-v 
host using libvirt-php I get an internal server error (500) so it seems 
PHP is crashing. From the system log I see:

kernel: traps: php-cgi[43452] general protection ip:7f63907f74a0 
sp:7fff12d61f68 error:0 in libvirt.so.0.2001.0[7f6390735000+385000]

Is there any other patch that I'm missing?
Any ideas on how to fix the libvirt_connect credentials issue without 
applying the patches above?

Sofware versions:

OS: CentOS Linux release 7.2.1511 (Core)
Kernel: 3.10.0-327.28.2.el7.x86_64
PHP: 5.4.16-36.3.el7_2.x86_64
libvirt: 2.1.0-4.1.x86_64
libvirt-php: 0.5.2

Thanks in advance for your replies.

Fer


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160902/c4b0d5a9/attachment-0001.htm>


More information about the libvir-list mailing list