LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-07-2011, 06:36 AM   #1
iamotor
LQ Newbie
 
Registered: Jan 2011
Posts: 4

Rep: Reputation: 0
Can't connect to libvirt socket


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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to UNIX socket /var/run/clamav/clamd.socket ganick Linux - Server 8 08-01-2008 01:22 PM
Connect to a socket leamassiot Linux - Networking 2 03-09-2007 08:40 AM
Unable to connect to UNIX socket /tmp/.esd/socket error while using grip dr_zayus69 Linux - Software 4 08-23-2005 07:28 PM
Socket error on Connect mdimanna Programming 2 06-24-2005 10:28 AM
connect: socket operation on non-socket bit7 Linux - Networking 0 02-18-2003 05:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration