How to use PHP libvirt_connect?

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

 



I'm having a go at writing some PHP scripts to do simple things like view the status of VMs running on my Ubuntu KVM host.

I've installed php_libvirt_php but am failing at the first hurdle at the moment as I can't get the PHP script to connect.

My normal way of connecting virsh from the command line is like this:

$ virsh -c qemu+ssh://localhost/system
This asks for a password which is fine as I'm doing it from the command line. 

I can't get a connection when I use other protocols:

$ virsh -c qemu+tcp://192.168.0.103/system
error: failed to connect to the hypervisor
error: unable to connect to server at '192.168.0.103:16509': Connection refused

I've tried using various $uri values for libvirt_connect but I get connection errors:

$uri="qemu+tcp://localhost/system";
Connecting to libvirt (URI:qemu+tcp://localhost/system) 
Warning: libvirt_connect(): unable to connect to server at 'localhost:16509': Connection refused in /var/www/html/libvirt_test1.php on line 8
Libvirt last error: unable to connect to server at 'localhost:16509': Connection refused

$uri="qemu://localhost/system";
Connecting to libvirt (URI:qemu://localhost/system) 
Warning: libvirt_connect(): Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory in /var/www/html/libvirt_test1.php on line 8
Libvirt last error: Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory

$uri="qemu+tcp://localhost/system";
Connecting to libvirt (URI:qemu+tcp://localhost/system) 
Warning: libvirt_connect(): unable to connect to server at 'localhost:16509': Connection refused in /var/www/html/libvirt_test1.php on line 8
Libvirt last error: unable to connect to server at 'localhost:16509': Connection refused


Presumably the answer is to 1) either allow connections that don't require SSH, or 2) somehow allow a password-less SSH connection from the www-data user that's running the PHP script. 2) sounds like it might be very difficult, and I don't know how to do 1) as I've only ever connected this way with SSH. 

Can anyone please provide some advise on getting this working.
_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users

[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux