Hi guys,
I have a problem here. On my Debian 5 server I installed kvm, libvirt and php-libvirt.
Now I am testing with an example if I can connect with libvirt and see some information about the servers. Well, now I get this error:
Code:
Warning: libvirt_connect() [function.libvirt-connect]: unable to connect to server at 'localhost:16509': Connection refused in /home/team7/public_html/example.php on line 5
Libvirt last error: unable to connect to server at 'localhost:16509': Connection refused
The script that I try to run is this:
Code:
<?php
$uri="qemu+tcp:///system";
$credentials=Array(VIR_CRED_AUTHNAME=>"user",VIR_CRED_PASSPHRASE=>"Password");
echo ("Connecting to libvirt (URI:$uri)\n");
$conn=libvirt_connect($uri,false,$credentials);
if ($conn==false)
{
echo ("Libvirt last error: ".libvirt_get_last_error()."\n");
exit;
}
else
{
$hostname=libvirt_get_hostname($conn);
echo ("hostname:$hostname\n");
echo ("Domain count: Active ".libvirt_get_active_domain_count($conn).",Inactive ".libvirt_$
$domains=libvirt_list_domains($conn);
foreach ($domains as $dom)
{
echo ("Name:\t".libvirt_domain_get_name($dom)."\n");
echo("UUID:\t".libvirt_domain_get_uuid_string($dom)."\n");
$dominfo=libvirt_domain_get_info($dom);
print_r($dominfo);
}
}
?>
I changed these variables:
VIR_CRED_AUTHNAME: to a user which exists on Debian
VIR_CRED_PASSPHRASE: password of the user
The users which exitsts on the Debian server are also added to the group libvirt.
Which files do I have to change in order to make this php file working correctly.
Do I have to change something in /etc/libvirt/libvirtd.conf? Because the php file is running on the same server as where kvm and libvirt is running.
Hope you guys can help me.
With kind regards,
Wouter.