Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied #240

Closed
TurboCheetah opened this issue Jun 10, 2019 · 16 comments

Comments

@TurboCheetah
Copy link

I have just installed it and have not changed anything. I added a compute node and then got this error. I added myself to the libvirt group and virt-manager works just fine. Only Webvirtcloud has this issue. Help?

@catborise
Copy link
Collaborator

catborise commented Jun 10, 2019

where did you install webvirtcloud?
on kvm host or a vm instance?
which protocol did you use while adding host(ssh, tcp, ...)

image

@shinebayar-g
Copy link

shinebayar-g commented Nov 6, 2019

After fresh install on ubuntu 18.04 I've got the same issue after adding compute machine by selecting local option. What should I do? Compute status says: Connected. But I cannot create Instance on it.

@catborise
Copy link
Collaborator

Have you run that script on the host?
wget -O - https://clck.ru/9V9fH | sudo sh
Before you run that script you can look what is it. What configs have it.

What is the error while creating instance?

@shinebayar-g
Copy link

shinebayar-g commented Nov 6, 2019

Yes I've run the script. But I guess I mixed up users. I initially started process as sudo user and then run that script as root user. I guess this fucked up my installation. Recreating fresh VPS again.

@catborise
Copy link
Collaborator

I recommend you that isolate webvirtcloud from hypervisor host.
How;

  1. If you want to manage more than one host, you can create a vm and install webvirtcloud on it.
  2. If you do not want to reserve a vm for webvirtcloud. You could use containers. Docker installation is simple as dead.
    So that your users and other Configurations do not mixed up.

@shinebayar-g
Copy link

I see thank you very much for your suggestion. Right now this is my first try of webvirtcloud. So I'm just testing things out. Once I get familiar with the project concepts I'll create dedicated host for webvirtcloud :)

Also I'll try to enhance docs here and there If I see something broken.

@shinebayar-g
Copy link

shinebayar-g commented Nov 6, 2019

Okay, just finished installing. I'm still seeing this error. Here is my whole installation steps.

sudo apt-get update
sudo apt-get -y install git virtualenv python-virtualenv python-dev python-lxml libvirt-dev zlib1g-dev libxslt1-dev nginx supervisor libsasl2-modules gcc pkg-config python-guestfs
git clone https://github.com/retspen/webvirtcloud
cd webvirtcloud
cp webvirtcloud/settings.py.template webvirtcloud/settings.py
python # Generating secret key in python shell
vim webvirtcloud/settings.py # putting the key here
sudo cp conf/supervisor/webvirtcloud.conf /etc/supervisor/conf.d
sudo cp conf/nginx/webvirtcloud.conf /etc/nginx/conf.d
cd ..
sudo mv webvirtcloud /srv
sudo chown -R www-data:www-data /srv/webvirtcloud
cd /srv/webvirtcloud
virtualenv venv # This line gave error, because folder was owned by www-data:www-data now
sudo chown -R me:me venv # So I had to change back permission to my current user
pip install -r conf/requirements.txt
python manage.py migrate
sudo chown -R www-data:www-data /srv/webvirtcloud # fixing permissions back after installing things
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
sudo service supervisor restart
wget -O - https://clck.ru/9V9fH | sudo sh

Now I'm here.

image

image

I guess I followed everything correctly, are you seeing anything abnormal here?

@catborise
Copy link
Collaborator

Hmm, i never try local connection. I should ...
Have you install virt-manager? Can you run it to check if libvirt service is working. This problem seems to libvirt service problem.

@shinebayar-g
Copy link

shinebayar-g commented Nov 6, 2019

I didn't install virt-manager. I guess it wasn't needed.

$ sudo service libvirt status
Unit libvirt.service could not be found.

Edit: Ah it is called libvirtd

$ sudo service libvirtd status
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-11-06 17:54:25 UTC; 12min ago
     Docs: man:libvirtd(8)
           https://libvirt.org
 Main PID: 20575 (libvirtd)
    Tasks: 19 (limit: 32768)
   CGroup: /system.slice/libvirtd.service
           ├─20575 /usr/sbin/libvirtd
           ├─20937 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
           └─20938 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper

Nov 06 17:54:27 instance-2 dnsmasq[20937]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify
Nov 06 17:54:27 instance-2 dnsmasq-dhcp[20937]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Nov 06 17:54:27 instance-2 dnsmasq-dhcp[20937]: DHCP, sockets bound exclusively to interface virbr0

@catborise
Copy link
Collaborator

Virt-manager does not need. But to check somethings, it is useful.
Please run on the host:
virsh list

@shinebayar-g
Copy link

shinebayar-g commented Nov 6, 2019

Ran command as my current user

$ virsh list
error: failed to connect to the hypervisor
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied

$ sudo virsh list
 Id    Name                           State
----------------------------------------------------

@catborise
Copy link
Collaborator

As you see it is related with users and permissions.
This link mention that permission problem, could you look:
http://thelinuxerrors.blogspot.com/2012/10/failed-to-connect-socket-to.html

@shinebayar-g
Copy link

shinebayar-g commented Nov 6, 2019

It is indeed. Okay I've fixed it. I've added myself to libvirt group. Now virsh list command works fine for my user. But on the web I'm still seeing the error?
I've tried to restart all supervisor processes, rebooted server no help. What should I do now? Should I add www-data user into libvirt group too? @catborise

Edit: adding www-data user to libvirt group helped? After reboot now I got rid of error.

@shinebayar-g
Copy link

Now I'm seeing this error. How can I add storage?

image

@catborise
Copy link
Collaborator

Libvirt-sock problem Seems to solved.
Latest one is not related with that problem.
—-
You should create a storage pool on the host.
Go to computes.
Storages, create a pool which will contain disk images.

@shinebayar-g
Copy link

Just double checked it by removing www-data user from libvirt group again. Error was caused by this indeed. I'll make PR changes to document these things.

Oh thank you! I didn't know I actually had to click on the compute name. Now I'm seeing whole lot of menus out there! Thank you very much.

/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants