22

I have problem with libvirtd, the service is inactive even though I run systemctl start libvirtd.service.

I am member of libvirt and kvm

The output of systemctl status libvirtd is

libvirtd.service - Virtualization daemon
   Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Tue 2020-04-07 23:44:24 -04; 8s ago
     Docs: man:libvirtd(8)
           https://libvirt.org
  Process: 19508 ExecStart=/usr/sbin/libvirtd $libvirtd_opts (code=exited, status=0/SUCCESS)
 Main PID: 19508 (code=exited, status=0/SUCCESS)

And the error when I run others command like virsh list

error: failed to connect to the hypervisor
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock':  No such file or directory

The directory /var/run/libvirt/ does not contain the file libvirt-sock and I think that it is the principal problem, but i don't know the solution.

ls /var/run/libvirt
network  storage  virtlockd-sock  virtlogd-sock

I installed libvirt-daemon-system qemu-kvm libvirt-bin bridge-utils virt-manager qemu libvirt0.

I tried with systemctl enable libvirtd and systemctl enable libvirtd but is inactive.

Output of journalctl -f when i run systemctl restart libvirtd

abr 08 08:40:56 susan sudo[7195]: susan : TTY=pts/1 ; PWD=/home/susan ; USER=root ; COMMAND=/bin/systemctl restart libvirtd
abr 08 08:40:56 susan sudo[7195]: pam_unix(sudo:session): session opened for user root by (uid=0)
abr 08 08:40:56 susan systemd[1]: Starting Virtualization daemon...
abr 08 08:40:56 susan systemd[1]: Started Virtualization daemon.
abr 08 08:40:56 susan sudo[7195]: pam_unix(sudo:session): session closed for user root
abr 08 08:40:56 susan libvirtd[7198]: 2020-04-08 12:40:56.120+0000: 7225: info : libvirt version: 4.0.0, package: 1ubuntu8.15 (Guilherme G. Piccoli <gpiccoli@canonical.com> Thu, 20 Feb 2020 13:07:33 -0300)
abr 08 08:40:56 susan libvirtd[7198]: 2020-04-08 12:40:56.120+0000: 7225: info : hostname: susan
abr 08 08:40:56 susan libvirtd[7198]: 2020-04-08 12:40:56.120+0000: 7225: error : virFirewallValidateBackend:193 : direct firewall backend requested, but /sbin/ebtables is not available: No existe el archivo o el directorio
abr 08 08:40:56 susan libvirtd[7198]: 2020-04-08 12:40:56.120+0000: 7225: error : virFirewallApply:916 : internal error: Failed to initialize a valid firewall backend
abr 08 08:40:56 susan libvirtd[7198]: 2020-04-08 12:40:56.128+0000: 7225: error : virConfParseValue:529 : configuration file syntax error: /etc/libvirt/qemu.conf:412: expecting a value
abr 08 08:40:56 susan libvirtd[7198]: 2020-04-08 12:40:56.128+0000: 7225: error : virStateInitialize:775 : Initialization of QEMU state driver failed: configuration file syntax error: /etc/libvirt/qemu.conf:412: expecting a value
abr 08 08:40:56 susan libvirtd[7198]: 2020-04-08 12:40:56.128+0000: 7225: error : daemonRunStateInit:849 : Driver state initialization failed

The line 412 in etc/libvirt/qemu.conf

group=kvm

Any solutions for this problem? Thanks!

Susan
  • 321
  • Could you track "journalctl -f" while issuing a "systemctl restart libvirtd" that way more what is going on can be captured. Add that output to your question please. – Christian Ehrhardt Apr 08 '20 at 08:41
  • Thanks! I add this information in the question! – Susan Apr 08 '20 at 12:45
  • Please provide version of Ubuntu and is this some hosted computer or VPS (which sometimes have similar issues)? You seem to be missing iptables, which provides ebtables. – Doug Smythies Apr 08 '20 at 14:51
  • Hi, "group=kvm" would need to be "group = kvm" I think, but also this is really odd you clearly should not need to set this - it might even fail due to that. In 99.9% of the cases you are fine with all of qemu.conf being commented out and keeping the defaults. Otherwise I agree to Doug, which version of Ubuntu does this run on and which *tables do you have installed - maybe report dpkg -l '*iptables*' '*ebtables*' as well? – Christian Ehrhardt Apr 09 '20 at 04:40
  • Since you say that "I am member of libvirt and kvm", and in my case this was my only issue to get it working, are you sure the membership has been applied? You can run groups in your shell to verify, because it only applies after you re-login (or run su - $(whoami). – pzkpfw Feb 27 '21 at 10:59
  • Encountering same issue in 20.04. Installed from official guide – soufrk Jun 24 '21 at 20:04

3 Answers3

28

Have you installed kvm? To install libvirt and kvm try running below

sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system virtinst bridge-utils

sudo systemctl enable libvirtd sudo systemctl start libvirtd

I noticed in your output missing ebtables. You can install them by running:

sudo apt install -y ebtables

Then restart the services. Hope this helps you.

Elazar
  • 105
ognjen011
  • 1,403
2

Try these steps:

sudo setfacl -m user:$USER:rw /var/run/libvirt/libvirt-sock

Exit the session and again logged in then,

sudo systemctl enable libvirtd
sudo systemctl start libvirtd
0

In one case, I had the error because (at least) one part of libvirt was "masked" in systemd. So I had to find them all (systemctl |grep virt), check whether they were masked (systemctl status ...) and unmask the masked ones (systemctl unmask ...). I also enabled and started them.