On 02.09.2016 11:11, Fernando Casas Schössow wrote: > 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>'; > ?> > Unfortunately, I don't have a hyperv instance to try this out, but for other connection URIs (like qemu:///system) this works for me. > 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-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] If you could attach a debugger and get a stack trace where this is happening that'd be great. > > Is there any other patch that I'm missing? Doesn't look like it, but if you could try the current git HEAD that would help. I mean, if you see the error even with that the bug is still there. > Any ideas on how to fix the libvirt_connect credentials issue without > applying the patches above? I should probably do a release soon. Not that there was a much movement since the last one though. Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list